Index

Package: Entities

Description

package Entities is

Classes

Entity (abstract)

type Entity is abstract new Object with private;

Ancestors:

Immediate Children:

Primitive operations:

Adjust (overriding Objects.Adjust)
Construct
Delete (overriding Objects.Delete)
Object_Input
Object_Read (overriding Objects.Object_Read)
Object_Write (overriding Objects.Object_Write)
Objects.Construct (Inherited)
On_Activate
On_Collide
On_Hit_Wall
On_Separate
Set_Attribute
To_String (overriding Objects.To_String)
Update_Frame
An Entity represents any distinct object with a location within a World, visible or invisible, physical or static. Each entity in the Game's World is updated by a call to Tick while the game is running.

Types

Entity_Id

type Entity_Id is private;
Uniquely identifies an Entity within a World.

A_Entity

type A_Entity is access all Entity'Class;

Constants & Global variables

INVALID_ID (Entity_Id)

INVALID_ID : constant Entity_Id;
Default value for no entity.

Subprograms & Entries

<

function "<"
( l, r: Entity_Id ) return Boolean;
Compares Entity_Id values to support ordering.

Image

function Image
( id: Entity_Id ) return String;
Returns a string representation of 'id'.

Activate

procedure Activate
( this: not null access Entity'Class;
activator: not null A_Entity );
Notifies the entity that it is being activated. To implement behavior to handle this event, override On_Activate.

Collided

procedure Collided
( this: not null access Entity'Class;
e: not null A_Entity );
Notifies the entity that it has collided with 'e', updating the entity's touch list and calling On_Collide to invoke collision behavior. To add entity behavior to handle a collision event, override On_Collide.

Face

procedure Face
( this: access Entity;
dir: Direction_Type ) is null;
This procedure is called to change the direction the entity is facing. The default implementation is a null procedure so it must be overridden to provide some specific behavior.

Get_Attributes

function Get_Attributes
( this: not null access Entity'Class ) return A_Association;
Returns a reference to the entity's internal attributes. The reference belongs to the entity, do not delete it!

Get_Direction

function Get_Direction
( this: not null access Entity'Class ) return Direction_Type;
Returns the direction that the entity is currently facing.

Get_Frame

function Get_Frame
( this: not null access Entity'Class ) return Integer;
Returns the entity's frame as a tile id in the entity's tile library.

Get_Height

function Get_Height
( this: not null access Entity'Class ) return Integer;
Returns the entity's physical height in world units.

Get_Id

function Get_Id
( this: not null access Entity'Class ) return Entity_Id;
Returns the entity's unique id.

Get_Lib_Name

function Get_Lib_Name
( this: not null access Entity'Class ) return String;
Returns the name of the entity's tile library. This does not change over the lifetime of the object.

Get_Width

function Get_Width
( this: not null access Entity'Class ) return Integer;
Returns the entity's physical width in world units.

Get_X

function Get_X
( this: not null access Entity'Class ) return Float;
Returns the X location of the center of the entity in world coordinates.

Get_XV

function Get_XV
( this: not null access Entity'Class ) return Float;
Returns the X velocity of the entity in world units.

Get_Y

function Get_Y
( this: not null access Entity'Class ) return Float;
Returns the Y location of the center of the entity in world coordinates.

Get_YV

function Get_YV
( this: not null access Entity'Class ) return Float;
Returns the Y velocity of the entity in world units.

Hit_Wall

procedure Hit_Wall
( this: not null access Entity'Class;
dir: Cardinal_Direction;
firstContact: Boolean );
Notifies the entity that it hit a wall. To implement behavior to handle this event, override On_Hit_Wall.

Is_Clipped

function Is_Clipped
( this: not null access Entity'Class ) return Boolean;
Returns True if the entity is clipped to the walls in the world.

Is_Permanent

function Is_Permanent
( this: not null access Entity'Class ) return Boolean;
Returns True if this entity is a permanent part of the world and isn't allowed to be deleted. The player, for example, is permanent.

Is_Metaphysical

function Is_Metaphysical
( this: not null access Entity'Class ) return Boolean;
Returns True if the entity is invisible, existing metaphysically.

Is_Physical

function Is_Physical
( this: not null access Entity'Class ) return Boolean;
Returns True if the entity is subject to the laws of physics.

Object_Input (abstract)

function Object_Input
( stream: access Root_Stream_Type'Class ) return Entity is abstract;
Reads an entity object from a stream and returns it. All concrete Entity subclasses must implement this function.

On_Load

procedure On_Load
( this: access Entity );
Override this procedure to implement behavior for when the entity's world is loaded from disk. On_Load is invoked once over the life of the object and before its logic is executed. The overriding implementation should call this first.

Separated

procedure Separated
( this: not null access Entity'Class;
e: not null A_Entity );
Notifies the entity that it has separated with 'e', updating the entity's touch list and calling On_Separate to invoke separation behavior. To implement behavior to handle this event, override On_Separate.

Set_Attribute

procedure Set_Attribute
( this: access Entity;
name: String;
val: in out A_Value );
Sets an attribute of this entity. An Entity_Attribute_Changed event will be queued.

Set_Grounded

procedure Set_Grounded
( this: not null access Entity'Class;
grounded: Boolean );
Sets the grounded state of the entity. If 'grounded' is True, the entity is resting on the ground. The entity's frame will be updated.

Set_Location

procedure Set_Location
( this: not null access Entity'Class;
x, y: Float );
Sets the entity's location without sending an event.

Set_Size

procedure Set_Size
( this: not null access Entity'Class;
width, height: Natural );
Sets the entity's physical size without sending an event.

Set_World

procedure Set_World
( this: not null access Entity'Class;
world: not null access Worlds.World_Object'Class );
Sets the entity's reference to the world in which it exists. An exception will be raised if the entity already has a world reference because it cannot be transplanted between worlds.

Set_Velocity_X

procedure Set_Velocity_X
( this: not null access Entity'Class;
xv: Float );
Sets the entity's X velocity in world units without sending an event. The entity's frame will be updated.

Set_Velocity_Y

procedure Set_Velocity_Y
( this: not null access Entity'Class;
yv: Float );
Sets the entity's Y velocity in world units without sending an event. The entity's frame will be updated.

Tick

procedure Tick
( this: access Entity;
time: Tick_Time );
Runs the entity logic for one execution frame. An overriding implementation should call this first.

Allocate

function Allocate
( id: String ) return A_Entity;
Allocates and returns a new Entity instance by class id.

Copy

function Copy
( src: A_Entity ) return A_Entity;
Entities can't be copied; Raises COPY_NOT_ALLOWED.

Delete

procedure Delete
( this: in out A_Entity );
Deletes an entity.

In_Class

function In_Class
( id: String;
pattern: String ) return Boolean;
Returns True if class 'id' is a class id that matches the regular expression 'pattern' (case insensitive). For example, to determine if 'Entities.Enemies.Cat' is an enemy entity class, you can check if it is in the class pattern 'Entities.Enemies.*'.

Iterate_Classes

procedure Iterate_Classes
( pattern: String := "";
examine: access procedure( id : String ) );
Iterates across the registered entity class ids, matching against a regular expression pattern. If 'pattern' is empty, all classes will be iterated.

Template

function Template
( id: String ) return A_Entity;
Returns a reference to a template Entity instance for the given class id or null, if 'id' is not a registered class. Do not modify the object!

Initialize

procedure Initialize;
Initializes the Entity factory.

Finalize

procedure Finalize;
Finalizes the Entity factory.