supertux
path_object.hpp
1 // SuperTux
2 // Copyright (C) 2018 Tobias Markus <tobbi@supertux.org>
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 
18 #ifndef HEADER_SUPERTUX_OBJECT_PATH_OBJECT_HPP
19 #define HEADER_SUPERTUX_OBJECT_PATH_OBJECT_HPP
20 
21 #include <memory>
22 
23 #include "object/path.hpp"
24 #include "object/path_gameobject.hpp"
25 #include "object/path_walker.hpp"
26 #include "util/uid.hpp"
27 
28 namespace ssq {
29 class Class;
30 } // namespace ssq
31 
37 {
38 protected:
39  static void register_members(ssq::Class& cls);
40 
41 public:
42  PathObject();
43  virtual ~PathObject();
44 
47  void init_path(const ReaderMapping& mapping, bool running_default);
48  void init_path_pos(const Vector& pos, bool running = false);
49 
50  PathGameObject* get_path_gameobject() const;
51  Path* get_path() const;
52  PathWalker* get_walker() const { return m_walker.get(); }
53 
54  void editor_clone_path(PathGameObject* path_object);
55 
56  std::string get_path_ref() const;
57  void editor_set_path_by_ref(const std::string& new_ref);
58 
64  void goto_node(int node_idx);
70  void set_node(int node_idx);
75  void start_moving();
80  void stop_moving();
81 
82 protected:
83  void save_state() const;
84  void check_state() const;
85 
86  void on_flip();
87 
88 protected:
89  PathWalker::Handle m_path_handle;
90 
91 private:
92  UID m_path_uid;
93  std::unique_ptr<PathWalker> m_walker;
94 
95 private:
96  PathObject(const PathObject&) = delete;
97  PathObject& operator=(const PathObject&) = delete;
98 };
99 
100 #endif
101 
102 /* EOF */
Definition: class.hpp:57
A walker that travels along a path.
Definition: path_walker.hpp:31
Helper class that allows to displace a handle on an object.
Definition: path_walker.hpp:35
Definition: path_object.hpp:28
Definition: path.hpp:48
Definition: uid.hpp:37
A base class for all objects that contain, or make use of a path.
Definition: path_object.hpp:36
Definition: reader_mapping.hpp:32
Definition: path_gameobject.hpp:32