#include
Public Types | |
enum | EEntityLoadFlags { EF_AUTO_PHYSICALIZE = 0x0001, EF_NO_STREAMING = 0x0002 } |
enum | EAttachmentFlags { ATTACHMENT_KEEP_TRANSFORMATION = BIT(0), ATTACHMENT_GEOMCACHENODE = BIT(1), ATTACHMENT_CHARACTERBONE = BIT(2), ATTACHMENT_LOCAL_SIM = BIT(3), ATTACHMENT_SUPPRESS_UPDATE = BIT(4), ATTACHMENT_COUNT = 5 } |
using | AttachmentFlagsMask = CEnumFlags< EAttachmentFlags > |
using | AttachmentFlagsType = uint32 |
typedef std::function< void(IEntityComponent *)> | ComponentsVisitor |
Public Member Functions | |
virtual EntityId | GetId () const =0 |
virtual const EntityGUID & | GetGuid () const =0 |
virtual IEntityClass * | GetClass () const =0 |
virtual CRY_DEPRECATED_ENTTIY_ARCHETYPE IEntityArchetype * | GetArchetype () const =0 |
virtual void | SetFlags (uint32 flags)=0 |
virtual uint32 | GetFlags () const =0 |
Gets current entity flags. | |
virtual void | AddFlags (uint32 flagsToAdd)=0 |
virtual void | ClearFlags (uint32 flagsToClear)=0 |
virtual bool | CheckFlags (uint32 flagsToCheck) const =0 |
virtual void | SetFlagsExtended (uint32 flags)=0 |
virtual uint32 | GetFlagsExtended () const =0 |
Gets current entity EEntityFlagsExtended flags. | |
virtual bool | IsGarbage () const =0 |
virtual uint8 | GetComponentChangeState () const =0 |
virtual void | SetName (const char *sName)=0 |
virtual const char * | GetName () const =0 |
virtual string | GetEntityTextDescription () const =0 |
Returns textual description of entity for logging. | |
virtual void | SerializeXML (XmlNodeRef &entityNode, bool bLoading, bool bIncludeScriptProxy=true, bool bExcludeSchematycProperties=false)=0 |
Serializes entity parameters to/from XML. | |
virtual bool | IsLoadedFromLevelFile () const =0 |
virtual void | AttachChild (IEntity *pChildEntity, const SChildAttachParams &attachParams=SChildAttachParams())=0 |
virtual void | DetachAll (AttachmentFlagsType attachmentFlags=0)=0 |
Detaches all the child entities attached to this entity. | |
virtual void | DetachThis (AttachmentFlagsType attachmentFlags=0, EntityTransformationFlagsType transformReasons=0)=0 |
Detach this entity from the parent entity (assumes that this entity is the child entity). | |
virtual int | GetChildCount () const =0 |
Retrieves the number of attached child entities. | |
virtual IEntity * | GetChild (int nIndex) const =0 |
virtual IEntity * | GetParent () const =0 |
virtual IEntity * | GetLocalSimParent () const =0 |
virtual Matrix34 | GetParentAttachPointWorldTM () const =0 |
virtual bool | IsParentAttachmentValid () const =0 |
virtual void | SetWorldTM (const Matrix34 &tm, EntityTransformationFlagsMask transformReasons=EntityTransformationFlagsMask())=0 |
virtual void | SetLocalTM (const Matrix34 &tm, EntityTransformationFlagsMask transformReasons=EntityTransformationFlagsMask())=0 |
virtual const Matrix34 & | GetWorldTM () const =0 |
virtual Matrix34 | GetLocalTM () const =0 |
virtual void | GetWorldBounds (AABB &bbox) const =0 |
virtual void | GetLocalBounds (AABB &bbox) const =0 |
virtual void | SetLocalBounds (const AABB &bounds, bool bDoNotRecalculate)=0 |
virtual void | InvalidateLocalBounds ()=0 |
Invalidates local or world space bounding box. | |
virtual void | SetPos (const Vec3 &vPos, EntityTransformationFlagsMask transformReasons=EntityTransformationFlagsMask(), bool bRecalcPhyBounds=false, bool bForce=false)=0 |
Set the entity local space position. | |
virtual const Vec3 & | GetPos () const =0 |
Retrieve the entity local space position. | |
virtual void | SetRotation (const Quat &qRotation, EntityTransformationFlagsMask transformReasons=EntityTransformationFlagsMask())=0 |
Sets the entity local space rotation quaternion. | |
virtual const Quat & | GetRotation () const =0 |
Retrieves the entity local space rotation quaternion. | |
virtual void | SetScale (const Vec3 &vScale, EntityTransformationFlagsMask transformReasons=EntityTransformationFlagsMask())=0 |
Sets the entity local space scale. | |
virtual const Vec3 & | GetScale () const =0 |
Retrieves the entity local space scale. | |
virtual void | SetPosRotScale (const Vec3 &vPos, const Quat &qRotation, const Vec3 &vScale, EntityTransformationFlagsMask transformReasons=EntityTransformationFlagsMask())=0 |
Sets the entity position,rotation and scale at once. | |
virtual Vec3 | GetWorldPos () const =0 |
Helper function to retrieve world space entity position. | |
virtual Ang3 | GetWorldAngles () const =0 |
Helper function to retrieve world space entity orientation angles. | |
virtual Quat | GetWorldRotation () const =0 |
Helper function to retrieve world space entity orientation quaternion. | |
virtual Vec3 | GetWorldScale () const =0 |
Helper function to retrieve world space entity scale. | |
virtual void | UpdateComponentEventMask (const IEntityComponent *pComponent)=0 |
virtual bool | IsActivatedForUpdates () const =0 |
Checks whether the entity is set to be updated this / next frame. | |
virtual void | Serialize (TSerialize serializer, int nFlags=0)=0 |
virtual bool | SendEvent (const SEntityEvent &event)=0 |
virtual void | AddEventListener (EEntityEvent event, IEntityEventListener *pListener)=0 |
Adds a listener that can receive the specified event from this entity. | |
virtual void | RemoveEventListener (EEntityEvent event, IEntityEventListener *pListener)=0 |
Removes an existing event listener from the entity. | |
virtual int | SetTimer (int nTimerId, int nMilliSeconds)=0 |
virtual void | KillTimer (int nTimerId)=0 |
virtual void | Hide (bool bHide, EEntityHideFlags hideFlags=ENTITY_HIDE_NO_FLAG)=0 |
virtual bool | IsHidden () const =0 |
Checks if the entity is hidden. | |
virtual void | Invisible (bool bInvisible)=0 |
virtual bool | IsInvisible () const =0 |
Checks if the entity is invisible. | |
virtual const IAIObject * | GetAI () const =0 |
virtual IAIObject * | GetAI ()=0 |
virtual bool | HasAI () const =0 |
virtual tAIObjectID | GetAIObjectID () const =0 |
virtual void | SetAIObjectID (tAIObjectID id)=0 |
IEntity * | GetRenderInterface () |
Retrieve access to the rendering functionality of the Entity. | |
virtual ISerializableInfoPtr | GetSerializableNetworkSpawnInfo () const =0 |
virtual IEntityComponent * | GetProxy (EEntityProxy proxy) const =0 |
virtual IEntityComponent * | CreateProxy (EEntityProxy proxy)=0 |
virtual IEntityComponent * | CreateComponentByInterfaceID (const CryInterfaceID &interfaceId, IEntityComponent::SInitParams *pInitParams=nullptr)=0 |
virtual bool | AddComponent (std::shared_ptr< IEntityComponent > pComponent, IEntityComponent::SInitParams *pInitParams=nullptr)=0 |
virtual void | RemoveComponent (IEntityComponent *pComponent)=0 |
virtual void | RemoveAllComponents ()=0 |
Removes and shut downs all components that entity contains. | |
virtual void | ReplaceComponent (IEntityComponent *pExistingComponent, std::shared_ptr< IEntityComponent > pNewComponent)=0 |
virtual IEntityComponent * | GetComponentByTypeId (const CryInterfaceID &interfaceID) const =0 |
virtual void | GetComponentsByTypeId (const CryInterfaceID &interfaceID, DynArray< IEntityComponent *> &components) const =0 |
virtual IEntityComponent * | GetComponentByGUID (const CryGUID &guid) const =0 |
virtual void | QueryComponentsByInterfaceID (const CryInterfaceID &interfaceID, DynArray< IEntityComponent *> &components) const =0 |
Queries an array of entity components implementing the specified component interface. | |
virtual IEntityComponent * | QueryComponentByInterfaceID (const CryInterfaceID &interfaceID) const =0 |
Queries an entity component implementing the specified component interface. | |
template | |
ComponentType * | CreateComponent () |
template | |
ComponentType * | GetOrCreateComponent (bool bCheckHierarchy=true) |
template | |
ComponentType * | GetComponent (bool bCheckHierarchy=true) const |
template | |
void | GetAllComponents (DynArray< ComponentType *> &components, bool bCheckHierarchy=true) const |
template | |
ComponentType * | CreateComponentClass (TArgs &&... args) |
Create a new initialized component using a new operator of the class type. | |
template | |
ComponentType * | GetOrCreateComponentClass (TArgs &&... args) |
Get existing or Create a new initialized component using the new operator of the class type, typeid of the component is null guid. | |
template | |
void | RemoveComponent (bool checkHierarchy=true) |
template | |
void | RemoveAllComponents (bool checkHierarchy=true) |
virtual void | GetComponents (DynArray< IEntityComponent *> &components) const =0 |
Retrieve array of entity components. | |
virtual uint32 | GetComponentsCount () const =0 |
Retrieve nu number of components in the entity. | |
virtual void | VisitComponents (const ComponentsVisitor &visitor)=0 |
virtual void | Physicalize (SEntityPhysicalizeParams ¶ms)=0 |
virtual void | EnablePhysics (bool enable)=0 |
Enable/Disable physics by flag. | |
virtual bool | IsPhysicsEnabled () const =0 |
Is physical simulation enabled? | |
virtual void | AssignPhysicalEntity (IPhysicalEntity *pPhysEntity, int nSlot=-1)=0 |
virtual IPhysicalEntity * | GetPhysics () const =0 |
IPhysicalEntity * | GetPhysicalEntity () const |
virtual int | PhysicalizeSlot (int slot, SEntityPhysicalizeParams ¶ms)=0 |
virtual void | UnphysicalizeSlot (int slot)=0 |
virtual void | UpdateSlotPhysics (int slot)=0 |
virtual void | SetPhysicsState (XmlNodeRef &physicsState)=0 |
virtual void | GetPhysicsWorldBounds (AABB &bounds) const =0 |
virtual void | AddImpulse (int ipart, const Vec3 &pos, const Vec3 &impulse, bool bPos, float fAuxScale, float fPushScale=1.0f)=0 |
Add impulse to physical entity. | |
virtual bool | PhysicalizeFoliage (int iSlot)=0 |
Physicalizes the foliage of StatObj in slot iSlot. | |
virtual void | DephysicalizeFoliage (int iSlot)=0 |
Dephysicalizes the foliage in slot iSlot. | |
virtual int | GetPhysicalEntityPartId0 (int islot=0)=0 |
retrieve starting partid for a given slot. | |
virtual void | PhysicsNetSerializeEnable (bool enable)=0 |
Enable/disable network serialization of the physics aspect. | |
virtual void | PhysicsNetSerializeTyped (TSerialize &ser, int type, int flags)=0 |
virtual void | PhysicsNetSerialize (TSerialize &ser)=0 |
virtual void | SetMaterial (IMaterial *pMaterial)=0 |
virtual IMaterial * | GetMaterial ()=0 |
virtual bool | IsSlotValid (int nIndex) const =0 |
virtual int | AllocateSlot ()=0 |
Allocates index for an entity slot. | |
virtual void | FreeSlot (int nIndex)=0 |
Frees slot at specified index. | |
virtual int | GetSlotCount () const =0 |
Gets number of allocated object slots in the entity. | |
virtual void | ClearSlots ()=0 |
Removes all object slots from the entity. | |
virtual bool | GetSlotInfo (int nIndex, SEntitySlotInfo &slotInfo) const =0 |
virtual Matrix34 | GetSlotWorldTM (int nSlot) const =0 |
virtual Matrix34 | GetSlotLocalTM (int nSlot, bool bRelativeToParent) const =0 |
virtual void | SetSlotLocalTM (int nSlot, const Matrix34 &localTM, EntityTransformationFlagsMask transformReasons=EntityTransformationFlagsMask())=0 |
Sets local transformation matrix of the object slot. | |
virtual void | SetSlotCameraSpacePos (int nSlot, const Vec3 &cameraSpacePos)=0 |
Sets camera space position of the object slot. | |
virtual void | GetSlotCameraSpacePos (int nSlot, Vec3 &cameraSpacePos) const =0 |
Gets camera space position of the object slot. | |
virtual bool | SetParentSlot (int nParentIndex, int nChildIndex)=0 |
virtual void | UpdateSlotForComponent (IEntityComponent *pComponent)=0 |
Prepare and update an entity slot to be used with component. | |
virtual void | SetSlotMaterial (int nSlot, IMaterial *pMaterial)=0 |
virtual IMaterial * | GetSlotMaterial (int nSlot) const =0 |
virtual IMaterial * | GetRenderMaterial (int nSlot=-1) const =0 |
virtual void | SetSlotFlags (int nSlot, uint32 nFlags)=0 |
virtual uint32 | GetSlotFlags (int nSlot) const =0 |
virtual void | SetSubObjHideMask (int nSlot, hidemask nSubObjHideMask)=0 |
virtual hidemask | GetSubObjHideMask (int nSlot) const =0 |
virtual bool | ShouldUpdateCharacter (int nSlot) const =0 |
virtual ICharacterInstance * | GetCharacter (int nSlot)=0 |
virtual int | SetCharacter (ICharacterInstance *pCharacter, int nSlot, bool bUpdatePhysics=true)=0 |
virtual IStatObj * | GetStatObj (int nSlot)=0 |
virtual IParticleEmitter * | GetParticleEmitter (int nSlot)=0 |
virtual IGeomCacheRenderNode * | GetGeomCacheRenderNode (int nSlot)=0 |
virtual void | MoveSlot (IEntity *targetIEnt, int nSlot)=0 |
virtual int | SetStatObj (IStatObj *pStatObj, int nSlot, bool bUpdatePhysics, float mass=-1.0f)=0 |
virtual int | LoadGeometry (int nSlot, const char *sFilename, const char *sGeomName=NULL, int nLoadFlags=0)=0 |
virtual int | LoadCharacter (int nSlot, const char *sFilename, int nLoadFlags=0)=0 |
virtual int | LoadGeomCache (int nSlot, const char *sFilename)=0 |
virtual int | SetSlotRenderNode (int nSlot, IRenderNode *pRenderNode)=0 |
Assigns a 3DEngine render node to the Entity Slot. | |
virtual IRenderNode * | GetSlotRenderNode (int nSlot)=0 |
Returns a 3DEngine render node assigned to an Entity Slot. | |
virtual INetEntity * | GetNetEntity ()=0 |
virtual INetEntity * | AssignNetEntityLegacy (INetEntity *ptr)=0 |
virtual int | LoadParticleEmitter (int nSlot, IParticleEffect *pEffect, SpawnParams const *params=NULL, bool bPrime=false, bool bSerialize=false)=0 |
virtual int | SetParticleEmitter (int nSlot, IParticleEmitter *pEmitter, bool bSerialize=false)=0 |
virtual int | LoadLight (int nSlot, SRenderLight *pLight)=0 |
virtual int | LoadFogVolume (int nSlot, const SFogVolumeProperties &properties)=0 |
virtual void | InvalidateTM (EntityTransformationFlagsMask transformReasons=EntityTransformationFlagsMask(), bool bRecalcPhyBounds=false)=0 |
Invalidates the entity's and all its children's transformation matrices! | |
virtual CRY_DEPRECATED_ENTTIY_LUA IScriptTable * | GetScriptTable () const =0 |
Easy Script table access. | |
virtual IRenderNode * | GetRenderNode (int nSlot=-1) const =0 |
virtual bool | IsRendered () const =0 |
virtual void | PreviewRender (SEntityPreviewContext &context)=0 |
virtual void | SetRenderNodeParams (const IEntity::SRenderNodeParams ¶ms)=0 |
Sets common parameters that are applied on all render nodes for this render proxy. | |
virtual IEntity::SRenderNodeParams | GetRenderNodeParams () const =0 |
virtual IEntityLink * | GetEntityLinks ()=0 |
Entity links. More... | |
virtual IEntityLink * | AddEntityLink (const char *sLinkName, EntityId entityId, EntityGUID entityGuid)=0 |
virtual void | RenameEntityLink (IEntityLink *pLink, const char *sNewLinkName)=0 |
virtual void | RemoveEntityLink (IEntityLink *pLink)=0 |
virtual void | RemoveAllEntityLinks ()=0 |
virtual IEntity * | UnmapAttachedChild (int &partId)=0 |
virtual void | GetMemoryUsage (ICrySizer *pSizer) const =0 |
virtual void | IncKeepAliveCounter ()=0 |
virtual void | DecKeepAliveCounter ()=0 |
virtual void | ResetKeepAliveCounter ()=0 |
virtual bool | IsKeptAlive () const =0 |
virtual bool | HandleVariableChange (const char *szVarName, const void *pVarData)=0 |
virtual void | OnRenderNodeVisibilityChange (bool bBecomeVisible)=0 |
Called by the 3DEngine when RenderNode created by this entity start or stop being rendered. | |
virtual float | GetLastSeenTime () const =0 |
virtual uint32 | GetEditorObjectID () const =0 |
virtual void | GetEditorObjectInfo (bool &bSelected, bool &bHighlighted) const =0 |
virtual void | SetEditorObjectInfo (bool bSelected, bool bHighlighted)=0 |
virtual EEntitySimulationMode | GetSimulationMode () const =0 |
Retrieve current simulation mode of the Entity. | |
virtual Schematyc::IObject * | GetSchematycObject () const =0 |
Schematyc Object associated with this entity. | |
virtual void | OnSchematycObjectDestroyed ()=0 |
void | SetViewDistRatio (int nViewDistRatio) |
Set the viewDistRatio on the render node. | |
void | SetLodRatio (int nLodRatio) |
Sets the LodRatio on the render node. | |
void | SetAdditionalRenderNodeFlags (uint64 flags, bool bEnable) |
void | SetOpacity (float fAmount) |
float | GetOpacity () const |
Vec3 | GetForwardDir () const |
Returns the forward facing direction of the entity. | |
Vec3 | GetRightDir () const |
Returns the right facing direction of the entity. | |
Vec3 | GetUpDir () const |
Returns the up facing direction of the entity. | |
Static Public Member Functions | |
static CryGUID | GetEntityScopeGUID () |
This is a GUID of the Schematyc environment scope where all entity components must be registered under to be found in UI. | |
Static Public Attributes | |
static constexpr int | CREATE_NEW_UNIQUE_TIMER_ID = -666 |
static constexpr int | KILL_ALL_TIMER = -1 |
Entities represent dynamic objects that can manipulate themselves or the scene they reside in during runtime. Examples include light sources, physicalized objects (such as bullets) and players. Entities themselves can not contain custom logic, instead they can contain Components (see IEntityComponent).
typedef std::function |
Callback used for visiting components
|
pure virtual |
Adds an already created component to the entity
pComponent | A shared pointer to the component we want to add, can not be null! |
pInitParams | Optional initialization parameters to determine the initial state of the component |
|
pure virtual |
Adds flag/s to the current set of entity flags (logical OR).
flagsToAdd | Combination of bit flags to add. |
|
pure virtual |
Do not use. Provides a way for CGameObject to replace NetEntity with itself.
|
pure virtual |
Assign a pre-created physical entity to this proxy.
pPhysEntity | The pre-created physical entity. |
nSlot | Slot Index to which the new position will be taken from. |
|
pure virtual |
Attaches the child entity to this entity. The child entity will inherit all the transformation of the parent entity.
pChildEntity | Child entity to attach. |
attachParams | Attachment parameters. |
|
pure virtual |
Checks if the specified entity flag is set.
flagsToCheck | Combination of bit flags to check. |
|
pure virtual |
Removes flag/s from the current set of entity flags (logical AND NOT).
flagsToClear | Combination of bit flags to remove. |
|
inline |
Creates a new entity component of type ComponentType from a registered factory and adds it to the entity. ComponentType must be a valid IEntityComponent implementation.
|
pure virtual |
Queries an entity component type by interface, and then creates the component inside this entity
interfaceId | The GUID of the component we want to add |
pInitParams | Optional initialization parameters to determine the initial state of the component |
|
pure virtual |
Creates a specified proxy in the entity.
proxy | Proxy interface identifier. |
|
inline |
Helper template function to simplify finding all components implementing the specified component type
components | DynArray into which any found components will be stored |
bCheckHierarchy | Whether or not we should traverse the inheritance hierarchy for all components, otherwise performs a (much faster) equality check to see if the implementation is ComponentType |
|
pure virtual |
Retrieves the entity archetype. Entity archetype contain definition for entity script properties.
|
pure virtual |
Fast method to get the character at the specified slot.
nSlot | Index of the slot. |
|
pure virtual |
Retrieves the attached child entity by index.
nIndex | Index of the child entity, must be 0 <= nIndex < GetChildCount(). |
|
pure virtual |
Retrieves the entity class pointer. Entity class defines entity type, what script it will use, etc...
|
inline |
Helper template function to simplify finding the first component implementing the specified component type This will traverse the inheritance tree, and is therefore slower than GetComponentByImplementation which simply does an equality check. ex: auto pScriptProxy = pEntity->GetComponent
bCheckHierarchy | Whether or not we should traverse the inheritance hierarchy for all components, otherwise performs a (much faster) equality check to see if the implementation is ComponentType |
|
pure virtual |
Return component with the unique GUID.
guid | Identifier for the component. |
|
pure virtual |
Return first component of the entity with the specified class ID.
interfaceID | Identifier for the component implementation. |
|
pure virtual |
Returns a number which is incremeting every time the entity components get changed Can be checked with an older one to determine if the entity components have changed
|
pure virtual |
Return all components with the specified class ID contained in the entity.
interfaceID | Identifier for the component implementation. |
|
pure virtual |
ObjectID that corresponds to editor base objects. This is used for selection and highlighting so it should be set by editor and have a 1-1 correspondence with a baseobject. This is intended as a runtime ID and does not need to be serialized
|
pure virtual |
Entity links.
Gets pointer to the first entity link.
|
pure virtual |
Fast method to get the geom cache render cache at the specified slot.
nSlot | Index of the slot. |
|
pure virtual |
Retrieves the globally unique identifier of this entity assigned to it by the Entity System. EntityGuid is guaranteed to be the same when saving / loading entity, it is also same in the editor and in the game.
|
pure virtual |
Retrieves the runtime unique identifier of this entity assigned to it by the Entity System. EntityId may not be the same when saving/loading entity EntityId is not unique across the network, but can be serialized via the 'eid' compression policy EntityId is mostly used in runtime for fast and unique identification of entities, as the system allows for an O(1) retrieval
|
pure virtual |
|
pure virtual |
Retrieves the entity axis aligned bounding box in the local entity space.
bbox | Output parameter for the bounding box. |
|
pure virtual |
Retrieves the parent of this entity if the parent is a local simulation grid
|
pure virtual |
Retrieves the entity transformation matrix in the local entity space.
|
pure virtual |
Retrieves a custom material set to the entity.
|
pure virtual |
Gets entity name.
|
pure virtual |
Returns the network proxy associated with the entity. Use the proxy to modify the entity's network behavior.
|
inline |
Get existing or Create a new initialized component inside the entity.
bCheckHierarchy | Whether or not we should traverse the inheritance hierarchy for all components, otherwise performs a (much faster) equality check to see if the implementation is ComponentType |
|
pure virtual |
Retrieves the parent of this entity.
|
pure virtual |
Retrieves the TM of the point this entity is attached to if it has a parent.
|
pure virtual |
Fast method to get the particle em at the specified slot.
nSlot | Index of the slot. |
|
pure virtual |
|
pure virtual |
Get world bounds of physical object.
[out] | bounds | Bounding box in world space. |
|
pure virtual |
Retrieves a pointer to the specified proxy interface in the entity.
proxy | Proxy interface identifier. |
|
pure virtual |
Retrieve an actual material used for rendering specified slot. Will return custom applied material or if custom material not set will return an actual material assigned to the slot geometry.
nSlot | Slot to query used material from, if -1 material will be taken from the first renderable slot. |
|
pure virtual |
Retrieve 3D Engine render node, used to render this entity for a given slot. If nSlot is -1 return first existing render node in slots.
|
pure virtual |
Called by networking on the server to serialize entity information in order to replicate the entity (and its components) on a remote host. The data is then deserialized on the remote host via SEntitySpawnParams::pSpawnSerializer. This function will collect information from components by calling IEntityComponent::NetReplicateSerialize.
|
pure virtual |
Retrieves the flags of the specified slot.
nSlot | Index of the slot. |
|
pure virtual |
Gets object slot information.
nIndex | Index of required slot. |
slotInfo | Output variable where description of the slot will be written. |
|
pure virtual |
nSlot | - Index of required slot. |
bRelativeToParent | - flag specifying whether the local transformation matrix is relative to the parent slot or the entity. |
|
pure virtual |
Retrieve slot's custom material (This material Must have been applied before with the SetSlotMaterial).
nSlot | Slot to query custom material from. |
|
pure virtual |
|
pure virtual |
Fast method to get the static object at the specified slot.
nSlot | Index of the slot; | with ENTITY_SLOT_ACTUAL to disable compound statobj handling. |
|
pure virtual |
Retrieve sub-object hide mask from slot.
nSlot | Slot to apply hide mask to. |
|
pure virtual |
Retrieves the entity axis aligned bounding box in the world space.
bbox | Output parameter for the bounding box. |
|
pure virtual |
Retrieves the entity transformation matrix in the world space.
|
pure virtual |
LiveCreate entity manipulation. Process the LiveCreate message with a variable change. This function is used as low-latency update vs updating the whole entity.
|
pure virtual |
Hides this entity, makes it invisible and disable its physics.
bHide | If true hide the entity, is false unhides it. |
|
pure virtual |
Increase/or decrease KeepAliveCounter Used as a refcount to prevent deletion when deferring some events (like physics collisions which can refer these entities).
|
pure virtual |
Makes the entity invisible and disable its physics. Different from hide in that the entity is still updated.
|
pure virtual |
Checks if this entity was marked for deletion. If this function returns true, it will be deleted on next frame, and it is pointless to perform any operations on such entity.
|
pure virtual |
true | if this entity was loaded from level file. |
false | for entities created dynamically. |
|
pure virtual |
|
pure virtual |
Check if Entity is being Rendered by 3dengine. It doesn't necessary mean that it will be visible on screen but only that 3d engine considers it for a rendering now
|
pure virtual |
Check if the slot with specified index exist.
nIndex | Index of required slot. |
|
pure virtual |
Stops already started entity timer with this id.
nTimerId | Timer ID of the timer started for this entity. (specify IEntity::KILL_ALL_TIMER to stop all timer on this entity) |
|
pure virtual |
Loads character to the specified slot, or to next available slot. If same character is already loaded in this slot, operation is ignored. If this slot number is occupied by different kind of object it is overwritten.
#include
// Load a character definition (.CDF) file into the next available entity slot
void LoadCharacter(IEntity& entity)
{
// For the sake of this example, load the character definition from /Characters/MyCharacter.cdf
const char* szCharacterPath = "Characters/MyCharacter.cdf";
// Load the specified CDF into the next available slot
const int slotId = entity.LoadCharacter(-1, szCharacterPath);
// Attempt to query the character instance, will always succeed if the file was successfully loaded from disk
if (ICharacterInstance* pCharacter = entity.GetCharacter(slotId))
{
/* pCharacter can now be used to manipulate and query the rendered character */
}
}
|
pure virtual |
Loads a fog volume to the specified slot, or to the next available slot.
#include
#include
void LoadFogVolume(IEntity& entity)
{
// Create a SFogVolumeProperties instance to define the fog volume characteristics
SFogVolumeProperties fogProperties;
// Render the volume as a box
fogProperties.m_volumeType = IFogVolumeRenderNode::eFogVolumeType_Box;
// Render as a 1x1x1m box
fogProperties.m_size = Vec3(1, 1, 1);
// Set color to red (range is 0 - 1)
fogProperties.m_color = ColorF(1, 0, 0, 1);
// Helpers to convert emission intensity to the engine's format
const float kiloScale = 1000.0f;
const float toLightUnitScale = kiloScale / RENDERER_LIGHT_UNIT_SCALE;
// Specify the desired emitted color, in our case red.
ColorF emission = ColorF(1, 0, 0, 1);
// Scale the intensity of the emission
const float emissionIntensity = 1.f;
emission.adjust_luminance(emissionIntensity * toLightUnitScale);
// Apply the calculated emission to the fog properties
fogProperties.m_emission = emission.toVec3();
// Load the fog volume into the next available slot
const int loadedSlotId = entity.LoadFogVolume(-1, fogProperties);
}
|
pure virtual |
Loads geometry cache to the specified slot, or to next available slot. If same geometry cache is already loaded in this slot, operation is ignored. If this slot number is occupied by different kind of object it is overwritten.
#include
// Load an alembic / geom cache file into the next available entity slot
void LoadGeomCache(IEntity& entity)
{
// For the sake of this example, load the geometry cache from /MyGeomCache.cbc
const char* szGeomCachePath = "MyGeomCache.cbc";
// Load the alembic definition into the next available slot
int slotId = entity.LoadGeomCache(-1, szGeomCachePath);
// Attempt to query the render node, will always succeed if the file was successfully loaded from disk
if (IGeomCacheRenderNode* pRenderNode = entity.GetGeomCacheRenderNode(slotId))
{
/* pRenderNode can now be used to manipulate geom cache playback */
}
}
|
pure virtual |
Loads static geometry to the specified slot, or to next available slot. If same object is already loaded in this slot, operation is ignored. If this slot number is occupied by different kind of object it is overwritten with static object.
nLoadFlags | See ELoadFlags |
#include
// Load a static geometry (.CGF) file into the next available entity slot
void LoadGeometry(IEntity& entity)
{
// For the sake of this example, load the static geometry from /Objects/MyBrush.cgf
const char* szGeometryPath = "Objects/MyBrush.cgf";
// Load the specified CGF into the next available slot
const int slotId = entity.LoadGeometry(-1, szGeometryPath);
// Attempt to query the IStatObj pointer, will always succeed if the file was successfully loaded from disk
if (IStatObj* pStatObj = entity.GetStatObj(slotId))
{
/*
pStatObj can now be used to query the rendered geometry
Note that pStatObj does *not* represent an instance, any modifications will modify all instances.
*/
}
}
|
pure virtual |
Loads a light source to the specified slot, or to next available slot.
#include
#include
// Loads a dynamic point light into the next available entity slot
void LoadPointLight(IEntity& entity)
{
// Create the CDLight structure
SRenderLight light;
// Create a deferred point light that only affects the current area
light.m_Flags = DLF_DEFERRED_LIGHT | DLF_THIS_AREA_ONLY | DLF_POINT;
// Emit in a 10 meter radius
light.m_fRadius = 10.f;
// Set the color to pure white (RGBA), on a scale of 0 - 1
light.SetLightColor(ColorF(1.f, 1.f, 1.f, 1.f));
// Load the light into the next available entity slot
const int lightSlot = entity.LoadLight(-1, &light);
}
// Loads a dynamic projector light into the next available entity slot
void LoadProjectorLight(IEntity& entity)
{
// Create the CDLight structure
SRenderLight light;
// Create a deferred projector light that only affects the current area
light.m_Flags = DLF_DEFERRED_LIGHT | DLF_THIS_AREA_ONLY | DLF_PROJECT;
// Emit at a distance of 10 meters
light.m_fRadius = 10.f;
// Set the color to pure white (RGBA), on a scale of 0 - 1
light.SetLightColor(ColorF(1.f, 1.f, 1.f, 1.f));
// Load a sample projector texture from the engine assets (included with all projects)
const char* szProjectedTexturePath = "%ENGINEASSETS%/Textures/Lights/ce_logo_white.dds";
// Load the texture we want to project onto other objects
light.m_pLightImage = gEnv->pRenderer->EF_LoadTexture(szProjectedTexturePath, FT_DONT_STREAM);
// Project in a 90-degree cone
light.m_fLightFrustumAngle = 90;
// Load the light into the next available entity slot
const int lightSlot = entity.LoadLight(-1, &light);
}
|
pure virtual |
Loads a new particle emitter to the specified slot, or to next available slot. If this slot number is occupied by different kind of object it is overwritten.
#include
#include
// Creates a particle emitter into the specified entity slot that emits continuously emits a specific effect
void LoadParticleEmitter(IEntity& entity)
{
// For the sake of this example, load the particle effect from /Particles/MyEffect.pfx2
const char* szParticleEffectPath = "Particles/MyEffect.pfx2";
if (IParticleEffect* pEffect = gEnv->pParticleManager->FindEffect(szParticleEffectPath, "ParticleLoadExample"))
{
// Create a new SpawnParams instance to define how our particles should behave
SpawnParams spawnParams;
/* The spawn params could be modified here, but we choose to use the default settings set up by the designer in the Particle Editor */
// Create a particle emitter in the next available slot, using the specified spawn parameters
const int slotId = entity.LoadParticleEmitter(-1, pEffect, &spawnParams);
}
}
|
pure virtual |
Moves the contents of a render slot from one entity to another, will also move any associated physics.
targetIEnt | Entity to receive the new slot info. |
nSlot | Index of the slot. |
|
pure virtual |
Physicalize entity by creating a PhysicalEntity based on a specified physical parameters
#include
// Simple example for physicalizing an entity and all of its slots
void Physicalize(IEntity& entity)
{
// The SEntityPhysicalizeParams is used to describe how an entity should be physicalized
SEntityPhysicalizeParams physicalizeParams;
// The type indicates which IPhysicalEntity implementation to use, in our case we want a rigid entity that can be moved around in the world and influence other entities
physicalizeParams.type = PE_RIGID;
// Physical entities can specify either a mass, or a density - but never both. In our case, we specify a mass of 50 kilograms.
// If density is specified, the mass is calculated based on volume.
physicalizeParams.mass = 50.f;
// It is possible to automatically physicalize a specific slot, or all. In our case, we choose to automatically create physics parts for each entity slot in our entity.
physicalizeParams.nSlot = -1;
// Call IEntity::Physicalize to create the physical entity
entity.Physicalize(physicalizeParams);
// Now query the physical entity, will return a valid entity if Physicalize succeeded.
if (IPhysicalEntity* pPhysicalEntity = entity.GetPhysicalEntity())
{
/* pPhysicalEntity can now be used, valid until entity is dephysicalized */
}
}
|
pure virtual |
Adds physical geometry to the physical entity tied to this entity, based on the slot (if present) Entity has to have been physicalized with IEntity::Physicalize first.
#include
// Simple example for physicalizing an entity slot
void PhysicalizeSlot(IEntity& entity, const int slotId)
{
// Entity must have been physicalized using IEntity::Physicalize first
if (IPhysicalEntity* pPhysicalEntity = entity.GetPhysicalEntity())
{
SEntityPhysicalizeParams partPhysicalizeParams;
// Specify the type of physicalization to use, has to be the same as the entity we are applying to
partPhysicalizeParams.type = pPhysicalEntity->GetType();
// Specify the slot identifier inside the physicalization parameters
partPhysicalizeParams.nSlot = slotId;
// Mass of this entity in kilograms
// Note that mass and density cannot be specified at the same time, if density is specified then mass is calculated based on volume
partPhysicalizeParams.mass = 10.f;
// Now add the slot geometry to our physical entity
entity.PhysicalizeSlot(slotId, partPhysicalizeParams);
}
}
|
pure virtual |
Render a preview of the Entity This method is not used when entity is normally rendered But only used for previewing the entity in the Sandbox Editor
|
inline |
Removes all instances of the specified component type found in the entity
checkHierarchy | Whether or not we should traverse the inheritance hierarchy for all components, otherwise performs a (much faster) equality check to see if the implementation is ComponentType |
|
pure virtual |
Remove previously created component from the Entity
pComponent | Component pointer to remove from the Entity |
|
inline |
Removes the first instance of the specified component type found in the entity
checkHierarchy | Whether or not we should traverse the inheritance hierarchy for all components, otherwise performs a (much faster) equality check to see if the implementation is ComponentType |
|
pure virtual |
Replaces an existing component in the entity with another, without shutting down the existing component Used for reallocating components at run-time while keeping internal state intact Note that this function does not copy any data between the components, that is up to the caller.
|
pure virtual |
Sends event to the entity.
event | Event description (event id, parameters). |
|
pure virtual |
Saves or loads entity parameters to/from stream using serialization context class.
serializer | Serialization context class, provides all the information needed to properly serialize entity contents. |
nFlags | Additional custom serialization flags. |
|
pure virtual |
Sets character instance of a slot, and creates slot if necessary.
nSlot | Index of a slot, or -1 if a new slot need to be allocated. |
pCharacter | A pointer to character instance. |
|
pure virtual |
Sets entity flags, completely replaces all flags which are already set in the entity.
flags | Flag values which are defined in EEntityFlags. |
|
pure virtual |
Sets entity flags, completely replaces all flags which are already set in the entity.
flags | - Extended flag values which are defined in EEntityFlagsExtended. |
|
pure virtual |
Force local bounds.
[out] | bounds | Bounding box in local space. |
bDoNotRecalculate | When set to true entity will never try to recalculate local bounding box set by this call. |
|
pure virtual |
Sets entity transformation matrix in the local entity space.
tm | Local space transformation matrix (Non unifrorm scale is not supported). |
|
pure virtual |
Assigns a custom material to the entity.
pMaterial | Pointer to custom material interface. |
|
pure virtual |
Changes the entity name. Entity name does not have to be unique, but for the sake of easier finding entities by name it is better to not assign the same name to different entities.
sName | New name for the entity. |
|
pure virtual |
Attaches child slot to the parent slot. This will form hierarchical transformation relationship between object slots.
nParentIndex | Index of the parent slot (Child slot will be attached to this one). |
nChildIndex | Index of the child slot. |
|
pure virtual |
Sets an existing particle emitter to the specified slot, or the next available slot. If this slot number is occupied by different kind of object it is overwritten.
|
pure virtual |
Sets the flags of the specified slot.
nSlot | Index of the slot, if -1 apply to all existing slots. |
nFlags | Flags to set. |
|
pure virtual |
Assigns a custom material to the specified object slot.
nSlot | Index of the slot, if -1 assign this material to all existing slots. |
pMaterial | Pointer to custom material interface. |
|
pure virtual |
Sets static object of a slot, creates slot if necessary
nSlot | Index of a slot, or -1 if a new slot need to be allocated; | with ENTITY_SLOT_ACTUAL to disable compound statobj handling. |
pStatObj | Pointer to the new static object. |
mass | New mass of the slot, negative value to keep the current. |
|
pure virtual |
Assign sub-object hide mask to slot.
nSlot | Slot to apply hide mask to. |
|
pure virtual |
Starts the entity timer. Entity timers are owned by entity, every entity can have it`s own independent timers, so TimerId must not be unique across multiple entities. When timer finishes entity system will signal to the entity once with an event ENTITY_EVENT_TIME. Multiple timers can be started simultaneously with different timer ids. If some timer is not yet finished and another timer with the same timerID is set, the new one will override old timer, and old timer will not send finish event.
nTimerId | Timer ID, multiple timers with different IDs are possible. (specify IEntity::CREATE_NEW_UNIQUE_TIMER_ID to let the system generate a new and unique Id) |
nMilliSeconds | Timer timeout time in milliseconds. |
|
pure virtual |
Sets entity transformation matrix in the world space.
tm | World space transformation matrix (Non unifrorm scale is not supported). |
|
pure virtual |
nSlot | - Index of the slot. |
|
pure virtual |
[out] | partId | Set to the child's partId. |
|
pure virtual |
Used to update the stored mask for a certain component, from IEntityComponent::GetEventMask For example, changing IEntityComponent::GetEventMask to return ENTITY_EVENT_UPDATE and then calling GetEventMask will result in the component and its entity being updated the next frame.
#include
class CMyEventComponent final : public IEntityComponent
{
public:
// Provide a virtual destructor, ensuring correct destruction of IEntityComponent members
virtual ~CMyEventComponent() = default;
static void ReflectType(Schematyc::CTypeDesc& desc) { /* Reflect the component GUID in here. */}
// Override the ProcessEvent function to receive the callback whenever an event specified in GetEventMask is triggered
virtual void ProcessEvent(const SEntityEvent& event) override
{
// Check if this is the update event
if (event.event == ENTITY_EVENT_UPDATE)
{
// The Update event provides delta time as the first floating-point parameter
const float frameTime = event.fParam[0];
/* Handle update logic here */
}
}
// As an optimization, components have to specify a bitmask of the events that they want to handle
// This is called once at component creation, and then only if IEntity::UpdateComponentEventMask is called, to support dynamic change of desired events (useful for disabling update when you don't need it)
virtual uint64 GetEventMask() const override { return BIT64(ENTITY_EVENT_UPDATE); }
};
|
pure virtual |
Calls a callback on all of the components in the entity This is a more efficient way to operate on components then using GetComponents method as it is not require temporary allocations