Add Term, Filter, Query, Rule shorthands to World

main
copygirl 2 years ago
parent ef00efd4bc
commit 3bea2a6ba0
  1. 2
      src/gaemstone.ECS/Entity.cs
  2. 6
      src/gaemstone.ECS/World.cs

@ -30,7 +30,7 @@ public unsafe readonly partial struct Entity<TContext>
public Entity<TContext>? Parent
=> GetOrNull(World, GetTargets(FlecsBuiltIn.ChildOf).FirstOrDefault());
public IEnumerable<Entity<TContext>> Children
=> Iterator<TContext>.FromTerm(World, new(FlecsBuiltIn.ChildOf, this)).GetAllEntities();
=> World.Term(new(FlecsBuiltIn.ChildOf, this)).GetAllEntities();
private Entity(World<TContext> world, Entity value)

@ -60,6 +60,12 @@ public unsafe struct World<TContext>
=> Pair(Entity<TRelation>(), Entity<TTarget>());
public Iterator<TContext> Term(Term term) => Iterator<TContext>.FromTerm(this, term);
public Filter<TContext> Filter(FilterDesc desc) => new(this, desc);
public Query<TContext> Query(QueryDesc desc) => new(this, desc);
public Rule<TContext> Rule(FilterDesc desc) => new(this, desc);
public bool Equals(World<TContext> other) => Value == other.Value;
public override bool Equals(object? obj) => (obj is World<TContext> other) && Equals(other);
public override int GetHashCode() => Value.GetHashCode();

Loading…
Cancel
Save