BITFALL/Assets/BITKit/Core/Interfaces/IStateMachine.cs

27 lines
752 B
C#
Raw Normal View History

2023-08-12 01:43:24 +08:00
using System;
using System.Collections.Generic;
namespace BITKit.StateMachine
{
public interface IState
{
2023-08-23 01:59:40 +08:00
bool Enabled { get; set; }
2023-08-12 01:43:24 +08:00
void Initialize();
2023-08-23 01:59:40 +08:00
void OnStateEntry(IState old);
2023-08-27 02:58:19 +08:00
void OnStateUpdate(float deltaTime);
2023-08-12 01:43:24 +08:00
void OnStateExit(IState old, IState newState);
}
2023-08-23 01:59:40 +08:00
2023-08-12 01:43:24 +08:00
public interface IStateMachine<T> where T : IState
{
2023-08-23 01:59:40 +08:00
bool Enabled { get; set; }
2023-08-12 01:43:24 +08:00
T CurrentState { get; set; }
2023-08-23 01:59:40 +08:00
event Action<T,T> OnStateChanged;
2023-08-12 01:43:24 +08:00
IDictionary<Type, T> StateDictionary { get; }
2023-08-23 01:59:40 +08:00
void Initialize();
2023-08-27 02:58:19 +08:00
void UpdateState(float deltaTime);
2023-08-23 01:59:40 +08:00
void DisposeState();
void TransitionState<State>() where State : T;
void TransitionState(T state);
2023-08-12 01:43:24 +08:00
}
}