Refactor ConsumeAmmoCost to use readonly field for ammoId and improve Entity struct equality methods

This commit is contained in:
2025-10-29 02:58:49 +01:00
parent 341173c53f
commit 5ee7945bfc
2 changed files with 21 additions and 7 deletions

View File

@@ -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();
}
}