1. with Events; 
  2. with Values;                            use Values; 
  3.  
  4. pragma Elaborate_All( Events ); 
  5.  
  6. package Events.Game is 
  7.  
  8.     END_GAME_ID : constant Event_Id := To_Event_Id( "End_Game" ); 
  9.  
  10.     -- A command to end the game session. 
  11.     type End_Game_Event is new Event with private; 
  12.     type A_End_Game_Event is access all End_Game_Event'Class; 
  13.  
  14.     ---------------------------------------------------------------------------- 
  15.  
  16.     GAME_PAUSED_ID : constant Event_Id := To_Event_Id( "Game_Paused" ); 
  17.  
  18.     -- A notification that the game paused state has changed. 
  19.     type Game_Paused_Event is new Event with private; 
  20.     type A_Game_Paused_Event is access all Game_Paused_Event'Class; 
  21.  
  22.     -- Returns True if the gameplay has been paused or False if it has been resumed. 
  23.     function Is_Paused( this : not null access Game_Paused_Event'Class ) return Boolean; 
  24.  
  25.     ---------------------------------------------------------------------------- 
  26.  
  27.     GAME_STATE_ID : constant Event_Id := To_Event_Id( "Game_State" ); 
  28.  
  29.     -- A notification that the gameplay state has changed. This happens when a 
  30.     -- game session begins and ends. 
  31.     type Game_State_Event is new Event with private; 
  32.     type A_Game_State_Event is access all Game_State_Event'Class; 
  33.  
  34.     -- Returns True if gameplay is in progress. 
  35.     function Is_Playing( this : not null access Game_State_Event'Class ) return Boolean; 
  36.  
  37.     ---------------------------------------------------------------------------- 
  38.  
  39.     GAME_VAR_CHANGED_ID : constant Event_Id := To_Event_Id( "Game_Var_Changed" ); 
  40.  
  41.     -- A notification that a game session variable has changed. 
  42.     type Game_Var_Changed_Event is new Event with private; 
  43.     type A_Game_Var_Changed_Event is access all Game_Var_Changed_Event'Class; 
  44.  
  45.     -- Returns the name of the variable that changed. 
  46.     function Get_Var( this : not null access Game_Var_Changed_Event'Class ) return String; 
  47.  
  48.     -- Returns a copy of the variable's new value. The value can be of any type. 
  49.     procedure Copy_Value( this : access Game_Var_Changed_Event; 
  50.                           val  : in out A_Value ); 
  51.     pragma Precondition( val = null ); 
  52.  
  53.     ---------------------------------------------------------------------------- 
  54.  
  55.     LOADING_ID : constant Event_Id := To_Event_Id( "Loading" ); 
  56.  
  57.     -- A notification that the game loading state has changed. This happens when 
  58.     -- the game logic begins and finishes loading resources. 
  59.     type Loading_Event is new Event with private; 
  60.     type A_Loading_Event is access all Loading_Event'Class; 
  61.  
  62.     -- Returns True if loading is in progress or False if it has completed. 
  63.     function Is_Loading( this : not null access Loading_Event'Class ) return Boolean; 
  64.  
  65.     ---------------------------------------------------------------------------- 
  66.  
  67.     NEW_GAME_ID : constant Event_Id := To_Event_Id( "New_Game" ); 
  68.  
  69.     -- A command to begin a new game session. 
  70.     type New_Game_Event is new Event with private; 
  71.     type A_New_Game_Event is access all New_Game_Event'Class; 
  72.  
  73.     ---------------------------------------------------------------------------- 
  74.  
  75.     PAUSE_GAME_ID : constant Event_Id := To_Event_Id( "Pause_Game" ); 
  76.  
  77.     -- A command to change the game paused state. 
  78.     type Pause_Game_Event is new Event with private; 
  79.     type A_Pause_Game_Event is access all Pause_Game_Event'Class; 
  80.  
  81.     -- Returns True if the command is to pause the gameplay, or False if the 
  82.     -- command is to resume gameplay. 
  83.     function Is_Paused( this : not null access Pause_Game_Event'Class ) return Boolean; 
  84.  
  85.     ---------------------------------------------------------------------------- 
  86.  
  87.     PLAYER_DIED_ID : constant Event_Id := To_Event_Id( "Player_Died" ); 
  88.  
  89.     -- A notification that the player died. 
  90.     type Player_Died_Event is new Event with private; 
  91.     type A_Player_Died_Event is access all Player_Died_Event'Class; 
  92.  
  93.     ---------------------------------------------------------------------------- 
  94.  
  95.     SCROLL_VIEW_ID : constant Event_Id := To_Event_Id( "Scroll_View" ); 
  96.  
  97.     -- A command to scroll the gaame view's viewport of the world. 
  98.     type Scroll_View_Event is new Event with private; 
  99.     type A_Scroll_View_Event is access all Scroll_View_Event'Class; 
  100.  
  101.     -- Amount to scroll view in the X axis in world coordinates. 
  102.     function Get_X( this : not null access Scroll_View_Event'Class ) return Float; 
  103.  
  104.     -- Amount to scroll view in the Y axis in world coordinates. 
  105.     function Get_Y( this : not null access Scroll_View_Event'Class ) return Float; 
  106.  
  107.     ---------------------------------------------------------------------------- 
  108.  
  109.     VIEW_READY_ID : constant Event_Id := To_Event_Id( "View_Ready" ); 
  110.  
  111.     -- A notification that the gameplay readiness state of the view has changed. 
  112.     -- When a new world is loaded, the view also loads the required content 
  113.     -- referenced in the World_Loaded event and sends a View_Ready event when it 
  114.     -- is finished loading and finished display the level loading dialog and is 
  115.     -- ready for gameplay to begin. 
  116.     type View_Ready_Event is new Event with private; 
  117.     type A_View_Ready_Event is access all View_Ready_Event'Class; 
  118.  
  119.     -- Returns True if the view is ready for gameplay. 
  120.     function Is_Ready( this : not null access View_Ready_Event'Class ) return Boolean; 
  121.  
  122.     ---------------------------------------------------------------------------- 
  123.  
  124.     -- Queues an End_Game_Event. 
  125.     procedure Queue_End_Game; 
  126.  
  127.     -- Queues a Game_Paused_Event. 
  128.     procedure Queue_Game_Paused( paused : Boolean ); 
  129.  
  130.     -- Queues a Game_State_Event. 
  131.     procedure Queue_Game_State( playing : Boolean ); 
  132.  
  133.     -- Queues a Game_Var_Changed_Event. 
  134.     procedure Queue_Game_Var_Changed( var : String; 
  135.                                       val : in out A_Value ); 
  136.     pragma Precondition( var'Length > 0 ); 
  137.     pragma Postcondition( val = null ); 
  138.  
  139.     -- Queues a Loading_Event. 
  140.     procedure Queue_Loading( loading : Boolean ); 
  141.  
  142.     -- Queues a New_Game_Event. 
  143.     procedure Queue_New_Game; 
  144.  
  145.     -- Queues a Pause_Game_Event. 
  146.     procedure Queue_Pause_Game( paused : Boolean ); 
  147.  
  148.     -- Queues a Player_Died_Event. 
  149.     procedure Queue_Player_Died; 
  150.  
  151.     -- Queues a Scroll_View_Event. 
  152.     procedure Queue_Scroll_View( x, y : Float ); 
  153.  
  154.     -- Queues a View_Ready_Event. 
  155.     procedure Queue_View_Ready( ready : Boolean ); 
  156.  
  157. private 
  158.  
  159.     type End_Game_Event is new Event with null record; 
  160.  
  161.     ---------------------------------------------------------------------------- 
  162.  
  163.     type Game_Paused_Event is new Event with 
  164.         record 
  165.             paused : Boolean := True; 
  166.         end record; 
  167.  
  168.     procedure Construct( this : access Game_Paused_Event; paused : Boolean ); 
  169.  
  170.     function To_String( this : access Game_Paused_Event ) return String; 
  171.  
  172.     ---------------------------------------------------------------------------- 
  173.  
  174.     type Game_State_Event is new Event with 
  175.         record 
  176.             playing : Boolean := True; 
  177.         end record; 
  178.  
  179.     procedure Construct( this : access Game_State_Event; playing : Boolean ); 
  180.  
  181.     function To_String( this : access Game_State_Event ) return String; 
  182.  
  183.     ---------------------------------------------------------------------------- 
  184.  
  185.     type Game_Var_Changed_Event is new Event with 
  186.         record 
  187.             var : Unbounded_String; 
  188.             val : A_Value := null; 
  189.         end record; 
  190.  
  191.     procedure Adjust( this : access Game_Var_Changed_Event ); 
  192.  
  193.     procedure Construct( this : access Game_Var_Changed_Event; 
  194.                          var  : String; 
  195.                          val  : in out A_Value ); 
  196.     pragma Precondition( var'Length > 0 ); 
  197.     pragma Postcondition( val = null ); 
  198.  
  199.     procedure Delete( this : in out Game_Var_Changed_Event ); 
  200.  
  201.     function To_String( this : access Game_Var_Changed_Event ) return String; 
  202.  
  203.     ---------------------------------------------------------------------------- 
  204.  
  205.     type Loading_Event is new Event with 
  206.         record 
  207.             loading : Boolean; 
  208.         end record; 
  209.  
  210.     procedure Construct( this : access Loading_Event; loading : Boolean ); 
  211.  
  212.     function To_String( this : access Loading_Event ) return String; 
  213.  
  214.     ---------------------------------------------------------------------------- 
  215.  
  216.     type New_Game_Event is new Event with null record; 
  217.  
  218.     ---------------------------------------------------------------------------- 
  219.  
  220.     type Pause_Game_Event is new Event with 
  221.         record 
  222.             paused : Boolean := True; 
  223.         end record; 
  224.  
  225.     procedure Construct( this : access Pause_Game_Event; paused : Boolean ); 
  226.  
  227.     ---------------------------------------------------------------------------- 
  228.  
  229.     type Player_Died_Event is new Event with null record; 
  230.  
  231.     ---------------------------------------------------------------------------- 
  232.  
  233.     type Scroll_View_Event is new Event with 
  234.         record 
  235.             x, y : Float := 0.0; 
  236.         end record; 
  237.  
  238.     procedure Construct( this : access Scroll_View_Event; x, y : Float ); 
  239.  
  240.     ---------------------------------------------------------------------------- 
  241.  
  242.     type View_Ready_Event is new Event with 
  243.         record 
  244.             ready : Boolean := True; 
  245.         end record; 
  246.  
  247.     procedure Construct( this : access View_Ready_Event; ready : Boolean ); 
  248.  
  249. end Events.Game;