|
|
@ -1,5 +1,6 @@ |
|
|
|
using System; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Collections.Generic; |
|
|
|
|
|
|
|
using System.Linq; |
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
using System.Runtime.CompilerServices; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using System.Runtime.InteropServices; |
|
|
|
using gaemstone.Utility; |
|
|
|
using gaemstone.Utility; |
|
|
@ -60,7 +61,7 @@ public unsafe class EntityRef |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public EntityRef? Parent |
|
|
|
public EntityRef? Parent |
|
|
|
=> GetTarget(World.ChildOf); |
|
|
|
=> GetTargets(World.ChildOf).FirstOrDefault(); |
|
|
|
|
|
|
|
|
|
|
|
public IEnumerable<EntityRef> GetChildren() |
|
|
|
public IEnumerable<EntityRef> GetChildren() |
|
|
|
{ |
|
|
|
{ |
|
|
@ -139,12 +140,14 @@ public unsafe class EntityRef |
|
|
|
return this; |
|
|
|
return this; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public EntityRef? GetTarget(Entity relation, int index = 0) |
|
|
|
private EntityRef? GetTarget(Entity relation, int index) |
|
|
|
=> CreateOrNull(World, new(ecs_get_target(World, this, relation, index))); |
|
|
|
=> CreateOrNull(World, new(ecs_get_target(World, this, relation, index))); |
|
|
|
public EntityRef? GetTarget(string symbol, int index = 0) |
|
|
|
public IEnumerable<EntityRef> GetTargets(Entity relation) |
|
|
|
=> GetTarget(World.LookupBySymbolOrThrow(symbol), index); |
|
|
|
{ var index = 0; while (GetTarget(relation, index++) is EntityRef target) yield return target; } |
|
|
|
public EntityRef? GetTarget<T>(int index = 0) |
|
|
|
public IEnumerable<EntityRef> GetTargets(string symbol) |
|
|
|
=> GetTarget(World.LookupByTypeOrThrow(typeof(T)), index); |
|
|
|
=> GetTargets(World.LookupBySymbolOrThrow(symbol)); |
|
|
|
|
|
|
|
public IEnumerable<EntityRef> GetTargets<T>() |
|
|
|
|
|
|
|
=> GetTargets(World.LookupByTypeOrThrow(typeof(T))); |
|
|
|
|
|
|
|
|
|
|
|
public bool Equals(EntityRef? other) => (other is not null) && (World == other.World) && (Entity == other.Entity); |
|
|
|
public bool Equals(EntityRef? other) => (other is not null) && (World == other.World) && (Entity == other.Entity); |
|
|
|
public override bool Equals(object? obj) => Equals(obj as EntityRef); |
|
|
|
public override bool Equals(object? obj) => Equals(obj as EntityRef); |
|
|
|