iOS fixes

This commit is contained in:
Anuken 2018-07-20 13:59:00 -04:00
parent 3c83b88127
commit 48c7daa4ab
3 changed files with 43 additions and 26 deletions

View File

@ -13,12 +13,12 @@ import io.anuke.mindustry.entities.TileEntity;
import io.anuke.mindustry.game.Content;
import io.anuke.mindustry.game.ContentDatabase;
import io.anuke.mindustry.game.EventType.*;
import io.anuke.mindustry.game.Saves;
import io.anuke.mindustry.input.DefaultKeybinds;
import io.anuke.mindustry.input.DesktopInput;
import io.anuke.mindustry.input.InputHandler;
import io.anuke.mindustry.input.MobileInput;
import io.anuke.mindustry.maps.Map;
import io.anuke.mindustry.game.Saves;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.Recipe;
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
@ -48,7 +48,7 @@ public class Control extends Module{
private ObjectMap<Sound, Long> soundMap = new ObjectMap<>();
private Throwable error;
private Input gdxInput;
//private Input gdxInput;
public Control(){
@ -68,12 +68,7 @@ public class Control extends Module{
db.load();
gdxInput = Gdx.input;
//Sounds.load("shoot.mp3", "place.mp3", "explosion.mp3", "enemyshoot.mp3",
// "corexplode.mp3", "break.mp3", "spawn.mp3", "flame.mp3", "die.mp3",
// "respawn.mp3", "purchase.mp3", "flame2.mp3", "bigshot.mp3", "laser.mp3", "lasershot.mp3",
// "ping.mp3", "tesla.mp3", "waveend.mp3", "railgun.mp3", "blast.mp3", "bang2.mp3");
//gdxInput = Gdx.input;
Sounds.setFalloff(9000f);
Sounds.setPlayer((sound, volume) -> {
@ -86,8 +81,6 @@ public class Control extends Module{
}
});
//Musics.load("1.mp3", "2.mp3", "3.mp3", "4.mp3", "5.mp3", "6.mp3");
DefaultKeybinds.load();
Settings.defaultList(
@ -224,7 +217,7 @@ public class Control extends Module{
}
public Input gdxInput(){
return gdxInput;
return Gdx.input;
}
public void setError(Throwable error){

View File

@ -207,6 +207,11 @@ public class ItemDrop extends SolidEntity implements SaveTrait, SyncTrait, DrawT
return 10;
}
@Override
public float fin() {
return time()/lifetime();
}
@Override
public EntityGroup targetGroup(){
return itemGroup;

View File

@ -3,11 +3,12 @@ package io.anuke.mindustry.graphics;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Sort;
import io.anuke.mindustry.content.blocks.Blocks;
import io.anuke.mindustry.game.EventType.TileChangeEvent;
import io.anuke.mindustry.game.EventType.WorldLoadGraphicsEvent;
import io.anuke.mindustry.game.Team;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Graphics;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.core.Events;
import io.anuke.ucore.util.Mathf;
import static io.anuke.mindustry.Vars.*;
@ -19,6 +20,7 @@ public class BlockRenderer{
private FloorRenderer floorRenderer;
private Array<BlockRequest> requests = new Array<>(initialRequests);
private int lastCamX, lastCamY;
private Layer lastLayer;
private int requestidx = 0;
private int iterateidx = 0;
@ -29,22 +31,38 @@ public class BlockRenderer{
for(int i = 0; i < requests.size; i++){
requests.set(i, new BlockRequest());
}
Events.on(WorldLoadGraphicsEvent.class, () -> {
lastCamY = lastCamX = -99; //invalidate camera position so blocks get updated
});
Events.on(TileChangeEvent.class, tile -> {
threads.runGraphics(() -> {
//TODO invalidate camera position if it's in the view range
});
});
}
/**Process all blocks to draw, simultaneously drawing block shadows.*/
public void processBlocks(){
requestidx = 0;
iterateidx = 0;
lastLayer = null;
int avgx = Mathf.scl(camera.position.x, tilesize);
int avgy = Mathf.scl(camera.position.y, tilesize);
if(avgx == lastCamX && avgy == lastCamY){
return;
}
requestidx = 0;
int rangex = (int) (camera.viewportWidth * camera.zoom / tilesize / 2) + 2;
int rangey = (int) (camera.viewportHeight * camera.zoom / tilesize / 2) + 2;
int expandr = 4;
Graphics.surface(renderer.effectSurface, true, false);
int avgx = Mathf.scl(camera.position.x, tilesize);
int avgy = Mathf.scl(camera.position.y, tilesize);
//Graphics.surface(renderer.effectSurface, true, false);
int minx = Math.max(avgx - rangex - expandr, 0);
int miny = Math.max(avgy - rangey - expandr, 0);
@ -61,9 +79,9 @@ public class BlockRenderer{
if(tile != null){
Block block = tile.block();
if(!expanded && block != Blocks.air && world.isAccessible(x, y)){
tile.block().drawShadow(tile);
}
//if(!expanded && block != Blocks.air && world.isAccessible(x, y)){
// tile.block().drawShadow(tile);
//}
if(block != Blocks.air){
if(!expanded){
@ -80,19 +98,20 @@ public class BlockRenderer{
}
}
}
}
}
}
}
//TODO this actually isn't necessary
Draw.color(0, 0, 0, 0.15f);
Graphics.flushSurface();
Draw.color();
//Draw.color(0, 0, 0, 0.15f);
//Graphics.flushSurface();
//Draw.color();
Sort.instance().sort(requests.items, 0, requestidx);
iterateidx = 0;
lastCamX = avgx;
lastCamY = avgy;
}
public int getRequests(){