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 ActorMoveStruct;
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 
111  bool processBehaviourExecution(int actorIdx);
112  bool processAttackExecution(int actorIdx);
113  void processManualMovementExecution(int actorIdx);
114  void processManualRotationExecution(int actorIdx);
115 
119  bool _actionNormal = false;
120  void manualRealAngle(ActorStruct *actor);
121 
122 public:
123  Movements(TwinEEngine *engine);
124 
125  void setActionNormal(bool actionNormal);
126 
127  void update();
128 
132  bool shouldExecuteAction() const;
133 
134  bool _lastJoyFlag = false;
135 
136  int32 _targetActorDistance = 0;
137 
142  IVec3 getShadow(const IVec3 &pos);
143 
151  void initRealAngle(int16 startAngle, int16 endAngle, int16 stepAngle, ActorMoveStruct *movePtr);
152 
157  void clearRealAngle(ActorStruct *actorPtr);
158 
166  void setActorAngle(int16 startAngle, int16 endAngle, int16 stepAngle, ActorMoveStruct *movePtr);
167 
175  int32 getAngle(int32 x1, int32 z1, int32 x2, int32 z2);
176 
177  inline int32 getAngle(const IVec3& v1, const IVec3 &v2) {
178  return getAngle(v1.x, v1.z, v2.x, v2.z);
179  }
180 
188  void initRealAngleConst(int32 start, int32 end, int32 duration, ActorMoveStruct *movePtr) const;
189 
190  void doDir(int32 actorIdx);
191 };
192 
193 inline void Movements::setActionNormal(bool actionNormal) {
194  _actionNormal = actionNormal;
195 }
196 
197 inline bool Movements::shouldExecuteAction() const {
198  return _actionNormal;
199 }
200 
201 } // namespace TwinE
202 
203 #endif
IVec3 getShadow(const IVec3 &pos)
bool shouldExecuteAction() const
Definition: movements.h:197
Definition: actor.h:145
void initRealAngleConst(int32 start, int32 end, int32 duration, ActorMoveStruct *movePtr) const
Definition: shared.h:113
void clearRealAngle(ActorStruct *actorPtr)
Definition: twine.h:200
Definition: achievements_tables.h:27
void setActorAngle(int16 startAngle, int16 endAngle, int16 stepAngle, ActorMoveStruct *movePtr)
Definition: actor.h:40
int32 getAngle(int32 x1, int32 z1, int32 x2, int32 z2)
void initRealAngle(int16 startAngle, int16 endAngle, int16 stepAngle, ActorMoveStruct *movePtr)
Definition: movements.h:34