ispy.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // SuperTux - Ispy
  2. // Copyright (C) 2007 Christoph Sommer <christoph.sommer@2007.expires.deltadevelopment.de>
  3. // 2022 Jiri Palecek <narre@protonmail.com>
  4. //
  5. // This program is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // This program is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU General Public License
  16. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. #ifndef HEADER_SUPERTUX_OBJECT_ISPY_HPP
  18. #define HEADER_SUPERTUX_OBJECT_ISPY_HPP
  19. #include "object/moving_sprite.hpp"
  20. #include "supertux/direction.hpp"
  21. /** An Ispy: When it spots Tux, a script will run. */
  22. class Ispy final : public MovingSprite
  23. {
  24. public:
  25. Ispy(const ReaderMapping& mapping);
  26. virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
  27. virtual void update(float dt_sec) override;
  28. static std::string class_name() { return "ispy"; }
  29. virtual std::string get_class_name() const override { return class_name(); }
  30. static std::string display_name() { return _("Ispy"); }
  31. virtual std::string get_display_name() const override { return display_name(); }
  32. virtual ObjectSettings get_settings() override;
  33. virtual void after_editor_set() override;
  34. virtual void on_flip(float height) override;
  35. private:
  36. enum IspyState {
  37. ISPYSTATE_IDLE,
  38. ISPYSTATE_ALERT,
  39. ISPYSTATE_HIDING,
  40. ISPYSTATE_SHOWING
  41. };
  42. private:
  43. IspyState m_state; /**< current state */
  44. std::string m_script; /**< script to execute when Tux is spotted */
  45. Direction m_dir;
  46. private:
  47. Ispy(const Ispy&) = delete;
  48. Ispy& operator=(const Ispy&) = delete;
  49. };
  50. #endif
  51. /* EOF */