1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 15:35:23 +00:00
OpenMW/apps/openmw/mwmechanics/aiescort.hpp
elsid 45db56b382
Rework fixed string
* Avoid inheritance.
* Define equality operators out of the class definition.
* Replace toString with toStringView where it doesn't make sense to create a string.
2022-01-28 18:39:09 +01:00

66 lines
2.2 KiB
C++

#ifndef GAME_MWMECHANICS_AIESCORT_H
#define GAME_MWMECHANICS_AIESCORT_H
#include "typedaipackage.hpp"
#include <string>
#include <string_view>
namespace ESM
{
namespace AiSequence
{
struct AiEscort;
}
}
namespace MWMechanics
{
/// \brief AI Package to have an NPC lead the player to a specific point
class AiEscort final : public TypedAiPackage<AiEscort>
{
public:
/// Implementation of AiEscort
/** The Actor will escort the specified actor to the world position x, y, z until they reach their position, or they run out of time
\implement AiEscort **/
AiEscort(std::string_view actorId, int duration, float x, float y, float z, bool repeat);
/// Implementation of AiEscortCell
/** The Actor will escort the specified actor to the cell position x, y, z until they reach their position, or they run out of time
\implement AiEscortCell **/
AiEscort(std::string_view actorId, std::string_view cellId, int duration, float x, float y, float z, bool repeat);
AiEscort(const ESM::AiSequence::AiEscort* escort);
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) override;
static constexpr AiPackageTypeId getTypeId() { return AiPackageTypeId::Escort; }
static constexpr Options makeDefaultOptions()
{
AiPackage::Options options;
options.mUseVariableSpeed = true;
options.mSideWithTarget = true;
return options;
}
void writeState(ESM::AiSequence::AiSequence &sequence) const override;
void fastForward(const MWWorld::Ptr& actor, AiState& state) override;
osg::Vec3f getDestination() const override { return osg::Vec3f(mX, mY, mZ); }
private:
const std::string mCellId;
const float mX;
const float mY;
const float mZ;
float mMaxDist = 450;
const float mDuration; // In hours
float mRemainingDuration; // In hours
const int mCellX;
const int mCellY;
};
}
#endif