chore: initial commit
This commit is contained in:
21
Assets/Scripts/Core/Events/GameStateId.cs
Normal file
21
Assets/Scripts/Core/Events/GameStateId.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
namespace BaseGames.Core.Events
|
||||
{
|
||||
/// <summary>
|
||||
/// 游戏状态 ID(值类型,替代旧版 GameState 枚举)。
|
||||
/// 具体实例由 GameStates 静态工厂创建。
|
||||
/// </summary>
|
||||
public readonly struct GameStateId : System.IEquatable<GameStateId>
|
||||
{
|
||||
public readonly string Id;
|
||||
|
||||
public GameStateId(string id) => Id = id;
|
||||
|
||||
public bool Equals(GameStateId other) => Id == other.Id;
|
||||
public override bool Equals(object obj) => obj is GameStateId g && Equals(g);
|
||||
public override int GetHashCode() => Id?.GetHashCode() ?? 0;
|
||||
public override string ToString() => Id ?? "<null>";
|
||||
|
||||
public static bool operator ==(GameStateId a, GameStateId b) => a.Equals(b);
|
||||
public static bool operator !=(GameStateId a, GameStateId b) => !a.Equals(b);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user