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/nebular/core/msurface.h"
31 
32 namespace MADS {
33 namespace Nebular {
34 
35 class WalkNode {
36 public:
37  Common::Point _walkPos;
38  uint16 _distances[MAX_ROUTE_NODES];
39  bool _active;
40 
44  WalkNode();
45 
50 };
52 
57 class Rails {
58 private:
59  WalkNodeList _nodes;
60  DepthSurface *_depthSurface;
61  int _depthStyle;
62  int _routeLength;
63  int _next;
64  int _tempRoute[MAX_ROUTE_NODES];
65  Common::Stack<int> _routeIndexes;
66 private:
71  void setNodePosition(int nodeIndex, const Common::Point &pt);
72 
73  int getRouteFlags(const Common::Point &src, const Common::Point &dest);
74 public:
78  Rails();
79 
86  void load(const WalkNodeList &nodes, DepthSurface *depthSurface, int depthStyle);
87 
91  void setupRoute(bool bitFlag, const Common::Point &srcPos, const Common::Point &destPos);
92 
93  void setupRouteNode(int *routeIndexP, int nodeIndex, int flags, int routeLength);
94 
98  void resetRoute();
99 
104  int scanPath(const Common::Point &srcPos, const Common::Point &destPos);
105 
106  /*
107  * Return the number of walk nodes in the calculated route
108  */
109  int size() const {
110  return _routeIndexes.size();
111  }
112 
116  bool empty() const {
117  return _routeIndexes.empty();
118  }
119 
123  const WalkNode &operator[](int idx) {
124  return _nodes[_routeIndexes[idx]];
125  }
126 
127  const WalkNode &popNode();
128 
129  void resetNext() {
130  _next = 0;
131  }
132  int getNext() {
133  return _next;
134  }
135 
139  void synchronize(Common::Serializer &s);
140 
141  void disableNode(int idx);
142  void disableLine(int from, int to);
143 
144 };
145 
146 } // namespace Nebular
147 } // namespace MADS
148 
149 #endif
Definition: msurface.h:203
Definition: rails.h:35
const WalkNode & operator[](int idx)
Definition: rails.h:123
Definition: stream.h:745
Definition: serializer.h:80
void load(Common::SeekableReadStream *f)
bool empty() const
Definition: rails.h:116
Definition: rect.h:144
Definition: rails.h:57
Definition: mps_installer.h:31