candle.hpp 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. // SuperTux
  2. // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
  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_OBJECT_CANDLE_HPP
  17. #define HEADER_SUPERTUX_OBJECT_CANDLE_HPP
  18. #include "object/moving_sprite.hpp"
  19. /**
  20. * A burning candle: Simple, scriptable level decoration.
  21. * @scripting
  22. * @summary A ""Candle"" that was given a name can be controlled by scripts.
  23. * @instances A ""Candle"" is instantiated by placing a definition inside a level.
  24. It can then be accessed by its name from a script or via ""sector.name"" from the console.
  25. */
  26. class Candle final : public MovingSprite
  27. {
  28. public:
  29. static void register_class(ssq::VM& vm);
  30. public:
  31. Candle(const ReaderMapping& mapping);
  32. virtual void draw(DrawingContext& context) override;
  33. virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
  34. static std::string class_name() { return "candle"; }
  35. virtual std::string get_class_name() const override { return class_name(); }
  36. virtual std::string get_exposed_class_name() const override { return "Candle"; }
  37. static std::string display_name() { return _("Candle"); }
  38. virtual std::string get_display_name() const override { return display_name(); }
  39. virtual GameObjectClasses get_class_types() const override { return MovingSprite::get_class_types().add(typeid(Candle)); }
  40. virtual ObjectSettings get_settings() override;
  41. virtual void after_editor_set() override;
  42. virtual void on_flip(float height) override;
  43. /**
  44. * @scripting
  45. * @description Spawns a puff of smoke.
  46. */
  47. void puff_smoke();
  48. /**
  49. * @scripting
  50. * @description Returns ""true"" if the candle is lit up.
  51. */
  52. bool get_burning() const;
  53. /**
  54. * @scripting
  55. * @description Sets the burning state of the candle.
  56. * @param bool $burning If ""true"", the candle is lit up. If ""false"", it's extinguished.
  57. */
  58. void set_burning(bool burning);
  59. private:
  60. /**
  61. * @scripting
  62. * @description The burning state of the candle.
  63. */
  64. bool burning; /**< true if candle is currently lighted */
  65. bool flicker; /**< true if candle light is to flicker */
  66. Color lightcolor; /**< determines color or light given off */
  67. SpritePtr candle_light_1; /**< drawn to lightmap */
  68. SpritePtr candle_light_2; /**< drawn to lightmap (alternative image) */
  69. private:
  70. Candle(const Candle&) = delete;
  71. Candle& operator=(const Candle&) = delete;
  72. };
  73. #endif
  74. /* EOF */