add project files
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user