1 | // SuperTux - Switch Trigger |
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 | |
17 | #ifndef HEADER_SUPERTUX_TRIGGER_SWITCH_HPP |
18 | #define |
19 | |
20 | #include <string> |
21 | |
22 | #include "trigger/trigger_base.hpp" |
23 | |
24 | class ReaderMapping; |
25 | |
26 | class Switch final : public TriggerBase |
27 | { |
28 | public: |
29 | Switch(const ReaderMapping& reader); |
30 | virtual ~Switch(); |
31 | |
32 | virtual std::string get_class() const override { return "switch" ; } |
33 | |
34 | virtual ObjectSettings get_settings() override; |
35 | virtual void after_editor_set() override; |
36 | |
37 | virtual void update(float dt_sec) override; |
38 | virtual void draw(DrawingContext& context) override; |
39 | virtual void event(Player& player, EventType type) override; |
40 | |
41 | private: |
42 | enum SwitchState { |
43 | OFF, |
44 | TURN_ON, |
45 | ON, |
46 | TURN_OFF |
47 | }; |
48 | |
49 | private: |
50 | std::string sprite_name; |
51 | SpritePtr sprite; |
52 | std::string script; |
53 | std::string off_script; |
54 | SwitchState state; |
55 | bool bistable; |
56 | |
57 | private: |
58 | Switch(const Switch&) = delete; |
59 | Switch& operator=(const Switch&) = delete; |
60 | }; |
61 | |
62 | #endif |
63 | |
64 | /* EOF */ |
65 | |