edict_t
(Redirected from Edict)
edict_t
("entity dictionary") is an interface struct that allows entities to cross the client/server divide: with one attached, an entity has the same index at both ends. The edict also manages the state of the entity's DataTable and provides a common representation across all DLLs. It cannot be used on the client.
![Note.png](/w/images/thumb/c/cc/Note.png/10px-Note.png)
CHandle
for long-term storage.![Warning.png](/w/images/thumb/c/cb/Warning.png/10px-Warning.png)
edict_t
or CBaseEdict
. If the memory footprint of either changes, engine DLLs will start accessing invalid addresses.Limitations
![Warning.png](/w/images/thumb/c/cb/Warning.png/10px-Warning.png)
![Source](/w/images/thumb/1/10/Icon-Source.png/16px-Icon-Source.png)
![Note.png](/w/images/thumb/c/cc/Note.png/10px-Note.png)
![Portal 2](/w/images/thumb/3/3c/Portal2_icon.png/16px-Portal2_icon.png)
![Garry's Mod](/w/images/thumb/e/ea/Gmod_icon.png/16px-Gmod_icon.png)
![Portal 2: Community Edition](/w/images/thumb/a/ae/Icon_P2CE_full.png/16px-Icon_P2CE_full.png)
![Counter-Strike: Global Offensive](/w/images/thumb/8/85/Csgo_icon.png/16px-Csgo_icon.png)
![Team Fortress 2](/w/images/thumb/8/84/Tf2-16px.png/16px-Tf2-16px.png)
![Tip.png](/w/images/thumb/4/45/Tip.png/9px-Tip.png)
![GoldSrc](/w/images/thumb/6/61/Gldsrc_icon.png/16px-Gldsrc_icon.png)
edicts "2048"
.![Confirm.png](/w/images/thumb/2/2e/Confirm.png/10px-Confirm.png)
![Sven Co-op](/w/images/thumb/1/13/Sven-16px.png/16px-Sven-16px.png)
Avoiding
Edicts are assigned by CBaseEntity::PostConstructor()
. If your entity won't ever need to be transmitted to the client, construct it like so:
CMyEntity() : CBaseEntity(true) { /* your constructor code */ }
![Tip.png](/w/images/thumb/4/45/Tip.png/9px-Tip.png)
CServerOnlyEntity
already does this. CLogicalEntity
inherits, and as such none of Valve's logic entities or VPhysics constraints have edicts.Edict-less entities count toward non-networked entity limit, which is also 2048.
Getting
edict_t* CBaseEntity::edict()
- Simple accessor. Returns null if there is no edict.
edict_t* INDEXENT( int iEdictNum )
int ENTINDEX( edict_t* pEdict )
- Converts between an entity index and its attached edict.
int GetEntityCount()
- Returns the current number of assigned edicts (not entities).
Setting
void CBaseEntity::NetworkProp()->AttachEdict(edict_t* pRequiredEdict);
- Assigns an edict via the entity's
CServerNetworkProperty
object. Pass NULL unless a specific edict is required. void CBaseEntity::NetworkProp()->DetachEdict()
- Detaches the entity's assigned edict. It will go back into the edict pool for re-use.
Notable members
CBaseEntity* GetUnknown()->GetBaseEntity()
- Pointer to the entity's local representation.
char* GetClassName()
- The classname of the assigned entity.
bool IsFree()
- Whether there is currently an entity assigned to this edict.
float freetime
- The server timestamp at which the edict was last freed. Can be used to avoid reallocating the edict immediately.
bool HasStateChanged()
- Whether anything in the DataTable needs transmission.
void StateChanged()
- Tell the edict of a change to the entity's DataTable that needs transmission.
IServerEntity* GetIServerEntity()
IServerNetworkable* GetNetworkable()
ICollideable* GetCollideable()
- Accessors to various interfaces.