Wiki

Clone wiki

agtools / EntityFlags

The EntityFlags type defines properties or attributes which are attached to entities and affect how they are processed by various systems.

enum EntityFlags
{
   ...
};

The attributes are defined together, but there are really three kinds involved.

Classification attributes

These identify the entity as belonging to a particular category of object, enabling interactions to be filtered properly into groups.

For example PLAYER objects can interact with NME (enemy) objects, but usually not (player) BULLET objects. Being able to tag objects with these categories helps eliminate unnecessary interaction tests. These flags can be changed at any time and will take immediate effect.

This section lists the default categories and roughly what they get used for. See the iteractions page to understand how to actually use them to set up sensible interactions.

These are more or less 'default' archetypal categories, but can be changed to suit the game.

EntityFlag_INERT/EntityFlag_NONE

No interaction category - object is inert from the point of view of other objects.

Note that INERT objects can still affect other objects (see f_interactswith for outward interactions), they just can't themselves be noticed/affected by other objects.

EntityFlag_PLAYER

Identifies a player object. Typically under the control of player input, but not necessarily. Typically would interact with NME and NMEBULLET types, but not player BULLET types.

EntityFlag_BULLET

Identifies a bullet or projectile or other object created by PLAYER entities and which is (usually) not expected to interact with PLAYER. This allows PLAYER and BULLET inward interactions (their appearance to other objects) to be filtered differently while not interacting with each other.

EntityFlag_POWERUP

Identifies objects which PLAYER objects are expected to pick up or activate, but which no other object can interact with.

EntityFlag_NME

Identifies any enemy object. Typically would interact with PLAYER or player BULLET types. Might also be configured to interact with NMEAVOID, allowing enemies to see and avoid each other.

EntityFlag_NMEBULLET

Identifies a projectile or object which can interact with PLAYER but not necessarily NME types (opposite to player BULLET).

EntityFlag_NMEAVOID

Identifies certain enemy objects as interacting with each other (e.g. for enemy-enemy avoidance or bump reactions), where others will remain insensitive to each other.

Note that all of these categories are used only for interaction filtering, defined in the entity dictionary for each game and have no other impact on the engine. They have no specific internal meaning and can be renamed and used as required.

Entity management control attributes

These instruct the entity manager to include or exclude the object from specific processes such as ticking (AI) and drawing/collisions when inserted into the world. They are mainly used when new objects are spawned and may not react to edits while the object is active. It is therefore best not to modify them inside tick functions.

EntityFlag_VIEWPORT

Identifies the viewport object, within which visible objects are processed for drawing. There must always be one of these defined.

EntityFlag_SPATIAL

Any entity which is to be drawn within the viewport, or which can interact with other objects will require the SPATIAL attribute. Without this, an entity will not be attached to any systems which deal with coordinates.

There are some kinds of object which don't have spatial relationships - such as a game timer/clock or bonus/secret unlock logic which needs periodically executed but has no 'position' in the world. Most other kinds of object will however need this attribute defined.

EntityFlag_TICKED

Any object which can move or has any kind of behaviour will need this attribute. Objects marked TICKED will be attached to the AI tick manager and its associated fntick function will be called on every game refresh.

The order in which objects are ticked can be changed with the entity tick_priority field. This is useful for ensuring related objects are updated in the right order. e.g. objects following the player should generally be ticked after the player, to avoid unwanted lag.

EntityFlag_VISTRIG

This is an alternative to TICKED, allowing objects to be spawned in a dormant state where their fntick function is temporarily frozen so long as they remain outside of the viewport. Contact with the viewport edge will activate them and cause the VISTRIG state to transition permanently to TICKED, after which the object continues to behave normally.

This is useful whens spawning many objects into a level on level startup, but without activating them immediately. They activate as they are encountered - e.g. enemy waves, placements or ground turrets in a SHMUP are encountered in sequence and until that time should be idling with as low a cost as possible.

Internal attributes

These are used by the entity manager to indicate important changes in state

While visible to the game code and can be read/tested, they should not be written to objects by the game code.

EntityFlags_KILL

Used internally to mark an entity as pending for removal, before the removal pass takes place at the end of a tick. This ensures the same object can't be removed multiple times by unrelated events. e.g. the same object being killed by two different entities during the same tick, or by a tick function and by a collision reaction function - i.e. different reasons - during the same tick.

It can be read by the tick functions but not modified.

Updated