lantern.hpp 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // SuperTux - Lantern
  2. // Copyright (C) 2006 Wolfgang Becker <uafr@gmx.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_LANTERN_HPP
  17. #define HEADER_SUPERTUX_OBJECT_LANTERN_HPP
  18. #include "object/rock.hpp"
  19. /** Lantern. A portable Light Source. */
  20. class Lantern final : public Rock
  21. {
  22. public:
  23. Lantern(const Vector& pos);
  24. Lantern(const ReaderMapping& reader);
  25. virtual void draw(DrawingContext& context) override;
  26. virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
  27. virtual void grab(MovingObject& object, const Vector& pos, Direction dir) override;
  28. virtual void ungrab(MovingObject& object, Direction dir) override;
  29. static std::string class_name() { return "lantern"; }
  30. virtual std::string get_class_name() const override { return class_name(); }
  31. static std::string display_name() { return _("Lantern"); }
  32. virtual std::string get_display_name() const override { return display_name(); }
  33. virtual ObjectSettings get_settings() override;
  34. virtual GameObjectTypes get_types() const override { return {}; }
  35. virtual void after_editor_set() override;
  36. /** returns true if lamp is currently open */
  37. bool is_open() const;
  38. /** returns the lamp's color */
  39. Color get_color() const { return lightcolor; }
  40. void add_color(const Color& c);
  41. private:
  42. Color lightcolor;
  43. SpritePtr lightsprite;
  44. void updateColor();
  45. private:
  46. Lantern(const Lantern&) = delete;
  47. Lantern& operator=(const Lantern&) = delete;
  48. };
  49. #endif
  50. /* EOF */