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
The EntityStore provide the features listed below
- Store a map (container) of entities in linear memory.
Entity data can retrieved by entity id using the property GetEntityById(int).
Entity's have the states below:
- StoreOwnership: attached / detached
if detached - System.NullReferenceException are thrown by Entity properties and methods. - TreeMembership: treeNode / floating node (not part of the EntityStore tree graph).
All children of a treeNode are treeNode's themselves.
- StoreOwnership: attached / detached
- Manage a tree graph of entities which starts with the StoreRoot entity to build up a scene graph.
- Store the data of IComponent's and Script's.
Constructors | |
---|---|
EntityStore() | |
EntityStore(PidType) |
Fields | |
---|---|
Info | Return store information used for debugging and optimization. |
Properties | |
---|---|
Capacity | Get the number of internally reserved entities. |
Entities | Return all Entity's stored in the EntityStore. |
EntityScripts | Return all Script's added to Entity's in the EntityStore. |
EventRecorder | Record adding/removing of components/tags to/from entities if Enabled is true. It is required to filter these events using an EventFilter. |
NodeMaxId | Return the largest entity Id store in the entity store. |
RecycleIds | If 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. |
StoreRoot | Return 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 | |
---|---|
OnChildEntitiesChanged | Add / remove an event handler for ChildEntitiesChanged events triggered by: AddChild(Entity) InsertChild(int, Entity) RemoveChild(Entity). |
OnEntitiesChanged | Fire events in case an Entity changed. |
OnEntityCreate | Add / remove an event handler for EntityCreate events triggered by CreateEntity(). |
OnEntityDelete | Add / remove an event handler for EntityDelete events triggered by DeleteEntity(). |
OnScriptAdded | Add / remove an event handler for ScriptChanged events triggered by: AddScript<TScript>(TScript). |
OnScriptRemoved | Add / remove an event handler for ScriptChanged events triggered by: RemoveScript<TScript>() . |