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