1. with Associations;                      use Associations; 
  2. with Directions;                        use Directions; 
  3. with Events; 
  4. with Entities;                          use Entities; 
  5. with Hashed_Strings;                    use Hashed_Strings; 
  6. with Values;                            use Values; 
  7.  
  8. pragma Elaborate_All( Events ); 
  9.  
  10. package Events.Entities is 
  11.  
  12.     -- An abstract event involving an entity. 
  13.     type Entity_Event is abstract new Event with private; 
  14.  
  15.     -- Returns the Entity_Id of the entity involved in the event. 
  16.     function Get_Id( this : not null access Entity_Event'Class ) return Entity_Id; 
  17.  
  18.     ---------------------------------------------------------------------------- 
  19.  
  20.     -- An abstract event involving the interaction of two entities. 
  21.     type Entities_Event is abstract new Event with private; 
  22.  
  23.     -- Returns the Entity_Id of the first entity involved in the interaction, 
  24.     -- deemed entity A. 
  25.     function Get_A( this : not null access Entities_Event'Class ) return Entity_Id; 
  26.  
  27.     -- Returns the Entity_Id of the second entity involved in the interaction, 
  28.     -- deemed entity B. 
  29.     function Get_B( this : not null access Entities_Event'Class ) return Entity_Id; 
  30.  
  31.     ---------------------------------------------------------------------------- 
  32.  
  33.     ACCELERATE_ID : constant Event_Id := To_Event_Id( "Accelerate" ); 
  34.  
  35.     -- 
  36.     type Accelerate_Event is new Entity_Event with private; 
  37.     type A_Accelerate_Event is access all Accelerate_Event'Class; 
  38.  
  39.     function Get_Acceleration( this : not null access Accelerate_Event'Class ) return Float; 
  40.     pragma Postcondition( Get_Acceleration'Result >= 0.0 ); 
  41.  
  42.     function Get_Direction( this : not null access Accelerate_Event'Class ) return Cardinal_Direction; 
  43.  
  44.     function Get_Velocity( this : not null access Accelerate_Event'Class ) return Float; 
  45.     pragma Postcondition( Get_Velocity'Result >= 0.0 ); 
  46.  
  47.     ---------------------------------------------------------------------------- 
  48.  
  49.     DELETE_ENTITY_ID : constant Event_Id := To_Event_Id( "Delete_Entity" ); 
  50.  
  51.     -- A command to delete an entity by Entity_Id. 
  52.     type Delete_Entity_Event is new Entity_Event with private; 
  53.     type A_Delete_Entity_Event is access all Delete_Entity_Event'Class; 
  54.  
  55.     ---------------------------------------------------------------------------- 
  56.  
  57.     ENTITIES_COLLIDED_ID: constant Event_Id := To_Event_Id( "Entities_Collided" ); 
  58.  
  59.     -- A notification that two entities collided (began touching). 
  60.     type Entities_Collided_Event is new Entities_Event with private; 
  61.     type A_Entities_Collided_Event is access all Entities_Collided_Event'Class; 
  62.  
  63.     ---------------------------------------------------------------------------- 
  64.  
  65.     ENTITIES_SEPARATED_ID: constant Event_Id := To_Event_Id( "Entities_Separated" ); 
  66.  
  67.     -- A notification that two entities separated (are no longer touching). 
  68.     type Entities_Separated_Event is new Entities_Event with private; 
  69.     type A_Entities_Separated_Event is access all Entities_Separated_Event'Class; 
  70.  
  71.     ---------------------------------------------------------------------------- 
  72.  
  73.     -- An abstract event involving an entity attribute. 
  74.     type Entity_Attribute_Event is new Entity_Event with private; 
  75.  
  76.     -- Returns a copy of the attribute value. The caller is responsible for 
  77.     -- deleting the object. 
  78.     procedure Copy_Value( this : access Entity_Attribute_Event; 
  79.                           val  : in out A_Value ); 
  80.     pragma Precondition( val = null ); 
  81.  
  82.     -- Returns the attribute name. 
  83.     function Get_Attribute( this : access Entity_Attribute_Event ) return String; 
  84.     pragma Postcondition( Get_Attribute'Result'Length > 0 ); 
  85.  
  86.     ---------------------------------------------------------------------------- 
  87.  
  88.     ENTITY_ATTRIBUTE_CHANGED_ID : constant Event_Id := To_Event_Id( "Entity_Attribute_Changed" ); 
  89.  
  90.     -- A notification that an entity attribute has changed. 
  91.     type Entity_Attribute_Changed_Event is new Entity_Attribute_Event with private; 
  92.     type A_Entity_Attribute_Changed_Event is access all Entity_Attribute_Changed_Event; 
  93.  
  94.     ---------------------------------------------------------------------------- 
  95.  
  96.     ENTITY_CREATED_ID : constant Event_Id := To_Event_Id( "Entity_Created" ); 
  97.  
  98.     -- A notification that a new entity has been created. 
  99.     type Entity_Created_Event is new Entity_Event with private; 
  100.     type A_Entity_Created_Event is access all Entity_Created_Event'Class; 
  101.  
  102.     -- Returns a copy of the entity's attributes as an association. 
  103.     procedure Copy_Attributes( this       : not null access Entity_Created_Event'Class; 
  104.                                attributes : in out A_Association ); 
  105.     pragma Precondition( attributes = null ); 
  106.     pragma Postcondition( attributes /= null ); 
  107.  
  108.     -- Returns the entity's class name. 
  109.     function Get_Class( this : not null access Entity_Created_Event'Class ) return String; 
  110.     pragma Postcondition( Get_Class'Result'Length > 0 ); 
  111.  
  112.     -- Returns the entity's current display frame or 0 for none. 
  113.     function Get_Frame( this : not null access Entity_Created_Event'Class ) return Natural; 
  114.  
  115.     -- Returns the physical height of the entity in world units. 
  116.     function Get_Height( this : not null access Entity_Created_Event'Class ) return Natural; 
  117.  
  118.     -- Returns the name of the library that contains the entity's frames. 
  119.     function Get_Lib_Name( this : not null access Entity_Created_Event'Class ) return String; 
  120.  
  121.     -- Returns the physical width of the entity in world units. 
  122.     function Get_Width( this : not null access Entity_Created_Event'Class ) return Natural; 
  123.  
  124.     -- Returns the X coordinate of the entity in world coordinates. 
  125.     function Get_X( this : not null access Entity_Created_Event'Class ) return Float; 
  126.  
  127.     -- Returns the X velocity of the entity in world units per second. 
  128.     function Get_XV( this : not null access Entity_Created_Event'Class ) return Float; 
  129.  
  130.     -- Returns the Y coordinate of the entity in world coordinates. 
  131.     function Get_Y( this : not null access Entity_Created_Event'Class ) return Float; 
  132.  
  133.     -- Returns the Y velocity of the entity in world units per second. 
  134.     function Get_YV( this : not null access Entity_Created_Event'Class ) return Float; 
  135.  
  136.     -- Returns True if the entity is clipped to the solid walls in the world. 
  137.     function Is_Clipped( this : not null access Entity_Created_Event'Class ) return Boolean; 
  138.  
  139.     -- Returns True if the entity is invisible, existing metaphysically like a 
  140.     -- Trigger. 
  141.     function Is_Metaphysical( this : not null access Entity_Created_Event'Class ) return Boolean; 
  142.  
  143.     -- Returns True if physics apply to the entity, ie: gravity. 
  144.     function Is_Physical( this : not null access Entity_Created_Event'Class ) return Boolean; 
  145.  
  146.     ---------------------------------------------------------------------------- 
  147.  
  148.     ENTITY_DELETED_ID : constant Event_Id := To_Event_Id( "Entity_Deleted" ); 
  149.  
  150.     -- A notification that an entity was deleted. 
  151.     type Entity_Deleted_Event is new Entity_Event with private; 
  152.     type A_Entity_Deleted_Event is access all Entity_Deleted_Event'Class; 
  153.  
  154.     ---------------------------------------------------------------------------- 
  155.  
  156.     -- An abstract event involving the interaction of an entity with a tile. 
  157.     type Entity_Tile_Event is abstract new Entity_Event with private; 
  158.  
  159.     -- Returns the X location in tile coordinates. 
  160.     function Get_X( this : not null access Entity_Tile_Event'Class ) return Natural; 
  161.  
  162.     -- Returns the Y location in tile coordinates. 
  163.     function Get_Y( this : not null access Entity_Tile_Event'Class ) return Natural; 
  164.  
  165.     ---------------------------------------------------------------------------- 
  166.  
  167.     ENTITY_ENTERED_TILE_ID : constant Event_Id := To_Event_Id( "Entity_Entered_Tile" ); 
  168.  
  169.     -- A notification that part of an entity's bounding rectangle entered a tile. 
  170.     type Entity_Entered_Tile_Event is new Entity_Tile_Event with private; 
  171.     type A_Entity_Entered_Tile_Event is access all Entity_Entered_Tile_Event'Class; 
  172.  
  173.     ---------------------------------------------------------------------------- 
  174.  
  175.     ENTITY_EXITED_TILE_ID : constant Event_Id := To_Event_Id( "Entity_Exited_Tile" ); 
  176.  
  177.     -- A notification that no part of an entity's bounding rectangle is now 
  178.     -- touching a tile. 
  179.     type Entity_Exited_Tile_Event is new Entity_Tile_Event with private; 
  180.     type A_Entity_Exited_Tile_Event is access all Entity_Exited_Tile_Event'Class; 
  181.  
  182.     ---------------------------------------------------------------------------- 
  183.  
  184.     ENTITY_FACE_ID : constant Event_Id := To_Event_Id( "Entity_Face" ); 
  185.  
  186.     -- A command to set the direction than an entity should face. 
  187.     type Entity_Face_Event is new Entity_Event with private; 
  188.     type A_Entity_Face_Event is access all Entity_Face_Event'Class; 
  189.  
  190.     -- Returns the direction for the entity to face. 
  191.     function Get_Direction( this : not null access Entity_Face_Event'Class ) return Direction_Type; 
  192.  
  193.     ---------------------------------------------------------------------------- 
  194.  
  195.     ENTITY_GROUNDED_ID : constant Event_Id := To_Event_Id( "Entity_Grounded" ); 
  196.  
  197.     -- A notification that an entity has landed on/left the ground. 
  198.     type Entity_Grounded_Event is new Entity_Event with private; 
  199.     type A_Entity_Grounded_Event is access all Entity_Grounded_Event'Class; 
  200.  
  201.     -- Returns True if the entity landed on the ground or False if the entity 
  202.     -- left the ground. 
  203.     function Is_Grounded( this : not null access Entity_Grounded_Event'Class ) return Boolean; 
  204.  
  205.     ---------------------------------------------------------------------------- 
  206.  
  207.     ENTITY_HIT_WALL_ID : constant Event_Id := To_Event_Id( "Entity_Hit_Wall" ); 
  208.  
  209.     -- A notification that a clipped entity collided with a wall and was stopped. 
  210.     type Entity_Hit_Wall_Event is new Entity_Event with private; 
  211.     type A_Entity_Hit_Wall_Event is access all Entity_Hit_Wall_Event'Class; 
  212.  
  213.     -- Returns the direction that the entity was travelling when it hit the wall. 
  214.     function Get_Direction( this : not null access Entity_Hit_Wall_Event'Class ) return Cardinal_Direction; 
  215.  
  216.     -- Returns True if this is the entity's first contact with the wall in that 
  217.     -- direction. If the entity hits the wall and continues accelerating into 
  218.     -- it, pressing against it, then this will return False until the entity 
  219.     -- moves away from the wall and hits it again. 
  220.     function Is_First_Contact( this : not null access Entity_Hit_Wall_Event'Class ) return Boolean; 
  221.  
  222.     ---------------------------------------------------------------------------- 
  223.  
  224.     ENTITY_MOVED_ID : constant Event_Id := To_Event_Id( "Entity_Moved" ); 
  225.  
  226.     -- A notification that an entity moved. 
  227.     type Entity_Moved_Event is new Entity_Event with private; 
  228.     type A_Entity_Moved_Event is access all Entity_Moved_Event'Class; 
  229.  
  230.     -- Returns the entity's new X coordinate in world units. 
  231.     function Get_X( this : not null access Entity_Moved_Event'Class ) return Float; 
  232.  
  233.     -- Returns the entity's X velocity in world units per second. 
  234.     function Get_XV( this : not null access Entity_Moved_Event'Class ) return Float; 
  235.  
  236.     -- Returns the entity's new Y coordinate in world units. 
  237.     function Get_Y( this : not null access Entity_Moved_Event'Class ) return Float; 
  238.  
  239.     -- Returns the entity's Y velocity in world units per second. 
  240.     function Get_YV( this : not null access Entity_Moved_Event'Class ) return Float; 
  241.  
  242.     ---------------------------------------------------------------------------- 
  243.  
  244.     ENTITY_RESIZED_ID : constant Event_Id := To_Event_Id( "Entity_Resized" ); 
  245.  
  246.     -- A notification that an entity's physical size changed. 
  247.     type Entity_Resized_Event is new Entity_Event with private; 
  248.     type A_Entity_Resized_Event is access all Entity_Resized_Event'Class; 
  249.  
  250.     -- Returns the entity's new height in world units. 
  251.     function Get_Height( this : not null access Entity_Resized_Event'Class ) return Natural; 
  252.  
  253.     -- Returns the entity's new width in world units. 
  254.     function Get_Width( this : not null access Entity_Resized_Event'Class ) return Natural; 
  255.  
  256.     ---------------------------------------------------------------------------- 
  257.  
  258.     FOLLOW_ENTITY_ID : constant Event_Id := To_Event_Id( "Follow_Entity" ); 
  259.  
  260.     -- A command to the game view follow an entity with the view's viewport. 
  261.     type Follow_Entity_Event is new Entity_Event with private; 
  262.     type A_Follow_Entity_Event is access all Follow_Entity_Event'Class; 
  263.  
  264.     ---------------------------------------------------------------------------- 
  265.  
  266.     FRAME_CHANGED_ID : constant Event_Id := To_Event_Id( "Frame_Changed" ); 
  267.  
  268.     -- A notification that an entity's display frame has changed. 
  269.     type Frame_Changed_Event is new Entity_Event with private; 
  270.     type A_Frame_Changed_Event is access all Frame_Changed_Event'Class; 
  271.  
  272.     -- Returns the id of the new display frame or 0 for none. 
  273.     function Get_Frame( this : not null access Frame_Changed_Event'Class ) return Natural; 
  274.  
  275.     ---------------------------------------------------------------------------- 
  276.  
  277.     IMPULSE_ID : constant Event_Id := To_Event_Id( "Impulse" ); 
  278.  
  279.     -- A command sent to an entity. The entity may choose to respond to the 
  280.     -- impulse depending on its current state and the impulse (command) given. 
  281.     type Impulse_Event is new Entity_Event with private; 
  282.     type A_Impulse_Event is access all Impulse_Event'Class; 
  283.  
  284.     -- Returns the name of the impulse being sent to the entity. 
  285.     function Get_Impulse_Name( this : not null access Impulse_Event'Class ) return Hashed_String; 
  286.  
  287.     ---------------------------------------------------------------------------- 
  288.  
  289.     MOVE_ENTITY_ID : constant Event_Id := To_Event_Id( "Move_Entity" ); 
  290.  
  291.     -- A command to move an entity. 
  292.     type Move_Entity_Event is new Entity_Event with private; 
  293.     type A_Move_Entity_Event is access all Move_Entity_Event'Class; 
  294.  
  295.     -- Returns the new X coordinate for the entity in world units. 
  296.     function Get_X( this : not null access Move_Entity_Event'Class ) return Float; 
  297.  
  298.     -- Returns the new Y coordinate for the entity in world units. 
  299.     function Get_Y( this : not null access Move_Entity_Event'Class ) return Float; 
  300.  
  301.     ---------------------------------------------------------------------------- 
  302.  
  303.     RESIZE_ENTITY_ID : constant Event_Id := To_Event_Id( "Resize_Entity" ); 
  304.  
  305.     -- A command to change the physical size of an entity. 
  306.     type Resize_Entity_Event is new Entity_Event with private; 
  307.     type A_Resize_Entity_Event is access all Resize_Entity_Event'Class; 
  308.  
  309.     -- Returns the new height for the entity in world units. 
  310.     function Get_Height( this : not null access Resize_Entity_Event'Class ) return Natural; 
  311.  
  312.     -- Returns the new width for the entity in world units. 
  313.     function Get_Width( this : not null access Resize_Entity_Event'Class ) return Natural; 
  314.  
  315.     ---------------------------------------------------------------------------- 
  316.  
  317.     SET_ENTITY_ATTRIBUTE_ID : constant Event_Id := To_Event_Id( "Set_Entity_Attribute" ); 
  318.  
  319.     -- A command to set an attribute of an entity. 
  320.     type Set_Entity_Attribute_Event is new Entity_Attribute_Event with private; 
  321.     type A_Set_Entity_Attribute_Event is access all Set_Entity_Attribute_Event; 
  322.  
  323.     ---------------------------------------------------------------------------- 
  324.  
  325.     SPAWN_ENTITY_ID : constant Event_Id := To_Event_Id( "Spawn_Entity" ); 
  326.  
  327.     -- A command to create a new entity. 
  328.     type Spawn_Entity_Event is new Event with private; 
  329.     type A_Spawn_Entity_Event is access all Spawn_Entity_Event; 
  330.  
  331.     -- Returns the physical height for the entity in world units. 
  332.     function Get_Height( this : access Spawn_Entity_Event ) return Integer; 
  333.  
  334.     -- Returns class id of the entity to create. 
  335.     function Get_Id( this : access Spawn_Entity_Event ) return String; 
  336.  
  337.     -- Returns the physical width for the entity in world units. 
  338.     function Get_Width( this : access Spawn_Entity_Event ) return Integer; 
  339.  
  340.     -- Returns the X coordinate for the entity in world units. 
  341.     function Get_X( this : access Spawn_Entity_Event ) return Float; 
  342.  
  343.     -- Returns the X velocity for the entity in world units per second. 
  344.     function Get_XV( this : access Spawn_Entity_Event ) return Float; 
  345.  
  346.     -- Returns the Y coordinate for the entity in world units. 
  347.     function Get_Y( this : access Spawn_Entity_Event ) return Float; 
  348.  
  349.     -- Returns the Y velocity for the entity in world units per second. 
  350.     function Get_YV( this : access Spawn_Entity_Event ) return Float; 
  351.  
  352.     ---------------------------------------------------------------------------- 
  353.  
  354.     -- Queues an Accelerate_Event. 
  355.     procedure Queue_Accelerate( id  : Entity_Id; 
  356.                                 dir : Cardinal_Direction; 
  357.                                 vel : Float; 
  358.                                 acc : Float ); 
  359.     pragma Precondition( vel >= 0.0 ); 
  360.     pragma Precondition( acc >= 0.0 ); 
  361.  
  362.     -- Queues a Delete_Entity_Event. 
  363.     procedure Queue_Delete_Entity( id : Entity_Id ); 
  364.  
  365.     -- Queues an Entities_Collided_Event. 
  366.     procedure Queue_Entities_Collided( a, b : Entity_Id ); 
  367.  
  368.     -- Queues an Entities_Separated_Event. 
  369.     procedure Queue_Entities_Separated( a, b : Entity_Id ); 
  370.  
  371.     -- Queues an Entity_Attribute_Changed_Event. 
  372.     procedure Queue_Entity_Attribute_Changed( id        : Entity_Id; 
  373.                                               attribute : String; 
  374.                                               val       : in out A_Value ); 
  375.     pragma Precondition( attribute'Length > 0 ); 
  376.     pragma Postcondition( val = null ); 
  377.  
  378.     -- Queues an Entity_Created_Event. Argument 'attributes' is copied and not 
  379.     -- modified. 
  380.     procedure Queue_Entity_Created( id           : Entity_Id; 
  381.                                     class        : String; 
  382.                                     physical, 
  383.                                     metaphysical, 
  384.                                     clipped      : Boolean; 
  385.                                     width, 
  386.                                     height       : Natural; 
  387.                                     x, y         : Float; 
  388.                                     xv, yv       : Float; 
  389.                                     libName      : String; 
  390.                                     frame        : Natural; 
  391.                                     attributes   : not null A_Association ); 
  392.     pragma Precondition( class'Length > 0 ); 
  393.  
  394.     -- Queues an Entity_Deleted_Event. 
  395.     procedure Queue_Entity_Deleted( id : Entity_Id ); 
  396.  
  397.     -- Queues an Entity_Entered_Tile_Event. 
  398.     procedure Queue_Entity_Entered_Tile( id : Entity_Id; x, y : Natural ); 
  399.  
  400.     -- Queues an Entity_Exited_Tile_Event. 
  401.     procedure Queue_Entity_Exited_Tile( id : Entity_Id; x, y : Natural ); 
  402.  
  403.     -- Queues an Entity_Face_Event. 
  404.     procedure Queue_Entity_Face( id : Entity_Id; dir : Direction_Type ); 
  405.  
  406.     -- Queues an Entity_Grounded_Event. 
  407.     procedure Queue_Entity_Grounded( id : Entity_Id; grounded : Boolean ); 
  408.  
  409.     -- Queues an Entity_Hit_Wall_Event. Set 'firstContact' True if the entity 
  410.     -- bumped into the wall, or False if the entity already made contact with 
  411.     -- the wall and is pressing itself against it. 
  412.     procedure Queue_Entity_Hit_Wall( id           : Entity_Id; 
  413.                                      dir          : Cardinal_Direction; 
  414.                                      firstContact : Boolean ); 
  415.  
  416.     -- Queues an Entity_Moved_Event. 
  417.     procedure Queue_Entity_Moved( id : Entity_Id; x, y, xv, yv : Float ); 
  418.  
  419.     -- Queues an Entity_Resized_Event. 
  420.     procedure Queue_Entity_Resized( id : Entity_Id; width, height : Natural ); 
  421.  
  422.     -- Queues an Impulse_Event. 
  423.     procedure Queue_Impulse( id : Entity_Id; name : Hashed_String ); 
  424.  
  425.     -- Queues a Follow_Entity_Event. 
  426.     procedure Queue_Follow_Entity( id : Entity_Id ); 
  427.  
  428.     -- Queues a Frame_Changed_Event. 
  429.     procedure Queue_Frame_Changed( id : Entity_Id; frame : Natural ); 
  430.  
  431.     -- Queues a Move_Entity_Event. 
  432.     procedure Queue_Move_Entity( id : Entity_Id; x, y : Float ); 
  433.  
  434.     -- Queues a Resize_Entity_Event. 
  435.     procedure Queue_Resize_Entity( id : Entity_Id; width, height : Natural ); 
  436.  
  437.     -- Queues a Set_Entity_Attribute_Event with a value of any type. 
  438.     procedure Queue_Set_Entity_Attribute( id        : Entity_Id; 
  439.                                           attribute : String; 
  440.                                           val       : in out A_Value ); 
  441.     pragma Precondition( attribute'Length > 0 ); 
  442.     pragma Postcondition( val = null ); 
  443.  
  444.     -- Queues a Set_Entity_Attribute_Event with a boolean value. 
  445.     procedure Queue_Set_Entity_Attribute( id        : Entity_Id; 
  446.                                           attribute : String; 
  447.                                           val       : Boolean ); 
  448.     pragma Precondition( attribute'Length > 0 ); 
  449.  
  450.     -- Queues a Spawn_Entity_Event. 
  451.     procedure Queue_Spawn_Entity( id     : String; 
  452.                                   x, y   : Float; 
  453.                                   width, 
  454.                                   height : Natural := 0; 
  455.                                   xv, yv : Float := 0.0 ); 
  456.     pragma Precondition( id'Length > 0 ); 
  457.  
  458. private 
  459.  
  460.     type Entity_Event is abstract new Event with 
  461.         record 
  462.             id : Entity_Id := INVALID_ID; 
  463.         end record; 
  464.  
  465.     procedure Construct( this : access Entity_Event; name : String; id : Entity_Id ); 
  466.     pragma Precondition( name'Length > 0 ); 
  467.  
  468.     function To_String( this : access Entity_Event ) return String; 
  469.  
  470.     ---------------------------------------------------------------------------- 
  471.  
  472.     type Entities_Event is abstract new Event with 
  473.         record 
  474.             a, b : Entity_Id := INVALID_ID; 
  475.         end record; 
  476.  
  477.     procedure Construct( this : access Entities_Event; name : String; a, b : Entity_Id ); 
  478.     pragma Precondition( name'Length > 0 ); 
  479.  
  480.     function To_String( this : access Entities_Event ) return String; 
  481.  
  482.     ---------------------------------------------------------------------------- 
  483.  
  484.     type Accelerate_Event is new Entity_Event with 
  485.         record 
  486.             dir : Cardinal_Direction := Left; 
  487.             vel : Float := 0.0; 
  488.             acc : Float := 0.0; 
  489.         end record; 
  490.  
  491.     procedure Construct( this : access Accelerate_Event; 
  492.                          id   : Entity_Id; 
  493.                          dir  : Cardinal_Direction; 
  494.                          vel  : Float; 
  495.                          acc  : Float ); 
  496.  
  497.     ---------------------------------------------------------------------------- 
  498.  
  499.     type Delete_Entity_Event is new Entity_Event with null record; 
  500.  
  501.     procedure Construct( this : access Delete_Entity_Event; id : Entity_Id ); 
  502.  
  503.     ---------------------------------------------------------------------------- 
  504.  
  505.     type Entities_Collided_Event is new Entities_Event with null record; 
  506.  
  507.     procedure Construct( this : access Entities_Collided_Event; a, b : Entity_Id ); 
  508.  
  509.     ---------------------------------------------------------------------------- 
  510.  
  511.     type Entities_Separated_Event is new Entities_Event with null record; 
  512.  
  513.     procedure Construct( this : access Entities_Separated_Event; a, b : Entity_Id ); 
  514.  
  515.     ---------------------------------------------------------------------------- 
  516.  
  517.     type Entity_Attribute_Event is new Entity_Event with 
  518.         record 
  519.             attribute : Unbounded_String; 
  520.             val       : A_Value := null; 
  521.         end record; 
  522.  
  523.     procedure Adjust( this : access Entity_Attribute_Event ); 
  524.  
  525.     -- 'name' is event name 
  526.     -- 'attribute' is the name of the attribute 
  527.     -- 'val' is the value of the attribute 
  528.     procedure Construct( this      : access Entity_Attribute_Event; 
  529.                          name      : String; 
  530.                          id        : Entity_Id; 
  531.                          attribute : String; 
  532.                          val       : in out A_Value ); 
  533.     pragma Precondition( name'Length > 0 ); 
  534.     pragma Precondition( attribute'Length > 0 ); 
  535.     pragma Postcondition( val = null ); 
  536.  
  537.     procedure Delete( this : in out Entity_Attribute_Event ); 
  538.  
  539.     ---------------------------------------------------------------------------- 
  540.  
  541.     type Entity_Attribute_Changed_Event is new Entity_Attribute_Event with null record; 
  542.  
  543.     procedure Construct( this      : access Entity_Attribute_Changed_Event; 
  544.                          id        : Entity_Id; 
  545.                          attribute : String; 
  546.                          val       : in out A_Value ); 
  547.     pragma Precondition( attribute'Length > 0 ); 
  548.     pragma Postcondition( val = null ); 
  549.  
  550.     ---------------------------------------------------------------------------- 
  551.  
  552.     type Entity_Created_Event is new Entity_Event with 
  553.         record 
  554.             class        : Unbounded_String; 
  555.             physical     : Boolean := True; 
  556.             metaphysical : Boolean := False; 
  557.             clipped      : Boolean := True; 
  558.             width, 
  559.             height       : Natural := 0; 
  560.             x, y         : Float := 0.0; 
  561.             xv, yv       : Float := 0.0; 
  562.             libName      : Unbounded_String; 
  563.             frame        : Natural := 0; 
  564.             attributes   : A_Association := null; 
  565.         end record; 
  566.  
  567.     procedure Adjust( this : access Entity_Created_Event ); 
  568.  
  569.     procedure Construct( this         : access Entity_Created_Event; 
  570.                          id           : Entity_Id; 
  571.                          class        : String; 
  572.                          physical, 
  573.                          metaphysical, 
  574.                          clipped      : Boolean; 
  575.                          width, 
  576.                          height       : Natural; 
  577.                          x, y         : Float; 
  578.                          xv, yv       : Float; 
  579.                          libName      : String; 
  580.                          frame        : Natural; 
  581.                          attributes   : not null A_Association ); 
  582.  
  583.     procedure Delete( this : in out Entity_Created_Event ); 
  584.  
  585.     function To_String( this : access Entity_Created_Event ) return String; 
  586.  
  587.     ---------------------------------------------------------------------------- 
  588.  
  589.     type Entity_Deleted_Event is new Entity_Event with null record; 
  590.  
  591.     procedure Construct( this : access Entity_Deleted_Event; id : Entity_Id ); 
  592.  
  593.     ---------------------------------------------------------------------------- 
  594.  
  595.     type Entity_Tile_Event is new Entity_Event with 
  596.         record 
  597.             x, y : Natural; 
  598.         end record; 
  599.  
  600.     procedure Construct( this : access Entity_Tile_Event; 
  601.                          name : String; 
  602.                          id   : Entity_Id; 
  603.                          x, y : Natural ); 
  604.  
  605.     ---------------------------------------------------------------------------- 
  606.  
  607.     type Entity_Entered_Tile_Event is new Entity_Tile_Event with null record; 
  608.  
  609.     procedure Construct( this : access Entity_Entered_Tile_Event; 
  610.                          id   : Entity_Id; 
  611.                          x, y : Natural ); 
  612.  
  613.     ---------------------------------------------------------------------------- 
  614.  
  615.     type Entity_Exited_Tile_Event is new Entity_Tile_Event with null record; 
  616.  
  617.     procedure Construct( this : access Entity_Exited_Tile_Event; 
  618.                          id   : Entity_Id; 
  619.                          x, y : Natural ); 
  620.  
  621.     ---------------------------------------------------------------------------- 
  622.  
  623.     type Entity_Face_Event is new Entity_Event with 
  624.         record 
  625.             dir : Direction_Type := Dir_Left; 
  626.         end record; 
  627.  
  628.     procedure Construct( this : access Entity_Face_Event; 
  629.                          id   : Entity_Id; 
  630.                          dir  : Direction_Type ); 
  631.  
  632.     ---------------------------------------------------------------------------- 
  633.  
  634.     type Entity_Grounded_Event is new Entity_Event with 
  635.         record 
  636.             grounded : Boolean := False; 
  637.         end record; 
  638.  
  639.     procedure Construct( this     : access Entity_Grounded_Event; 
  640.                          id       : Entity_Id; 
  641.                          grounded : Boolean ); 
  642.  
  643.     ---------------------------------------------------------------------------- 
  644.  
  645.     type Entity_Hit_Wall_Event is new Entity_Event with 
  646.         record 
  647.             dir          : Cardinal_Direction; 
  648.             firstContact : Boolean; 
  649.         end record; 
  650.  
  651.     procedure Construct( this         : access Entity_Hit_Wall_Event; 
  652.                          id           : Entity_Id; 
  653.                          dir          : Cardinal_Direction; 
  654.                          firstContact : Boolean ); 
  655.  
  656.     ---------------------------------------------------------------------------- 
  657.  
  658.     type Entity_Moved_Event is new Entity_Event with 
  659.         record 
  660.             x, y   : Float := 0.0; 
  661.             xv, yv : Float := 0.0; 
  662.         end record; 
  663.  
  664.     procedure Construct( this   : access Entity_Moved_Event; 
  665.                          id     : Entity_Id; 
  666.                          x, y   : Float; 
  667.                          xv, yv : Float ); 
  668.  
  669.     ---------------------------------------------------------------------------- 
  670.  
  671.     type Entity_Resized_Event is new Entity_Event with 
  672.         record 
  673.             width, height : Natural := 0; 
  674.         end record; 
  675.  
  676.     procedure Construct( this   : access Entity_Resized_Event; 
  677.                          id     : Entity_Id; 
  678.                          width, 
  679.                          height : Natural ); 
  680.  
  681.     ---------------------------------------------------------------------------- 
  682.  
  683.     type Follow_Entity_Event is new Entity_Event with null record; 
  684.  
  685.     procedure Construct( this : access Follow_Entity_Event; id : Entity_Id ); 
  686.  
  687.     ---------------------------------------------------------------------------- 
  688.  
  689.     type Frame_Changed_Event is new Entity_Event with 
  690.         record 
  691.             frame : Natural; 
  692.         end record; 
  693.  
  694.     procedure Construct( this  : access Frame_Changed_Event; 
  695.                          id    : Entity_Id; 
  696.                          frame : Natural ); 
  697.  
  698.     ---------------------------------------------------------------------------- 
  699.  
  700.     type Impulse_Event is new Entity_Event with 
  701.         record 
  702.             name : Hashed_String; 
  703.         end record; 
  704.  
  705.     procedure Construct( this : access Impulse_Event; 
  706.                          id   : Entity_Id; 
  707.                          name : Hashed_String ); 
  708.  
  709.     function To_String( this : access Impulse_Event ) return String; 
  710.  
  711.     ---------------------------------------------------------------------------- 
  712.  
  713.     type Move_Entity_Event is new Entity_Event with 
  714.         record 
  715.             x, y : Float := 0.0; 
  716.         end record; 
  717.  
  718.     procedure Construct( this : access Move_Entity_Event; 
  719.                          id   : Entity_Id; 
  720.                          x, y : Float ); 
  721.  
  722.     ---------------------------------------------------------------------------- 
  723.  
  724.     type Resize_Entity_Event is new Entity_Event with 
  725.         record 
  726.             width, height : Natural := 0; 
  727.         end record; 
  728.  
  729.     procedure Construct( this   : access Resize_Entity_Event; 
  730.                          id     : Entity_Id; 
  731.                          width, 
  732.                          height : Natural ); 
  733.  
  734.     ---------------------------------------------------------------------------- 
  735.  
  736.     type Set_Entity_Attribute_Event is new Entity_Attribute_Event with null record; 
  737.  
  738.     procedure Construct( this      : access Set_Entity_Attribute_Event; 
  739.                          id        : Entity_Id; 
  740.                          attribute : String; 
  741.                          val       : in out A_Value ); 
  742.     pragma Precondition( attribute'Length > 0 ); 
  743.     pragma Postcondition( val = null ); 
  744.  
  745.     ---------------------------------------------------------------------------- 
  746.  
  747.     type Spawn_Entity_Event is new Event with 
  748.         record 
  749.             id     : Unbounded_String; 
  750.             x, y   : Float; 
  751.             width, 
  752.             height : Natural; 
  753.             xv, yv : Float; 
  754.         end record; 
  755.  
  756.     procedure Construct( this   : access Spawn_Entity_Event; 
  757.                          id     : String; 
  758.                          x, y   : Float; 
  759.                          width, 
  760.                          height : Natural; 
  761.                          xv, yv : Float ); 
  762.     pragma Precondition( id'Length > 0 ); 
  763.  
  764.     function To_String( this : access Spawn_Entity_Event ) return String; 
  765.  
  766. end Events.Entities;