1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00
OpenMW/apps/openmw/mwmechanics/aiavoiddoor.hpp

51 lines
1.3 KiB
C++
Raw Normal View History

2014-05-13 13:07:27 -04:00
#ifndef GAME_MWMECHANICS_AIAVOIDDOOR_H
#define GAME_MWMECHANICS_AIAVOIDDOOR_H
#include "aipackage.hpp"
2016-06-17 23:07:16 +09:00
2014-05-13 13:07:27 -04:00
#include <string>
2016-06-17 23:07:16 +09:00
#include <components/esm/defs.hpp>
2016-06-17 23:07:16 +09:00
2014-05-13 13:07:27 -04:00
#include "../mwworld/class.hpp"
2016-06-17 23:07:16 +09:00
#include "pathfinding.hpp"
2014-05-13 13:07:27 -04:00
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 AiPackage
{
2014-05-13 13:07:27 -04:00
public:
/// Avoid door until the door is fully open
2015-12-19 15:57:37 +01:00
AiAvoidDoor(const MWWorld::ConstPtr& doorPtr);
2014-05-13 13:07:27 -04:00
AiAvoidDoor *clone() const final;
2014-05-13 13:07:27 -04:00
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
2014-05-13 13:07:27 -04:00
int getTypeId() const final;
2014-05-13 13:07:27 -04:00
unsigned int getPriority() const final;
2014-06-12 23:27:04 +02:00
bool canCancel() const final { return false; }
bool shouldCancelPreviousAi() const final { return false; }
2014-05-13 13:07:27 -04:00
private:
float mDuration;
2015-12-19 15:57:37 +01:00
MWWorld::ConstPtr mDoorPtr;
osg::Vec3f mLastPos;
int mDirection;
bool isStuck(const osg::Vec3f& actorPos) const;
void adjustDirection();
float getAdjustedAngle() const;
};
}
#endif
2014-05-13 13:07:27 -04:00