EntityNode.md

May 28, 2024 ยท View on GitHub

Friflo.Engine.ECS

Friflo.Engine.ECS

EntityNode Struct

Used by the EntityStore to store Entity components, scripts, tags and child entities internally as an array of nodes.

public struct EntityNode

Remarks

EntityNode's enable organizing entities in a tree graph structure.
The tree graph is stored in a EntityStore starting with a single StoreRoot entity.

When creating a new entity in an EntityStore instantiated with RandomPids it generates a unique random pid assigned to the entity.
Using random pids avoid merge conflicts when multiples users make changes to the same EntityStore file / database.
The probability generating the same pid by two different users is:

p = 1 - exp(-r^2 / (2 * N))
r:  number of new entities added by a user to an existing [EntityStore](EntityStore.md 'Friflo.Engine.ECS.EntityStore') (not the number of all entities)
N:  number of possible values = int.MaxValue = 2147483647
        See: https://en.wikipedia.org/wiki/Birthday_problem
Properties
ArchetypeThe Archetype storing the entity.
FlagsInternally used flags assigned to the entity.
Methods
ToString()