-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathIStateMachine.cs
More file actions
50 lines (43 loc) · 1.73 KB
/
IStateMachine.cs
File metadata and controls
50 lines (43 loc) · 1.73 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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System;
using System.Collections.Generic;
namespace BAStudio.StatePattern
{
/// <summary>
/// Minimal contract for driving a state machine forward each frame.
/// Implemented by StateMachine<T>, wrappers, and adapters.
/// </summary>
public interface IStateMachine
{
void Update();
bool UpdatePaused { get; }
bool IsChangingState { get; }
bool IsUpdating { get; }
#if UNITY_2017_1_OR_NEWER
bool IsFixedUpdating { get; }
bool IsLateUpdating { get; }
void FixedUpdate();
void LateUpdate();
#endif
}
/// <summary>
/// Typed facade for state machine interaction: state transitions, popup states, events, and observation.
/// <para>States receive this interface in their lifecycle methods. For operations beyond this facade
/// (component delivery, caching, debug), cast to <c>StateMachine<T></c>.</para>
/// </summary>
public interface IStateMachine<T> : IStateMachine
{
T Subject { get; }
IState<T> CurrentState { get; }
void ChangeState(IState<T> state, object parameter = null);
void ChangeState<S>(object parameter = null) where S : IState<T>;
bool SendEvent<E>(E ev);
void Popup(IPopupState<T> state, object parameter = null);
S Popup<S>(object parameter = null) where S : IPopupState<T>, new();
void EndPopupState(IPopupState<T> state, object parameter = null);
IReadOnlyCollection<IPopupState<T>> ViewPopupStates();
event Action<IState<T>, IState<T>> OnStateChanging;
event Action<IState<T>, IState<T>> OnStateChanged;
event Action<IPopupState<T>> PopupStateStarted;
event Action<IPopupState<T>> PopupStateEnded;
}
}