BITKit/Src/Core/Interfaces/IStateMachine.cs

27 lines
752 B
C#
Raw Normal View History

2023-06-05 19:57:17 +08:00
using System;
using System.Collections.Generic;
2023-06-29 14:57:11 +08:00
2023-06-05 19:57:17 +08:00
namespace BITKit.StateMachine
{
public interface IState
{
2023-08-23 01:59:26 +08:00
bool Enabled { get; set; }
2023-06-05 19:57:17 +08:00
void Initialize();
2023-08-23 01:59:26 +08:00
void OnStateEntry(IState old);
2023-09-01 14:35:05 +08:00
void OnStateUpdate(float deltaTime);
2023-06-05 19:57:17 +08:00
void OnStateExit(IState old, IState newState);
}
2023-08-23 01:59:26 +08:00
2023-06-05 19:57:17 +08:00
public interface IStateMachine<T> where T : IState
{
2023-08-23 01:59:26 +08:00
bool Enabled { get; set; }
2023-06-05 19:57:17 +08:00
T CurrentState { get; set; }
2023-08-23 01:59:26 +08:00
event Action<T,T> OnStateChanged;
2023-08-11 23:57:37 +08:00
IDictionary<Type, T> StateDictionary { get; }
2023-08-23 01:59:26 +08:00
void Initialize();
2023-09-01 14:35:05 +08:00
void UpdateState(float deltaTime);
2023-08-23 01:59:26 +08:00
void DisposeState();
void TransitionState<State>() where State : T;
void TransitionState(T state);
2023-06-05 19:57:17 +08:00
}
}