Various sync fixes

This commit is contained in:
Anuken
2020-05-24 17:01:17 -04:00
parent d202c6ebdd
commit 3051598b92
14 changed files with 71 additions and 79 deletions

View File

@@ -43,14 +43,15 @@ public class CoreBlock extends StorageBlock{
CoreEntity entity = tile.ent();
CoreBlock block = (CoreBlock)tile.block();
Fx.spawn.at(entity);
entity.progress = 0;
Unitc unit = block.unitType.create(tile.team());
unit.set(entity);
unit.impulse(0f, 8f);
unit.controller(player);
unit.spawnedByCore(true);
unit.add();
if(!net.client()){
Unitc unit = block.unitType.create(tile.team());
unit.set(entity);
unit.impulse(0f, 2f);
unit.controller(player);
unit.spawnedByCore(true);
unit.add();
}
}
@Override
@@ -78,20 +79,10 @@ public class CoreBlock extends StorageBlock{
}
public class CoreEntity extends TileEntity{
protected float time, heat, progress;
protected int storageCapacity;
protected boolean shouldBuild;
protected Playerc lastRequested;
public void requestSpawn(Playerc player){
shouldBuild = true;
if(lastRequested == null){
lastRequested = player;
}
if(progress >= 1f){
Call.onPlayerSpawn(tile, player);
}
Call.onPlayerSpawn(tile, player);
}
@Override
@@ -210,17 +201,6 @@ public class CoreBlock extends StorageBlock{
state.teams.registerCore(this);
}
@Override
public void draw(){
super.draw();
if(heat > 0.001f){
Draw.draw(Layer.blockOver, () -> {
Drawf.respawn(this, heat, progress, time, unitType, lastRequested);
});
}
}
@Override
public void handleItem(Tilec source, Item item){
if(net.server() || !net.active()){
@@ -230,26 +210,5 @@ public class CoreBlock extends StorageBlock{
}
}
}
@Override
public void updateTile(){
if(shouldBuild){
heat = Mathf.lerpDelta(heat, 1f, 0.1f);
time += delta();
progress += 1f / state.rules.respawnTime * delta();
}else{
progress = 0f;
heat = Mathf.lerpDelta(heat, 0f, 0.1f);
}
shouldBuild = false;
lastRequested = null;
}
@Override
public boolean shouldActiveSound(){
return shouldBuild;
}
}
}