sector_base.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // SuperTux
  2. // Copyright (C) 2023 Vankata453
  3. //
  4. // This program is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // This program is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU General Public License
  15. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #ifndef HEADER_SUPERTUX_SUPERTUX_SECTOR_BASE_HPP
  17. #define HEADER_SUPERTUX_SUPERTUX_SECTOR_BASE_HPP
  18. #include "supertux/game_object_manager.hpp"
  19. #include "squirrel/squirrel_environment.hpp"
  20. class Level;
  21. class TileSet;
  22. namespace Base {
  23. /** A base for sector classes. Contains main properties and functions. */
  24. class Sector : public GameObjectManager
  25. {
  26. public:
  27. Sector(const std::string& type);
  28. /** Needs to be called after parsing to finish the construction of
  29. the Sector before using it. */
  30. virtual void finish_construction(bool editable);
  31. virtual void draw(DrawingContext& context) = 0;
  32. virtual void update(float dt_sec) = 0;
  33. virtual TileSet* get_tileset() const = 0;
  34. virtual bool in_worldmap() const = 0;
  35. void set_name(const std::string& name) { m_name = name; }
  36. const std::string& get_name() const { return m_name; }
  37. void set_init_script(const std::string& init_script) { m_init_script = init_script; }
  38. void run_script(const std::string& script, const std::string& sourcename);
  39. protected:
  40. virtual bool before_object_add(GameObject& object) override;
  41. virtual void before_object_remove(GameObject& object) override;
  42. protected:
  43. std::string m_name;
  44. std::string m_init_script;
  45. std::unique_ptr<SquirrelEnvironment> m_squirrel_environment;
  46. private:
  47. Sector(const Sector&) = delete;
  48. Sector& operator=(const Sector&) = delete;
  49. };
  50. } // namespace Base
  51. #endif
  52. /* EOF */