00001 /* ResidualVM - A 3D game interpreter 00002 * 00003 * ResidualVM is the legal property of its developers, whose names 00004 * are too numerous to list here. Please refer to the AUTHORS 00005 * file distributed with this source distribution. 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU General Public License 00009 * as published by the Free Software Foundation; either version 2 00010 * of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 * GNU General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU General Public License 00018 * along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00020 * 00021 */ 00022 00023 #ifndef STARK_MOVEMENT_WALK_H 00024 #define STARK_MOVEMENT_WALK_H 00025 00026 #include "engines/stark/movement/movement.h" 00027 00028 #include "common/array.h" 00029 00030 namespace Stark { 00031 00032 class StringPullingPath; 00033 00034 namespace Resources { 00035 class FloorPositionedItem; 00036 } 00037 00042 class Walk : public Movement { 00043 public: 00044 Walk(Resources::FloorPositionedItem *item); 00045 virtual ~Walk(); 00046 00047 // Movement API 00048 void start() override; 00049 void stop(bool force = false) override; 00050 void onGameLoop() override; 00051 bool hasReachedDestination() const override; 00052 uint32 getType() const override; 00053 void saveLoad(ResourceSerializer *serializer) override; 00054 00056 void setDestination(const Math::Vector3d &destination); 00057 void setDestinationWithoutHeight(Math::Vector3d destination); 00058 00060 void changeDestination(const Math::Vector3d &destination); 00061 00063 void setRunning(); 00064 00065 private: 00066 void doWalk(); 00067 void doWalkCollisionSimple(); 00068 void doWalkCollisionAvoid(); 00069 00070 float computeDistancePerGameLoop() const; 00071 float getAngularSpeed() const; 00072 00073 void changeItemAnim(); 00074 void updatePath() const; 00075 00076 void queueDestinationToAvoidItem(Resources::FloorPositionedItem *item, const Math::Vector3d &destination); 00077 bool isItemAlreadyAvoided(Resources::FloorPositionedItem *item) const; 00078 00079 static bool isPointNearPath(const Math::Vector3d &point3d, const Math::Vector3d &pathStart3d, const Math::Vector3d &pathEnd3d); 00080 00081 Resources::FloorPositionedItem *_item3D; 00082 StringPullingPath *_path; 00083 00084 Math::Vector3d _destination; 00085 Common::Array<Math::Vector3d> _destinations; 00086 00087 Common::Array<Resources::ItemVisual *> _avoidedItems; 00088 00089 bool _running; 00090 bool _reachedDestination; 00091 TurnDirection _turnDirection; 00092 00093 int32 _collisionWaitTimeout; 00094 int32 _collisionWaitCount; 00095 Math::Vector3d _previousPosition; 00096 Math::Vector3d _currentTarget; 00097 }; 00098 00099 } // End of namespace Stark 00100 00101 #endif // STARK_MOVEMENT_WALK_H