IEntityClass

#include

Classes

struct SEventInfo
Events info for this entity class. More...

Public Types

enum EventValueType {
EVT_INT, EVT_FLOAT, EVT_BOOL, EVT_VECTOR,
EVT_ENTITY, EVT_STRING
}
typedef std::function< bool(IEntity &entity, SEntitySpawnParams &params)> OnSpawnCallback
typedef IEntityComponent *(* UserProxyCreateFunc) (IEntity *pEntity, SEntitySpawnParams &params, void *pUserData)

Public Member Functions

virtual void Release ()=0
Destroy IEntityClass object, do not call directly, only EntityRegisty can destroy entity classes.
virtual const char * GetName () const =0
virtual CryGUID GetGUID () const =0
Retrieve unique identifier for this entity class.
virtual uint32 GetFlags () const =0
virtual void SetFlags (uint32 nFlags)=0
Set entity class flags.
virtual const char * GetScriptFile () const =0
virtual IEntityScript * GetIEntityScript () const =0
virtual IScriptTable * GetScriptTable () const =0
virtual IEntityEventHandler * GetEventHandler () const =0
virtual IEntityScriptFileHandler * GetScriptFileHandler () const =0
virtual const SEditorClassInfo & GetEditorClassInfo () const =0
virtual void SetEditorClassInfo (const SEditorClassInfo &editorClassInfo)=0
virtual bool LoadScript (bool bForceReload)=0
virtual IEntityClass::UserProxyCreateFunc GetUserProxyCreateFunc () const =0
virtual void * GetUserProxyData () const =0
virtual int GetEventCount ()=0
virtual IEntityClass::SEventInfo GetEventInfo (int nIndex)=0
virtual bool FindEventInfo (const char *sEvent, SEventInfo &event)=0
virtual const OnSpawnCallback & GetOnSpawnCallback () const =0
Return On spawn callback for the class.
virtual void GetMemoryUsage (ICrySizer *pSizer) const =0

Detailed Description

Entity class defines what is this entity, what script it uses, what user proxy will be spawned with the entity, etc. IEntityClass unique identify type of the entity, Multiple entities share the same entity class. Two entities can be compared if they are of the same type by just comparing their IEntityClass pointers.

Member Typedef Documentation

◆ OnSpawnCallback

typedef std::functionIEntity& entity, SEntitySpawnParams& params)> IEntityClass::OnSpawnCallback

OnSpawnCallback is called when entity of that class is spawned. When registering new entity class this callback allow user to execute custom code on entity spawn, Like creation and initialization of some default components

◆ UserProxyCreateFunc

typedef IEntityComponent*(* IEntityClass::UserProxyCreateFunc) (IEntity *pEntity, SEntitySpawnParams &params, void *pUserData)

UserProxyCreateFunc is a function pointer type,. By calling this function EntitySystem can create user defined UserProxy class for an entity in SpawnEntity. For example: IEntityComponent* CreateUserProxy( IEntity *pEntity, SEntitySpawnParams &params ) { return new CUserProxy( pEntity,params );. }

Member Function Documentation

◆ FindEventInfo()

virtual bool IEntityClass::FindEventInfo ( const char * sEvent,
SEventInfo & event
)
pure virtual

Find event by name.

Parameters
sEventName of the event.
eventOutput parameter for event.
Returns
True if event found and event parameter is initialized.

◆ GetEventCount()

virtual int IEntityClass::GetEventCount ( )
pure virtual
Returns
Return Number of input and output events defined in the entity script.

◆ GetEventInfo()

virtual IEntityClass::SEventInfo IEntityClass::GetEventInfo ( int nIndex)
pure virtual

Retrieve information about input/output event of the entity.

Parameters
nIndexIndex of the event to retrieve, must be in 0 to GetEventCount()-1 range.
Returns
Specified event description in SEventInfo structure.

◆ GetFlags()

virtual uint32 IEntityClass::GetFlags ( ) const
pure virtual
Returns
Entity class flags.

◆ GetIEntityScript()

virtual IEntityScript* IEntityClass::GetIEntityScript ( ) const
pure virtual

Returns the IEntityScript interface assigned for this entity class.

Returns
IEntityScript interface if this entity have script, or nullptr if no script defined for this entity class.

◆ GetName()

virtual const char* IEntityClass::GetName ( ) const
pure virtual

If this entity also uses a script, this is the name of the Lua table representing the entity behavior.

Returns
Name of the entity class. Class name must be unique among all the entity classes.

◆ GetScriptFile()

virtual const char* IEntityClass::GetScriptFile ( ) const
pure virtual

Returns the Lua script file name.

Returns
Lua Script filename, return empty string if entity does not use script.

◆ GetScriptTable()

virtual IScriptTable* IEntityClass::GetScriptTable ( ) const
pure virtual

Returns the IScriptTable interface assigned for this entity class.

Returns
IScriptTable interface if this entity have script, or nullptr if no script defined for this entity class.

◆ GetUserProxyCreateFunc()

virtual IEntityClass::UserProxyCreateFunc IEntityClass::GetUserProxyCreateFunc ( ) const
pure virtual

Returns pointer to the user defined function to create UserProxy.

Returns
Return UserProxyCreateFunc function pointer.

◆ GetUserProxyData()

virtual void* IEntityClass::GetUserProxyData ( ) const
pure virtual

Returns pointer to the user defined data to be passed when creating UserProxy.

Returns
Return pointer to custom user proxy data.

◆ LoadScript()

virtual bool IEntityClass::LoadScript ( bool bForceReload)
pure virtual

Loads the script.

Note
It is safe to call LoadScript multiple times, the script will only be loaded on the first call (unless bForceReload is specified).