mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-05 17:45:34 +00:00
Single AI package clone definition
This commit is contained in:
parent
103188b61d
commit
8e0934cbd8
23 changed files with 4 additions and 75 deletions
|
@ -18,11 +18,6 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AiActivate *MWMechanics::AiActivate::clone() const
|
|
||||||
{
|
|
||||||
return new AiActivate(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AiActivate::execute(const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
bool AiActivate::execute(const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
||||||
{
|
{
|
||||||
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mObjectId, false); //The target to follow
|
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mObjectId, false); //The target to follow
|
||||||
|
|
|
@ -28,7 +28,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
AiActivate(const ESM::AiSequence::AiActivate* activate);
|
AiActivate(const ESM::AiSequence::AiActivate* activate);
|
||||||
|
|
||||||
AiActivate *clone() const final;
|
|
||||||
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
||||||
int getTypeId() const final;
|
int getTypeId() const final;
|
||||||
|
|
||||||
|
|
|
@ -72,11 +72,6 @@ bool MWMechanics::AiAvoidDoor::execute (const MWWorld::Ptr& actor, CharacterCont
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWMechanics::AiAvoidDoor *MWMechanics::AiAvoidDoor::clone() const
|
|
||||||
{
|
|
||||||
return new AiAvoidDoor(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
int MWMechanics::AiAvoidDoor::getTypeId() const
|
int MWMechanics::AiAvoidDoor::getTypeId() const
|
||||||
{
|
{
|
||||||
return TypeIdAvoidDoor;
|
return TypeIdAvoidDoor;
|
||||||
|
|
|
@ -22,8 +22,6 @@ namespace MWMechanics
|
||||||
/// Avoid door until the door is fully open
|
/// Avoid door until the door is fully open
|
||||||
AiAvoidDoor(const MWWorld::ConstPtr& doorPtr);
|
AiAvoidDoor(const MWWorld::ConstPtr& doorPtr);
|
||||||
|
|
||||||
AiAvoidDoor *clone() const final;
|
|
||||||
|
|
||||||
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
||||||
|
|
||||||
int getTypeId() const final;
|
int getTypeId() const final;
|
||||||
|
|
|
@ -32,11 +32,6 @@ bool MWMechanics::AiBreathe::execute (const MWWorld::Ptr& actor, CharacterContro
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWMechanics::AiBreathe *MWMechanics::AiBreathe::clone() const
|
|
||||||
{
|
|
||||||
return new AiBreathe(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
int MWMechanics::AiBreathe::getTypeId() const
|
int MWMechanics::AiBreathe::getTypeId() const
|
||||||
{
|
{
|
||||||
return TypeIdBreathe;
|
return TypeIdBreathe;
|
||||||
|
|
|
@ -10,8 +10,6 @@ namespace MWMechanics
|
||||||
class AiBreathe final : public TypedAiPackage<AiBreathe>
|
class AiBreathe final : public TypedAiPackage<AiBreathe>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AiBreathe *clone() const final;
|
|
||||||
|
|
||||||
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
||||||
|
|
||||||
int getTypeId() const final;
|
int getTypeId() const final;
|
||||||
|
|
|
@ -18,11 +18,6 @@ MWMechanics::AiCast::AiCast(const std::string& targetId, const std::string& spel
|
||||||
mDistance = action.getCombatRange(isRanged);
|
mDistance = action.getCombatRange(isRanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
MWMechanics::AiPackage *MWMechanics::AiCast::clone() const
|
|
||||||
{
|
|
||||||
return new AiCast(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MWMechanics::AiCast::execute(const MWWorld::Ptr& actor, MWMechanics::CharacterController& characterController, MWMechanics::AiState& state, float duration)
|
bool MWMechanics::AiCast::execute(const MWWorld::Ptr& actor, MWMechanics::CharacterController& characterController, MWMechanics::AiState& state, float duration)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr target;
|
MWWorld::Ptr target;
|
||||||
|
|
|
@ -15,8 +15,6 @@ namespace MWMechanics
|
||||||
public:
|
public:
|
||||||
AiCast(const std::string& targetId, const std::string& spellId, bool manualSpell=false);
|
AiCast(const std::string& targetId, const std::string& spellId, bool manualSpell=false);
|
||||||
|
|
||||||
AiPackage *clone() const final;
|
|
||||||
|
|
||||||
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
||||||
|
|
||||||
int getTypeId() const final;
|
int getTypeId() const final;
|
||||||
|
|
|
@ -421,11 +421,6 @@ namespace MWMechanics
|
||||||
return MWBase::Environment::get().getWorld()->searchPtrViaActorId(mTargetActorId);
|
return MWBase::Environment::get().getWorld()->searchPtrViaActorId(mTargetActorId);
|
||||||
}
|
}
|
||||||
|
|
||||||
AiCombat *MWMechanics::AiCombat::clone() const
|
|
||||||
{
|
|
||||||
return new AiCombat(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void AiCombat::writeState(ESM::AiSequence::AiSequence &sequence) const
|
void AiCombat::writeState(ESM::AiSequence::AiSequence &sequence) const
|
||||||
{
|
{
|
||||||
std::unique_ptr<ESM::AiSequence::AiCombat> combat(new ESM::AiSequence::AiCombat());
|
std::unique_ptr<ESM::AiSequence::AiCombat> combat(new ESM::AiSequence::AiCombat());
|
||||||
|
|
|
@ -102,8 +102,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
AiCombat *clone() const final;
|
|
||||||
|
|
||||||
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
||||||
|
|
||||||
int getTypeId() const final;
|
int getTypeId() const final;
|
||||||
|
|
|
@ -55,12 +55,6 @@ namespace MWMechanics
|
||||||
mDuration = 0;
|
mDuration = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AiEscort *MWMechanics::AiEscort::clone() const
|
|
||||||
{
|
|
||||||
return new AiEscort(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AiEscort::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
bool AiEscort::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
||||||
{
|
{
|
||||||
// If AiEscort has ran for as long or longer then the duration specified
|
// If AiEscort has ran for as long or longer then the duration specified
|
||||||
|
|
|
@ -30,8 +30,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
AiEscort(const ESM::AiSequence::AiEscort* escort);
|
AiEscort(const ESM::AiSequence::AiEscort* escort);
|
||||||
|
|
||||||
AiEscort *clone() const final;
|
|
||||||
|
|
||||||
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
||||||
|
|
||||||
int getTypeId() const final;
|
int getTypeId() const final;
|
||||||
|
|
|
@ -9,11 +9,6 @@ MWMechanics::AiFace::AiFace(float targetX, float targetY)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
MWMechanics::AiPackage *MWMechanics::AiFace::clone() const
|
|
||||||
{
|
|
||||||
return new AiFace(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MWMechanics::AiFace::execute(const MWWorld::Ptr& actor, MWMechanics::CharacterController& /*characterController*/, MWMechanics::AiState& /*state*/, float /*duration*/)
|
bool MWMechanics::AiFace::execute(const MWWorld::Ptr& actor, MWMechanics::CharacterController& /*characterController*/, MWMechanics::AiState& /*state*/, float /*duration*/)
|
||||||
{
|
{
|
||||||
osg::Vec3f dir = osg::Vec3f(mTargetX, mTargetY, 0) - actor.getRefData().getPosition().asVec3();
|
osg::Vec3f dir = osg::Vec3f(mTargetX, mTargetY, 0) - actor.getRefData().getPosition().asVec3();
|
||||||
|
|
|
@ -10,8 +10,6 @@ namespace MWMechanics
|
||||||
public:
|
public:
|
||||||
AiFace(float targetX, float targetY);
|
AiFace(float targetX, float targetY);
|
||||||
|
|
||||||
AiPackage *clone() const final;
|
|
||||||
|
|
||||||
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
||||||
|
|
||||||
int getTypeId() const final;
|
int getTypeId() const final;
|
||||||
|
|
|
@ -201,11 +201,6 @@ std::string AiFollow::getFollowedActor()
|
||||||
return mTargetActorRefId;
|
return mTargetActorRefId;
|
||||||
}
|
}
|
||||||
|
|
||||||
AiFollow *MWMechanics::AiFollow::clone() const
|
|
||||||
{
|
|
||||||
return new AiFollow(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
int AiFollow::getTypeId() const
|
int AiFollow::getTypeId() const
|
||||||
{
|
{
|
||||||
return TypeIdFollow;
|
return TypeIdFollow;
|
||||||
|
|
|
@ -57,8 +57,6 @@ namespace MWMechanics
|
||||||
bool followTargetThroughDoors() const final { return true; }
|
bool followTargetThroughDoors() const final { return true; }
|
||||||
bool shouldCancelPreviousAi() const final { return !mCommanded; }
|
bool shouldCancelPreviousAi() const final { return !mCommanded; }
|
||||||
|
|
||||||
AiFollow *clone() const final;
|
|
||||||
|
|
||||||
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
||||||
|
|
||||||
int getTypeId() const final;
|
int getTypeId() const final;
|
||||||
|
|
|
@ -27,10 +27,6 @@ AiPursue::AiPursue(const ESM::AiSequence::AiPursue *pursue)
|
||||||
mTargetActorId = pursue->mTargetActorId;
|
mTargetActorId = pursue->mTargetActorId;
|
||||||
}
|
}
|
||||||
|
|
||||||
AiPursue *MWMechanics::AiPursue::clone() const
|
|
||||||
{
|
|
||||||
return new AiPursue(*this);
|
|
||||||
}
|
|
||||||
bool AiPursue::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
bool AiPursue::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
||||||
{
|
{
|
||||||
if(actor.getClass().getCreatureStats(actor).isDead())
|
if(actor.getClass().getCreatureStats(actor).isDead())
|
||||||
|
|
|
@ -26,7 +26,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
AiPursue(const ESM::AiSequence::AiPursue* pursue);
|
AiPursue(const ESM::AiSequence::AiPursue* pursue);
|
||||||
|
|
||||||
AiPursue *clone() const final;
|
|
||||||
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
||||||
int getTypeId() const final;
|
int getTypeId() const final;
|
||||||
|
|
||||||
|
|
|
@ -36,11 +36,6 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AiTravel *MWMechanics::AiTravel::clone() const
|
|
||||||
{
|
|
||||||
return new AiTravel(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool AiTravel::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
bool AiTravel::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
||||||
{
|
{
|
||||||
auto& stats = actor.getClass().getCreatureStats(actor);
|
auto& stats = actor.getClass().getCreatureStats(actor);
|
||||||
|
|
|
@ -26,8 +26,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
void writeState(ESM::AiSequence::AiSequence &sequence) const final;
|
void writeState(ESM::AiSequence::AiSequence &sequence) const final;
|
||||||
|
|
||||||
AiTravel *clone() const final;
|
|
||||||
|
|
||||||
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
||||||
|
|
||||||
int getTypeId() const final;
|
int getTypeId() const final;
|
||||||
|
|
|
@ -115,11 +115,6 @@ namespace MWMechanics
|
||||||
mDuration = 0;
|
mDuration = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
AiPackage * MWMechanics::AiWander::clone() const
|
|
||||||
{
|
|
||||||
return new AiWander(*this);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* AiWander high level states (0.29.0). Not entirely accurate in some cases
|
* AiWander high level states (0.29.0). Not entirely accurate in some cases
|
||||||
* e.g. non-NPC actors do not greet and some creatures may be moving even in
|
* e.g. non-NPC actors do not greet and some creatures may be moving even in
|
||||||
|
|
|
@ -91,8 +91,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
AiWander (const ESM::AiSequence::AiWander* wander);
|
AiWander (const ESM::AiSequence::AiWander* wander);
|
||||||
|
|
||||||
AiPackage *clone() const final;
|
|
||||||
|
|
||||||
bool execute(const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
bool execute(const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;
|
||||||
|
|
||||||
int getTypeId() const final;
|
int getTypeId() const final;
|
||||||
|
|
|
@ -8,6 +8,10 @@ namespace MWMechanics
|
||||||
template <class T>
|
template <class T>
|
||||||
struct TypedAiPackage : public AiPackage
|
struct TypedAiPackage : public AiPackage
|
||||||
{
|
{
|
||||||
|
virtual TypedAiPackage<T> *clone() const override
|
||||||
|
{
|
||||||
|
return new T(*static_cast<const T*>(this));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue