1. package Entities.Triggers is 
  2.  
  3.     -- A Trigger is an entity that performs an action when a condition is met at 
  4.     -- a configurable time. For example, when a player collides with a trigger, 
  5.     -- a new level may be loaded. 
  6.     type Trigger is abstract new Entity with private; 
  7.     type A_Trigger is access all Trigger'Class; 
  8.  
  9.     -- Evaluates the given conditional expression and returns the result. By 
  10.     -- default this returns True. Override it to evaluate 'expr'. 
  11.     function Evaluate( this : access Trigger; expr : String ) return Boolean is abstract; 
  12.  
  13.     -- Implement this procedure to execute the trigger's action. Execute is 
  14.     -- called when the conditions for executing the trigger are met. 'action' is 
  15.     -- canonically lower case. 'activator' may be null if there is no activating 
  16.     -- entity. (ie: executing on world load) 
  17.     procedure Execute( this      : access Trigger; 
  18.                        action, 
  19.                        argument  : String; 
  20.                        activator : A_Entity ) is abstract; 
  21.  
  22. private 
  23.  
  24.     -- Valid values for the "When" attribute are: 
  25.     --   OnActivate - The player manually activated a trigger 
  26.     --   OnLoad     - The world was loaded 
  27.     --   OnTouch    - The player touched the trigger (once per collision) 
  28.  
  29.     WHEN_ATTR      : constant String := "When";       -- when the trigger may trip 
  30.     CONDITION_ATTR : constant String := "Condition";  -- the necessary condition 
  31.     ACTION_ATTR    : constant String := "Action";     -- what the trigger will do 
  32.     ARG_ATTR       : constant String := "Argument";   -- parameterizes the action 
  33.  
  34.     type Trigger is abstract new Entity with 
  35.         record 
  36.             activatable : Boolean := True; 
  37.         end record; 
  38.  
  39.     -- Raises an exception if 'icon' can't be found in library 'libName'. 
  40.     procedure Construct( this    : access Trigger; 
  41.                          libName : String; 
  42.                          icon    : String ); 
  43.  
  44.     procedure Object_Read( stream : access Root_Stream_Type'Class; obj : out Trigger ); 
  45.     for Trigger'Read use Object_Read; 
  46.  
  47.     procedure Object_Write( stream : access Root_Stream_Type'Class; obj : Trigger ); 
  48.     for Trigger'Write use Object_Write; 
  49.  
  50.     -- Called when the trigger is manually activated by entity 'activator'. 
  51.     -- Don't override this procedure. 
  52.     procedure On_Activate( this      : access Trigger; 
  53.                            activator : not null A_Entity ); 
  54.  
  55.     -- Called when the trigger is touched by an entity. Don't override this 
  56.     -- procedure. 
  57.     procedure On_Collide( this : access Trigger; e : not null A_Entity ); 
  58.  
  59.     -- Called when the triggers's world is loaded from disk. Don't override this 
  60.     -- procedure. 
  61.     procedure On_Load( this : access Trigger ); 
  62.  
  63.     -- Deletes the Trigger. 
  64.     procedure Delete( this : in out A_Trigger ); 
  65.     pragma Postcondition( this = null ); 
  66.  
  67. end Entities.Triggers;