2014-05-13 17:07:27 +00:00
|
|
|
#ifndef GAME_MWMECHANICS_AIAVOIDDOOR_H
|
|
|
|
#define GAME_MWMECHANICS_AIAVOIDDOOR_H
|
|
|
|
|
2020-05-17 20:10:36 +00:00
|
|
|
#include "typedaipackage.hpp"
|
2016-06-17 14:07:16 +00:00
|
|
|
|
2014-05-13 17:07:27 +00:00
|
|
|
#include "../mwworld/class.hpp"
|
|
|
|
|
2016-06-17 14:07:16 +00:00
|
|
|
#include "pathfinding.hpp"
|
|
|
|
|
2014-05-13 17:07:27 +00: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
|
2014-05-14 23:53:52 +00:00
|
|
|
**/
|
2020-05-17 20:10:36 +00:00
|
|
|
class AiAvoidDoor final : public TypedAiPackage<AiAvoidDoor>
|
2014-05-14 23:53:52 +00:00
|
|
|
{
|
2014-05-13 17:07:27 +00:00
|
|
|
public:
|
|
|
|
/// Avoid door until the door is fully open
|
2020-10-22 21:57:53 +00:00
|
|
|
explicit AiAvoidDoor(const MWWorld::ConstPtr& doorPtr);
|
2014-05-13 17:07:27 +00:00
|
|
|
|
2020-10-22 21:57:53 +00:00
|
|
|
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) override;
|
2014-05-13 17:07:27 +00:00
|
|
|
|
2020-05-16 19:52:16 +00:00
|
|
|
static constexpr AiPackageTypeId getTypeId() { return AiPackageTypeId::AvoidDoor; }
|
2020-05-16 19:08:39 +00:00
|
|
|
|
|
|
|
static constexpr Options makeDefaultOptions()
|
|
|
|
{
|
|
|
|
AiPackage::Options options;
|
|
|
|
options.mPriority = 2;
|
|
|
|
options.mCanCancel = false;
|
|
|
|
options.mShouldCancelPreviousAi = false;
|
|
|
|
return options;
|
|
|
|
}
|
2016-01-19 13:51:42 +00:00
|
|
|
|
2014-05-13 17:07:27 +00:00
|
|
|
private:
|
|
|
|
float mDuration;
|
2020-06-02 19:30:46 +00:00
|
|
|
const MWWorld::ConstPtr mDoorPtr;
|
2019-08-25 15:21:14 +00:00
|
|
|
osg::Vec3f mLastPos;
|
|
|
|
int mDirection;
|
|
|
|
|
|
|
|
bool isStuck(const osg::Vec3f& actorPos) const;
|
|
|
|
|
|
|
|
void adjustDirection();
|
|
|
|
|
|
|
|
float getAdjustedAngle() const;
|
2014-05-14 23:53:52 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|
2014-05-13 17:07:27 +00:00
|
|
|
|