1. with Entities;                          use Entities; 
  2. with Hashed_Strings;                    use Hashed_Strings; 
  3. with Objects;                           use Objects; 
  4.  
  5. limited with Games; 
  6.  
  7. private with Object_Factory; 
  8.  
  9. pragma Elaborate_All( Object_Factory ); 
  10.  
  11. package Actors is 
  12.  
  13.     type Actor is abstract new Limited_Object with private; 
  14.     type A_Actor is access all Actor'Class; 
  15.  
  16.     -- Creates a new actor to control an entity, given the entity's class name. 
  17.     -- The allocator used for creation is registered at elaboration time. 
  18.     function Create_Actor( entityClass : String ) return A_Actor; 
  19.     pragma Precondition( entityClass'Length > 0 ); 
  20.  
  21.     -- Handles Impulses given by a user. 
  22.     procedure Impulse( this : access Actor; name : Hashed_String ) is abstract; 
  23.  
  24.     -- Override this to stop any on-going actions begun with a previous impulse 
  25.     -- when the game is paused. 
  26.     procedure Pause( this : access Actor ) is null; 
  27.  
  28.     -- Returns True if the actor's life span is confined to the life span of the 
  29.     -- world in which its entity exists. The default for actors is True unless 
  30.     -- overridden. 
  31.     function Is_Temporal( this : access Actor ) return Boolean; 
  32.  
  33.     -- Sets the entity that the actor controls, returning True on acceptance. 
  34.     -- For non-temporal actors, this can be 'null' between worlds or before 
  35.     -- loading a world. The concrete subclasses should override this function to 
  36.     -- verify the entity's class before calling the base Set_Entity procedure. 
  37.     function Set_Entity( this : access Actor; e : A_Entity ) return Boolean; 
  38.  
  39.     -- Sets the entity that the actor controls. The actor must be able to 
  40.     -- control entities of the given class. 
  41.     procedure Set_Entity( this : access Actor; e : A_Entity ); 
  42.  
  43.     -- Sets the Actor's reference to its parent Game object. 
  44.     procedure Set_Game( this : not null access Actor'Class; 
  45.                         game : not null access Games.Game'Class ); 
  46.  
  47.     -- Deletes an actor object. 
  48.     procedure Delete( this : in out A_Actor ); 
  49.  
  50.     ---------------------------------------------------------------------------- 
  51.  
  52.     procedure Initialize; 
  53.  
  54.     procedure Finalize; 
  55.  
  56. private 
  57.  
  58.     type Actor is abstract new Limited_Object with 
  59.         record 
  60.             entity : A_Entity := null;                 -- this is not owned by the actor 
  61.             game   : access Games.Game'Class := null;  -- the actor's parent game object 
  62.         end record; 
  63.  
  64.     ---------------------------------------------------------------------------- 
  65.  
  66.     package Factory is new Object_Factory( Actor, A_Actor, Delete ); 
  67.  
  68. end Actors;