Heal bullet effect fix / Spawned ID sync / Crash fix

This commit is contained in:
Anuken
2019-03-11 14:54:15 -04:00
parent 4909c28ed9
commit b0c1aff783
6 changed files with 19 additions and 10 deletions

View File

@@ -360,6 +360,7 @@ public class Bullets implements ContentList{
{ {
shootEffect = Fx.shootHeal; shootEffect = Fx.shootHeal;
smokeEffect = Fx.hitLaser;
hitEffect = Fx.hitLaser; hitEffect = Fx.hitLaser;
despawnEffect = Fx.hitLaser; despawnEffect = Fx.hitLaser;
collidesTeam = true; collidesTeam = true;

View File

@@ -162,7 +162,7 @@ public class Fx implements ContentList{
heal = new Effect(11, e -> { heal = new Effect(11, e -> {
Draw.color(Pal.heal); Draw.color(Pal.heal);
Lines.stroke(e.fout() * 2f); Lines.stroke(e.fout() * 2f);
Lines.poly(e.x, e.y, 10, 2f + e.finpow() * 7f); Lines.poly(e.x, e.y, 24, 2f + e.finpow() * 7f);
Draw.color(); Draw.color();
}); });

View File

@@ -98,16 +98,15 @@ public class NetClient implements ApplicationListener{
}); });
Net.handleClient(Disconnect.class, packet -> { Net.handleClient(Disconnect.class, packet -> {
state.set(State.menu);
connecting = false;
Platform.instance.updateRPC();
if(quiet) return; if(quiet) return;
Time.runTask(3f, ui.loadfrag::hide); Time.runTask(3f, ui.loadfrag::hide);
state.set(State.menu);
ui.showError("$disconnect"); ui.showError("$disconnect");
connecting = false;
Platform.instance.updateRPC();
}); });
Net.handleClient(WorldStream.class, data -> { Net.handleClient(WorldStream.class, data -> {

View File

@@ -233,6 +233,12 @@ public class NetServer implements ApplicationListener{
} }
public static void onDisconnect(Player player){ public static void onDisconnect(Player player){
//singleplayer multiplayer wierdness
if(player.con == null){
player.remove();
return;
}
if(player.con.hasConnected){ if(player.con.hasConnected){
Call.sendMessage("[accent]" + player.name + "[accent] has disconnected."); Call.sendMessage("[accent]" + player.name + "[accent] has disconnected.");
Call.onPlayerDisconnect(player.id); Call.onPlayerDisconnect(player.id);
@@ -573,7 +579,7 @@ public class NetServer implements ApplicationListener{
NetConnection connection = player.con; NetConnection connection = player.con;
if(!connection.isConnected() || !connections.containsKey(connection.id)){ if(connection == null || !connection.isConnected() || !connections.containsKey(connection.id)){
//player disconnected, call d/c event //player disconnected, call d/c event
onDisconnect(player); onDisconnect(player);
return; return;

View File

@@ -337,6 +337,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
public void write(DataOutput data) throws IOException{ public void write(DataOutput data) throws IOException{
super.writeSave(data); super.writeSave(data);
data.writeByte(type.id); data.writeByte(type.id);
data.writeInt(spawner);
} }
@Override @Override
@@ -344,6 +345,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
float lastx = x, lasty = y, lastrot = rotation; float lastx = x, lasty = y, lastrot = rotation;
super.readSave(data); super.readSave(data);
this.type = content.getByID(ContentType.unit, data.readByte()); this.type = content.getByID(ContentType.unit, data.readByte());
this.spawner = data.readInt();
interpolator.read(lastx, lasty, x, y, rotation); interpolator.read(lastx, lasty, x, y, rotation);
rotation = lastrot; rotation = lastrot;

View File

@@ -35,6 +35,7 @@ import java.io.DataOutput;
import java.io.IOException; import java.io.IOException;
public class UnitFactory extends Block{ public class UnitFactory extends Block{
//for attack mode
protected float gracePeriodMultiplier = 15f; protected float gracePeriodMultiplier = 15f;
protected float speedupTime = 60f * 60f * 20; protected float speedupTime = 60f * 60f * 20;
protected float maxSpeedup = 2f; protected float maxSpeedup = 2f;
@@ -57,14 +58,14 @@ public class UnitFactory extends Block{
} }
@Remote(called = Loc.server) @Remote(called = Loc.server)
public static void onUnitFactorySpawn(Tile tile){ public static void onUnitFactorySpawn(Tile tile, int spawns){
if(!(tile.entity instanceof UnitFactoryEntity) || !(tile.block() instanceof UnitFactory)) return; if(!(tile.entity instanceof UnitFactoryEntity) || !(tile.block() instanceof UnitFactory)) return;
UnitFactoryEntity entity = tile.entity(); UnitFactoryEntity entity = tile.entity();
UnitFactory factory = (UnitFactory) tile.block(); UnitFactory factory = (UnitFactory) tile.block();
entity.buildTime = 0f; entity.buildTime = 0f;
entity.spawned ++; entity.spawned = spawns;
Effects.shake(2f, 3f, entity); Effects.shake(2f, 3f, entity);
Effects.effect(Fx.producesmoke, tile.drawx(), tile.drawy()); Effects.effect(Fx.producesmoke, tile.drawx(), tile.drawy());
@@ -182,7 +183,7 @@ public class UnitFactory extends Block{
if(entity.buildTime >= produceTime){ if(entity.buildTime >= produceTime){
entity.buildTime = 0f; entity.buildTime = 0f;
Call.onUnitFactorySpawn(tile); Call.onUnitFactorySpawn(tile, entity.spawned + 1);
useContent(tile, type); useContent(tile, type);
for(ItemStack stack : consumes.items()){ for(ItemStack stack : consumes.items()){