using GFramework.Core.Abstractions.state;
using GFramework.Core.state;
namespace GFramework.Game.state;
///
/// 游戏状态机类,继承自ContextAwareStateMachine,用于管理游戏中的各种状态
///
public sealed class GameStateMachineSystem : StateMachineSystem
{
///
/// 检查当前状态是否为指定类型的状态
///
/// 要检查的状态类型,必须实现IState接口
/// 如果当前状态是指定类型则返回true,否则返回false
public bool IsIn() where T : IState
{
return Current is T;
}
///
/// 获取当前状态的实例,如果当前状态是指定类型则进行类型转换
///
/// 要获取的状态类型,必须是引用类型并实现IState接口
/// 如果当前状态是指定类型则返回转换后的实例,否则返回null
public T? Get() where T : class, IState
{
return Current as T;
}
}