ScummVM API documentation
CharacterMove.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/*
23 * Copyright (C) 2006-2010 - Frictional Games
24 *
25 * This file is part of Penumbra Overture.
26 */
27
28#ifndef GAME_CHARACTER_MOVE_H
29#define GAME_CHARACTER_MOVE_H
30
31#include "hpl1/engine/engine.h"
32
33using namespace hpl;
34
35class iGameEnemy;
36
37#include "hpl1/penumbra-overture/Init.h"
38
39//------------------------------------------
40
41class cCharacterMove;
42
44public:
46
47 bool CanAddNode(cAINode *apParentNode, cAINode *apChildNode);
48
49 bool Intersects(iPhysicsBody *pBody, cPhysicsRayParams *apParams);
50
51 bool mbCheckDynamic;
52
53 cCharacterMove *mpMove;
54};
55
56//------------------------------------------
57
59public:
60 void Reset();
61 bool BeforeIntersect(iPhysicsBody *pBody);
62 bool OnIntersect(iPhysicsBody *pBody, cPhysicsRayParams *apParams);
63
64 bool mbIntersection;
65};
66
67//------------------------------------------
68
70 friend class cCharacterAStarCallback;
71
72public:
73 cCharacterMove(cInit *apInit);
75
76 void Update(float afTimeStep);
77
78 void OnDraw(cInit *apInit);
79 void OnPostSceneDraw(iLowLevelGraphics *apLowLevelGfx);
80
82 // Actions
86 bool MoveToPos(const cVector3f &avPos);
87 void MoveDirectToPos(const cVector3f &avFeetPos, float afTimeStep);
88
89 void TurnToAngle(float afAngle);
90 void TurnToPos(const cVector3f &avPos);
91
92 void Stop();
93
95 // Helpers
96
97 bool FreeDirectPathToChar(iCharacterBody *apBody);
98
99 float DistanceToChar(iCharacterBody *apBody);
100 float DistanceToChar2D(iCharacterBody *apBody);
101
102 cAINode *GetAINodeInRange(float afMinDistance, float afMaxDistance);
103 cAINode *GetAINodeAtPosInRange(const cVector3f &avPos, float afMinDistance, float afMaxDistance,
104 bool abRayCheck, float afEndOffset);
105
107 // Properties
108 bool IsMoving() { return mbMoving; }
109
110 bool IsTurning() { return mbTurning; }
111
112 void SetCharBody(iCharacterBody *apCharBody);
113 iCharacterBody *GetCharBody() { return mpCharBody; }
114
115 void SetNodeContainer(cAINodeContainer *apContainer);
116 cAINodeContainer *GetNodeContainer() { return mpContainer; }
117
118 void SetAStar(cAStarHandler *apAStar);
119 cAStarHandler *GetAStar() { return mpAStar; }
120
121 void SetMaxTurnSpeed(float afX) { mfMaxTurnSpeed = afX; }
122 void SetAngleDistTurnMul(float afX) { mfAngleDistTurnMul = afX; };
123
124 void SetMinBreakAngle(float afX) { mfMinBreakAngle = afX; }
125 void SetBreakAngleMul(float afX) { mfBreakAngleMul = afX; }
126
127 void SetMaxPushMass(float afX) { mfMaxPushMass = afX; }
128
129 float GetTurnSpeed() { return mfTurnSpeed; }
130
131 const cVector3f &GetGoalPos() { return mvGoalPos; }
132
133 float GetStuckCounter() { return mfStuckCounter; }
134 void ResetStuckCounter() { mfStuckCounter = 0; }
135
136 void SetMaxDoorToughness(int alX) { mlMaxDoorToughness = alX; }
137 int GetMaxDoorToughness() { return mlMaxDoorToughness; }
138
139private:
140 cInit *mpInit;
141
142 iCharacterBody *mpCharBody;
143
144 cAINodeContainer *mpContainer;
145 cAStarHandler *mpAStar;
146 cBoundingVolume mBoundingVolume;
147
148 tAINodeList mlstNodes;
149
150 bool mbMoving;
151 bool mbTurning;
152
153 float mfTurnSpeed;
154
155 cVector3f mvGoalPos;
156
157 float mfGoalAngle;
158
159 float mfStuckCounter;
160 float mfStuckLimit;
161
162 Common::List<float> mlstNodeDistances;
163 int mlMaxNodeDistances;
164 float mfNodeDistAvg;
165
166 // Properties
167 float mfMaxTurnSpeed;
168 float mfAngleDistTurnMul;
169
170 float mfMinBreakAngle;
171 float mfBreakAngleMul;
172
173 float mfMaxPushMass;
174
175 cMoverRayCallback mRayCallback;
176
177 int mlMaxDoorToughness;
178
179 // Debug:
180 float mfCurrentBreak;
181 cVector3f mvTempStart;
182 cVector3f mvTempEnd;
183
184 bool mbMoveToNewNode;
185
186 cCharacterAStarCallback *mpAStarCallback;
187};
188
189//--------------------------------------
190
191#endif // GAME_CHARACTER_MOVE_H
Definition: CharacterMove.h:43
Definition: CharacterMove.h:69
bool MoveToPos(const cVector3f &avPos)
Definition: Init.h:70
Definition: CharacterMove.h:58
Definition: AINodeContainer.h:158
Definition: AINodeContainer.h:65
Definition: AStar.h:84
Definition: BoundingVolume.h:71
Definition: AINodeContainer.h:100
Definition: AStar.h:75
Definition: CharacterBody.h:153
Definition: LowLevelGraphics.h:200
Definition: PhysicsBody.h:117
Definition: PhysicsWorld.h:100
Definition: GameEnemy.h:189
Definition: PhysicsWorld.h:92