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
- Static Functions
Functions that are called without an instance of the Entity class.
- add( odf, player, position )
Add a new Entity
- add( odf, playerNumber, position )
Add a new Entity
- remove( entity )
Remove an Entity
- add( odf, player, position )
- Instance Functions
Functions that are used with an Entity instance.
- isType( entityType )
Check to see if an Entity is of a specific type
- replace( odf )
Replace this entity with a new ODF
- canPlayerSee( player )
Check if a player can see this entity
- hook( id, hookType, table, func, arg )
Register to be notified about changes in this entity
- unhook( id )
Remove a hook function from the Entity.
- unhook( hook )
Remove a hook function from the Entity.
- isType( entityType )
- Enumerations
Enumerations that are part of the Entity class.
- Type
Entity type identifiers
- Type