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.     -- Keen tries to grab a pole and enter the climbing action state if he is 
  47.     -- touching a pole and able to climb. 'dir' must be the direction keen is 
  48.     -- trying to climb: either Up or Down. 
  49.     procedure Try_To_Climb( this : not null access Keen'Class; 
  50.                             dir  : Cardinal_Direction ); 
  51.  
  52.     -- Make Keen attempt to jump. The attempt will be in effect until the 
  53.     -- attempt is stopped. The jump will begin on the attempt if he is able to 
  54.     -- do so. 
  55.     procedure Try_To_Jump( this : not null access Keen'Class ); 
  56.  
  57.     ---------------------------------------------------------------------------- 
  58.  
  59.     -- An impulse the Keen entity sends to itself on completion of teleporting 
  60.     Finish_Teleporting : constant Hashed_String := To_Hashed_String( "Finish_Teleporting" ); 
  61.  
  62. private 
  63.  
  64.     type Action_Type is (Act_Moving, Act_Looking, Act_Looking_Back, 
  65.                          Act_Teleporting, Act_Idle, Act_Rising, Act_Dying, 
  66.                          Act_Climbing); 
  67.  
  68.     type Keen is new Player with 
  69.         record 
  70.             -- *** these fields are streamed *** 
  71.  
  72.             -- true when keen is jumping (actively accelerating upward) 
  73.             jumping : Boolean := False; 
  74.  
  75.             -- the world y location of keen when he started his jump. this is 
  76.             -- used to determine when the jump has reached min and max heights. 
  77.             jumpStartY : Float := 0.0; 
  78.  
  79.             -- true if keen is on his pogo stick. note that jumping and grounded 
  80.             -- are independent states and may or may not be true. 
  81.             onPogo : Boolean := False; 
  82.  
  83.             -- true if keen is currently shooting. keen may shoot while 
  84.             -- performing certain actions. (ie: moving, hanging from a pole) 
  85.             shooting : Boolean := False; 
  86.  
  87.             -- the time when keen last fired a shot, used for keeping a delay 
  88.             -- between shots. (relative to .age) 
  89.             shootStart : Time_Span := Time_Span_Zero; 
  90.  
  91.             -- related to keen performing a one-shot action 
  92.             action         : Action_Type := Act_Moving; 
  93.             actionStart    : Time_Span := Time_Span_Zero;  -- (relative to .age) 
  94.             actionDuration : Time_Span := Time_Span_Zero; 
  95.  
  96.             idleStart  : Time_Span := Time_Span_Zero;      -- (relative to .age) 
  97.             idleNumber : Positive := 1;     -- number of the next idle animation 
  98.  
  99.             -- for the teleporting action 
  100.             teleportX,                                   -- teleport destination 
  101.             teleportY    : Float := 0.0;                 -- 
  102.             lastTeleport : Time_Span := Time_Span_Zero;  -- time of previous teleport (relative to .age) 
  103.  
  104.             -- for the climbing action 
  105.             poleId     : Entity_Id := INVALID_ID;   -- id of pole being climbed (action = Act_Climbing) 
  106.             poleTop    : Boolean := False;          -- reached the top of the pole 
  107.             poleBottom : Boolean := False;          -- reached the bottom of the pole 
  108.  
  109.             deathX, 
  110.             deathY : Float := 0.0;      -- location of keen when he died 
  111.  
  112.             -- ** these fields do not need to be streamed ** 
  113.  
  114.             dead : Boolean := False;    -- dead fully dead? (temporary) 
  115.  
  116.             upTime : Time_Span := Time_Span_Zero; 
  117.  
  118.             attemptingJump : Boolean := False;  -- true when the jump key is held down 
  119.             activating     : Boolean := False;  -- true if busy activating something (activate button held down) 
  120.  
  121.             minJumpHeight,                  -- entity.player.keen.min_jump_height 
  122.             maxJumpHeight,                  -- entity.player.keen.max_jump_height 
  123.             minPogoHeight,                  -- entity.player.keen.min_pogo_height 
  124.             maxPogoHeight,                  -- entity.player.keen.max_pogo_height 
  125.             maxBounceHeight : Float := 0.0; -- entity.player.keen.max_bounce_height 
  126.             lookSpeed       : Float := 0.0; -- entity.player.keen.look_speed 
  127.         end record; 
  128.  
  129.     procedure Construct( this : access Keen ); 
  130.  
  131.     procedure Die( this : access Keen ); 
  132.  
  133.     procedure Face( this : access Keen; dir : Direction_Type ); 
  134.  
  135.     -- Returns True if an action duration has not yet been met and False when 
  136.     -- the current action's duration has expired. 
  137.     function Is_Busy( this : not null access Keen'Class ) return Boolean; 
  138.  
  139.     function Object_Input( stream : access Root_Stream_Type'Class ) return Keen; 
  140.     for Keen'Input use Object_Input; 
  141.  
  142.     procedure Object_Read( stream : access Root_Stream_Type'Class; obj : out Keen ); 
  143.     for Keen'Read use Object_Read; 
  144.  
  145.     procedure Object_Write( stream : access Root_Stream_Type'Class; obj : Keen ); 
  146.     for Keen'Write use Object_Write; 
  147.  
  148.     procedure On_Hit_Wall( this         : access Keen; 
  149.                            dir          : Cardinal_Direction; 
  150.                            firstContact : Boolean ); 
  151.  
  152.     procedure Reset_Idle( this : not null access Keen'Class ); 
  153.  
  154.     procedure Start_Action( this   : not null access Keen'Class; 
  155.                             action : Action_Type; 
  156.                             length : Time_Span := Time_Span_Zero ); 
  157.  
  158.     procedure Start_Jump( this : not null access Keen'Class ); 
  159.  
  160.     -- Stop jumping upward if Keen has reached the minimum jump height. If Keen 
  161.     -- collided with the ceiling, set 'collision' True. The jump will be stopped 
  162.     -- regardless of minimum jump height. 
  163.     procedure Stop_Jump( this      : not null access Keen'Class; 
  164.                          collision : Boolean := False ); 
  165.  
  166.     procedure Tick( this : access Keen; time : Tick_Time ); 
  167.  
  168.     procedure Update_Frame( this : access Keen; notify : Boolean := True ); 
  169.  
  170. end Entities.Players.Keen;