iOS fixes
This commit is contained in:
@@ -13,12 +13,12 @@ import io.anuke.mindustry.entities.TileEntity;
|
|||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.Content;
|
||||||
import io.anuke.mindustry.game.ContentDatabase;
|
import io.anuke.mindustry.game.ContentDatabase;
|
||||||
import io.anuke.mindustry.game.EventType.*;
|
import io.anuke.mindustry.game.EventType.*;
|
||||||
|
import io.anuke.mindustry.game.Saves;
|
||||||
import io.anuke.mindustry.input.DefaultKeybinds;
|
import io.anuke.mindustry.input.DefaultKeybinds;
|
||||||
import io.anuke.mindustry.input.DesktopInput;
|
import io.anuke.mindustry.input.DesktopInput;
|
||||||
import io.anuke.mindustry.input.InputHandler;
|
import io.anuke.mindustry.input.InputHandler;
|
||||||
import io.anuke.mindustry.input.MobileInput;
|
import io.anuke.mindustry.input.MobileInput;
|
||||||
import io.anuke.mindustry.maps.Map;
|
import io.anuke.mindustry.maps.Map;
|
||||||
import io.anuke.mindustry.game.Saves;
|
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.type.Recipe;
|
import io.anuke.mindustry.type.Recipe;
|
||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||||
@@ -48,7 +48,7 @@ public class Control extends Module{
|
|||||||
private ObjectMap<Sound, Long> soundMap = new ObjectMap<>();
|
private ObjectMap<Sound, Long> soundMap = new ObjectMap<>();
|
||||||
|
|
||||||
private Throwable error;
|
private Throwable error;
|
||||||
private Input gdxInput;
|
//private Input gdxInput;
|
||||||
|
|
||||||
public Control(){
|
public Control(){
|
||||||
|
|
||||||
@@ -68,12 +68,7 @@ public class Control extends Module{
|
|||||||
|
|
||||||
db.load();
|
db.load();
|
||||||
|
|
||||||
gdxInput = Gdx.input;
|
//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");
|
|
||||||
|
|
||||||
Sounds.setFalloff(9000f);
|
Sounds.setFalloff(9000f);
|
||||||
Sounds.setPlayer((sound, volume) -> {
|
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();
|
DefaultKeybinds.load();
|
||||||
|
|
||||||
Settings.defaultList(
|
Settings.defaultList(
|
||||||
@@ -224,7 +217,7 @@ public class Control extends Module{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Input gdxInput(){
|
public Input gdxInput(){
|
||||||
return gdxInput;
|
return Gdx.input;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setError(Throwable error){
|
public void setError(Throwable error){
|
||||||
|
|||||||
@@ -207,6 +207,11 @@ public class ItemDrop extends SolidEntity implements SaveTrait, SyncTrait, DrawT
|
|||||||
return 10;
|
return 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float fin() {
|
||||||
|
return time()/lifetime();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public EntityGroup targetGroup(){
|
public EntityGroup targetGroup(){
|
||||||
return itemGroup;
|
return itemGroup;
|
||||||
|
|||||||
@@ -3,11 +3,12 @@ package io.anuke.mindustry.graphics;
|
|||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
import com.badlogic.gdx.utils.Sort;
|
import com.badlogic.gdx.utils.Sort;
|
||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
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.game.Team;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.ucore.core.Graphics;
|
import io.anuke.ucore.core.Events;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
@@ -19,6 +20,7 @@ public class BlockRenderer{
|
|||||||
private FloorRenderer floorRenderer;
|
private FloorRenderer floorRenderer;
|
||||||
|
|
||||||
private Array<BlockRequest> requests = new Array<>(initialRequests);
|
private Array<BlockRequest> requests = new Array<>(initialRequests);
|
||||||
|
private int lastCamX, lastCamY;
|
||||||
private Layer lastLayer;
|
private Layer lastLayer;
|
||||||
private int requestidx = 0;
|
private int requestidx = 0;
|
||||||
private int iterateidx = 0;
|
private int iterateidx = 0;
|
||||||
@@ -29,22 +31,38 @@ public class BlockRenderer{
|
|||||||
for(int i = 0; i < requests.size; i++){
|
for(int i = 0; i < requests.size; i++){
|
||||||
requests.set(i, new BlockRequest());
|
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.*/
|
/**Process all blocks to draw, simultaneously drawing block shadows.*/
|
||||||
public void processBlocks(){
|
public void processBlocks(){
|
||||||
requestidx = 0;
|
iterateidx = 0;
|
||||||
lastLayer = null;
|
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 rangex = (int) (camera.viewportWidth * camera.zoom / tilesize / 2) + 2;
|
||||||
int rangey = (int) (camera.viewportHeight * camera.zoom / tilesize / 2) + 2;
|
int rangey = (int) (camera.viewportHeight * camera.zoom / tilesize / 2) + 2;
|
||||||
|
|
||||||
int expandr = 4;
|
int expandr = 4;
|
||||||
|
|
||||||
Graphics.surface(renderer.effectSurface, true, false);
|
//Graphics.surface(renderer.effectSurface, true, false);
|
||||||
|
|
||||||
int avgx = Mathf.scl(camera.position.x, tilesize);
|
|
||||||
int avgy = Mathf.scl(camera.position.y, tilesize);
|
|
||||||
|
|
||||||
int minx = Math.max(avgx - rangex - expandr, 0);
|
int minx = Math.max(avgx - rangex - expandr, 0);
|
||||||
int miny = Math.max(avgy - rangey - expandr, 0);
|
int miny = Math.max(avgy - rangey - expandr, 0);
|
||||||
@@ -61,9 +79,9 @@ public class BlockRenderer{
|
|||||||
if(tile != null){
|
if(tile != null){
|
||||||
Block block = tile.block();
|
Block block = tile.block();
|
||||||
|
|
||||||
if(!expanded && block != Blocks.air && world.isAccessible(x, y)){
|
//if(!expanded && block != Blocks.air && world.isAccessible(x, y)){
|
||||||
tile.block().drawShadow(tile);
|
// tile.block().drawShadow(tile);
|
||||||
}
|
//}
|
||||||
|
|
||||||
if(block != Blocks.air){
|
if(block != Blocks.air){
|
||||||
if(!expanded){
|
if(!expanded){
|
||||||
@@ -80,19 +98,20 @@ public class BlockRenderer{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO this actually isn't necessary
|
//TODO this actually isn't necessary
|
||||||
Draw.color(0, 0, 0, 0.15f);
|
//Draw.color(0, 0, 0, 0.15f);
|
||||||
Graphics.flushSurface();
|
//Graphics.flushSurface();
|
||||||
Draw.color();
|
//Draw.color();
|
||||||
|
|
||||||
Sort.instance().sort(requests.items, 0, requestidx);
|
Sort.instance().sort(requests.items, 0, requestidx);
|
||||||
iterateidx = 0;
|
|
||||||
|
lastCamX = avgx;
|
||||||
|
lastCamY = avgy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRequests(){
|
public int getRequests(){
|
||||||
|
|||||||
Reference in New Issue
Block a user