ScummVM API documentation
rails.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef MADS_RAILS_H
23 #define MADS_RAILS_H
24 
25 #include "common/scummsys.h"
26 #include "common/array.h"
27 #include "common/rect.h"
28 #include "common/serializer.h"
29 #include "common/stack.h"
30 #include "mads/msurface.h"
31 
32 namespace MADS {
33 
34 class WalkNode {
35 public:
36  Common::Point _walkPos;
37  uint16 _distances[MAX_ROUTE_NODES];
38  bool _active;
39 
43  WalkNode();
44 
49 };
51 
56 class Rails {
57 private:
58  WalkNodeList _nodes;
59  DepthSurface *_depthSurface;
60  int _depthStyle;
61  int _routeLength;
62  int _next;
63  int _tempRoute[MAX_ROUTE_NODES];
64  Common::Stack<int> _routeIndexes;
65 private:
70  void setNodePosition(int nodeIndex, const Common::Point &pt);
71 
72  int getRouteFlags(const Common::Point &src, const Common::Point &dest);
73 public:
77  Rails();
78 
85  void load(const WalkNodeList &nodes, DepthSurface *depthSurface, int depthStyle);
86 
90  void setupRoute(bool bitFlag, const Common::Point &srcPos, const Common::Point &destPos);
91 
92  void setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int routeLength);
93 
97  void resetRoute();
98 
103  int scanPath(const Common::Point &srcPos, const Common::Point &destPos);
104 
105  /*
106  * Return the number of walk nodes in the calculated route
107  */
108  int size() const { return _routeIndexes.size(); }
109 
113  bool empty() const { return _routeIndexes.empty(); }
114 
118  const WalkNode &operator[](int idx) { return _nodes[_routeIndexes[idx]]; }
119 
120  const WalkNode &popNode();
121 
122  void resetNext() { _next = 0; }
123  int getNext() { return _next; }
124 
128  void synchronize(Common::Serializer &s);
129 
130  void disableNode(int idx);
131  void disableLine(int from, int to);
132 
133 };
134 
135 } // End of namespace MADS
136 
137 #endif /* MADS_RAILS_H */
Definition: rails.h:56
Definition: stream.h:745
Definition: serializer.h:79
bool empty() const
Definition: rails.h:113
Definition: msurface.h:184
Definition: rect.h:45
const WalkNode & operator[](int idx)
Definition: rails.h:118
Definition: action.h:28
Definition: rails.h:34
void load(Common::SeekableReadStream *f)