struct IEntity { 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) }; };
IEntity.h
Interface to entity object.
enum EAttachmentFlags { ATTACHMENT_KEEP_TRANSFORMATION = BIT(0), ATTACHMENT_GEOMCACHENODE = BIT(1), ATTACHMENT_CHARACTERBONE = BIT(2) };
IEntity.h
Members |
Description |
ATTACHMENT_KEEP_TRANSFORMATION = BIT(0) |
Keeps world transformation of entity when attaching or detaching it. |
ATTACHMENT_GEOMCACHENODE = BIT(1) |
Attach to geom cache node |
ATTACHMENT_CHARACTERBONE = BIT(2) |
Attached to character bone |
enum EEntityLoadFlags { EF_AUTO_PHYSICALIZE = 0x0001, EF_NO_STREAMING = 0x0002 };
IEntity.h
virtual ~IEntity();
virtual void Activate(bool bActive) = 0;
Activates entity, if entity is active it will be updated every frame.
virtual IEntityLink* AddEntityLink(const char * sLinkName, EntityId entityId, EntityGUID entityGuid = 0) = 0;
virtual void AddFlags(uint32 flagsToAdd) = 0;
Parameters |
Description |
uint32 flagsToAdd |
Combination of bit flags to add. |
Adds flag/s to the current set of entity flags (logical OR).
virtual void AttachChild(IEntity * pChildEntity, const SChildAttachParams & attachParams = SChildAttachParams()) = 0;
Parameters |
Description |
IEntity * pChildEntity |
Child entity to attach. |
const SChildAttachParams & attachParams = SChildAttachParams() |
attachment parameters |
Attaches the child entity to this entity. The child entity will inherit all the transformation of the parent entity.
virtual bool CheckFlags(uint32 flagsToCheck) const = 0;
Parameters |
Description |
uint32 flagsToCheck |
Combination of bit flags to check. |
Checks if the specified entity flag is set.
virtual void ClearFlags(uint32 flagsToClear) = 0;
Parameters |
Description |
uint32 flagsToClear |
Combination of bit flags to remove. |
Removes flag/s from the current set of entity flags (logical AND NOT).
virtual IEntityProxyPtr CreateProxy(EEntityProxy proxy) = 0;
Parameters |
Description |
EEntityProxy proxy |
Proxy interface identifier. |
Valid pointer to the created entity proxy object, or NULL if creation failed.
Creates a specified proxy in the entity.
virtual void DebugDraw(const struct SGeometryDebugDrawInfo & info) = 0;
Draw a debug view of this entity geometry
virtual void DecKeepAliveCounter() = 0;
virtual void DetachAll(int nDetachFlags = 0) = 0;
Parameters |
Description |
int nDetachFlags = 0 |
Combination of the EAttachmentFlags flags. |
Detaches all the child entities attached to this entity.
virtual void DetachThis(int nDetachFlags = 0, int nWhyFlags = 0) = 0;
Parameters |
Description |
int nDetachFlags = 0 |
Combination of the EAttachmentFlags flags. |
Detach this entity from the parent entity (assumes that this entity is the child entity).
virtual void EnablePhysics(bool enable) = 0;
Enable/Disable physics by flag.
virtual void FreeSlot(int nIndex) = 0;
Frees slot at specified index.
virtual IAIObject* GetAI() = 0;
virtual tAIObjectID GetAIObjectID() const = 0;
virtual IEntityArchetype* GetArchetype() = 0;
Retrieves the entity archetype. Entity archetype contain definition for entity script properties. Return: Pointer to the entity archetype interface.
virtual ICharacterInstance* GetCharacter(int nSlot) = 0;
Parameters |
Description |
int nSlot |
Index of the slot. |
Character pointer or NULL if character with this slot does not exist.
Fast method to get the character at the specified slot.
virtual IEntity* GetChild(int nIndex) const = 0;
Parameters |
Description |
int nIndex |
Index of the child entity, must be 0 <= nIndex < GetChildCount(). |
Return |
Pointer to the child entity interface. |
Retrieves the attached child entity by index.
virtual int GetChildCount() const = 0;
Retrieves the number of attached child entities.
virtual IEntityClass* GetClass() const = 0;
Retrieves the entity class pointer. Entity class defines entity type, what script it will use, etc... Return: Pointer to the entity class interface.
virtual IEntityLink* GetEntityLinks() = 0;
Gets pointer to the first entity link.
virtual const char* GetEntityTextDescription() const = 0;
Returns textual description of entity for logging.
virtual uint32 GetFlags() const = 0;
Gets current entity flags.
virtual uint32 GetFlagsExtended() const = 0;
Gets current entity EEntityFlagsExtended flags.
virtual const Vec3& GetForwardDir() const = 0;
Helper function to retrieve world space forward dir
virtual IGeomCacheRenderNode* GetGeomCacheRenderNode(int nSlot) = 0;
Parameters |
Description |
int nSlot |
Index of the slot. |
IGeomCacheRenderNode pointer or NULL if stat object with this slot does not exist.
Fast method to get the geom cache render cache at the specified slot.
virtual EntityGUID GetGuid() const = 0;
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. Return: The entity globally unique identifier.
virtual EntityId GetId() const = 0;
virtual void GetLocalBounds(AABB & bbox) const = 0;
Parameters |
Description |
AABB & bbox |
Output parameter for the bounding box. |
Retrieves the entity axis aligned bounding box in the local entity space.
GetLocalBounds
virtual Matrix34 GetLocalTM() const = 0;
Retrieves the entity transformation matrix in the local entity space.
SetWorldTM,GetWorldTM,SetLocalTM,GetLocalTM Return: Local space transformation matrix.
virtual IMaterial* GetMaterial() = 0;
Pointer to custom material interface or NULL if custom material not set.
Retrieves a custom material set to the entity.
virtual void GetMemoryUsage(ICrySizer * pSizer) const = 0;
virtual const char* GetName() const = 0;
Name of the entity.
Gets entity name.
virtual IEntity* GetParent() const = 0;
Retrieves the parent of this entity.
GetChild,DetachThis Return: Pointer to the parent entity interface, or NULL if this entity does not have a parent.
virtual Matrix34 GetParentAttachPointWorldTM() const = 0;
Retrieves the TM of the point this entity is attached to if it has a parent Note that this can be different from GetParent()->GetWorldTM() when the attachment point is not the pivot. Return: World space matrix of the parent attachment transform
virtual IParticleEmitter* GetParticleEmitter(int nSlot) = 0;
Parameters |
Description |
int nSlot |
Index of the slot. |
IParticleEmitter pointer or NULL if stat object with this slot does not exist.
Fast method to get the particle em at the specified slot.
virtual IPhysicalEntity* GetPhysics() const = 0;
Returns a physical entity assigned to an entity.
virtual const Vec3& GetPos() const = 0;
Retrieves the entity local space position.
SetPos,GetPos,SetRotation,GetRotation,SetScale,GetScale
virtual IEntityProxy* GetProxy(EEntityProxy proxy) const = 0;
Parameters |
Description |
EEntityProxy proxy |
Proxy interface identifier. |
Return |
Valid pointer to the requested entity proxy object, or NULL if such proxy not exist. |
Entity Proxies Interfaces access functions. ///////////////////////////////////////////////////////////////////////
Retrieves a pointer to the specified proxy interface in the entity.
virtual const Quat& GetRotation() const = 0;
Retrieves the entity local space rotation quaternion.
SetPos,GetPos,SetRotation,GetRotation,SetScale,GetScale
virtual const Vec3& GetScale() const = 0;
Retrieves the entity local space scale.
SetPos,GetPos,SetRotation,GetRotation,SetScale,GetScale
IScriptTable* GetScriptTable() const;
Easy Script table access.
Inline implementation.
virtual void GetSlotCameraSpacePos(int nSlot, Vec3 & cameraSpacePos) const = 0;
Gets camera space position of the object slot.
virtual int GetSlotCount() const = 0;
Gets number of allocated object slots in the entity.
virtual uint32 GetSlotFlags(int nSlot) const = 0;
Parameters |
Description |
int nSlot |
Index of the slot. |
The slot flags, or 0 if specified slot is not valid.
Retrieves the flags of the specified slot.
virtual bool GetSlotInfo(int nIndex, SEntitySlotInfo & slotInfo) const = 0;
Parameters |
Description |
int nIndex |
Index of required slot. |
SEntitySlotInfo & slotInfo |
Output variable where description of the slot will be written. |
Gets object slot information.
virtual const Matrix34& GetSlotLocalTM(int nSlot, bool bRelativeToParent) const = 0;
Parameters |
Description |
int nSlot |
Index of required slot. |
bool bRelativeToParent |
flag specifying whether the local transformation matrix is relative to the parent slot or the entity |
Returns local transformation matrix relative to host entity transformation matrix of the object slot.
virtual const Matrix34& GetSlotWorldTM(int nSlot) const = 0;
Returns world transformation matrix of the object slot.
virtual IStatObj* GetStatObj(int nSlot) = 0;
Parameters |
Description |
int nSlot |
Index of the slot; | with ENTITY_SLOT_ACTUAL to disable compound statobj handling. |
StatObj pointer or NULL if stat object with this slot does not exist.
Fast method to get the static object at the specified slot.
virtual EEntityUpdatePolicy GetUpdatePolicy() const = 0;
Retrieves the entity update policy.
virtual Ang3 GetWorldAngles() const = 0;
Helper function to retrieve world space entity orientation angles.
virtual void GetWorldBounds(AABB & bbox) const = 0;
Parameters |
Description |
AABB & bbox |
Output parameter for the bounding box. |
Retrieves the entity axis aligned bounding box in the world space.
virtual Vec3 GetWorldPos() const = 0;
Helper function to retrieve world space entity position.
virtual Quat GetWorldRotation() const = 0;
Helper function to retrieve world space entity orientation quaternion
virtual const Matrix34& GetWorldTM() const = 0;
Retrieves the entity transformation matrix in the world space.
SetWorldTM,GetWorldTM,SetLocalTM,GetLocalTM Return: World space transformation matrix (Include transformations of all parent entities).
virtual bool HandleVariableChange(const char* szVarName, const void* pVarData) = 0;
LiveCreate entity manipulation /////////////////////////////////////////////////////////////////////// Process the LiveCreate message with a variable change, return true if handled This function is used as low-latency update vs updating the whole entity
virtual bool HasAI() const = 0;
virtual void Hide(bool bHide) = 0;
Parameters |
Description |
bool bHide |
if true hide the entity, is false unhides it. |
Hides this entity, makes it invisible and disable its physics.
virtual void IncKeepAliveCounter() = 0;
Increase/or decrease KeepAliveCounter, used as a refcount to prevent deletion when deferring some events(like physics collisions which can refer these entities)
virtual void InvalidateTM(int nWhyFlags = 0, bool bRecalcPhyBounds = false) = 0;
Invalidates the entity's and all its children's transformation matrices!
virtual void Invisible(bool bInvisible) = 0;
Makes the entity invisible and disable its physics. Different from hide in that the entity is still updated.
virtual bool IsActive() const = 0;
Check if the entity is active now.
virtual bool IsFromPool() const = 0;
Returns if the entity is from an entity pool.
virtual bool IsGarbage() const = 0;
True if entity marked for deletion, false otherwise.
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.
virtual bool IsHidden() const = 0;
Checks if the entity is hidden.
virtual bool IsInitialized() const = 0;
Returns true if entity is completely initialized.
virtual bool IsInvisible() const = 0;
Checks if the entity is invisible.
virtual bool IsKeptAlive() const = 0;
virtual bool IsLoadedFromLevelFile() const = 0;
Returns true if this entity was loaded from level file Returns false for entities created dynamically
virtual bool IsParentAttachmentValid() const = 0;
Checks if the matrix returned by GetParentAttachPointWorldTM is valid E.g. it would return false if a geometry cache frame isn't loaded yet Return: World space matrix of the parent attachment transform
virtual bool IsPrePhysicsActive() = 0;
Check if the entity is active now.
virtual bool IsSlotValid(int nIndex) const = 0;
Parameters |
Description |
int nIndex |
Index of required slot. |
Working with Slots. ///////////////////////////////////////////////////////////////////////
Check if the slot with specified index exist.
virtual void KillTimer(int nTimerId) = 0;
Parameters |
Description |
int nTimerId |
Timer ID of the timer started for this entity. |
Stops already started entity timer with this id.
virtual int LoadCharacter(int nSlot, const char * sFilename, int nLoadFlags = 0) = 0;
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. Return: Slot id where the object was loaded, or -1 if loading failed.
virtual int LoadGeometry(int nSlot, const char * sFilename, const char * sGeomName = NULL, int nLoadFlags = 0) = 0;
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 Return: Slot id where the object was loaded, or -1 if loading failed.
virtual int LoadLight(int nSlot, CDLight * pLight) = 0;
Loads a light source to the specified slot, or to next available slot. Return: Slot id where the light source was loaded, or -1 if loading failed.
virtual int LoadParticleEmitter(int nSlot, IParticleEffect* pEffect, SpawnParams const* params = NULL, bool bPrime = false, bool bSerialize = false) = 0;
Loads a new particle emitter 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. Return: Slot id where the particle emitter was loaded, or -1 if loading failed.
virtual void MoveSlot(IEntity * targetIEnt, int nSlot) = 0;
Parameters |
Description |
IEntity * targetIEnt |
entity to receive the new slot info |
int nSlot |
Index of the slot. |
None.
Moves the contents of a render slot from one entity to another, will also move any associated physics.
virtual void Physicalize(SEntityPhysicalizeParams & params) = 0;
Physics.
virtual int PhysicalizeSlot(int slot, SEntityPhysicalizeParams & params) = 0;
virtual void PrePhysicsActivate(bool bActive) = 0;
Activates entity, if entity is active it will be updated every frame.
virtual void RegisterComponent(IComponentPtr pComponent, const int flags) = 0;
Parameters |
Description |
IComponentPtr pComponent |
the target component. |
const int flags |
IComponent contains the relevent flags to control registration behaviour. |
Register or unregisters a component with the entity.
virtual bool RegisterInAISystem(const AIObjectParams & params) = 0;
virtual void RemoveAllEntityLinks() = 0;
virtual void RemoveEntityLink(IEntityLink* pLink) = 0;
virtual void ResetKeepAliveCounter() = 0;
virtual bool SendEvent(SEntityEvent & event) = 0;
Parameters |
Description |
SEntityEvent & event |
Event description (event id, parameters). |
Sends event to the entity.
virtual void Serialize(TSerialize serializer, int nFlags = 0) = 0;
Parameters |
Description |
TSerialize serializer |
Serialization context class, provides all the information needed to properly serialize entity contents. |
int nFlags = 0 |
Additional custom serialization flags. |
Saves or loads entity parameters to/from stream using serialization context class.
virtual void SerializeXML(XmlNodeRef & entityNode, bool bLoading) = 0;
Serializes entity parameters to/from XML.
virtual void SetAIObjectID(tAIObjectID id) = 0;
virtual int SetCharacter(ICharacterInstance * pCharacter, int nSlot) = 0;
Parameters |
Description |
ICharacterInstance * pCharacter |
A pointer to character instance. |
int nSlot |
Index of a slot, or -1 if a new slot need to be allocated. |
An integer which refers to the slot index which used.
Sets character instance of a slot, and creates slot if necessary.
virtual void SetFlags(uint32 flags) = 0;
Parameters |
Description |
uint32 flags |
Flag values which are defined in EEntityFlags. |
Sets entity flags, completely replaces all flags which are already set in the entity.
virtual void SetFlagsExtended(uint32 flags) = 0;
Parameters |
Description |
uint32 flags |
Extended flag values which are defined in EEntityFlagsExtended. |
Sets entity flags, completely replaces all flags which are already set in the entity.
virtual void SetLocalTM(const Matrix34 & tm, int nWhyFlags = 0) = 0;
Parameters |
Description |
const Matrix34 & tm |
Local space transformation matrix (Non unifrorm scale is not supported). |
Sets entity transformation matrix in the local entity space.
SetWorldTM,GetWorldTM,SetLocalTM,GetLocalTM
virtual void SetMaterial(IMaterial * pMaterial) = 0;
Parameters |
Description |
IMaterial * pMaterial |
Pointer to custom material interface. |
Assigns a custom material to the entity.
virtual void SetName(const char * sName) = 0;
Parameters |
Description |
const char * sName |
New name for the entity. |
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 same name to different entities.
virtual bool SetParentSlot(int nParentIndex, int nChildIndex) = 0;
Parameters |
Description |
int nParentIndex |
Index of the parent slot (Child slot will be attached to this one). |
int nChildIndex |
Index of the child slot. |
Attaches child slot to the parent slot. This will form hierarchical transformation relationship between object slots.
virtual int SetParticleEmitter(int nSlot, IParticleEmitter* pEmitter, bool bSerialize = false) = 0;
virtual void SetPhysicsState(XmlNodeRef & physicsState) = 0;
virtual void SetPos(const Vec3 & vPos, int nWhyFlags = 0, bool bRecalcPhyBounds = false, bool bForce = false) = 0;
Sets the entity local space position.
SetPos,GetPos,SetRotation,GetRotation,SetScale,GetScale
virtual void SetPosRotScale(const Vec3 & vPos, const Quat & qRotation, const Vec3 & vScale, int nWhyFlags = 0) = 0;
Sets the entity position,rotation and scale at once.
virtual void SetProxy(EEntityProxy proxy, IEntityProxyPtr pProxy) = 0;
Parameters |
Description |
EEntityProxy proxy |
Proxy interface identifier. |
IEntityProxyPtr pProxy |
Pointer to the Proxy interface. |
Replaces the specified proxy interface in the entity.
virtual void SetRotation(const Quat & qRotation, int nWhyFlags = 0) = 0;
Sets the entity local space rotation quaternion.
SetPos,GetPos,SetRotation,GetRotation,SetScale,GetScale
virtual void SetScale(const Vec3 & vScale, int nWhyFlags = 0) = 0;
Sets the entity local space scale.
SetPos,GetPos,SetRotation,GetRotation,SetScale,GetScale
virtual void SetSlotCameraSpacePos(int nSlot, const Vec3 & cameraSpacePos) = 0;
Sets camera space position of the object slot.
virtual void SetSlotFlags(int nSlot, uint32 nFlags) = 0;
Parameters |
Description |
int nSlot |
Index of the slot, if -1 apply to all existing slots. |
uint32 nFlags |
Flags to set. |
Sets the flags of the specified slot.
virtual void SetSlotLocalTM(int nSlot, const Matrix34 & localTM, int nWhyFlags = 0) = 0;
Sets local transformation matrix of the object slot.
virtual void SetSlotMaterial(int nSlot, IMaterial * pMaterial) = 0;
Parameters |
Description |
int nSlot |
Index of the slot, if -1 assign this material to all existing slots. |
IMaterial * pMaterial |
Pointer to custom material interface. |
Assigns a custom material to the specified object slot.
virtual int SetStatObj(IStatObj * pStatObj, int nSlot, bool bUpdatePhysics, float mass = -1.0f) = 0;
Parameters |
Description |
IStatObj * pStatObj |
pointer to the new static object |
int nSlot |
Index of a slot, or -1 if a new slot need to be allocated; | with ENTITY_SLOT_ACTUAL to disable compound statobj handling |
float mass = -1.0f |
new mass of the slot, negative value to keep the current |
Return |
An integer which refer to the slot index which used |
Sets static object of a slot, creates slot if necessary
virtual void SetTimer(int nTimerId, int nMilliSeconds) = 0;
Parameters |
Description |
int nTimerId |
Timer ID, multiple timers with different IDs are possible. |
int nMilliSeconds |
Timer timeout time in milliseconds. |
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.
virtual void SetUpdatePolicy(EEntityUpdatePolicy eUpdatePolicy) = 0;
Parameters |
Description |
EEntityUpdatePolicy eUpdatePolicy |
Update policy, one of EEntityUpdatePolicy enums. |
Changes the entity update policy. Update policy of entity defines the automatic activation rules for the entity. Ex. When physical object becomes awaken it will activate the entity, and when will go to sleep again will deactivate it. Or entity can become active every time that it becomes visible, and deactivated when goes out of view. There are multiple such predefined update policies exist, consider EEntityUpdatePolicy enum.
virtual void SetWorldTM(const Matrix34 & tm, int nWhyFlags = 0) = 0;
Parameters |
Description |
const Matrix34 & tm |
World space transformation matrix (Non unifrorm scale is not supported). |
Sets entity transformation matrix in the world space.
SetWorldTM,GetWorldTM,SetLocalTM,GetLocalTM
virtual bool ShouldUpdateCharacter(int nSlot) const = 0;
Parameters |
Description |
int nSlot |
Index of the slot. |
Returns true if character is to be updated.
Returns true if character is to be updated.
virtual IEntity * UnmapAttachedChild(int & partId) = 0;
Returns an attached child entity that corresponds to the physical part partId set partId to the child's partId.
virtual void UnphysicalizeSlot(int slot) = 0;
virtual void UpdateSlotPhysics(int slot) = 0;