#include
Public Types | |
enum | SinkEventSubscriptions : uint32 { OnBeforeSpawn = BIT(0), OnSpawn = BIT(1), OnRemove = BIT(2), OnReused = BIT(3), Last = OnReused, Count = 4, AllSinkEvents = ~0u } |
enum | EEditorSimulationMode { EEditorSimulationMode::Editing, EEditorSimulationMode::InGame, Simulation } |
Determines the state of simulation in the Editor, see OnEditorSimulationModeChanged. More... | |
Public Member Functions | |
virtual void | Release ()=0 |
Releases entity system. | |
virtual void | PrePhysicsUpdate ()=0 |
virtual void | Update ()=0 |
Updates entity system and all entities. This function executes once a frame. | |
virtual void | Reset ()=0 |
Resets whole entity system, and destroy all entities. | |
virtual void | Unload ()=0 |
Unloads whole entity system - should be called when level is unloaded. | |
virtual void | PurgeHeaps ()=0 |
virtual void | DeletePendingEntities ()=0 |
Deletes any pending entities (which got marked for deletion). | |
virtual IEntityClassRegistry * | GetClassRegistry ()=0 |
virtual IEntity * | SpawnEntity (SEntitySpawnParams ¶ms, bool bAutoInit=true)=0 |
virtual bool | InitEntity (IEntity *pEntity, SEntitySpawnParams ¶ms)=0 |
virtual IEntity * | GetEntity (EntityId id) const =0 |
virtual IEntity * | FindEntityByName (const char *sEntityName) const =0 |
virtual void | ReserveEntityId (const EntityId id)=0 |
virtual EntityId | ReserveUnknownEntityId ()=0 |
Reserves a dynamic entity id. | |
virtual void | RemoveEntity (EntityId entity, bool bForceRemoveNow=false)=0 |
virtual uint32 | GetNumEntities () const =0 |
virtual IEntityItPtr | GetEntityIterator ()=0 |
virtual void | SendEventToAll (SEntityEvent &event)=0 |
virtual void | OnEditorSimulationModeChanged (EEditorSimulationMode mode)=0 |
Sent when game mode in Editor is changed. | |
virtual void | OnLevelLoaded ()=0 |
Sent after the level has finished loading. | |
virtual void | OnLevelGameplayStart ()=0 |
Sent when level is loaded and gameplay can start, triggers start of simulation for entities. | |
virtual int | QueryProximity (SEntityProximityQuery &query)=0 |
virtual void | ResizeProximityGrid (int nWidth, int nHeight)=0 |
virtual int | GetPhysicalEntitiesInBox (const Vec3 &origin, float radius, IPhysicalEntity **&pList, int physFlags=(1<< 1)|(1<< 2)|(1<< 3)|(1<< 4)) const =0 |
virtual IEntity * | GetEntityFromPhysics (IPhysicalEntity *pPhysEntity) const =0 |
Retrieves host entity from the physical entity. | |
virtual void | AddSink (IEntitySystemSink *sink, std::underlying_type< SinkEventSubscriptions >::type subscriptions)=0 |
virtual void | RemoveSink (IEntitySystemSink *sink)=0 |
virtual void | PauseTimers (bool bPause, bool bResume=false)=0 |
virtual bool | IsIDUsed (EntityId nID) const =0 |
Checks whether a given entity ID is already used. | |
virtual void | GetMemoryStatistics (ICrySizer *pSizer) const =0 |
Puts the memory statistics of the entities into the given sizer object according to the specifications in interface ICrySizer. | |
virtual ISystem * | GetSystem () const =0 |
Gets pointer to original ISystem. | |
virtual bool | ExtractArcheTypeLoadParams (XmlNodeRef &entityNode, SEntitySpawnParams &spawnParams) const =0 |
virtual bool | ExtractEntityLoadParams (XmlNodeRef &entityNode, SEntitySpawnParams &spawnParams) const =0 |
virtual void | BeginCreateEntities (int amtToCreate)=0 |
virtual bool | CreateEntity (XmlNodeRef &entityNode, SEntitySpawnParams &pParams, EntityId &outUsingId)=0 |
virtual void | EndCreateEntities ()=0 |
virtual void | LoadEntities (XmlNodeRef &objectsNode, bool bIsLoadingLevelFile)=0 |
virtual void | LoadEntities (XmlNodeRef &objectsNode, bool bIsLoadingLevelFile, const Vec3 &segmentOffest)=0 |
virtual void | AddEntityLayerListener (const char *szLayerName, IEntityLayerListener *pListener, const bool bCaseSensitive=true)=0 |
Register entity layer listener. | |
virtual void | RemoveEntityLayerListener (const char *szLayerName, IEntityLayerListener *pListener, const bool bCaseSensitive=true)=0 |
virtual EntityId | FindEntityByGuid (const EntityGUID &guid) const =0 |
Finds entity by Entity GUID. | |
virtual IAreaManager * | GetAreaManager () const =0 |
Gets a pointer to access to area manager. | |
virtual IBreakableManager * | GetBreakableManager () const =0 |
virtual IEntityArchetype * | LoadEntityArchetype (XmlNodeRef oArchetype)=0 |
Entity archetypes. | |
virtual IEntityArchetype * | LoadEntityArchetype (const char *sArchetype)=0 |
virtual void | UnloadEntityArchetype (const char *sArchetype)=0 |
virtual IEntityArchetype * | CreateEntityArchetype (IEntityClass *pClass, const char *sArchetype)=0 |
virtual void | RefreshEntityArchetypesInRegistry ()=0 |
virtual void | SetEntityArchetypeManagerExtension (IEntityArchetypeManagerExtension *pEntityArchetypeManagerExtension)=0 |
virtual IEntityArchetypeManagerExtension * | GetEntityArchetypeManagerExtension () const =0 |
virtual void | Serialize (TSerialize ser)=0 |
Serializes basic entity system members (timers etc. ) to/from a savegame;. | |
virtual void | SetNextSpawnId (EntityId id)=0 |
Makes sure the next SpawnEntity will use the id provided (if it's in use, the current entity is deleted). | |
virtual void | ResetAreas ()=0 |
Resets any area state for the specified entity. | |
virtual void | UnloadAreas ()=0 |
Unloads any area state for the specified entity. | |
virtual void | DumpEntities ()=0 |
Dumps entities in system. | |
virtual void | LockSpawning (bool lock)=0 |
Do not spawn any entities unless forced to. | |
virtual bool | OnLoadLevel (const char *szLevelPath)=0 |
Handles entity-related loading of a level. | |
virtual IEntityLayer * | AddLayer (const char *szName, const char *szParent, uint16 id, bool bHasPhysics, int specs, bool bDefaultLoaded)=0 |
Add entity layer. | |
virtual void | LoadLayers (const char *dataFile)=0 |
Load layer infos. | |
virtual void | LinkLayerChildren ()=0 |
Reorganize layer children. | |
virtual void | AddEntityToLayer (const char *layer, EntityId id)=0 |
Add entity to entity layer. | |
virtual void | RemoveEntityFromLayers (EntityId id)=0 |
Remove entity from all layers. | |
virtual void | ClearLayers ()=0 |
Clear list of entity layers. | |
virtual void | EnableDefaultLayers (bool isSerialized=true)=0 |
Enable all the default layers. | |
virtual void | EnableLayer (const char *layer, bool isEnable, bool isSerialized=true)=0 |
Enable entity layer. | |
virtual void | EnableLayerSet (const char *const *pLayers, size_t layerCount, bool isSerialized=true, IEntityLayerSetUpdateListener *pListener=nullptr)=0 |
Enable entity layers specified in the layer set and hide all other known layers. | |
virtual IEntityLayer * | FindLayer (const char *szLayerName, const bool bCaseSensitive=true) const =0 |
Find a layer with a given name. | |
virtual bool | IsLayerEnabled (const char *layer, bool bMustBeLoaded, bool bCaseSensitive=true) const =0 |
Is layer with given name enabled ?. | |
virtual bool | ShouldSerializedEntity (IEntity *pEntity)=0 |
Returns true if entity is not in a layer or the layer is enabled/serialized. | |
virtual void | RegisterPhysicCallbacks ()=0 |
Register callbacks from Physics System. | |
virtual void | UnregisterPhysicCallbacks ()=0 |
virtual void | PurgeDeferredCollisionEvents (bool bForce=false)=0 |
virtual void | ResumePhysicsForSuppressedEntities (bool bWakeUp)=0 |
virtual void | SaveInternalState (struct IDataWriteStream &writer) const =0 |
Save/Load internal state (used mostly for LiveCreate). | |
virtual void | LoadInternalState (struct IDataReadStream &reader)=0 |
virtual int | GetLayerId (const char *szLayerName) const =0 |
Get the layer index, -1 if not found. | |
virtual const char * | GetLayerName (int layerId) const =0 |
Get the layer name, from an id. | |
virtual int | GetLayerChildCount (const char *szLayerName) const =0 |
Gets the number of children for a layer. | |
virtual const char * | GetLayerChild (const char *szLayerName, int childIdx) const =0 |
Gets the name of the specified child layer. | |
virtual int | GetVisibleLayerIDs (uint8 *pLayerMask, const uint32 maxCount) const =0 |
Get mask for visible layers, returns layer count. | |
virtual void | ToggleLayerVisibility (const char *layer, bool isEnabled, bool includeParent=true)=0 |
Toggle layer visibility (in-game only), used by LiveCreate, non recursive. | |
virtual void | ToggleLayersBySubstring (const char *pSearchSubstring, const char *pExceptionSubstring, bool isEnable)=0 |
Toggle layer visibility for all layers containing pSearchSubstring with the exception of any with pExceptionSubstring. | |
virtual IBSPTree3D * | CreateBSPTree3D (const IBSPTree3D::FaceList &faceList)=0 |
virtual void | ReleaseBSPTree3D (IBSPTree3D *&pTree)=0 |
void | AddEntityEventListener (EntityId entityId, EEntityEvent event, IEntityEventListener *pListener) |
Registers Entity Event's listeners. | |
void | RemoveEntityEventListener (EntityId entityId, EEntityEvent event, IEntityEventListener *pListener) |
Interface to the system that manages the entities in the game. Interface to the system that manages the entities in the game, their creation, deletion and upkeep. The entities are kept in a map indexed by their unique entity ID. The entity system updates only unbound entities every frame (bound entities are updated by their parent entities), and deletes the entities marked as garbage every frame before the update. The entity system also keeps track of entities that have to be drawn last and with more zbuffer resolution.
strong |
|
pure virtual |
Adds the sink of the entity system. The sink is a class which implements IEntitySystemSink.
sink | Pointer to the sink, must not be 0. |
subscription | - combination of SinkEventSubscriptions flags specifying which events to receive. |
|
pure virtual |
Creates entity from XML. To ensure that entity links work, call BeginCreateEntities. Before using CreateEntity, then call EndCreateEntities when you're done to setup all the links.
entityNode | XML entity node. |
spawnParams | Entity spawn parameters. |
outusingID | Resulting ID. |
|
pure virtual |
Extract entity archetype load parameters from XML.
entityNode | XML archetype entity node. |
spawnParams | Archetype entity spawn parameters. |
|
pure virtual |
Extract entity load parameters from XML.
entityNode | XML entity node. |
spawnParams | Entity spawn parameters. |
|
pure virtual |
Find first entity with given name.
sEntityName | Name to look for. |
#include
void FindEntityByName()
{
// The name of the entity that we want to query for
// This is the name specified with SEntitySpawnParams::sName, IEntity::SetName and in the properties panel inside the Editor when an entity is selected.
const char* szMyEntityName = "MyEntity";
// Query the entity system for the entity, searching the by-name entity map
// Note that this operation is more costly than looking up by Id, and is *not* reliable as entity names are not unique!
if (IEntity* pEntity = gEnv->pEntitySystem->FindEntityByName(szMyEntityName))
{
/* Entity was present in the world, and the pointer can now be used.
Note that the lifetime of pEntity is managed by the entity system, avoid storing the raw pointer to be safe. */
}
}
|
pure virtual |
|
pure virtual |
Retrieves the entity class registry interface.
|
pure virtual |
Retrieves entity from its unique id.
id | Unique ID of the entity required. |
#include
#include
void GetEntity()
{
// Identifier of the entity that we want to find, for example found by calling IEntity::GetId.
// For the sake of this example we will query the default player entity identifier.
EntityId id = LOCAL_PLAYER_ENTITY_ID;
// Query the entity system for the entity, this will result in a constant-time lookup.
if (IEntity* pEntity = gEnv->pEntitySystem->GetEntity(id))
{
/* Entity was present in the world, and the pointer can now be used.
Note that the lifetime of pEntity is managed by the entity system, avoid storing the raw pointer to be safe. */
}
}
|
pure virtual |
Gets a entity iterator. This iterator interface can be used to traverse all the entities in this entity system.
#include
void TraverseEntities()
{
// Retrieves an iterator that can be used to traverse all the entities in the scene
// Note that this can easily become expensive due to the sheer number of entities that can be in each scene
IEntityItPtr pEntityIterator = gEnv->pEntitySystem->GetEntityIterator();
// Traverse the entities until IEntityIt::Next returns a nullptr
while (IEntity* pEntity = pEntityIterator->Next())
{
// Skip entities that have been marked for deletion (clean-up will occur at the start of the next frame)
if (!pEntity->IsGarbage())
{
/* pEntity can now be safely used */
}
}
}
|
pure virtual |
|
pure virtual |
Gets all entities in specified radius.
origin | |
radius | |
pList | |
physFlags | Is one or more of PhysicalEntityFlag. |
|
pure virtual |
Initialize entity if entity was spawned not initialized (with bAutoInit false in SpawnEntity).
pEntity | Pointer to just spawned entity object. |
params | Entity descriptor structure that describes what kind of entity needs to be spawned. |
|
pure virtual |
Loads entities exported from Editor. bIsLoadingLevelFile indicates if the loaded entities come from the original level file.
|
pure virtual |
Pause all entity timers.
bPause | true to pause timer, false to resume. |
|
pure virtual |
Updates entity system and all entities before physics is called (or as early as possible after input in the multithreaded physics case). This function executes once per frame.
|
pure virtual |
Get all entities within proximity of the specified bounding box.
|
pure virtual |
Removes an entity by ID.
entity | Id of the entity to be removed. |
bForceRemoveNow | If true, forces immediately delete of entity, overwise will delete entity on next update. |
|
pure virtual |
Removes listening sink from the entity system. The sink is a class which implements IEntitySystemSink.
sink | Pointer to the sink, must not be 0. |
|
pure virtual |
id | Must not be 0. |
|
pure virtual |
Resizes the proximity grid.
|
pure virtual |
Resets physical simulation suppressed by LiveCreate during "edit mode". Called by LiveCreate subsystem when user resumed normal game mode.
|
pure virtual |
Sends the same event to all entities in Entity System.
event | Event to send. |
|
pure virtual |
Spawns a new entity according to the data in the Entity Descriptor.
params | Entity descriptor structure that describes what kind of entity needs to be spawned. |
bAutoInit | If true, automatically initialize entity. |
#include
void SpawnEntity(const Matrix34& initialWorldTransformation)
{
// Create a spawn parameters structure, used to specify the initial state of the entity we want to spawn
SEntitySpawnParams spawnParameters;
// Specify position in world coordinates
spawnParameters.vPosition = initialWorldTransformation.GetTranslation();
// Specify world rotation
spawnParameters.qRotation = Quat(initialWorldTransformation);
// Specify scale
spawnParameters.vScale = initialWorldTransformation.GetScale();
// Now spawn the entity in the world
if (IEntity* pEntity = gEnv->pEntitySystem->SpawnEntity(spawnParameters))
{
/* pEntity can now be used, and will persist until manually removed or when the level is unloaded */
}
}