25 lines
500 B
Java
25 lines
500 B
Java
package mindustry.entities.units;
|
|
|
|
public class StateMachine{
|
|
private UnitState state;
|
|
|
|
public void update(){
|
|
if(state != null) state.update();
|
|
}
|
|
|
|
public void set(UnitState next){
|
|
if(next == state) return;
|
|
if(state != null) state.exited();
|
|
this.state = next;
|
|
if(next != null) next.entered();
|
|
}
|
|
|
|
public UnitState current(){
|
|
return state;
|
|
}
|
|
|
|
public boolean is(UnitState state){
|
|
return this.state == state;
|
|
}
|
|
}
|