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.     ---------------------------------------------------------------------------- 
  217.  
  218.     ENTITY_MOVED_ID : constant Event_Id := To_Event_Id( "Entity_Moved" ); 
  219.  
  220.     -- A notification that an entity moved. 
  221.     type Entity_Moved_Event is new Entity_Event with private; 
  222.     type A_Entity_Moved_Event is access all Entity_Moved_Event'Class; 
  223.  
  224.     -- Returns the entity's new X coordinate in world units. 
  225.     function Get_X( this : not null access Entity_Moved_Event'Class ) return Float; 
  226.  
  227.     -- Returns the entity's X velocity in world units per second. 
  228.     function Get_XV( this : not null access Entity_Moved_Event'Class ) return Float; 
  229.  
  230.     -- Returns the entity's new Y coordinate in world units. 
  231.     function Get_Y( this : not null access Entity_Moved_Event'Class ) return Float; 
  232.  
  233.     -- Returns the entity's Y velocity in world units per second. 
  234.     function Get_YV( this : not null access Entity_Moved_Event'Class ) return Float; 
  235.  
  236.     ---------------------------------------------------------------------------- 
  237.  
  238.     ENTITY_RESIZED_ID : constant Event_Id := To_Event_Id( "Entity_Resized" ); 
  239.  
  240.     -- A notification that an entity's physical size changed. 
  241.     type Entity_Resized_Event is new Entity_Event with private; 
  242.     type A_Entity_Resized_Event is access all Entity_Resized_Event'Class; 
  243.  
  244.     -- Returns the entity's new height in world units. 
  245.     function Get_Height( this : not null access Entity_Resized_Event'Class ) return Natural; 
  246.  
  247.     -- Returns the entity's new width in world units. 
  248.     function Get_Width( this : not null access Entity_Resized_Event'Class ) return Natural; 
  249.  
  250.     ---------------------------------------------------------------------------- 
  251.  
  252.     FOLLOW_ENTITY_ID : constant Event_Id := To_Event_Id( "Follow_Entity" ); 
  253.  
  254.     -- A command to the game view follow an entity with the view's viewport. 
  255.     type Follow_Entity_Event is new Entity_Event with private; 
  256.     type A_Follow_Entity_Event is access all Follow_Entity_Event'Class; 
  257.  
  258.     ---------------------------------------------------------------------------- 
  259.  
  260.     FRAME_CHANGED_ID : constant Event_Id := To_Event_Id( "Frame_Changed" ); 
  261.  
  262.     -- A notification that an entity's display frame has changed. 
  263.     type Frame_Changed_Event is new Entity_Event with private; 
  264.     type A_Frame_Changed_Event is access all Frame_Changed_Event'Class; 
  265.  
  266.     -- Returns the id of the new display frame or 0 for none. 
  267.     function Get_Frame( this : not null access Frame_Changed_Event'Class ) return Natural; 
  268.  
  269.     ---------------------------------------------------------------------------- 
  270.  
  271.     IMPULSE_ID : constant Event_Id := To_Event_Id( "Impulse" ); 
  272.  
  273.     -- A command sent to an entity. The entity may choose to respond to the 
  274.     -- impulse depending on its current state and the impulse (command) given. 
  275.     type Impulse_Event is new Entity_Event with private; 
  276.     type A_Impulse_Event is access all Impulse_Event'Class; 
  277.  
  278.     -- Returns the name of the impulse being sent to the entity. 
  279.     function Get_Impulse_Name( this : not null access Impulse_Event'Class ) return Hashed_String; 
  280.  
  281.     ---------------------------------------------------------------------------- 
  282.  
  283.     MOVE_ENTITY_ID : constant Event_Id := To_Event_Id( "Move_Entity" ); 
  284.  
  285.     -- A command to move an entity. 
  286.     type Move_Entity_Event is new Entity_Event with private; 
  287.     type A_Move_Entity_Event is access all Move_Entity_Event'Class; 
  288.  
  289.     -- Returns the new X coordinate for the entity in world units. 
  290.     function Get_X( this : not null access Move_Entity_Event'Class ) return Float; 
  291.  
  292.     -- Returns the new Y coordinate for the entity in world units. 
  293.     function Get_Y( this : not null access Move_Entity_Event'Class ) return Float; 
  294.  
  295.     ---------------------------------------------------------------------------- 
  296.  
  297.     RESIZE_ENTITY_ID : constant Event_Id := To_Event_Id( "Resize_Entity" ); 
  298.  
  299.     -- A command to change the physical size of an entity. 
  300.     type Resize_Entity_Event is new Entity_Event with private; 
  301.     type A_Resize_Entity_Event is access all Resize_Entity_Event'Class; 
  302.  
  303.     -- Returns the new height for the entity in world units. 
  304.     function Get_Height( this : not null access Resize_Entity_Event'Class ) return Natural; 
  305.  
  306.     -- Returns the new width for the entity in world units. 
  307.     function Get_Width( this : not null access Resize_Entity_Event'Class ) return Natural; 
  308.  
  309.     ---------------------------------------------------------------------------- 
  310.  
  311.     SET_ENTITY_ATTRIBUTE_ID : constant Event_Id := To_Event_Id( "Set_Entity_Attribute" ); 
  312.  
  313.     -- A command to set an attribute of an entity. 
  314.     type Set_Entity_Attribute_Event is new Entity_Attribute_Event with private; 
  315.     type A_Set_Entity_Attribute_Event is access all Set_Entity_Attribute_Event; 
  316.  
  317.     ---------------------------------------------------------------------------- 
  318.  
  319.     SPAWN_ENTITY_ID : constant Event_Id := To_Event_Id( "Spawn_Entity" ); 
  320.  
  321.     -- A command to create a new entity. 
  322.     type Spawn_Entity_Event is new Event with private; 
  323.     type A_Spawn_Entity_Event is access all Spawn_Entity_Event; 
  324.  
  325.     -- Returns the physical height for the entity in world units. 
  326.     function Get_Height( this : access Spawn_Entity_Event ) return Integer; 
  327.  
  328.     -- Returns class id of the entity to create. 
  329.     function Get_Id( this : access Spawn_Entity_Event ) return String; 
  330.  
  331.     -- Returns the physical width for the entity in world units. 
  332.     function Get_Width( this : access Spawn_Entity_Event ) return Integer; 
  333.  
  334.     -- Returns the X coordinate for the entity in world units. 
  335.     function Get_X( this : access Spawn_Entity_Event ) return Float; 
  336.  
  337.     -- Returns the X velocity for the entity in world units per second. 
  338.     function Get_XV( this : access Spawn_Entity_Event ) return Float; 
  339.  
  340.     -- Returns the Y coordinate for the entity in world units. 
  341.     function Get_Y( this : access Spawn_Entity_Event ) return Float; 
  342.  
  343.     -- Returns the Y velocity for the entity in world units per second. 
  344.     function Get_YV( this : access Spawn_Entity_Event ) return Float; 
  345.  
  346.     ---------------------------------------------------------------------------- 
  347.  
  348.     -- Queues an Accelerate_Event. 
  349.     procedure Queue_Accelerate( id  : Entity_Id; 
  350.                                 dir : Cardinal_Direction; 
  351.                                 vel : Float; 
  352.                                 acc : Float ); 
  353.     pragma Precondition( vel >= 0.0 ); 
  354.     pragma Precondition( acc >= 0.0 ); 
  355.  
  356.     -- Queues a Delete_Entity_Event. 
  357.     procedure Queue_Delete_Entity( id : Entity_Id ); 
  358.  
  359.     -- Queues an Entities_Collided_Event. 
  360.     procedure Queue_Entities_Collided( a, b : Entity_Id ); 
  361.  
  362.     -- Queues an Entities_Separated_Event. 
  363.     procedure Queue_Entities_Separated( a, b : Entity_Id ); 
  364.  
  365.     -- Queues an Entity_Attribute_Changed_Event. 
  366.     procedure Queue_Entity_Attribute_Changed( id        : Entity_Id; 
  367.                                               attribute : String; 
  368.                                               val       : in out A_Value ); 
  369.     pragma Precondition( attribute'Length > 0 ); 
  370.     pragma Postcondition( val = null ); 
  371.  
  372.     -- Queues an Entity_Created_Event. Argument 'attributes' is copied and not 
  373.     -- modified. 
  374.     procedure Queue_Entity_Created( id           : Entity_Id; 
  375.                                     class        : String; 
  376.                                     physical, 
  377.                                     metaphysical, 
  378.                                     clipped      : Boolean; 
  379.                                     width, 
  380.                                     height       : Natural; 
  381.                                     x, y         : Float; 
  382.                                     xv, yv       : Float; 
  383.                                     libName      : String; 
  384.                                     frame        : Natural; 
  385.                                     attributes   : not null A_Association ); 
  386.     pragma Precondition( class'Length > 0 ); 
  387.  
  388.     -- Queues an Entity_Deleted_Event. 
  389.     procedure Queue_Entity_Deleted( id : Entity_Id ); 
  390.  
  391.     -- Queues an Entity_Entered_Tile_Event. 
  392.     procedure Queue_Entity_Entered_Tile( id : Entity_Id; x, y : Natural ); 
  393.  
  394.     -- Queues an Entity_Exited_Tile_Event. 
  395.     procedure Queue_Entity_Exited_Tile( id : Entity_Id; x, y : Natural ); 
  396.  
  397.     -- Queues an Entity_Face_Event. 
  398.     procedure Queue_Entity_Face( id : Entity_Id; dir : Direction_Type ); 
  399.  
  400.     -- Queues an Entity_Grounded_Event. 
  401.     procedure Queue_Entity_Grounded( id : Entity_Id; grounded : Boolean ); 
  402.  
  403.     -- Queues an Entity_Hit_Wall_Event. 
  404.     procedure Queue_Entity_Hit_Wall( id : Entity_Id; dir : Cardinal_Direction ); 
  405.  
  406.     -- Queues an Entity_Moved_Event. 
  407.     procedure Queue_Entity_Moved( id : Entity_Id; x, y, xv, yv : Float ); 
  408.  
  409.     -- Queues an Entity_Resized_Event. 
  410.     procedure Queue_Entity_Resized( id : Entity_Id; width, height : Natural ); 
  411.  
  412.     -- Queues an Impulse_Event. 
  413.     procedure Queue_Impulse( id : Entity_Id; name : Hashed_String ); 
  414.  
  415.     -- Queues a Follow_Entity_Event. 
  416.     procedure Queue_Follow_Entity( id : Entity_Id ); 
  417.  
  418.     -- Queues a Frame_Changed_Event. 
  419.     procedure Queue_Frame_Changed( id : Entity_Id; frame : Natural ); 
  420.  
  421.     -- Queues a Move_Entity_Event. 
  422.     procedure Queue_Move_Entity( id : Entity_Id; x, y : Float ); 
  423.  
  424.     -- Queues a Resize_Entity_Event. 
  425.     procedure Queue_Resize_Entity( id : Entity_Id; width, height : Natural ); 
  426.  
  427.     -- Queues a Set_Entity_Attribute_Event with a value of any type. 
  428.     procedure Queue_Set_Entity_Attribute( id        : Entity_Id; 
  429.                                           attribute : String; 
  430.                                           val       : in out A_Value ); 
  431.     pragma Precondition( attribute'Length > 0 ); 
  432.     pragma Postcondition( val = null ); 
  433.  
  434.     -- Queues a Set_Entity_Attribute_Event with a boolean value. 
  435.     procedure Queue_Set_Entity_Attribute( id        : Entity_Id; 
  436.                                           attribute : String; 
  437.                                           val       : Boolean ); 
  438.     pragma Precondition( attribute'Length > 0 ); 
  439.  
  440.     -- Queues a Spawn_Entity_Event. 
  441.     procedure Queue_Spawn_Entity( id     : String; 
  442.                                   x, y   : Float; 
  443.                                   width, 
  444.                                   height : Natural := 0; 
  445.                                   xv, yv : Float := 0.0 ); 
  446.     pragma Precondition( id'Length > 0 ); 
  447.  
  448. private 
  449.  
  450.     type Entity_Event is abstract new Event with 
  451.         record 
  452.             id : Entity_Id := INVALID_ID; 
  453.         end record; 
  454.  
  455.     procedure Construct( this : access Entity_Event; name : String; id : Entity_Id ); 
  456.     pragma Precondition( name'Length > 0 ); 
  457.  
  458.     function To_String( this : access Entity_Event ) return String; 
  459.  
  460.     ---------------------------------------------------------------------------- 
  461.  
  462.     type Entities_Event is abstract new Event with 
  463.         record 
  464.             a, b : Entity_Id := INVALID_ID; 
  465.         end record; 
  466.  
  467.     procedure Construct( this : access Entities_Event; name : String; a, b : Entity_Id ); 
  468.     pragma Precondition( name'Length > 0 ); 
  469.  
  470.     function To_String( this : access Entities_Event ) return String; 
  471.  
  472.     ---------------------------------------------------------------------------- 
  473.  
  474.     type Accelerate_Event is new Entity_Event with 
  475.         record 
  476.             dir : Cardinal_Direction := Left; 
  477.             vel : Float := 0.0; 
  478.             acc : Float := 0.0; 
  479.         end record; 
  480.  
  481.     procedure Construct( this : access Accelerate_Event; 
  482.                          id   : Entity_Id; 
  483.                          dir  : Cardinal_Direction; 
  484.                          vel  : Float; 
  485.                          acc  : Float ); 
  486.  
  487.     ---------------------------------------------------------------------------- 
  488.  
  489.     type Delete_Entity_Event is new Entity_Event with null record; 
  490.  
  491.     procedure Construct( this : access Delete_Entity_Event; id : Entity_Id ); 
  492.  
  493.     ---------------------------------------------------------------------------- 
  494.  
  495.     type Entities_Collided_Event is new Entities_Event with null record; 
  496.  
  497.     procedure Construct( this : access Entities_Collided_Event; a, b : Entity_Id ); 
  498.  
  499.     ---------------------------------------------------------------------------- 
  500.  
  501.     type Entities_Separated_Event is new Entities_Event with null record; 
  502.  
  503.     procedure Construct( this : access Entities_Separated_Event; a, b : Entity_Id ); 
  504.  
  505.     ---------------------------------------------------------------------------- 
  506.  
  507.     type Entity_Attribute_Event is new Entity_Event with 
  508.         record 
  509.             attribute : Unbounded_String; 
  510.             val       : A_Value := null; 
  511.         end record; 
  512.  
  513.     procedure Adjust( this : access Entity_Attribute_Event ); 
  514.  
  515.     -- 'name' is event name 
  516.     -- 'attribute' is the name of the attribute 
  517.     -- 'val' is the value of the attribute 
  518.     procedure Construct( this      : access Entity_Attribute_Event; 
  519.                          name      : String; 
  520.                          id        : Entity_Id; 
  521.                          attribute : String; 
  522.                          val       : in out A_Value ); 
  523.     pragma Precondition( name'Length > 0 ); 
  524.     pragma Precondition( attribute'Length > 0 ); 
  525.     pragma Postcondition( val = null ); 
  526.  
  527.     procedure Delete( this : in out Entity_Attribute_Event ); 
  528.  
  529.     ---------------------------------------------------------------------------- 
  530.  
  531.     type Entity_Attribute_Changed_Event is new Entity_Attribute_Event with null record; 
  532.  
  533.     procedure Construct( this      : access Entity_Attribute_Changed_Event; 
  534.                          id        : Entity_Id; 
  535.                          attribute : String; 
  536.                          val       : in out A_Value ); 
  537.     pragma Precondition( attribute'Length > 0 ); 
  538.     pragma Postcondition( val = null ); 
  539.  
  540.     ---------------------------------------------------------------------------- 
  541.  
  542.     type Entity_Created_Event is new Entity_Event with 
  543.         record 
  544.             class        : Unbounded_String; 
  545.             physical     : Boolean := True; 
  546.             metaphysical : Boolean := False; 
  547.             clipped      : Boolean := True; 
  548.             width, 
  549.             height       : Natural := 0; 
  550.             x, y         : Float := 0.0; 
  551.             xv, yv       : Float := 0.0; 
  552.             libName      : Unbounded_String; 
  553.             frame        : Natural := 0; 
  554.             attributes   : A_Association := null; 
  555.         end record; 
  556.  
  557.     procedure Adjust( this : access Entity_Created_Event ); 
  558.  
  559.     procedure Construct( this         : access Entity_Created_Event; 
  560.                          id           : Entity_Id; 
  561.                          class        : String; 
  562.                          physical, 
  563.                          metaphysical, 
  564.                          clipped      : Boolean; 
  565.                          width, 
  566.                          height       : Natural; 
  567.                          x, y         : Float; 
  568.                          xv, yv       : Float; 
  569.                          libName      : String; 
  570.                          frame        : Natural; 
  571.                          attributes   : not null A_Association ); 
  572.  
  573.     procedure Delete( this : in out Entity_Created_Event ); 
  574.  
  575.     function To_String( this : access Entity_Created_Event ) return String; 
  576.  
  577.     ---------------------------------------------------------------------------- 
  578.  
  579.     type Entity_Deleted_Event is new Entity_Event with null record; 
  580.  
  581.     procedure Construct( this : access Entity_Deleted_Event; id : Entity_Id ); 
  582.  
  583.     ---------------------------------------------------------------------------- 
  584.  
  585.     type Entity_Tile_Event is new Entity_Event with 
  586.         record 
  587.             x, y : Natural; 
  588.         end record; 
  589.  
  590.     procedure Construct( this : access Entity_Tile_Event; 
  591.                          name : String; 
  592.                          id   : Entity_Id; 
  593.                          x, y : Natural ); 
  594.  
  595.     ---------------------------------------------------------------------------- 
  596.  
  597.     type Entity_Entered_Tile_Event is new Entity_Tile_Event with null record; 
  598.  
  599.     procedure Construct( this : access Entity_Entered_Tile_Event; 
  600.                          id   : Entity_Id; 
  601.                          x, y : Natural ); 
  602.  
  603.     ---------------------------------------------------------------------------- 
  604.  
  605.     type Entity_Exited_Tile_Event is new Entity_Tile_Event with null record; 
  606.  
  607.     procedure Construct( this : access Entity_Exited_Tile_Event; 
  608.                          id   : Entity_Id; 
  609.                          x, y : Natural ); 
  610.  
  611.     ---------------------------------------------------------------------------- 
  612.  
  613.     type Entity_Face_Event is new Entity_Event with 
  614.         record 
  615.             dir : Direction_Type := Dir_Left; 
  616.         end record; 
  617.  
  618.     procedure Construct( this : access Entity_Face_Event; 
  619.                          id   : Entity_Id; 
  620.                          dir  : Direction_Type ); 
  621.  
  622.     ---------------------------------------------------------------------------- 
  623.  
  624.     type Entity_Grounded_Event is new Entity_Event with 
  625.         record 
  626.             grounded : Boolean := False; 
  627.         end record; 
  628.  
  629.     procedure Construct( this     : access Entity_Grounded_Event; 
  630.                          id       : Entity_Id; 
  631.                          grounded : Boolean ); 
  632.  
  633.     ---------------------------------------------------------------------------- 
  634.  
  635.     type Entity_Hit_Wall_Event is new Entity_Event with 
  636.         record 
  637.             dir : Cardinal_Direction; 
  638.         end record; 
  639.  
  640.     procedure Construct( this : access Entity_Hit_Wall_Event; 
  641.                          id   : Entity_Id; 
  642.                          dir  : Cardinal_Direction ); 
  643.  
  644.     ---------------------------------------------------------------------------- 
  645.  
  646.     type Entity_Moved_Event is new Entity_Event with 
  647.         record 
  648.             x, y   : Float := 0.0; 
  649.             xv, yv : Float := 0.0; 
  650.         end record; 
  651.  
  652.     procedure Construct( this   : access Entity_Moved_Event; 
  653.                          id     : Entity_Id; 
  654.                          x, y   : Float; 
  655.                          xv, yv : Float ); 
  656.  
  657.     ---------------------------------------------------------------------------- 
  658.  
  659.     type Entity_Resized_Event is new Entity_Event with 
  660.         record 
  661.             width, height : Natural := 0; 
  662.         end record; 
  663.  
  664.     procedure Construct( this   : access Entity_Resized_Event; 
  665.                          id     : Entity_Id; 
  666.                          width, 
  667.                          height : Natural ); 
  668.  
  669.     ---------------------------------------------------------------------------- 
  670.  
  671.     type Follow_Entity_Event is new Entity_Event with null record; 
  672.  
  673.     procedure Construct( this : access Follow_Entity_Event; id : Entity_Id ); 
  674.  
  675.     ---------------------------------------------------------------------------- 
  676.  
  677.     type Frame_Changed_Event is new Entity_Event with 
  678.         record 
  679.             frame : Natural; 
  680.         end record; 
  681.  
  682.     procedure Construct( this  : access Frame_Changed_Event; 
  683.                          id    : Entity_Id; 
  684.                          frame : Natural ); 
  685.  
  686.     ---------------------------------------------------------------------------- 
  687.  
  688.     type Impulse_Event is new Entity_Event with 
  689.         record 
  690.             name : Hashed_String; 
  691.         end record; 
  692.  
  693.     procedure Construct( this : access Impulse_Event; 
  694.                          id   : Entity_Id; 
  695.                          name : Hashed_String ); 
  696.  
  697.     function To_String( this : access Impulse_Event ) return String; 
  698.  
  699.     ---------------------------------------------------------------------------- 
  700.  
  701.     type Move_Entity_Event is new Entity_Event with 
  702.         record 
  703.             x, y : Float := 0.0; 
  704.         end record; 
  705.  
  706.     procedure Construct( this : access Move_Entity_Event; 
  707.                          id   : Entity_Id; 
  708.                          x, y : Float ); 
  709.  
  710.     ---------------------------------------------------------------------------- 
  711.  
  712.     type Resize_Entity_Event is new Entity_Event with 
  713.         record 
  714.             width, height : Natural := 0; 
  715.         end record; 
  716.  
  717.     procedure Construct( this   : access Resize_Entity_Event; 
  718.                          id     : Entity_Id; 
  719.                          width, 
  720.                          height : Natural ); 
  721.  
  722.     ---------------------------------------------------------------------------- 
  723.  
  724.     type Set_Entity_Attribute_Event is new Entity_Attribute_Event with null record; 
  725.  
  726.     procedure Construct( this      : access Set_Entity_Attribute_Event; 
  727.                          id        : Entity_Id; 
  728.                          attribute : String; 
  729.                          val       : in out A_Value ); 
  730.     pragma Precondition( attribute'Length > 0 ); 
  731.     pragma Postcondition( val = null ); 
  732.  
  733.     ---------------------------------------------------------------------------- 
  734.  
  735.     type Spawn_Entity_Event is new Event with 
  736.         record 
  737.             id     : Unbounded_String; 
  738.             x, y   : Float; 
  739.             width, 
  740.             height : Natural; 
  741.             xv, yv : Float; 
  742.         end record; 
  743.  
  744.     procedure Construct( this   : access Spawn_Entity_Event; 
  745.                          id     : String; 
  746.                          x, y   : Float; 
  747.                          width, 
  748.                          height : Natural; 
  749.                          xv, yv : Float ); 
  750.     pragma Precondition( id'Length > 0 ); 
  751.  
  752.     function To_String( this : access Spawn_Entity_Event ) return String; 
  753.  
  754. end Events.Entities;