Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 72 additions & 21 deletions public/entity2/entityinstance.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,51 @@ struct CEntityPrecacheContext;
struct ChangeAccessorFieldPathIndexInfo_t;
struct datamap_t;

struct NetworkStateChangedData
{
inline NetworkStateChangedData() : m_unk001(1), m_FieldOffset(-1), m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()), m_unk101(0) { }
inline explicit NetworkStateChangedData( bool bFullChanged ) :
m_unk001(static_cast<uint32>(!bFullChanged)), m_FieldOffset(-1),
m_nArrayIndex(-1), m_nPathIndex(ChangeAccessorFieldPathIndex_t()),
m_unk101(0)
{ }

// nLocalOffset is the flattened field offset
// calculated taking into account embedded structures
// if PathIndex is specified, then the offset must start from the last object in the chain
// nArrayIndex is the index of the array element
// if the field is a CNetworkUtlVectorBase, otherwise pass -1
// nPathIndex is the value to specify
// if the path to the field goes through one or more pointers, otherwise pass -1
// this value is usually a member of the CNetworkVarChainer and belongs to the last object in the chain
inline NetworkStateChangedData( uint32 nLocalOffset, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t() ) :
m_unk001(1), m_LocalOffsets(0, 1), m_FieldOffset(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_unk101(0)
{
m_LocalOffsets.AddToHead(nLocalOffset);
}

inline NetworkStateChangedData(const std::initializer_list< uint32 > nLocalOffsets, int32 nArrayIndex = -1, ChangeAccessorFieldPathIndex_t nPathIndex = ChangeAccessorFieldPathIndex_t()) :
m_unk001(1), m_LocalOffsets(0, nLocalOffsets.size()), m_FieldOffset(-1), m_nArrayIndex(nArrayIndex), m_nPathIndex(nPathIndex), m_unk101(1)
{
for ( const uint32& nLocalOffset : nLocalOffsets )
{
m_LocalOffsets.AddToTail( nLocalOffset );
}
}

uint32 m_unk001; // Perhaps it is an enum, default 1, when 0 adds FL_FULL_EDICT_CHANGED
CUtlVector<uint32> m_LocalOffsets;

// AMNOTE: Mostly unused/debug
CUtlString m_ClassName;
CUtlString m_FieldName;
int32 m_FieldOffset;
int32 m_nArrayIndex;
ChangeAccessorFieldPathIndex_t m_nPathIndex;

int16 m_unk101; // default 0, if m_LocalOffsets has multiple values, it is set to 1
};

class CEntityInstance
{
public:
Expand All @@ -30,14 +75,17 @@ class CEntityInstance
virtual void Precache( const CEntityPrecacheContext* pContext ) = 0;
virtual void AddedToEntityDatabase() = 0;
virtual void Spawn( const CEntityKeyValues* pKeyValues ) = 0;

virtual void unk001() = 0;

virtual void PostDataUpdate( /*DataUpdateType_t*/int updateType ) = 0;
virtual void OnDataUnchangedInPVS() = 0;
virtual void Activate( /*ActivateType_t*/int activateType ) = 0;
virtual void UpdateOnRemove() = 0;
virtual void OnSetDormant( /*EntityDormancyType_t*/int prevDormancyType, /*EntityDormancyType_t*/int newDormancyType ) = 0;

virtual void* ScriptEntityIO() = 0;
virtual int ScriptAcceptInput( const CUtlSymbolLarge &sInputName, CEntityInstance* pActivator, CEntityInstance* pCaller, const variant_t &value, int nOutputID ) = 0;
virtual int ScriptAcceptInput( const CUtlSymbolLarge &sInputName, CEntityInstance* pActivator, CEntityInstance* pCaller, const variant_t &value, int nOutputID, void* pUnk1, void* pUnk2 ) = 0;

virtual void PreDataUpdate( /*DataUpdateType_t*/int updateType ) = 0;

Expand All @@ -49,37 +97,40 @@ class CEntityInstance
virtual void OnSave() = 0;
virtual void OnRestore() = 0;

virtual void unk001() = 0;
virtual void unk101() = 0;

virtual int ObjectCaps() = 0;
virtual CEntityIndex RequiredEdictIndex() = 0;

// marks an entire entity for transmission over the network
virtual void NetworkStateChanged() = 0;


// marks a field for transmission over the network
// nOffset is the flattened field offset
// calculated taking into account embedded structures
// if PathIndex is specified, then the offset must start from the last object in the chain
// nItem is the index of the array element
// if the field is a CNetworkUtlVectorBase, otherwise pass -1
// PathIndex is the value to specify
// if the path to the field goes through one or more pointers, otherwise pass -1
// this value is usually a member of the CNetworkVarChainer and belongs to the last object in the chain
virtual void NetworkStateChanged( uint nOffset, int nItem = -1, ChangeAccessorFieldPathIndex_t PathIndex = ChangeAccessorFieldPathIndex_t() ) = 0;

virtual void LogFieldInfo( const char* pszFieldName, const char* pszInfo ) = 0;
virtual void NetworkStateChanged( const NetworkStateChangedData& data ) = 0;

// AMNOTE: NetworkState related methods
virtual void unk201( const void* data ) = 0;
virtual void unk202( const void* data ) = 0;

// Toggles network update state, if set to false would skip network updates
virtual void NetworkUpdateState( bool state ) = 0;
virtual void NetworkStateChangedLog( const char* pszFieldName, const char* pszInfo ) = 0;

virtual bool FullEdictChanged() = 0;
virtual void unk101() = 0;
virtual void unk102() = 0;

virtual void unk301() = 0;
virtual void unk302() = 0;

virtual ChangeAccessorFieldPathIndex_t AddChangeAccessorPath( const CFieldPath& path ) = 0;
virtual void AssignChangeAccessorPathIds() = 0;
virtual ChangeAccessorFieldPathIndexInfo_t* GetChangeAccessorPathInfo_1() = 0;
virtual ChangeAccessorFieldPathIndexInfo_t* GetChangeAccessorPathInfo_2() = 0;

virtual void unk201() = 0;
virtual void unk401() = 0;
virtual void unk402() = 0;

virtual void ReloadPrivateScripts() = 0;
virtual datamap_t* GetDataDescMap() = 0;
virtual void unk301() = 0;

virtual void unk501() = 0;

virtual SchemaMetaInfoHandle_t<CSchemaClassInfo> Schema_DynamicBinding() = 0;

public:
Expand Down