with Entities; use Entities;
with Hashed_Strings; use Hashed_Strings;
with Objects; use Objects;
limited with Games;
private with Object_Factory;
pragma Elaborate_All( Object_Factory );
package Actors is
type Actor is abstract new Limited_Object with private;
type A_Actor is access all Actor'Class;
-- Creates a new actor to control an entity, given the entity's class name.
-- The allocator used for creation is registered at elaboration time.
function Create_Actor( entityClass : String ) return A_Actor;
pragma Precondition( entityClass'Length > 0 );
-- Handles Impulses given by a user.
procedure Impulse( this : access Actor; name : Hashed_String ) is abstract;
-- Override this to stop any on-going actions begun with a previous impulse
-- when the game is paused.
procedure Pause( this : access Actor ) is null;
-- Returns True if the actor's life span is confined to the life span of the
-- world in which its entity exists. The default for actors is True unless
-- overridden.
function Is_Temporal( this : access Actor ) return Boolean;
-- Sets the entity that the actor controls, returning True on acceptance.
-- For non-temporal actors, this can be 'null' between worlds or before
-- loading a world. The concrete subclasses should override this function to
-- verify the entity's class before calling the base Set_Entity procedure.
function Set_Entity( this : access Actor; e : A_Entity ) return Boolean;
-- Sets the entity that the actor controls. The actor must be able to
-- control entities of the given class.
procedure Set_Entity( this : access Actor; e : A_Entity );
-- Sets the Actor's reference to its parent Game object.
procedure Set_Game( this : not null access Actor'Class;
game : not null access Games.Game'Class );
-- Deletes an actor object.
procedure Delete( this : in out A_Actor );
----------------------------------------------------------------------------
procedure Initialize;
procedure Finalize;
private
type Actor is abstract new Limited_Object with
record
entity : A_Entity := null; -- this is not owned by the actor
game : access Games.Game'Class := null; -- the actor's parent game object
end record;
----------------------------------------------------------------------------
package Factory is new Object_Factory( Actor, A_Actor, Delete );
end Actors;