Pyrogenesis Object Model : Entity Class

The Entity class allows interaction with engine entities from within JavaScript. This class is designed to be user-extensible, with only the minimum required functionality being defined by the engine, leaving other properties and methods to be defined and used via data files and scripting. This class also supports Prometheus' inheritance system, meaning an entity will, by default, use the properties of it's template object (see EntityTemplate), though these properties can be modified or overridden at will.

Entity Methods

Entity (Constructor)

  • Overview:
    • Instantiates an Entity object.
  • Syntax:
    • new Entity( templateObject, position );
    • new Entity( className, position );
    • new Entity( templateObject, position, orientation );
    • new Entity( className, position, orientation );
  • Parameters:
    • templateObject: An EntityTemplate object representing the class of the new entity.
    • className: A string giving the class name of the new entity (used to retrieve the appropriate EntityTemplate).
    • position: A Vector3D giving the position in the world the entity should be created at.
    • orientation: A real number giving the initial orientation of the entity, in radians. If unspecifed, defaults to zero orientation.
  • Returns:
    • An Entity object with the specified state.
  • Notes:
    • The entity is immediately registered and begins taking part in the simulation.

toString (Implicit)

  • Overview:
    • Overrides the default string conversion to include the name and type of this entity.
  • Syntax:
    • toString();
  • Parameters:
    • None.
  • Returns:
    • A string of the form '[object Entity "<Name>" (<Class>)]'.
  • Notes:
    • This function is called implicitly by the JavaScript engine to convert this object to a string.

Entity Properties

These are the properties currently defined for entities by the engine. A more complete list, including the properties defined by data for 0 A.D., can be found in the design document.

template

  • Overview:
    • Gets or sets a reference to the template object, used to determine this entity's class.
  • Type:
    • EntityTemplate

name

  • Overview:
    • Gets or sets the entity's displayed name.
  • Type:
    • string
  • Notes:
    • This property can be inherited from the class template.

extant

  • Overview:
    • Gets or sets a value that determines whether the entity is still active in the simulation.
  • Type:
    • boolean
  • Notes:
    • If extant is false, no processing whatsoever is performed on the entity. Such a state indicates that, while the memory for the entity is still allocated, no guarantee can be made about the state of any property other than this one. For this reason, it is not valid to set this property to true once it has become false.

selected

  • Overview:
    • Gets or sets a value that determines whether the entity is selected.
  • Type:
    • boolean

group

  • Overview:
    • Gets or sets a value indicating the entity's current group.
  • Type:
    • integer
  • Notes:
    • -1 indicates that the entity is ungrouped.

position

  • Overview:
    • Gets or sets the position of this entity.
  • Type:
    • Vector3D

orientation

  • Overview:
    • Gets or sets the orientation of this entity, in radians.
  • Type:
    • double

speed

  • Overview:
    • Gets or sets the maximum speed of this entity.
  • Type:
    • double
  • Notes:
    • This property can be inherited from the class template.

turningRadius

  • Overview:
    • Gets or sets the minimum turning radius of this entity.
  • Type:
    • double
  • Notes:
    • This property can be inherited from the class template.

Entity Global Functions

getEntityByHandle

  • Overview:
    • Retrieve the entity currently occupying the specified handle.
    • Caution, debug only.
  • Syntax:
    • entity = getEntityByHandle( handle );
  • Parameters:
    • handle [int]
  • Returns:
    • An object representing the entity occupying the handle, or null, if the argument is invalid or the specified handle is unused.
  • Notes:
    • Handles are a low-level internal representation of entities, and their use by JavaScript is not recommended where an alternative is available. Details of handle allocation and implementation may change. Handles are allocated starting from 0.

getEntityTemplate

  • Overview:
    • Retrieves the entity template object (holding attributes shared amongst all entities of that type) for the class with the specified name.
    • Deprecated. Will be removed shortly.

Entity Global Objects

groups

  • Overview:
    • Gets or sets an array representing the selection groups.
    • Caution, not multiplayer-safe.
  • Type:
    • Array of EntityCollection

selection

  • Overview:
    • Gets or sets a JavaScript object representing the current selection.
    • Caution, not multiplayer-safe.
  • Type:
    • EntityCollection
Last modified 16 years ago Last modified on Feb 23, 2008, 4:18:59 AM
Note: See TracWiki for help on using the wiki.