1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-06 00:55:50 +00:00
OpenMW/apps/openmw/mwmechanics/obstacle.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

66 lines
1.7 KiB
C++
Raw Normal View History

#ifndef OPENMW_MECHANICS_OBSTACLE_H
2014-04-18 06:45:31 +00:00
#define OPENMW_MECHANICS_OBSTACLE_H
#include "apps/openmw/mwworld/movementdirection.hpp"
#include <osg/Vec3f>
#include <vector>
namespace MWWorld
{
class Ptr;
class ConstPtr;
}
namespace MWMechanics
{
struct Movement;
/// tests actor's proximity to a closed door by default
bool proximityToDoor(const MWWorld::Ptr& actor, float minDist);
2016-12-14 15:39:33 +00:00
/// Returns door pointer within range. No guarantee is given as to which one
2018-10-09 06:21:12 +00:00
/** \return Pointer to the door, or empty pointer if none exists **/
const MWWorld::Ptr getNearbyDoor(const MWWorld::Ptr& actor, float minDist);
bool isAreaOccupiedByOtherActor(const MWWorld::ConstPtr& actor, const osg::Vec3f& destination,
bool ignorePlayer = false, std::vector<MWWorld::Ptr>* occupyingActors = nullptr);
class ObstacleCheck
{
public:
ObstacleCheck();
// Clear the timers and set the state machine to default
void clear();
bool isEvading() const;
2018-08-18 15:26:00 +00:00
// Updates internal state, call each frame for moving actor
void update(const MWWorld::Ptr& actor, const osg::Vec3f& destination, float duration,
MWWorld::MovementDirectionFlags supportedMovementDirection);
// change direction to try to fix "stuck" actor
void takeEvasiveAction(Movement& actorMovement) const;
private:
enum class WalkState
{
Initial,
Norm,
CheckStuck,
Evade,
};
WalkState mWalkState = WalkState::Initial;
float mStateDuration = 0;
float mInitialDistance = 0;
std::size_t mEvadeDirectionIndex;
osg::Vec3f mPrev;
osg::Vec3f mDestination;
};
}
#endif