48 lines
702 B
C#
48 lines
702 B
C#
using System;
|
|
|
|
namespace OHM.UnityToolkit.FSM
|
|
{
|
|
public class StateBase<T> where T : StateBase<T>
|
|
{
|
|
public Action startAction;
|
|
|
|
public Action updateAction;
|
|
|
|
public Action leaveAction;
|
|
|
|
public float MaxDuration { get; private set; }
|
|
|
|
public StateBase<T> NextState { get; private set; }
|
|
|
|
public void SetAutoTransition(StateBase<T> nextState, float duration)
|
|
{
|
|
MaxDuration = duration;
|
|
NextState = nextState;
|
|
}
|
|
|
|
public void Enter()
|
|
{
|
|
if (startAction != null)
|
|
{
|
|
startAction();
|
|
}
|
|
}
|
|
|
|
public void Update()
|
|
{
|
|
if (updateAction != null)
|
|
{
|
|
updateAction();
|
|
}
|
|
}
|
|
|
|
public void Leave()
|
|
{
|
|
if (leaveAction != null)
|
|
{
|
|
leaveAction();
|
|
}
|
|
}
|
|
}
|
|
}
|