Add managed entity and script component.

Added ManagedEntity and related methods in EntityManager;
Added ScriptComponent to write game play logic in oop;
This commit is contained in:
2025-12-10 16:12:56 +09:00
parent 99c1a1980e
commit 21e85e0c02
17 changed files with 549 additions and 152 deletions

View File

@@ -4,7 +4,7 @@ using System.Runtime.InteropServices;
namespace Ghost.Entities;
[StructLayout(LayoutKind.Sequential, Size = 8)]
public readonly struct Entity : IEquatable<Entity>, IComparable<Entity>
public readonly record struct Entity
{
public const EntityID INVALID_ID = -1;
@@ -41,36 +41,6 @@ public readonly struct Entity : IEquatable<Entity>, IComparable<Entity>
_generation = generation;
}
public bool Equals(Entity other)
{
return _id == other._id && _generation == other._generation;
}
public int CompareTo(Entity other)
{
return _id.CompareTo(other._id);
}
public override bool Equals(object? obj)
{
return obj is Entity other && Equals(other);
}
public override int GetHashCode()
{
return _id ^ _generation << 16;
}
public static bool operator ==(Entity left, Entity right)
{
return left.Equals(right);
}
public static bool operator !=(Entity left, Entity right)
{
return !(left == right);
}
public override string ToString()
{
return $"Entity {{ Index: {ID}, Generation: {Generation} }}";