Batched building health update packet

This commit is contained in:
Anuken
2022-06-22 18:30:59 -04:00
parent 2de706cc6d
commit 1a98a66f23
11 changed files with 135 additions and 54 deletions

View File

@@ -1762,13 +1762,13 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
@MethodPriority(100)
@Override
public void heal(){
indexer.notifyBuildHealed(self());
healthChanged();
}
@MethodPriority(100)
@Override
public void heal(float amount){
indexer.notifyBuildHealed(self());
healthChanged();
}
@Override
@@ -1779,7 +1779,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
@Replace
@Override
public void kill(){
Call.tileDestroyed(self());
Call.buildDestroyed(self());
}
@Replace
@@ -1796,13 +1796,27 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
damage = Damage.applyArmor(damage, block.armor) / dm;
}
Call.tileDamage(self(), health - handleDamage(damage));
//TODO handle this better on the client.
if(!net.client()){
health -= handleDamage(damage);
}
healthChanged();
if(health <= 0){
Call.tileDestroyed(self());
Call.buildDestroyed(self());
}
}
public void healthChanged(){
//server-side, health updates are batched.
if(net.server()){
netServer.buildHealthUpdate(self());
}
indexer.notifyHealthChanged(self());
}
@Override
public double sense(LAccess sensor){
return switch(sensor){