ScummVM API documentation
movements.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 TWINE_SCENE_MOVEMENTS_H
23#define TWINE_SCENE_MOVEMENTS_H
24
25#include "common/scummsys.h"
26#include "twine/shared.h"
27
28namespace TwinE {
29
30class TwinEEngine;
31class ActorStruct;
32struct RealValue;
33
34class Movements {
35private:
36 TwinEEngine *_engine;
37
38 struct ChangedCursorKeys {
39 uint8 forwardChange = 0;
40 uint8 backwardChange = 0;
41 uint8 leftChange = 0;
42 uint8 rightChange = 0;
43 uint8 forwardDown = 0;
44 uint8 backwardDown = 0;
45 uint8 leftDown = 0;
46 uint8 rightDown = 0;
47
48 void update(TwinEEngine *engine);
49
50 inline bool operator==(const ChangedCursorKeys &rhs) const {
51 return forwardChange == rhs.forwardChange && backwardChange == rhs.backwardChange && leftChange == rhs.leftChange && rightChange == rhs.rightChange;
52 }
53
54 inline operator bool() const {
55 return forwardChange && backwardChange && leftChange && rightChange;
56 }
57
58 inline bool operator!=(const ChangedCursorKeys &rhs) const {
59 return forwardChange != rhs.forwardChange || backwardChange != rhs.backwardChange || leftChange != rhs.leftChange || rightChange != rhs.rightChange;
60 }
61 };
62
63 // enter, space, ...
64 int16 _heroActionKey = 0;
65 int32 _previousLoopActionKey = 0;
66 // alt (throw magic ball / sabre)
67 int16 _heroAttackKey = 0;
68 int32 _previousLoopAttackKey = 0;
69 // cursor keys
70 ChangedCursorKeys _changedCursorKeys;
71 ChangedCursorKeys _previousChangedCursorKeys;
72
79 void processManualAction(int actorIdx);
88 void processFollowAction(int actorIdx);
96 void processRandomAction(int actorIdx);
101 void processTrackAction(int actorIdx);
108 void processSameXZAction(int actorIdx);
109
110 void processBehaviourExecution(int actorIdx);
111 bool processAttackExecution(int actorIdx);
112 void processManualMovementExecution(int actorIdx);
113 void processManualRotationExecution(int actorIdx);
114
120 bool _actionNormal = false;
121 void manualRealAngle(ActorStruct *actor);
122
123public:
124 Movements(TwinEEngine *engine);
125
126 void setActionNormal(bool actionNormal);
127
128 void update();
129
133 bool actionNormal() const;
134
135 bool _lastJoyFlag = false;
136
137 int32 _targetActorDistance = 0;
138
143 IVec3 getShadow(const IVec3 &pos);
144
152 void initRealAngle(int16 startAngle, int16 endAngle, int16 stepAngle, RealValue *movePtr);
153
159
167 void initRealValue(int16 startAngle, int16 endAngle, int16 stepAngle, RealValue *movePtr);
168
176 int32 getAngle(int32 x1, int32 z1, int32 x2, int32 z2);
177
178 inline int32 getAngle(const IVec3& v1, const IVec3 &v2) {
179 return getAngle(v1.x, v1.z, v2.x, v2.z);
180 }
181
189 void initRealAngleConst(int32 start, int32 end, int32 duration, RealValue *movePtr) const;
190
191 void doDir(int32 actorIdx);
192};
193
194inline void Movements::setActionNormal(bool actionNormal) {
195 _actionNormal = actionNormal;
196}
197
198inline bool Movements::actionNormal() const {
199 return _actionNormal;
200}
201
202} // namespace TwinE
203
204#endif
Definition: actor.h:137
Definition: movements.h:34
IVec3 getShadow(const IVec3 &pos)
void clearRealAngle(ActorStruct *actorPtr)
bool actionNormal() const
Definition: movements.h:198
void initRealAngleConst(int32 start, int32 end, int32 duration, RealValue *movePtr) const
void initRealValue(int16 startAngle, int16 endAngle, int16 stepAngle, RealValue *movePtr)
void initRealAngle(int16 startAngle, int16 endAngle, int16 stepAngle, RealValue *movePtr)
int32 getAngle(int32 x1, int32 z1, int32 x2, int32 z2)
Definition: twine.h:207
Definition: shared.h:127
Definition: actor.h:40