Remove & operator for creating Identifier(Ref)s

wip/source-generators
copygirl 1 year ago
parent 49ae2efc19
commit 0c6d63af21
  1. 2
      src/gaemstone/ECS/Entity.cs
  2. 6
      src/gaemstone/ECS/EntityBase.cs
  3. 3
      src/gaemstone/ECS/EntityRef.cs

@ -42,8 +42,6 @@ public readonly struct Entity
public static bool operator ==(Entity left, Entity right) => left.Equals(right);
public static bool operator !=(Entity left, Entity right) => !left.Equals(right);
public static Identifier operator &(Entity relation, Entity target) => Identifier.Pair(relation, target);
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;

@ -23,19 +23,19 @@ public abstract class EntityBase<TReturn>
public TReturn Add(string symbol) => Add(Universe.LookupSymbolOrThrow(symbol));
public TReturn Add<T>() => Add(Universe.LookupOrThrow(typeof(T)));
public TReturn Add(Entity relation, Entity target) => Add(relation & target);
public TReturn Add(Entity relation, Entity target) => Add(Identifier.Pair(relation, target));
public TReturn Add<TRelation>(Entity target) => Add(Universe.LookupOrThrow<TRelation>(), target);
public TReturn Add<TRelation, TTarget>() => Add(Universe.LookupOrThrow<TRelation>(), Universe.LookupOrThrow<TTarget>());
public TReturn Remove(string symbol) => Remove(Universe.LookupSymbolOrThrow(symbol));
public TReturn Remove<T>() => Remove(Universe.LookupOrThrow(typeof(T)));
public TReturn Remove(Entity relation, Entity target) => Remove(relation & target);
public TReturn Remove(Entity relation, Entity target) => Remove(Identifier.Pair(relation, target));
public TReturn Remove<TRelation>(Entity target) => Remove(Universe.LookupOrThrow<TRelation>(), target);
public TReturn Remove<TRelation, TTarget>() => Remove(Universe.LookupOrThrow<TRelation>(), Universe.LookupOrThrow<TTarget>());
public bool Has(string symbol) => Has(Universe.LookupSymbolOrThrow(symbol));
public bool Has<T>() => Has(Universe.LookupOrThrow(typeof(T)));
public bool Has(Entity relation, Entity target) => Has(relation & target);
public bool Has(Entity relation, Entity target) => Has(Identifier.Pair(relation, target));
public bool Has<TRelation>(Entity target) => Has(Universe.LookupOrThrow<TRelation>(), target);
public bool Has<TRelation, TTarget>() => Has(Universe.LookupOrThrow<TRelation>(), Universe.LookupOrThrow<TTarget>());

@ -161,9 +161,6 @@ public unsafe sealed class EntityRef
public static bool operator ==(EntityRef? left, EntityRef? right) => ReferenceEquals(left, right) || (left?.Equals(right) ?? false);
public static bool operator !=(EntityRef? left, EntityRef? right) => !(left == right);
public static IdentifierRef operator &(EntityRef relation, Entity target) => IdentifierRef.Pair(relation, target);
public static IdentifierRef operator &(Entity relation, EntityRef target) => IdentifierRef.Pair(relation, target);
public static implicit operator Entity(EntityRef? e) => e?.Entity ?? default;
public static implicit operator ecs_entity_t(EntityRef? e) => e?.Entity.Value ?? default;

Loading…
Cancel
Save