1. -- 
  2. -- Copyright (c) 2012 Kevin Wellwood 
  3. -- All rights reserved. 
  4. -- 
  5. -- This source code is distributed under the Modified BSD License. For terms and 
  6. -- conditions, see license.txt. 
  7. -- 
  8.  
  9. package Entities.Players.Little_Keen is 
  10.  
  11.     type Little_Keen is new Player with private; 
  12.     type A_Little_Keen is access all Little_Keen'Class; 
  13.  
  14. private 
  15.  
  16.     -- each Action_Type value represents a different state of Keen, in which 
  17.     -- he's performing the action. 
  18.     type Action_Type is 
  19.     ( 
  20.         Act_Moving,     -- standing still or moving around 
  21.         Act_Bored       -- bored animation due to idleness 
  22.     ); 
  23.  
  24.     type State is abstract tagged limited 
  25.         record 
  26.             action : Action_Type;     -- constant after initialization 
  27.         end record; 
  28.     type A_State is access all State'Class; 
  29.  
  30.     function Get_Frame( this : State; 
  31.                         k    : Little_Keen'Class ) return Natural is abstract; 
  32.  
  33.     procedure Update( this : State; 
  34.                       k    : A_Little_Keen ) is abstract; 
  35.  
  36.     ---------------------------------------------------------------------------- 
  37.  
  38.     type Little_Keen is new Player with 
  39.         record 
  40.             state         : A_State := null;          -- streamed as Action_Type 
  41.             stateStart    : Time_Span := Time_Span_Zero;  -- (relative to .age) 
  42.             stateDuration : Time_Span := Time_Span_Zero;  -- minimum duration 
  43.             idleStart     : Time_Span := Time_Span_Zero;  -- (relative to .age) 
  44.             swimming      : Boolean := False; 
  45.  
  46.             -- ** these fields do not need to be streamed ** 
  47.  
  48.             walkSpeed, 
  49.             walkAcceleration : Float := 0.0; 
  50.         end record; 
  51.  
  52.     procedure Construct( this : access Little_Keen ); 
  53.  
  54.     procedure Change_State( this  : not null access Little_Keen'Class; 
  55.                             state : not null A_State; 
  56.                             length : Time_Span := Time_Span_Zero ); 
  57.  
  58.     procedure Die( this : access Little_Keen ); 
  59.  
  60.     function Is_Busy( this : not null access Little_Keen'Class ) return Boolean; 
  61.  
  62.     function Object_Input( stream : access Root_Stream_Type'Class ) return Little_Keen; 
  63.     for Little_Keen'Input use Object_Input; 
  64.  
  65.     procedure Object_Read( stream : access Root_Stream_Type'Class; obj : out Little_Keen ); 
  66.     for Little_Keen'Read use Object_Read; 
  67.  
  68.     procedure Object_Write( stream : access Root_Stream_Type'Class; obj : Little_Keen ); 
  69.     for Little_Keen'Write use Object_Write; 
  70.  
  71.     procedure Reset_Idle( this : not null access Little_Keen'Class ); 
  72.  
  73.     procedure Update( this : access Little_Keen; time : Tick_Time ); 
  74.  
  75.     procedure Update_Frame( this : access Little_Keen; notify : Boolean := True ); 
  76.  
  77. end Entities.Players.Little_Keen;