1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-14 15:40:18 +00:00
OpenMW/apps/openmw/mwmechanics/aiavoiddoor.hpp

46 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 "typedaipackage.hpp"
2016-06-17 23:07:16 +09:00
2014-05-13 13:07:27 -04:00
namespace MWMechanics
{
/// \brief AiPackage to have an actor avoid an opening door
2022-09-22 21:26:05 +03:00
/** 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>
{
2022-09-22 21:26:05 +03:00
public:
/// Avoid door until the door is fully open
explicit AiAvoidDoor(const MWWorld::ConstPtr& doorPtr);
2014-05-13 13:07:27 -04:00
2022-09-22 21:26:05 +03:00
bool execute(const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state,
float duration) override;
2014-05-13 13:07:27 -04:00
2022-09-22 21:26:05 +03:00
static constexpr AiPackageTypeId getTypeId() { return AiPackageTypeId::AvoidDoor; }
2022-09-22 21:26:05 +03:00
static constexpr Options makeDefaultOptions()
{
AiPackage::Options options;
options.mPriority = 2;
options.mCanCancel = false;
options.mShouldCancelPreviousAi = false;
return options;
}
2022-09-22 21:26:05 +03:00
private:
float mDuration;
const MWWorld::ConstPtr mDoorPtr;
osg::Vec3f mLastPos;
int mDirection;
2022-09-22 21:26:05 +03:00
bool isStuck(const osg::Vec3f& actorPos) const;
2022-09-22 21:26:05 +03:00
void adjustDirection();
2022-09-22 21:26:05 +03:00
float getAdjustedAngle() const;
};
}
#endif