EntityStore.md

July 31, 2024 ยท View on GitHub

Friflo.Engine.ECS

Friflo.Engine.ECS

EntityStore Class

An EntityStore is a container for Entity's their components, scripts, tags and the tree structure.
See Example.

public sealed class EntityStore : Friflo.Engine.ECS.EntityStoreBase

Inheritance System.Object ๐Ÿก’ EntityStoreBase ๐Ÿก’ EntityStore

Remarks

The EntityStore provide the features listed below

Constructors
EntityStore()
EntityStore(PidType)
Fields
InfoReturn store information used for debugging and optimization.
Properties
CapacityGet the number of internally reserved entities.
EntitiesReturn all Entity's stored in the EntityStore.
EntityScriptsReturn all Script's added to Entity's in the EntityStore.
EventRecorderRecord adding/removing of components/tags to/from entities if Enabled is true.
It is required to filter these events using an EventFilter.
NodeMaxIdReturn the largest entity Id store in the entity store.
RecycleIdsIf true (default) ids of deleted entities are recycled when creating new entities.
If false every new entity gets its own unique id. As a result the store capacity will always grow over time.
StoreRootReturn the root Entity of the store.
Methods
CastEntitiesChanged(object, EntitiesChanged)
CloneEntity(Entity)Create and return a clone of the passed entity in the store.
CreateEntity()Create and return a new Entity in the entity store.
See Example.
CreateEntity(int)Create and return a new Entity with the passed id in the entity store.
EnsureCapacity(int)Allocates memory for entities in the store to enable creating entities without reallocation.
GetCommandBuffer()Returns a CommandBuffer used to record and Playback() entity changes.
GetEntityById(int)Returns the Entity with the passed id.
The returned entity can be null (IsNull == true).
GetEntityByPid(long)Return the Entity with the passed entity pid.
GetEntityNode(int)Return the internal node for the passed entity id.
GetEntitySchema()Return the EntitySchema containing all available IComponent, ITag and Script types.
GetInternalParentId(int)
IdToPid(int)Return the Pid for the passed entity id.
PidToId(long)Return the Id for the passed entity pid.
SetRandomSeed(int)Set the seed used to create random entity Pid's for an entity store
created with PidType == RandomPids.
SetStoreRoot(Entity)Set the passed entity as the StoreRoot entity.
TryGetEntityById(int, Entity)Get the Entity associated with the passed id.
Returns true if passed id is valid (id < Capacity).
The returned entity can be null (IsNull == true).
TryGetEntityByPid(long, Entity)Try to return the Entity with the passed entity pid.
UpdateEntityCompIndex(int, int)
Events
OnChildEntitiesChangedAdd / remove an event handler for ChildEntitiesChanged events triggered by:
AddChild(Entity)
InsertChild(int, Entity)
RemoveChild(Entity).
OnEntitiesChangedFire events in case an Entity changed.
OnEntityCreateAdd / remove an event handler for EntityCreate events triggered by CreateEntity().
OnEntityDeleteAdd / remove an event handler for EntityDelete events triggered by DeleteEntity().
OnScriptAddedAdd / remove an event handler for ScriptChanged events triggered by:
AddScript<TScript>(TScript).
OnScriptRemovedAdd / remove an event handler for ScriptChanged events triggered by:
RemoveScript<TScript>() .