Entity

The Entity class is the base class for all objects that exist in the Armada 2 world, such as ships, terrain objects and ordnance. The Entity class exposes properties common to all entities and also adds some extra management functions you can use to keep track of them with.

Entities can change over time - sometimes they are replaced completely with new entities, as is the case when replaceweapon based weaponry is triggered. They can also be destroyed; it is important that if you are holding a reference to an Entity for any period of time (in between updates for example) you ensure that the Entity is still valid by checking that the valid property is true. Checking this property will update the Entity if the type has changed due to it being replaced - you have to check it before you can use the properties and functions of the new type.

Note that using the replace function will automatically update the Entity with the new type, so there is no need to check if the Entity is valid immediately afterwards.

Properties

Name Type Access Description
id Number R Current ID number of the Entity
hide Boolean RW If true, this Entity will not be rendered
hooks Table of EntityHook R Currently active Entity hooks
position Vector RW The position of the Entity in world space
scale Vector RW The scale factor applied to the Entity
forward Vector RW The direction that the Entity is facing
valid Boolean R Checks to see if the Entity is valid and updates if necessary

Functions and Enumerations

Derived Types