-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIState.cs
More file actions
30 lines (26 loc) · 1.08 KB
/
IState.cs
File metadata and controls
30 lines (26 loc) · 1.08 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
27
28
29
30
namespace BAStudio.StatePattern
{
/// <summary>
/// Lifecycle contract for a state within a state machine.
/// Extracted from StateMachine<T>.IState to enable clean mutual references with IStateMachine<T>.
/// </summary>
public interface IState<T>
{
void OnEntered(IStateMachine<T> machine, IState<T> previous, object parameter = null);
/// <summary>
/// <para>Only happens in StateMachine<T>.Update().</para>
/// <para>Not guaranteed between OnEntered and OnLeaving — those can trigger ChangeState too.</para>
/// </summary>
void Update(IStateMachine<T> machine);
void OnLeaving(IStateMachine<T> machine, IState<T> next, object parameter = null);
/// <summary>
/// Called after the machine completes the full ChangeState sequence.
/// Used to reset cached/reused state instances.
/// </summary>
void Reset();
#if UNITY_2017_1_OR_NEWER
void FixedUpdate(IStateMachine<T> machine) {}
void LateUpdate(IStateMachine<T> machine) {}
#endif
}
}