1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 20:19:56 +00:00
openmw-tes3mp/apps/openmw/mwmechanics/aiavoiddoor.hpp
2020-05-20 20:15:29 +02:00

48 lines
1.3 KiB
C++

#ifndef GAME_MWMECHANICS_AIAVOIDDOOR_H
#define GAME_MWMECHANICS_AIAVOIDDOOR_H
#include "typedaipackage.hpp"
#include <string>
#include <components/esm/defs.hpp>
#include "../mwworld/class.hpp"
#include "pathfinding.hpp"
namespace MWMechanics
{
/// \brief AiPackage to have an actor avoid an opening door
/** The AI will retreat from the door until it has finished opening, walked far away from it, or one second has passed, in an attempt to avoid it
**/
class AiAvoidDoor final : public TypedAiPackage<AiAvoidDoor>
{
public:
/// Avoid door until the door is fully open
AiAvoidDoor(const MWWorld::ConstPtr& doorPtr);
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
int getTypeId() const final;
unsigned int getPriority() const final;
bool canCancel() const final { return false; }
bool shouldCancelPreviousAi() const final { return false; }
private:
float mDuration;
MWWorld::ConstPtr mDoorPtr;
osg::Vec3f mLastPos;
int mDirection;
bool isStuck(const osg::Vec3f& actorPos) const;
void adjustDirection();
float getAdjustedAngle() const;
};
}
#endif