Difference between revisions of "Entity"
(Created page with "Entity is a primitive type in quake-c language. They are essentially a struct which start with a predefined set of member variables == Engine Callbacks == Entities get callbacks from the engine depending on how they are set up === touch === touch is called when the physics engine has detected a collision between entities or the world and the entity. '''Important note''': The physics engine may not call the touch callback when an entity and the entity's '...") |
|||
Line 33: | Line 33: | ||
Each entity is created the same with all entity-defined variables attached | Each entity is created the same with all entity-defined variables attached | ||
[[Category:Primitive]] |
Revision as of 06:10, 17 February 2022
Entity is a primitive type in quake-c language. They are essentially a struct which start with a predefined set of member variables
Engine Callbacks
Entities get callbacks from the engine depending on how they are set up
touch
touch is called when the physics engine has detected a collision between entities or the world and the entity. Important note: The physics engine may not call the touch callback when an entity and the entity's 'owner' collide.
think
Think is called on the first game tick after 'nexttime' becomes less than or equal to 'time'.
Entity Variables
New entity variables can be defined much as in 'defs.qc'
The code:
.string deathtype;
defines the floating point variable 'deathtype' which can be accessed as in the if-statement below:
if (targ.deathtype == "falling")
Since all entities regardless of whether they are a projectile or a lamp or a monster each have the same set of member-variables to store things in, it is easy to make use of nonsensical fields to store properties for new behavior and has the benefit of not changing the memory footprint of every other entity created in the game.
There doesn't appear to be a limit on the number of variables that can be attached to an entity.
New entity variables can be declared anywhere in the code.
Trivia
Even in the 2021 release there are a limited number of entities that can be created in a given game
Entities can cause excessive network traffic and slow the game dramatically
Each entity is created the same with all entity-defined variables attached