ISource2ModEntities
Interface for entity lookup and Source2 Entity I/O system.
Provides:
- Entity searching (classname, name, picker)
- Entity creation
- Input triggering
- Output listening
Interface for interacting with entities and Entity I/O system.
Interface id ISource2ModEntities004 (SOURCE2MOD_ENTITIES_INTERFACE) · Global g_pSource2ModEntities · Header source2mod/ISource2ModEntities.h
Methods
GetGameRules
virtual CCSGameRules* GetGameRules() = 0;The active CCSGameRules, or null before the entity exists.
Source2Mod captures this from cs_gamerules as the entity is created, so it is live for the whole map and a plugin does not have to scan for the proxy itself.
FindPickerEntity
virtual CBaseEntity* FindPickerEntity(CBasePlayerController* pPlayer, CCSGameRules* pGameRules = nullptr) = 0;Finds entity under player's crosshair.
| Parameter | Type | Default |
|---|---|---|
pPlayer | CBasePlayerController* | |
pGameRules | CCSGameRules* | nullptr |
FindEntityByClassname
virtual CBaseEntity* FindEntityByClassname(CEntityInstance* pStart, const char* name) = 0;Finds entity by classname.
| Parameter | Type |
|---|---|
pStart | CEntityInstance* |
name | const char* |
FindEntityByName
virtual CBaseEntity* FindEntityByName(CEntityInstance* pStartEntity, const char* szName, CEntityInstance* pSearchingEntity = nullptr, CEntityInstance* pActivator = nullptr, CEntityInstance* pCaller = nullptr, IEntityFindFilter* pFilter = nullptr) = 0;Finds entity by name.
| Parameter | Type | Default |
|---|---|---|
pStartEntity | CEntityInstance* | |
szName | const char* | |
pSearchingEntity | CEntityInstance* | nullptr |
pActivator | CEntityInstance* | nullptr |
pCaller | CEntityInstance* | nullptr |
pFilter | IEntityFindFilter* | nullptr |
FindAllEntitiesByDesignerName
virtual std::vector<CBaseEntity*> FindAllEntitiesByDesignerName(const char* pszDesignerName) = 0;Every entity with this designer name ("prop_dynamic", "cs_player_controller"), in entity-list order; empty when the entity system is not up. UTIL_FindAllEntitiesByDesignerName<T> is the typed form.
| Parameter | Type |
|---|---|
pszDesignerName | const char* |
CreateEntityByName
virtual CBaseEntity* CreateEntityByName(const char* pszClassName) = 0;Creates entity by classname.
| Parameter | Type |
|---|---|
pszClassName | const char* |
AcceptInput
virtual void AcceptInput(CEntityInstance* pTarget, const char* pszInput, CEntityInstance* pActivator, CEntityInstance* pCaller, const char* pszValue = "") = 0;Sends input to entity.
| Parameter | Type | Default |
|---|---|---|
pTarget | CEntityInstance* | |
pszInput | const char* | |
pActivator | CEntityInstance* | |
pCaller | CEntityInstance* | |
pszValue | const char* | "" |
AddEntityIOEvent
virtual void AddEntityIOEvent(CEntityInstance* pTarget, const char* pszInput, CEntityInstance* pActivator = nullptr, CEntityInstance* pCaller = nullptr, const char* pszValue = "", float flDelay = 0.0f) = 0;Queues an entity I/O event.
| Parameter | Type | Default |
|---|---|---|
pTarget | CEntityInstance* | |
pszInput | const char* | |
pActivator | CEntityInstance* | nullptr |
pCaller | CEntityInstance* | nullptr |
pszValue | const char* | "" |
flDelay | float | 0.0f |
AddEntityListener
virtual void AddEntityListener(IEntityListener* pListener, const char* pszDesignerName = nullptr, CEntityInstance* pEntity = nullptr) = 0;Entity events: the IEntityListener's OnEntityCreated (keyvalues not applied, not spawned yet), OnEntitySpawned, OnEntityDeleted (the last call for it), OnEntityParentChanged. Override what you need.
| Parameter | Type | Default | Description |
|---|---|---|---|
pListener | IEntityListener* | The plugin whose class it is owns it; dropped for you when that plugin unloads. | |
pszDesignerName | const char* | nullptr | Only entities of this designer name ("player", "smokegrenade_projectile"); nullptr for every one. |
pEntity | CEntityInstance* | nullptr | Only this one entity; nullptr for every one. Gone with the entity, after its OnEntityDeleted. |
RemoveEntityListener
virtual void RemoveEntityListener(IEntityListener* pListener) = 0;Drops every registration of the listener.
| Parameter | Type |
|---|---|
pListener | IEntityListener* |
AddEntityOutputListener
virtual void AddEntityOutputListener(IEntityOutputListener* pListener, const char* pszDesignerName = nullptr, const char* pszOutput = nullptr, CEntityInstance* pEntity = nullptr) = 0;Entity outputs: IEntityOutputListener::OnEntityOutput, pre and post.
| Parameter | Type | Default | Description |
|---|---|---|---|
pListener | IEntityOutputListener* | The plugin whose class it is owns it; dropped for you when that plugin unloads. | |
pszDesignerName | const char* | nullptr | Only outputs of entities of this designer name (the caller's); nullptr for every one. |
pszOutput | const char* | nullptr | Only this output ("OnTrigger", "OnStartTouch"); nullptr for every one. |
pEntity | CEntityInstance* | nullptr | Only outputs of this one entity; nullptr for every one. Gone with the entity. |
RemoveEntityOutputListener
virtual void RemoveEntityOutputListener(IEntityOutputListener* pListener) = 0;Drops every registration of the listener.
| Parameter | Type |
|---|---|
pListener | IEntityOutputListener* |
IEntityOutputListener
Entity outputs firing (CEntityIOOutput::FireOutputInternal), for ISource2ModEntities::AddEntityOutputListener. Called pre (post = false), before the output's targets get it, and post, after; pre may answer Action::Supersede and the output does not fire. Override and Ignore both let it fire. The strongest answer of all listeners wins.
OnEntityOutput
virtual Action OnEntityOutput(CEntityInstance* pCaller, const char* pszOutput, CEntityInstance* pActivator, float flDelay, bool post) = 0;| Parameter | Type |
|---|---|
pCaller | CEntityInstance* |
pszOutput | const char* |
pActivator | CEntityInstance* |
flDelay | float |
post | bool |
Functions
UTIL_FindAllEntitiesByDesignerName
template <typename T = CBaseEntity> inline std::vector<T*> UTIL_FindAllEntitiesByDesignerName(const char* pszDesignerName);| Parameter | Type |
|---|---|
pszDesignerName | const char* |
Macros
| Macro | Expands to |
|---|---|
GET_GAME_RULES() | g_pSource2ModEntities->GetGameRules() |
FIND_PICKER_ENTITY(player, ...) | g_pSource2ModEntities->FindPickerEntity(player, ##__VA_ARGS__) |
FIND_ENTITY_BY_CLASSNAME(start, name) | g_pSource2ModEntities->FindEntityByClassname(start, name) |
FIND_ENTITY_BY_NAME(start, name, ...) | g_pSource2ModEntities->FindEntityByName(start, name, ##__VA_ARGS__) |
CREATE_ENTITY(classname) | g_pSource2ModEntities->CreateEntityByName(classname) |
ADD_ENTITY_LISTENER(l, ...) | g_pSource2ModEntities->AddEntityListener(l, ##__VA_ARGS__) |
REMOVE_ENTITY_LISTENER(l) | g_pSource2ModEntities->RemoveEntityListener(l) |
ADD_ENTITY_OUTPUT_LISTENER(l, ...) | g_pSource2ModEntities->AddEntityOutputListener(l, ##__VA_ARGS__) |
REMOVE_ENTITY_OUTPUT_LISTENER(l) | g_pSource2ModEntities->RemoveEntityOutputListener(l) |
ACCEPT_INPUT(target, input, ...) | g_pSource2ModEntities->AcceptInput(target, input, ##__VA_ARGS__) |
ADD_ENTITY_IO_EVENT(target, input, ...) | g_pSource2ModEntities->AddEntityIOEvent(target, input, ##__VA_ARGS__) |