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 
28 namespace TwinE {
29 
30 class TwinEEngine;
31 class ActorStruct;
32 struct RealValue;
33 
34 class Movements {
35 private:
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  // cursor keys
67  ChangedCursorKeys _changedCursorKeys;
68  ChangedCursorKeys _previousChangedCursorKeys;
69 
76  void processManualAction(int actorIdx);
85  void processFollowAction(int actorIdx);
93  void processRandomAction(int actorIdx);
98  void processTrackAction(int actorIdx);
105  void processSameXZAction(int actorIdx);
106 
107  void processBehaviourExecution(int actorIdx);
108  bool processAttackExecution(int actorIdx);
109  void processManualMovementExecution(int actorIdx);
110  void processManualRotationExecution(int actorIdx);
111 
117  bool _actionNormal = false;
118  void manualRealAngle(ActorStruct *actor);
119 
120 public:
121  Movements(TwinEEngine *engine);
122 
123  void setActionNormal(bool actionNormal);
124 
125  void update();
126 
130  bool actionNormal() const;
131 
132  bool _lastJoyFlag = false;
133 
134  int32 _targetActorDistance = 0;
135 
140  IVec3 getShadow(const IVec3 &pos);
141 
149  void initRealAngle(int16 startAngle, int16 endAngle, int16 stepAngle, RealValue *movePtr);
150 
155  void clearRealAngle(ActorStruct *actorPtr);
156 
164  void initRealValue(int16 startAngle, int16 endAngle, int16 stepAngle, RealValue *movePtr);
165 
173  int32 getAngle(int32 x1, int32 z1, int32 x2, int32 z2);
174 
175  inline int32 getAngle(const IVec3& v1, const IVec3 &v2) {
176  return getAngle(v1.x, v1.z, v2.x, v2.z);
177  }
178 
186  void initRealAngleConst(int32 start, int32 end, int32 duration, RealValue *movePtr) const;
187 
188  void doDir(int32 actorIdx);
189 };
190 
191 inline void Movements::setActionNormal(bool actionNormal) {
192  _actionNormal = actionNormal;
193 }
194 
195 inline bool Movements::actionNormal() const {
196  return _actionNormal;
197 }
198 
199 } // namespace TwinE
200 
201 #endif
IVec3 getShadow(const IVec3 &pos)
void initRealAngle(int16 startAngle, int16 endAngle, int16 stepAngle, RealValue *movePtr)
void initRealAngleConst(int32 start, int32 end, int32 duration, RealValue *movePtr) const
Definition: actor.h:143
Definition: shared.h:122
void clearRealAngle(ActorStruct *actorPtr)
void initRealValue(int16 startAngle, int16 endAngle, int16 stepAngle, RealValue *movePtr)
bool actionNormal() const
Definition: movements.h:195
Definition: actor.h:40
Definition: twine.h:207
Definition: achievements_tables.h:27
int32 getAngle(int32 x1, int32 z1, int32 x2, int32 z2)
Definition: movements.h:34