2014-04-17 23:03:36 +00:00
|
|
|
#ifndef OPENMW_MECHANICS_OBSTACLE_H
|
2014-04-18 06:45:31 +00:00
|
|
|
#define OPENMW_MECHANICS_OBSTACLE_H
|
2014-04-17 23:03:36 +00:00
|
|
|
|
2023-07-05 21:58:04 +00:00
|
|
|
#include "apps/openmw/mwworld/movementdirection.hpp"
|
|
|
|
|
2019-08-17 15:57:28 +00:00
|
|
|
#include <osg/Vec3f>
|
|
|
|
|
2021-09-28 22:42:29 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2014-04-17 23:03:36 +00:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
|
|
|
class Ptr;
|
2021-09-28 22:42:29 +00:00
|
|
|
class ConstPtr;
|
2014-04-17 23:03:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWMechanics
|
|
|
|
{
|
2015-08-29 22:06:09 +00:00
|
|
|
struct Movement;
|
|
|
|
|
2014-05-13 07:58:32 +00:00
|
|
|
/// tests actor's proximity to a closed door by default
|
2017-06-14 08:44:18 +00:00
|
|
|
bool proximityToDoor(const MWWorld::Ptr& actor, float minDist);
|
2014-05-13 07:58:32 +00:00
|
|
|
|
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 **/
|
2017-12-01 06:07:02 +00:00
|
|
|
const MWWorld::Ptr getNearbyDoor(const MWWorld::Ptr& actor, float minDist);
|
2014-04-17 23:03:36 +00:00
|
|
|
|
2022-04-11 17:30:54 +00:00
|
|
|
bool isAreaOccupiedByOtherActor(const MWWorld::ConstPtr& actor, const osg::Vec3f& destination,
|
2021-09-28 22:42:29 +00:00
|
|
|
bool ignorePlayer = false, std::vector<MWWorld::Ptr>* occupyingActors = nullptr);
|
|
|
|
|
2014-04-17 23:03:36 +00:00
|
|
|
class ObstacleCheck
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
ObstacleCheck();
|
|
|
|
|
|
|
|
// Clear the timers and set the state machine to default
|
|
|
|
void clear();
|
|
|
|
|
2016-08-19 19:15:26 +00:00
|
|
|
bool isEvading() const;
|
2014-04-17 23:03:36 +00:00
|
|
|
|
2018-08-18 15:26:00 +00:00
|
|
|
// Updates internal state, call each frame for moving actor
|
2023-07-05 21:58:04 +00:00
|
|
|
void update(const MWWorld::Ptr& actor, const osg::Vec3f& destination, float duration,
|
|
|
|
MWWorld::MovementDirectionFlags supportedMovementDirection);
|
2014-04-17 23:03:36 +00:00
|
|
|
|
2015-08-29 22:06:09 +00:00
|
|
|
// change direction to try to fix "stuck" actor
|
2023-07-01 16:28:09 +00:00
|
|
|
void takeEvasiveAction(Movement& actorMovement) const;
|
2015-08-29 22:06:09 +00:00
|
|
|
|
2014-04-17 23:03:36 +00:00
|
|
|
private:
|
2020-01-20 21:08:25 +00:00
|
|
|
enum class WalkState
|
2014-04-17 23:03:36 +00:00
|
|
|
{
|
2020-01-20 21:08:25 +00:00
|
|
|
Initial,
|
|
|
|
Norm,
|
|
|
|
CheckStuck,
|
2023-07-01 16:28:09 +00:00
|
|
|
Evade,
|
2014-04-17 23:03:36 +00:00
|
|
|
};
|
|
|
|
|
2023-07-01 16:28:09 +00:00
|
|
|
WalkState mWalkState = WalkState::Initial;
|
|
|
|
float mStateDuration = 0;
|
2020-02-05 23:20:55 +00:00
|
|
|
float mInitialDistance = 0;
|
2023-07-01 16:28:09 +00:00
|
|
|
std::size_t mEvadeDirectionIndex;
|
|
|
|
osg::Vec3f mPrev;
|
|
|
|
osg::Vec3f mDestination;
|
2014-04-17 23:03:36 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|