Files
test/Assets/Scripts/PlayerStateMachine.cs
T
2025-09-18 18:07:23 +07:00

40 lines
773 B
C#

using UnityEngine;
public class PlayerStateMachine
{
PlayerState _state;
CECHostPlayer _characterCtrl;
public void InitState(PlayerState state)
{
if (_state != null)
{
Debug.LogWarning("_state is already inited");
return;
}
_state = state;
_state.Enter();
}
public void ChangeState(PlayerState state)
{
if (_state == null )
{
Debug.LogError("you need to init state first ");
return;
}
if (_state == state)
{
Debug.LogWarning("Unchanged state");
}
_state.Exit();
_state = state;
_state.Enter();
}
public void UpdateState()
{
_state.Update();
}
}