namespace MoonTools.ECS { internal class RelationDepot { private Dictionary storages = new Dictionary(); private RelationStorage Lookup() { return storages[typeof(TRelationKind)]; } public void Register() { storages[typeof(TRelationKind)] = new RelationStorage(); } public void Add(Relation relation) { Lookup().Add(relation); } public void Remove(Relation relation) { Lookup().Remove(relation); } public void OnEntityDestroy(int entityID) { foreach (var storage in storages.Values) { storage.OnEntityDestroy(entityID); } } public IEnumerable Relations() { return Lookup().All(); } public IEnumerable RelatedToA(int entityID) { return Lookup().RelatedToA(entityID); } public IEnumerable RelatedToB(int entityID) { return Lookup().RelatedToB(entityID); } } }