You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1.0 KiB
31 lines
1.0 KiB
1 year ago
|
using System;
|
||
|
using static flecs_hub.flecs;
|
||
|
|
||
|
namespace gaemstone.ECS;
|
||
|
|
||
|
public readonly struct Entity
|
||
|
: IEquatable<Entity>
|
||
|
{
|
||
|
public static readonly Entity None = default;
|
||
|
|
||
|
public readonly ecs_entity_t Value;
|
||
|
public uint Id => (uint)Value.Data;
|
||
|
|
||
|
public bool IsSome => Value.Data != 0;
|
||
|
public bool IsNone => Value.Data == 0;
|
||
|
|
||
|
public Entity(ecs_entity_t value) => Value = value;
|
||
|
|
||
|
public bool Equals(Entity other) => Value.Data == other.Value.Data;
|
||
|
public override bool Equals(object? obj) => (obj is Entity other) && Equals(other);
|
||
|
public override int GetHashCode() => Value.Data.GetHashCode();
|
||
|
public override string? ToString() => $"Entity(0x{Value.Data.Data:X})";
|
||
|
|
||
|
public static bool operator ==(Entity left, Entity right) => left.Equals(right);
|
||
|
public static bool operator !=(Entity left, Entity right) => !left.Equals(right);
|
||
|
|
||
|
public static implicit operator ecs_entity_t(Entity e) => e.Value;
|
||
|
public static implicit operator Identifier(Entity e) => new(e.Value.Data);
|
||
|
public static implicit operator ecs_id_t(Entity e) => e.Value.Data;
|
||
|
}
|