ScummVM API documentation
walk.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 STARK_MOVEMENT_WALK_H
23 #define STARK_MOVEMENT_WALK_H
24 
25 #include "engines/stark/movement/movement.h"
26 
27 #include "common/array.h"
28 
29 namespace Stark {
30 
31 class StringPullingPath;
32 
33 namespace Resources {
34 class FloorPositionedItem;
35 }
36 
41 class Walk : public Movement {
42 public:
44  virtual ~Walk();
45 
46  // Movement API
47  void start() override;
48  void stop(bool force = false) override;
49  void onGameLoop() override;
50  bool hasReachedDestination() const override;
51  uint32 getType() const override;
52  void saveLoad(ResourceSerializer *serializer) override;
53 
55  void setDestination(const Math::Vector3d &destination);
56  void setDestinationWithoutHeight(Math::Vector3d destination);
57 
59  void changeDestination(const Math::Vector3d &destination);
60 
62  void setRunning();
63 
64 private:
65  void doWalk();
66  void doWalkCollisionSimple();
67  void doWalkCollisionAvoid();
68 
69  float computeDistancePerGameLoop() const;
70  float getAngularSpeed() const;
71 
72  void changeItemAnim();
73  void updatePath() const;
74 
75  void queueDestinationToAvoidItem(Resources::FloorPositionedItem *item, const Math::Vector3d &destination);
76  bool isItemAlreadyAvoided(Resources::FloorPositionedItem *item) const;
77 
78  static bool isPointNearPath(const Math::Vector3d &point3d, const Math::Vector3d &pathStart3d, const Math::Vector3d &pathEnd3d);
79 
81  StringPullingPath *_path;
82 
83  Math::Vector3d _destination;
84  Common::Array<Math::Vector3d> _destinations;
85 
87 
88  bool _running;
89  bool _reachedDestination;
90  TurnDirection _turnDirection;
91 
92  int32 _collisionWaitTimeout;
93  int32 _collisionWaitCount;
94  Math::Vector3d _previousPosition;
95  Math::Vector3d _currentTarget;
96 };
97 
98 } // End of namespace Stark
99 
100 #endif // STARK_MOVEMENT_WALK_H
Definition: walk.h:41
Definition: console.h:27
Definition: stringpullingpath.h:37
Definition: movement.h:38
Definition: stateprovider.h:51