Saving of unit commands

This commit is contained in:
Anuken
2022-02-14 18:24:18 -05:00
parent 9a2254cccb
commit 6c2e0c0b33
3 changed files with 16 additions and 1 deletions
@@ -334,7 +334,9 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
public void afterRead(){
afterSync();
//reset controller state
controller(type.createController(self()));
if(!(controller instanceof AIController ai && ai.keepState())){
controller(type.createController(self()));
}
}
@Override
@@ -45,6 +45,14 @@ public class AIController implements UnitController{
updateMovement();
}
/**
* @return whether controller state should not be reset after reading.
* Do not override unless you know exactly what you are doing.
* */
public boolean keepState(){
return false;
}
public void stopShooting(){
for(var mount : unit.mounts){
//ignore mount controllable stats too, they should not shoot either