1. with Events.Corrals;                    use Events.Corrals; 
  2. with Events.Listeners;                  use Events.Listeners; 
  3. with Objects;                           use Objects; 
  4. with Processes;                         use Processes; 
  5.  
  6. private with Ada.Containers.Doubly_Linked_Lists; 
  7. private with Ada.Containers.Ordered_Maps; 
  8. private with Ada.Real_Time; 
  9. private with Entities; 
  10. private with Events; 
  11. private with Events.Entities; 
  12. private with Events.World; 
  13. private with Physics.Bodies; 
  14. private with Physics.Clip_Maps; 
  15.  
  16. package Physics.Managers is 
  17.  
  18.     type Physics_Manager is new Object and Process and Event_Listener with private; 
  19.     type A_Physics is access all Physics_Manager'Class; 
  20.  
  21.     -- Creates a new physics manager attached to the given Corral. 
  22.     function Create_Physics( corral : not null A_Corral ) return A_Physics; 
  23.     pragma Postcondition( Create_Physics'Result /= null ); 
  24.  
  25.     -- Sets the friction in the X axis for entities handled by this physics 
  26.     -- manager. 
  27.     function Friction_X( this : not null access Physics_Manager'Class ) return Float; 
  28.  
  29.     -- Sets the friction in the Y axis for entities handled by this physics 
  30.     -- manager. 
  31.     function Friction_Y( this : not null access Physics_Manager'Class ) return Float; 
  32.  
  33.     -- Sets the gravitional acceleration for entities handled by this physics 
  34.     -- manager. 
  35.     function Gravity( this : not null access Physics_Manager'Class ) return Float; 
  36.  
  37.     -- Sets the maximum velocity in the X axis for entities handled by this 
  38.     -- physics manager. 
  39.     function Max_VX( this : not null access Physics_Manager'Class ) return Float; 
  40.  
  41.     -- Sets the maximum velocity in the Y axis for entities handled by this 
  42.     -- physics manager. 
  43.     function Max_VY( this : not null access Physics_Manager'Class ) return Float; 
  44.  
  45.     -- Deletes the physics manager and all its data (clip map, corps, etc.) 
  46.     procedure Delete( this : in out A_Physics ); 
  47.     pragma Postcondition( this = null ); 
  48.  
  49. private 
  50.  
  51.     use Ada.Real_Time; 
  52.     use Entities; 
  53.     use Events; 
  54.     use Events.Entities; 
  55.     use Events.World; 
  56.     use Physics.Bodies; 
  57.     use Physics.Clip_Maps; 
  58.  
  59.     package Corpus_Map is new 
  60.         Ada.Containers.Ordered_Maps( Entity_Id, A_Corpus, "<", "=" ); 
  61.  
  62.     package Corpus_Lists is new 
  63.         Ada.Containers.Doubly_Linked_Lists( A_Corpus, "=" ); 
  64.  
  65.     ---------------------------------------------------------------------------- 
  66.  
  67.     type Physics_Manager is new Object and Process and Event_Listener with 
  68.         record 
  69.             corral : A_Corral := null; 
  70.             map    : A_Clip_Map := null; 
  71.             corps  : Corpus_Map.Map; 
  72.             grav   : Float := 0.0; 
  73.             fricX, 
  74.             fricY  : Float := 0.0; 
  75.             maxVX, 
  76.             maxVY  : Float := 0.0; 
  77.         end record; 
  78.  
  79.     procedure Clear_Corps( this : not null access Physics_Manager'Class ); 
  80.  
  81.     procedure Construct( this   : access Physics_Manager; 
  82.                          corral : not null A_Corral ); 
  83.  
  84.     procedure Delete( this : in out Physics_Manager ); 
  85.  
  86.     function Find( this : not null access Physics_Manager'Class; 
  87.                    id   : Entity_Id ) return A_Corpus; 
  88.  
  89.     function Get_Process_Name( this : access Physics_Manager ) return String; 
  90.     pragma Postcondition( Get_Process_Name'Result'Length > 0 ); 
  91.  
  92.     procedure Handle( this : not null access Physics_Manager'Class; 
  93.                       evt  : not null A_Accelerate_Event ); 
  94.  
  95.     procedure Handle( this : not null access Physics_Manager'Class; 
  96.                       evt  : not null A_Entity_Created_Event ); 
  97.  
  98.     procedure Handle( this : not null access Physics_Manager'Class; 
  99.                       evt  : not null A_Entity_Deleted_Event ); 
  100.  
  101.     procedure Handle( this : not null access Physics_Manager'Class; 
  102.                       evt  : not null A_Move_Entity_Event ); 
  103.  
  104.     procedure Handle( this : not null access Physics_Manager'Class; 
  105.                       evt  : not null A_New_World_Event ); 
  106.  
  107.     procedure Handle( this : not null access Physics_Manager'Class; 
  108.                       evt  : not null A_Resize_Entity_Event ); 
  109.  
  110.     procedure Handle( this : not null access Physics_Manager'Class; 
  111.                       evt  : not null A_Set_Entity_Attribute_Event ); 
  112.  
  113.     procedure Handle( this : not null access Physics_Manager'Class; 
  114.                       evt  : not null A_Tile_Changed_Event ); 
  115.  
  116.     procedure Handle( this : not null access Physics_Manager'Class; 
  117.                       evt  : not null A_World_Property_Changed_Event ); 
  118.  
  119.     procedure Handle_Event( this : access Physics_Manager; 
  120.                             evt  : in out A_Event; 
  121.                             resp : out Response_Type ); 
  122.     pragma Precondition( evt /= null ); 
  123.  
  124.     procedure Tick( this : access Physics_Manager; upTime, dt : Time_Span ); 
  125.  
  126. end Physics.Managers;