it is done
This commit is contained in:
24
core/src/mindustry/entities/units/StateMachine.java
Normal file
24
core/src/mindustry/entities/units/StateMachine.java
Normal file
@@ -0,0 +1,24 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user