gcsx_spawn.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* GCSx
  2. ** SPAWN.H
  3. **
  4. ** Spawn-point support (starting point for sprite/script)
  5. ** Doesn't include any editor-only functionality
  6. ** Usually simply referred to as sprites/objects/scripts in the editor
  7. */
  8. /*****************************************************************************
  9. ** Copyright (C) 2003-2006 Janson
  10. **
  11. ** This program is free software; you can redistribute it and/or modify
  12. ** it under the terms of the GNU General Public License as published by
  13. ** the Free Software Foundation; either version 2 of the License, or
  14. ** (at your option) any later version.
  15. **
  16. ** This program is distributed in the hope that it will be useful,
  17. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. ** GNU General Public License for more details.
  20. **
  21. ** You should have received a copy of the GNU General Public License
  22. ** along with this program; if not, write to the Free Software
  23. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
  24. *****************************************************************************/
  25. #ifndef __GCSx_SPAWN_H_
  26. #define __GCSx_SPAWN_H_
  27. // (always loaded from elsewhere; doesn't cache by itself but only as part of
  28. // a parent object)
  29. class Spawn {
  30. protected:
  31. // Becomes name of entity
  32. // @TODO: not lowercased right now- never used as an index
  33. std::string name;
  34. // Only script present- spriteless object (if part of layer, blank sprite)
  35. // Only anim/tile present- sprite with no object
  36. // Both- sprite+script object
  37. // Neither- error condition
  38. class Script* script; // (never locked)
  39. // Not normally locked, but SpawnEdit can lock them if requested by layer
  40. class AnimGroup* animgroup;
  41. class TileSet* tileset;
  42. int subid; // (which anim or tile to use)
  43. // IDs unique within world
  44. int id;
  45. // Position within layer, pixel-based, may be negative
  46. int x;
  47. int y;
  48. // @TODO: color
  49. public:
  50. // ID of zero if loading or clipboard
  51. Spawn(int newId = 0);
  52. virtual ~Spawn();
  53. // Accessors
  54. const std::string& getName() const { return name; }
  55. int getX() const { return x; }
  56. int getY() const { return y; }
  57. int getId() const { return id; }
  58. class Script* getScript() { return script; }
  59. class AnimGroup* getAnimgroup() { return animgroup; }
  60. class TileSet* getTileset() { return tileset; }
  61. int getSubid() const { return subid; }
  62. // Load data from file- parent objects should call this
  63. virtual void load(class FileRead* file, const class World* world) throw_File;
  64. // GAMEPLAY
  65. // Tells spawn to spawn to given layer (optional) and world
  66. void generate(class Layer* toLayer, class WorldPlay* toWorld);
  67. };
  68. #endif