add project files

This commit is contained in:
Boris Nikolaev
2026-08-14 01:58:31 +03:00
parent 9134cad79b
commit 5f1e94b653
4399 changed files with 12286903 additions and 0 deletions
@@ -0,0 +1,48 @@
using UnityEngine;
namespace OHM.UnityToolkit.FSM
{
public class FiniteStateMachine<StateType> where StateType : StateBase<StateType>
{
private float _currentStateStartTime;
public StateType CurrentState { get; private set; }
public void SetState(StateType state)
{
if (state == null)
{
return;
}
if (CurrentState != null)
{
CurrentState.Leave();
}
_currentStateStartTime = Time.time;
CurrentState = state;
state.Enter();
}
public void Update()
{
if (CurrentState == null)
{
return;
}
CurrentState.Update();
if (CurrentState == null || CurrentState.NextState == null)
{
return;
}
if (Time.time - _currentStateStartTime >= CurrentState.MaxDuration)
{
SetState(CurrentState.NextState as StateType);
}
}
public float GetCurrentStateDuration()
{
return Time.time - _currentStateStartTime;
}
}
}