Client LuaCsForBarotrauma
BallastFloraStateMachine.cs
1 #nullable enable
3 {
5  {
6  private readonly BallastFloraBehavior parent;
7 
8  public BallastFloraStateMachine(BallastFloraBehavior parent)
9  {
10  this.parent = parent;
11  }
12 
13  private IBallastFloraState? lastState;
15 
16  public void EnterState(IBallastFloraState newState)
17  {
18  lastState = State;
19  State?.Exit();
20  State = null;
21 
22  newState.Enter();
23  State = newState;
24  }
25 
26  public void Update(float deltaTime)
27  {
28  if (State == null)
29  {
30  EnterState(new GrowIdleState(parent));
31  return;
32  }
33 
34  State.Update(deltaTime);
35 
36  switch (State.GetState())
37  {
38  case ExitState.Running:
39  break;
40  case ExitState.ReturnLast when lastState != null && lastState.GetState() == ExitState.Running:
41  EnterState(lastState);
42  break;
43  default:
44  EnterState(new GrowIdleState(parent));
45  break;
46  }
47  }
48  }
49 }