#ifndef ENTITYCLASS_H #define ENTITYCLASS_H #if _WIN32 #pragma once #endif #include "tier1/utlsymbollarge.h" #include "tier1/utlvector.h" #include "entity2/entitycomponent.h" #include "entityhandle.h" #include "networksystem/iflattenedserializers.h" enum EntityClassFlags_t { ECF_NOT_NETWORKED = (1 << 0), // If the EntityClass is non-networkable ECF_ALIAS = (1 << 1), // If the EntityClass is an alias ECF_SPAWN_GROUP_HANDLE_INVALID = (1 << 2), // Don't use spawngroups when creating entity ECF_HAS_REQUIRED_ENTITY_HANDLE = (1 << 3), // Forces m_requiredEHandle on created entities ECF_ALWAYS_SPAWN_ON_CLIENT = (1 << 4), ECF_BECOME_SUSPENDED_INSTEAD_OF_DORMANT = (1 << 5), // Suspend entities outside of PVS ECF_ANONYMOUS_ENTITY = (1 << 6), // If the EntityClass is anonymous ECF_PRECACHE_NETWORKED_ENTITY_ON_CLIENT = (1 << 7), ECF_UNK001 = (1 << 8), ECF_UNK002 = (1 << 9), ECF_FORCE_WORLDGROUPID = (1 << 10) // Forces worldgroupid to be 1 on created entities }; class CSchemaClassInfo; class CEntityClass; class CEntityIdentity; class CEntitySharedPulseSignature; class CPulseAPIExtensionRegistrationContext; class CNetworkSerializerClassInfo; class ServerClass; struct EntInput_t; struct ScriptClassDesc_t; struct EntOutput_t; struct datamap_t; typedef enum { USE_OFF = 0, USE_ON = 1, USE_SET = 2, USE_TOGGLE = 3 } USE_TYPE; // AMNOTE: In action these are member function ptrs instead of raw pointers typedef void (*BASEPTR)(CEntityInstance *ent); typedef void (*ENTITYFUNCPTR)(CEntityInstance *pOther); typedef void (*USEPTR)(CEntityInstance *pActivator, CEntityInstance *pCaller, USE_TYPE useType, float value); struct EntClassComponentOverride_t { const char* pszBaseComponent; const char* pszOverrideComponent; }; enum EntityClassInfoFlags_t { ECIF_NOT_SPAWNABLE = (1 << 0), // CreateEntityByName refuses to spawn the entity if set }; struct EntComponentNameEntry_t { const char* pszComponentClassName; size_t nOffsetInEntity; }; class CEntityClassInfo { public: const char* m_pszClassname; const char* m_pszCPPClassname; uint32 m_nFlags; // EntityClassInfoFlags_t CEntityClass *m_pClass; CEntityClassInfo *m_pBaseClassInfo; CSchemaClassInfo* m_pSchemaBinding; datamap_t* m_pDataDescMap; }; // Size: 0x128 class CEntityClass { struct ComponentOffsets_t { uint16 m_nOffset; }; struct ComponentHelper_t { size_t m_nOffset; CEntityComponentHelper* m_pComponentHelper; }; struct ClassInputInfo_t { CUtlSymbolLarge m_sName; EntInput_t* m_pInput; }; struct ClassOutputInfo_t { CUtlSymbolLarge m_sName; EntOutput_t* m_pOutput; }; public: inline CSchemaClassInfo *GetSchemaBinding() const { return m_pClassInfo->m_pSchemaBinding; } inline datamap_t *GetDataDescMap() const { return m_pClassInfo->m_pDataDescMap; } public: using FuncToNameCb = const char *(*)(BASEPTR think_fn); using NameToFuncCb = BASEPTR (*)(const char *fn_name); // Registers this class' pulse bindings, called base classes first using RegisterPulseBindingsCb = void (*)(CPulseAPIExtensionRegistrationContext *pContext); // Appends the components this class owns, overrides are applied by the caller using EnumerateComponentsCb = void (*)(CUtlVector *pOut); ScriptClassDesc_t* m_pScriptDesc; CNetworkSerializerClassInfo *m_NetworkSerializerInfo; EntInput_t* m_pInputs; EntOutput_t* m_pOutputs; int m_nInputCount; int m_nOutputCount; CEntitySharedPulseSignature *m_pSharedPulseSignature; RegisterPulseBindingsCb m_pfnRegisterPulseBindings; // Allows to get any think functions in use or to get its string name for this class // does searches to the parent classes as well NameToFuncCb m_NameToThinkFunc; FuncToNameCb m_ThinkFuncToName; EnumerateComponentsCb m_pfnEnumerateComponents; EntClassComponentOverride_t* m_pComponentOverrides; CEntityClassInfo* m_pClassInfo; CEntityClassInfo* m_pBaseClassInfo; CUtlSymbolLarge m_designerName; // Uses EntityClassFlags_t flags uint m_flags; int m_SpawnOrder; uint m_nAllHelpersFlags; CUtlVector m_ComponentOffsets; CUtlVector m_AllHelpers; ComponentUnserializerClassInfo_t m_componentUnserializerClassInfo; FlattenedSerializerDesc_t m_flattenedSerializer; CUtlVector m_classOutputInfos; CEntityHandle m_requiredEHandle; CEntityClass* m_pNext; CEntityIdentity* m_pFirstEntity; ServerClass* m_pServerClass; // Assigned from the global class counter on registration, used as a bit index by CEntitySystem int m_nClassIndex; }; #endif // ENTITYCLASS_H