check for specific relation
parent
0f4df1b948
commit
1123ef5662
|
@ -62,6 +62,11 @@ public abstract class EntityComponentReader
|
||||||
return RelationDepot.Relations<TRelationKind>();
|
return RelationDepot.Relations<TRelationKind>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected bool Related<TRelationKind>(in Entity a, in Entity b)
|
||||||
|
{
|
||||||
|
return RelationDepot.Related<TRelationKind>(a.ID, b.ID);
|
||||||
|
}
|
||||||
|
|
||||||
protected IEnumerable<Entity> RelatedToA<TRelationKind>(in Entity entity)
|
protected IEnumerable<Entity> RelatedToA<TRelationKind>(in Entity entity)
|
||||||
{
|
{
|
||||||
return RelationDepot.RelatedToA<TRelationKind>(entity.ID);
|
return RelationDepot.RelatedToA<TRelationKind>(entity.ID);
|
||||||
|
|
|
@ -37,6 +37,11 @@ namespace MoonTools.ECS
|
||||||
return Lookup<TRelationKind>().All();
|
return Lookup<TRelationKind>().All();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Related<TRelationKind>(int idA, int idB)
|
||||||
|
{
|
||||||
|
return Lookup<TRelationKind>().Has(new Relation(idA, idB));
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<Entity> RelatedToA<TRelationKind>(int entityID)
|
public IEnumerable<Entity> RelatedToA<TRelationKind>(int entityID)
|
||||||
{
|
{
|
||||||
return Lookup<TRelationKind>().RelatedToA(entityID);
|
return Lookup<TRelationKind>().RelatedToA(entityID);
|
||||||
|
|
|
@ -18,6 +18,7 @@ namespace MoonTools.ECS
|
||||||
public void Add(Relation relation)
|
public void Add(Relation relation)
|
||||||
{
|
{
|
||||||
if (relations.Contains(relation)) { return; }
|
if (relations.Contains(relation)) { return; }
|
||||||
|
|
||||||
var idA = relation.A.ID;
|
var idA = relation.A.ID;
|
||||||
var idB = relation.B.ID;
|
var idB = relation.B.ID;
|
||||||
|
|
||||||
|
@ -36,6 +37,11 @@ namespace MoonTools.ECS
|
||||||
relations.Add(relation);
|
relations.Add(relation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool Has(Relation relation)
|
||||||
|
{
|
||||||
|
return relations.Contains(relation);
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<Entity> RelatedToA(int entityID)
|
public IEnumerable<Entity> RelatedToA(int entityID)
|
||||||
{
|
{
|
||||||
if (entitiesRelatedToA.ContainsKey(entityID))
|
if (entitiesRelatedToA.ContainsKey(entityID))
|
||||||
|
|
Loading…
Reference in New Issue