with Events.Corrals; use Events.Corrals;
with Events.Listeners; use Events.Listeners;
with Game_Views; use Game_Views;
with Objects; use Objects;
with Processes; use Processes;
private with Ada.Containers.Indefinite_Doubly_Linked_Lists;
private with Ada.Real_Time;
private with Associations;
private with Events;
private with Physics.Managers;
private with Processes.Managers;
private with Worlds;
package Games is
type Game is abstract new Object and Event_Listener and Process with private;
type A_Game is access all Game'Class;
function Create_Game return A_Game;
pragma Postcondition( Create_Game'Result /= null );
procedure Add_View( this : access Game; view : in out A_Game_View );
pragma Precondition( view /= null );
pragma Postcondition( view = null );
function Get_Corral( this : access Game ) return A_Corral;
pragma Postcondition( Get_Corral'Result /= null );
procedure Load_World( this : access Game; name : String );
pragma Postcondition( name'Length > 0 );
procedure New_Game( this : access Game ) is abstract;
procedure Start( this : access Game );
procedure Stop( this : access Game );
procedure Delete( this : in out A_Game );
pragma Postcondition( this = null );
private
use Ada.Real_Time;
use Associations;
use Events;
use Physics.Managers;
use Processes.Managers;
use Worlds;
package View_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists( A_Game_View, "=" );
type Game is abstract new Object and Event_Listener and Process with
record
views : View_Lists.List;
corral : A_Corral := null;
physics : A_Physics := null;
pman : A_Process_Manager := null;
sessionVars : A_Association := null;
world : A_World := null;
paused : Boolean := False;
end record;
procedure Adjust( this : access Game );
procedure Construct( this : access Game );
procedure Delete( this : in out Game );
procedure Game_Var_Add( this : access Game; var : String; val : Integer );
pragma Precondition( var'Length > 0 );
function Get_Process_Name( this : access Game ) return String;
pragma Postcondition( Get_Process_Name'Result'Length > 0 );
procedure Handle_Event( this : access Game;
evt : in out A_Event;
resp : out Response_Type );
pragma Precondition( evt /= null );
procedure Pause( this : access Game; enabled : Boolean );
procedure Set_Game_Var( this : access Game; var : String; val : Integer );
pragma Precondition( var'Length > 0 );
procedure Set_Game_Var( this : access Game; var : String; val : Boolean );
pragma Precondition( var'Length > 0 );
procedure Set_World( this : not null access Game'Class; world : A_World );
procedure Tick( this : access Game; upTime, dt : Time_Span );
type Allocator is access function return A_Game;
procedure Register_Allocator( allocate : not null Allocator );
end Games;