Refactor ConsumeAmmoCost to use readonly field for ammoId and improve Entity struct equality methods
This commit is contained in:
@@ -1,11 +1,23 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
namespace GameCore.ECS;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a unique object in the game world.
|
||||
/// It's a simple struct containing an ID to keep it lightweight.
|
||||
/// All data associated with an Entity is stored in Components.
|
||||
/// Represents a unique object in the game world.
|
||||
/// It's a simple struct containing an ID to keep it lightweight.
|
||||
/// All data associated with an Entity is stored in Components.
|
||||
/// </summary>
|
||||
public readonly struct Entity(int id)
|
||||
{
|
||||
public readonly int Id = id;
|
||||
|
||||
public override bool Equals([NotNullWhen(true)] object? obj)
|
||||
{
|
||||
return base.Equals(obj);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id.GetHashCode();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user