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. private with Ada.Strings.Unbounded; 
  10.  
  11. package Tools.Entity_Spawners is 
  12.  
  13.     type Entity_Spawner is new Tool with private; 
  14.     type A_Entity_Spawner is access all Entity_Spawner'Class; 
  15.  
  16.     -- Creates a new entity of class 'id'. If 'snap' is True, the new entity 
  17.     -- will be snapped to the grid based if the gridsnap preference is enabled 
  18.     -- and holding ctrl while using the spawner tool will reverse the gridsnap 
  19.     -- behavior. If 'snap' is False, no grid snapping will ever be performed. 
  20.     function Create_Entity_Spawner( id : String; snap : Boolean := True ) return A_Tool; 
  21.     pragma Precondition( id'Length > 0 ); 
  22.     pragma Postcondition( Create_Entity_Spawner'Result /= null ); 
  23.  
  24.     function Get_ID( this : not null access Entity_Spawner'Class ) return String; 
  25.     pragma Postcondition( Get_ID'Result'Length > 0 ); 
  26.  
  27.     -- Returns True if the class id that this spawner will spawn is within 
  28.     -- the parent class specified by 'pattern' (case insensitive). For example, 
  29.     -- to check if the spawner's class id "Entities.Enemies.Cat" is an enemy, 
  30.     -- use class pattern "Entities.Enemies.*", which will match all registered 
  31.     -- enemy entity classes. A constant for matching enemy classes is specified 
  32.     -- in the Entities.Enemies package. 
  33.     function In_Class( this    : not null access Entity_Spawner'Class; 
  34.                        pattern : String ) return Boolean; 
  35.  
  36. private 
  37.  
  38.     use Ada.Strings.Unbounded; 
  39.  
  40.     type Entity_Spawner is new Tool with 
  41.         record 
  42.             id   : Unbounded_String; 
  43.             snap : Boolean := False;    -- allow grid snapping? 
  44.         end record; 
  45.  
  46.     procedure Construct( this : access Entity_Spawner; 
  47.                          id   : String; 
  48.                          snap : Boolean ); 
  49.     pragma Precondition( id'Length > 0 ); 
  50.  
  51.     procedure Apply( this : access Entity_Spawner; context : Tool_Context ); 
  52.  
  53.     function Get_Type( this : access Entity_Spawner ) return Tool_Type; 
  54.  
  55. end Tools.Entity_Spawners;