climbable.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. // SuperTux - Climbable area
  2. // Copyright (C) 2007 Christoph Sommer <christoph.sommer@2007.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_TRIGGER_CLIMBABLE_HPP
  17. #define HEADER_SUPERTUX_TRIGGER_CLIMBABLE_HPP
  18. #include "trigger/trigger_base.hpp"
  19. #include <vector>
  20. #include "supertux/timer.hpp"
  21. class Color;
  22. class Climbable final : public Trigger
  23. {
  24. private:
  25. struct ClimbPlayer
  26. {
  27. Player* m_player;
  28. std::unique_ptr<Timer> m_activate_try_timer;
  29. };
  30. private:
  31. static Color text_color;
  32. public:
  33. Climbable(const ReaderMapping& reader);
  34. ~Climbable() override;
  35. static std::string class_name() { return "climbable"; }
  36. virtual std::string get_class_name() const override { return class_name(); }
  37. static std::string display_name() { return _("Climbable"); }
  38. virtual std::string get_display_name() const override { return display_name(); }
  39. virtual bool has_variable_size() const override { return true; }
  40. virtual ObjectSettings get_settings() override;
  41. virtual void event(Player& player, EventType type) override;
  42. virtual void update(float dt_sec) override;
  43. virtual void draw(DrawingContext& context) override;
  44. /** returns true if the player is within bounds of the Climbable */
  45. bool may_climb(const Player& player) const;
  46. protected:
  47. std::vector<Player*> climbed_by; /** contains players who's currently climbing us, empty if nobody is. */
  48. std::vector<ClimbPlayer> trying_to_climb; /** Contains players that are trying to climb */
  49. std::string message;
  50. private:
  51. Climbable(const Climbable&) = delete;
  52. Climbable& operator=(const Climbable&) = delete;
  53. };
  54. #endif
  55. /* EOF */