gcsx_worldplay.h 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* GCSx
  2. ** WORLDPLAY.H
  3. **
  4. ** World storage- gameplay-only functionality
  5. */
  6. /*****************************************************************************
  7. ** Copyright (C) 2003-2006 Janson
  8. **
  9. ** This program is free software; you can redistribute it and/or modify
  10. ** it under the terms of the GNU General Public License as published by
  11. ** the Free Software Foundation; either version 2 of the License, or
  12. ** (at your option) any later version.
  13. **
  14. ** This program is distributed in the hope that it will be useful,
  15. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. ** GNU General Public License for more details.
  18. **
  19. ** You should have received a copy of the GNU General Public License
  20. ** along with this program; if not, write to the Free Software
  21. ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
  22. *****************************************************************************/
  23. #ifndef __GCSx_WORLDPLAY_H_
  24. #define __GCSx_WORLDPLAY_H_
  25. class WorldPlay : public World {
  26. private:
  27. // ALL Entities and Sprites, indexed by id
  28. EntityIndex entitysById;
  29. SpriteIndex spritesById;
  30. // The last entity/sprite ID we assigned
  31. int lastEntityId;
  32. int lastSpriteId;
  33. // Current scene is locked
  34. Scene* currentScene;
  35. // Scenes that we've handled initial spawning for (a one-time event)
  36. std::set<int> scenesSpawned;
  37. void spawnScene(Scene* scene);
  38. // Call after buildScripts() only!
  39. // Call if no errors only!
  40. // Locks EVERY library, and links them
  41. // Locks every SCRIPT too, if config setting enabled
  42. void lockLibraries();
  43. void unlockLibraries();
  44. int librariesLocked;
  45. int allScriptsLocked;
  46. public:
  47. // Opens an existing world for gameplay
  48. WorldPlay(const char* wFilename) throw_File;
  49. virtual ~WorldPlay();
  50. // Prepare game for play, with starting scene selected
  51. // OK to call before initializing GL
  52. // Undefined behavior if called after game started, etc.
  53. // Throws if any errors and game should be aborted
  54. void gameStart() throw_File;
  55. // Working with entities
  56. // Indexed entities are owned by WORLD and deleted by it for simplicity
  57. // (since there is currently no way to add/delete scenes/layers mid-game)
  58. void indexEntity(Entity* addEntity);
  59. void deindexEntity(Entity* remEntity);
  60. Entity* findEntity(int fId) const;
  61. int unusedEntityId();
  62. // Working with sprites
  63. // Indexed sprites are owned by WORLD and deleted by it for simplicity
  64. // (since there is currently no way to add/delete scenes/layers mid-game)
  65. void indexSprite(Sprite* addSprite);
  66. void deindexSprite(Sprite* remSprite);
  67. Sprite* findSprite(int fId) const;
  68. int unusedSpriteId();
  69. // Load a new current scene; NULL for none
  70. void changeScene(Scene* newScene);
  71. Scene* getCurrentScene() { return currentScene; }
  72. // Draw current scene- assumes you just reset GL for next frame
  73. void draw();
  74. // Run one cycle of all entities
  75. void cycle();
  76. };
  77. #endif