Save building enabled state

This commit is contained in:
Anuken
2021-01-09 22:13:41 -05:00
parent 462a5b941e
commit 0a5a301573
3 changed files with 13 additions and 18 deletions
@@ -147,7 +147,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
write.f(health);
write.b(rotation | 0b10000000);
write.b(team.id);
write.b(0); //extra padding for later use
write.b(1); //version
write.b(enabled ? 1 : 0);
if(items != null) items.write(write);
if(power != null) power.write(write);
if(liquids != null) liquids.write(write);
@@ -162,7 +163,14 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
rotation = rot & 0b01111111;
boolean legacy = true;
if((rot & 0b10000000) != 0){
read.b(); //padding
byte ver = read.b(); //version of entity save
if(ver == 1){
byte on = read.b();
this.enabled = on == 1;
if(!this.enabled){
enabledControlTime = timeToUncontrol;
}
}
legacy = false;
}
@@ -1376,7 +1384,8 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
timeScale = 1f;
}
if(block.autoResetEnabled){
if(!enabled && block.autoResetEnabled){
noSleep();
enabledControlTime -= Time.delta;
if(enabledControlTime <= 0){