-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathStateMachine.State.cs
More file actions
26 lines (24 loc) · 1.05 KB
/
StateMachine.State.cs
File metadata and controls
26 lines (24 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
namespace BAStudio.StatePattern
{
public partial class StateMachine<T>
{
public abstract class State
{
public abstract void OnEntered(StateMachine<T> machine, State previous, T subject, object parameter = null);
/// <summary>
/// <para> Only happens in StateMachine<T>.Update().</para>
/// <para> It's not guaranteed that this will get called between `OnEntered()` and `OnLeaving()`, because these 2 methods can `ChangeState()` too.</para>
/// </summary>
public abstract void Update(StateMachine<T> machine, T subject);
public abstract void OnLeaving(StateMachine<T> machine, State next, T subject, object parameter = null);
/// <summary>
/// When used with ChangedState<S>, states are cached and reused. Reset() get called after the machine finished the whole ChangeState().
/// </summary>
public abstract void Reset ();
#if UNITY_2017_1_OR_NEWER
public virtual void FixedUpdate(StateMachine<T> machine, T subject) {}
public virtual void LateUpdate(StateMachine<T> machine, T subject) {}
#endif
}
}
}