46 lines
1.1 KiB
C#
46 lines
1.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace BITKit.StateMachine
|
|
{
|
|
public struct EmptyState:IState
|
|
{
|
|
public bool Enabled { get; set; }
|
|
public void Initialize()
|
|
{
|
|
}
|
|
|
|
public void OnStateEntry(IState old)
|
|
{
|
|
}
|
|
|
|
public void OnStateUpdate(float deltaTime)
|
|
{
|
|
}
|
|
|
|
public void OnStateExit(IState old, IState newState)
|
|
{
|
|
}
|
|
}
|
|
public interface IState
|
|
{
|
|
bool Enabled { get; set; }
|
|
void Initialize();
|
|
void OnStateEntry(IState old);
|
|
void OnStateUpdate(float deltaTime);
|
|
void OnStateExit(IState old, IState newState);
|
|
}
|
|
|
|
public interface IStateMachine<T> where T : IState
|
|
{
|
|
bool Enabled { get; set; }
|
|
T CurrentState { get; set; }
|
|
event Action<T,T> OnStateChanged;
|
|
IDictionary<Type, T> StateDictionary { get; }
|
|
void Initialize();
|
|
void UpdateState(float deltaTime);
|
|
void DisposeState();
|
|
void TransitionState<State>() where State : T;
|
|
void TransitionState(T state);
|
|
}
|
|
} |