Saving of unit commands
This commit is contained in:
@@ -78,6 +78,11 @@ public class CommandAI extends AIController{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean keepState(){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Teamc findTarget(float x, float y, float range, boolean air, boolean ground){
|
public Teamc findTarget(float x, float y, float range, boolean air, boolean ground){
|
||||||
return attackTarget == null ? super.findTarget(x, y, range, air, ground) : attackTarget;
|
return attackTarget == null ? super.findTarget(x, y, range, air, ground) : attackTarget;
|
||||||
|
|||||||
@@ -334,8 +334,10 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
|||||||
public void afterRead(){
|
public void afterRead(){
|
||||||
afterSync();
|
afterSync();
|
||||||
//reset controller state
|
//reset controller state
|
||||||
|
if(!(controller instanceof AIController ai && ai.keepState())){
|
||||||
controller(type.createController(self()));
|
controller(type.createController(self()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void add(){
|
public void add(){
|
||||||
|
|||||||
@@ -45,6 +45,14 @@ public class AIController implements UnitController{
|
|||||||
updateMovement();
|
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(){
|
public void stopShooting(){
|
||||||
for(var mount : unit.mounts){
|
for(var mount : unit.mounts){
|
||||||
//ignore mount controllable stats too, they should not shoot either
|
//ignore mount controllable stats too, they should not shoot either
|
||||||
|
|||||||
Reference in New Issue
Block a user