1. with Hashed_Strings;                    use Hashed_Strings; 
  2.  
  3. package Entities.Players.Keen is 
  4.  
  5.     type Keen is new Player with private; 
  6.     type A_Keen is access all Keen'Class; 
  7.  
  8.     -- If Keen was teleporting, he will end the action and go back to the 
  9.     -- moving state. 
  10.     procedure Finish_Teleport( this : not null access Keen'Class ); 
  11.  
  12.     -- Accelerates Keen in the direction 'dir'. 
  13.     procedure Move_Start( this : access Keen; dir : Cardinal_Direction ); 
  14.  
  15.     -- Stops Keen's acceleration in the direction 'dir'. 
  16.     procedure Move_Stop( this : access Keen; dir : Cardinal_Direction ); 
  17.  
  18.     -- Shoots Keen's neural stunner, returning True on success. If 'fire' is 
  19.     -- False, an out of ammo sound will be played and no stunner shot will be 
  20.     -- spawned. 
  21.     function Shoot_Gun( this : not null access Keen'Class; fire : Boolean ) return Boolean; 
  22.  
  23.     -- Notifies the entity that he's not attempting to activate anymore, which 
  24.     -- will allow Try_Activating to work again. 
  25.     procedure Stop_Activating( this : not null access Keen'Class ); 
  26.  
  27.     -- Stops Keen's attempt to jump, if he was attempting to do so. 
  28.     procedure Stop_Jump_Attempt( this : not null access Keen'Class ); 
  29.  
  30.     -- Checks if Keen can teleport and then queues the events needed to enter 
  31.     -- the teleport state. 
  32.     procedure Teleport( this         : access Keen; 
  33.                         fromX, fromY : Float; 
  34.                         toX,   toY   : Float ); 
  35.  
  36.     -- Toggles Keen's pogostick, if it's possible to do so. He can use his 
  37.     -- pogostick when he's moving (walking, standing, jumping). Attempting to 
  38.     -- use the pogo when he's bored will abort the bored action. 
  39.     procedure Toggle_Pogostick( this : not null access Keen'Class ); 
  40.  
  41.     -- Activates the entities that Keen is currently touching, if he is allowed 
  42.     -- to perform the activate action right now. He must be standing flat footed 
  43.     -- on the ground and not already busy activating something. 
  44.     procedure Try_To_Activate( this : not null access Keen'Class ); 
  45.  
  46.     -- Make Keen attempt to jump. The attempt will be in effect until the 
  47.     -- attempt is stopped. The jump will begin on the attempt if he is able to 
  48.     -- do so. 
  49.     procedure Try_To_Jump( this : not null access Keen'Class ); 
  50.  
  51.     ---------------------------------------------------------------------------- 
  52.  
  53.     -- An impulse the Keen entity sends to itself on completion of teleporting 
  54.     Finish_Teleporting : constant Hashed_String := To_Hashed_String( "Finish_Teleporting" ); 
  55.  
  56. private 
  57.  
  58.     type Action_Type is (Act_Moving, Act_Looking, Act_Looking_Back, 
  59.                          Act_Teleporting, Act_Idle, Act_Rising, Act_Dying); 
  60.  
  61.     type Keen is new Player with 
  62.         record 
  63.             -- *** these fields are streamed *** 
  64.  
  65.             -- true when keen is jumping (actively accelerating upward) 
  66.             jumping : Boolean := False; 
  67.  
  68.             -- the world y location of keen when he started his jump. this is 
  69.             -- used to determine when the jump has reached min and max heights. 
  70.             jumpStartY : Float := 0.0; 
  71.  
  72.             -- true if keen is on his pogo stick. note that jumping and grounded 
  73.             -- are independent states and may or may not be true. 
  74.             onPogo : Boolean := False; 
  75.  
  76.             -- true if keen is currently shooting. keen may shoot while 
  77.             -- performing certain actions. (ie: moving, hanging from a pole) 
  78.             shooting : Boolean := False; 
  79.  
  80.             -- the time when keen last fired a shot, used for keeping a delay 
  81.             -- between shots. (relative to .age) 
  82.             shootStart : Time_Span := Time_Span_Zero; 
  83.  
  84.             -- related to keen performing a one-shot action 
  85.             action         : Action_Type := Act_Moving; 
  86.             actionStart    : Time_Span := Time_Span_Zero;  -- (relative to .age) 
  87.             actionDuration : Time_Span := Time_Span_Zero; 
  88.  
  89.             idleStart  : Time_Span := Time_Span_Zero;      -- (relative to .age) 
  90.             idleNumber : Positive := 1;     -- number of the next idle animation 
  91.  
  92.             -- for the teleporting action 
  93.             teleportX,                                   -- teleport destination 
  94.             teleportY    : Float := 0.0;                 -- 
  95.             lastTeleport : Time_Span := Time_Span_Zero;  -- time of previous teleport (relative to .age) 
  96.  
  97.             deathX, 
  98.             deathY : Float := 0.0;      -- location of keen when he died 
  99.  
  100.             -- ** these fields do not need to be streamed ** 
  101.  
  102.             dead : Boolean := False;    -- dead fully dead? (temporary) 
  103.  
  104.             upTime : Time_Span := Time_Span_Zero; 
  105.  
  106.             attemptingJump : Boolean := False;  -- true when the jump key is being held down 
  107.             activating     : Boolean := False;  -- true if busy activating something 
  108.  
  109.             minJumpHeight,                  -- entity.player.keen.min_jump_height 
  110.             maxJumpHeight,                  -- entity.player.keen.max_jump_height 
  111.             minPogoHeight,                  -- entity.player.keen.min_pogo_height 
  112.             maxPogoHeight,                  -- entity.player.keen.max_pogo_height 
  113.             maxBounceHeight : Float := 0.0; -- entity.player.keen.max_bounce_height 
  114.             lookSpeed       : Float := 0.0; -- entity.player.keen.look_speed 
  115.         end record; 
  116.  
  117.     procedure Construct( this : access Keen ); 
  118.  
  119.     procedure Die( this : access Keen ); 
  120.  
  121.     procedure Face( this : access Keen; dir : Direction_Type ); 
  122.  
  123.     function Is_Busy( this : not null access Keen'Class ) return Boolean; 
  124.  
  125.     function Object_Input( stream : access Root_Stream_Type'Class ) return Keen; 
  126.     for Keen'Input use Object_Input; 
  127.  
  128.     procedure Object_Read( stream : access Root_Stream_Type'Class; obj : out Keen ); 
  129.     for Keen'Read use Object_Read; 
  130.  
  131.     procedure Object_Write( stream : access Root_Stream_Type'Class; obj : Keen ); 
  132.     for Keen'Write use Object_Write; 
  133.  
  134.     procedure On_Hit_Wall( this : access Keen; dir : Cardinal_Direction ); 
  135.  
  136.     procedure Reset_Idle( this : not null access Keen'Class ); 
  137.  
  138.     procedure Start_Action( this   : not null access Keen'Class; 
  139.                             action : Action_Type; 
  140.                             length : Time_Span := Time_Span_Zero ); 
  141.  
  142.     procedure Start_Jump( this : not null access Keen'Class ); 
  143.  
  144.     procedure Stop_Jump( this : not null access Keen'Class ); 
  145.  
  146.     procedure Tick( this : access Keen; upTime, dt : Time_Span ); 
  147.  
  148.     procedure Update_Frame( this : access Keen; notify : Boolean := True ); 
  149.  
  150. end Entities.Players.Keen;