RelationIndex<T>
The links of relation T in one world, by target (World.Relations): which entities link to an entity, O(1) to start and O(1) per link.
public sealed class RelationIndex<T> where T : struct, IRelationThe links of relation T in one world, by target (World.Relations): which entities link to an entity, O(1) to start and O(1) per link. Kept current as links are written and as their entities are destroyed or lose the buffer; the first lookup (and the first after World.Restore) indexes every buffer once. Links to a destroyed target stay findable by its id, which no later entity has. Owner thread only. Memory: one 20-byte link per element, recycled, and 8 bytes in its target's list.
Methods
Count
public int Count(EntityId target);Number of links to target. O(1).
Complexity (API table): O(1)
Find
public RelationIndex<T>.Sources Find(EntityId target);The entities linking to target, once per link. Destroying entities during the loop is allowed, changing links is not.
Complexity (API table): O(1), then O(1) per link
WhenTargetDestroyed
public RelationIndex<T> WhenTargetDestroyed(TargetPolicy policy);Decide what destroying an entity does to the links to it: TargetPolicy.Remove drops them (a party forgets a member that left the world), TargetPolicy.Destroy destroys the linking entities (the buffs a caster applied end with the caster), TargetPolicy.Keep (the default) leaves them. Applied inside every destroy (the index is kept built); O(1) per destroyed entity, O(links of each source) per link. Owner thread only.
Complexity (API table): O(1); then O(1) per destroyed entity and O(L) per link
Last updated on
How is this guide?