mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-07-28 13:47:32 +07:00
Fixed bug with gameOver not being called properly
This commit is contained in:
@ -22,7 +22,6 @@ public class GameState{
|
||||
public boolean friendlyFire;
|
||||
|
||||
public void set(State astate){
|
||||
//TODO update RPC handler
|
||||
Events.fire(StateChangeEvent.class, state, astate);
|
||||
state = astate;
|
||||
}
|
||||
@ -30,6 +29,10 @@ public class GameState{
|
||||
public boolean is(State astate){
|
||||
return state == astate;
|
||||
}
|
||||
|
||||
public State getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
public enum State{
|
||||
paused, playing, menu
|
||||
|
@ -42,7 +42,6 @@ public class NetEvents {
|
||||
public static void handleEnemyDeath(Enemy enemy){
|
||||
EnemyDeathPacket packet = new EnemyDeathPacket();
|
||||
packet.id = enemy.id;
|
||||
state.gameOver = true;
|
||||
Net.send(packet, SendMode.tcp);
|
||||
}
|
||||
|
||||
|
@ -121,7 +121,9 @@ public class DebugFragment implements Fragment {
|
||||
"enemies: " + enemyGroup.size(),
|
||||
"tiles: " + tileGroup.size(),
|
||||
world.getCore() != null && world.getCore().entity != null ? "core.health: " + world.getCore().entity.health : "",
|
||||
"",
|
||||
"core: " + world.getCore(),
|
||||
"state.gameover: " + state.gameOver,
|
||||
"state: " + state.getState(),
|
||||
!Net.server() ? clientDebug.getOut() : serverDebug.getOut()
|
||||
);
|
||||
}
|
||||
|
@ -271,7 +271,7 @@ public class Tile{
|
||||
Block block = block();
|
||||
Block floor = floor();
|
||||
|
||||
return floor.name() + ":" + block.name() + "[" + x + "," + y + "] " +
|
||||
return floor.name() + ":" + block.name() + "[" + x + "," + y + "] " + "entity=" + entity +
|
||||
(link != 0 ? " link=[" + (Bits.getLeftByte(link) - 8) + ", " + (Bits.getRightByte(link) - 8) + "]" : "");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,60 @@
|
||||
package io.anuke.mindustry.world.blocks.types.distribution;
|
||||
|
||||
import io.anuke.mindustry.resource.Item;
|
||||
import io.anuke.mindustry.world.Block;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
public class Splitter extends Block{
|
||||
|
||||
public Splitter(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptItem(Item item, Tile tile, Tile source){
|
||||
if(source.block() instanceof Sorter) return false;
|
||||
Tile to = getTileTarget(item, tile, source, false);
|
||||
|
||||
return to != null && to.block().acceptItem(item, to, tile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Item item, Tile tile, Tile source){
|
||||
Tile to = getTileTarget(item, tile, source, true);
|
||||
|
||||
Timers.run(15, () -> {
|
||||
to.block().handleItem(item, to, tile);
|
||||
});
|
||||
}
|
||||
|
||||
Tile getTileTarget(Item item, Tile dest, Tile source, boolean flip){
|
||||
int dir = source.relativeTo(dest.x, dest.y);
|
||||
if(dir == -1) return null;
|
||||
Tile to;
|
||||
|
||||
Tile a = dest.getNearby()[Mathf.mod(dir - 1, 4)];
|
||||
Tile b = dest.getNearby()[Mathf.mod(dir + 1, 4)];
|
||||
boolean ac = a.block().acceptItem(item, a, dest);
|
||||
boolean bc = b.block().acceptItem(item, b, dest);
|
||||
|
||||
if(ac && !bc){
|
||||
to = a;
|
||||
}else if(bc && !ac){
|
||||
to = b;
|
||||
}else{
|
||||
if(dest.getDump() == 0){
|
||||
to = a;
|
||||
if(flip)
|
||||
dest.setDump((byte)1);
|
||||
}else{
|
||||
to = b;
|
||||
if(flip)
|
||||
dest.setDump((byte)0);
|
||||
}
|
||||
}
|
||||
|
||||
return to;
|
||||
}
|
||||
}
|
@ -17,7 +17,10 @@ public class ServerLauncher{
|
||||
//find and handle uncaught exceptions in libGDX thread
|
||||
for(Thread thread : Thread.getAllStackTraces().keySet()){
|
||||
if(thread.getName().equals("HeadlessApplication")){
|
||||
thread.setUncaughtExceptionHandler((t, throwable) -> System.exit(-1));
|
||||
thread.setUncaughtExceptionHandler((t, throwable) ->{
|
||||
throwable.printStackTrace();
|
||||
System.exit(-1);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user