mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-01 04:45:34 +00:00
Merge pull request #2859 from elsid/aipackage_single_clone
Single clone function definition for all AI packages
This commit is contained in:
commit
18bb6dd223
23 changed files with 41 additions and 106 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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef GAME_MWMECHANICS_AIACTIVATE_H
|
#ifndef GAME_MWMECHANICS_AIACTIVATE_H
|
||||||
#define GAME_MWMECHANICS_AIACTIVATE_H
|
#define GAME_MWMECHANICS_AIACTIVATE_H
|
||||||
|
|
||||||
#include "aipackage.hpp"
|
#include "typedaipackage.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
/// \brief Causes actor to walk to activatable object and activate it
|
/// \brief Causes actor to walk to activatable object and activate it
|
||||||
/** Will activate when close to object **/
|
/** Will activate when close to object **/
|
||||||
class AiActivate final : public AiPackage
|
class AiActivate final : public TypedAiPackage<AiActivate>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
static const int MAX_DIRECTIONS = 4;
|
static const int MAX_DIRECTIONS = 4;
|
||||||
|
|
||||||
MWMechanics::AiAvoidDoor::AiAvoidDoor(const MWWorld::ConstPtr& doorPtr)
|
MWMechanics::AiAvoidDoor::AiAvoidDoor(const MWWorld::ConstPtr& doorPtr)
|
||||||
: AiPackage(), mDuration(1), mDoorPtr(doorPtr), mDirection(0)
|
: mDuration(1), mDoorPtr(doorPtr), mDirection(0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef GAME_MWMECHANICS_AIAVOIDDOOR_H
|
#ifndef GAME_MWMECHANICS_AIAVOIDDOOR_H
|
||||||
#define GAME_MWMECHANICS_AIAVOIDDOOR_H
|
#define GAME_MWMECHANICS_AIAVOIDDOOR_H
|
||||||
|
|
||||||
#include "aipackage.hpp"
|
#include "typedaipackage.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -16,14 +16,12 @@ namespace MWMechanics
|
||||||
/// \brief AiPackage to have an actor avoid an opening door
|
/// \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
|
/** 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
|
class AiAvoidDoor final : public TypedAiPackage<AiAvoidDoor>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// 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;
|
||||||
|
|
|
@ -11,12 +11,6 @@
|
||||||
#include "movement.hpp"
|
#include "movement.hpp"
|
||||||
#include "steering.hpp"
|
#include "steering.hpp"
|
||||||
|
|
||||||
MWMechanics::AiBreathe::AiBreathe()
|
|
||||||
: AiPackage()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MWMechanics::AiBreathe::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
bool MWMechanics::AiBreathe::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
|
||||||
{
|
{
|
||||||
static const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fHoldBreathTime")->mValue.getFloat();
|
static const float fHoldBreathTime = MWBase::Environment::get().getWorld()->getStore().get<ESM::GameSetting>().find("fHoldBreathTime")->mValue.getFloat();
|
||||||
|
@ -38,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;
|
||||||
|
|
|
@ -1,19 +1,15 @@
|
||||||
#ifndef GAME_MWMECHANICS_AIBREATHE_H
|
#ifndef GAME_MWMECHANICS_AIBREATHE_H
|
||||||
#define GAME_MWMECHANICS_AIBREATHE_H
|
#define GAME_MWMECHANICS_AIBREATHE_H
|
||||||
|
|
||||||
#include "aipackage.hpp"
|
#include "typedaipackage.hpp"
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
/// \brief AiPackage to have an actor resurface to breathe
|
/// \brief AiPackage to have an actor resurface to breathe
|
||||||
// The AI will go up if lesser than half breath left
|
// The AI will go up if lesser than half breath left
|
||||||
class AiBreathe final : public AiPackage
|
class AiBreathe final : public TypedAiPackage<AiBreathe>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AiBreathe();
|
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef GAME_MWMECHANICS_AICAST_H
|
#ifndef GAME_MWMECHANICS_AICAST_H
|
||||||
#define GAME_MWMECHANICS_AICAST_H
|
#define GAME_MWMECHANICS_AICAST_H
|
||||||
|
|
||||||
#include "aipackage.hpp"
|
#include "typedaipackage.hpp"
|
||||||
|
|
||||||
namespace MWWorld
|
namespace MWWorld
|
||||||
{
|
{
|
||||||
|
@ -11,12 +11,10 @@ namespace MWWorld
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
/// AiPackage which makes an actor to cast given spell.
|
/// AiPackage which makes an actor to cast given spell.
|
||||||
class AiCast final : public AiPackage {
|
class AiCast final : public TypedAiPackage<AiCast> {
|
||||||
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());
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef GAME_MWMECHANICS_AICOMBAT_H
|
#ifndef GAME_MWMECHANICS_AICOMBAT_H
|
||||||
#define GAME_MWMECHANICS_AICOMBAT_H
|
#define GAME_MWMECHANICS_AICOMBAT_H
|
||||||
|
|
||||||
#include "aipackage.hpp"
|
#include "typedaipackage.hpp"
|
||||||
|
|
||||||
#include "../mwworld/cellstore.hpp" // for Doors
|
#include "../mwworld/cellstore.hpp" // for Doors
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ namespace MWMechanics
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Causes the actor to fight another actor
|
/// \brief Causes the actor to fight another actor
|
||||||
class AiCombat final : public AiPackage
|
class AiCombat final : public TypedAiPackage<AiCombat>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///Constructor
|
///Constructor
|
||||||
|
@ -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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef GAME_MWMECHANICS_AIESCORT_H
|
#ifndef GAME_MWMECHANICS_AIESCORT_H
|
||||||
#define GAME_MWMECHANICS_AIESCORT_H
|
#define GAME_MWMECHANICS_AIESCORT_H
|
||||||
|
|
||||||
#include "aipackage.hpp"
|
#include "typedaipackage.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ namespace AiSequence
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
/// \brief AI Package to have an NPC lead the player to a specific point
|
/// \brief AI Package to have an NPC lead the player to a specific point
|
||||||
class AiEscort final : public AiPackage
|
class AiEscort final : public TypedAiPackage<AiEscort>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Implementation of AiEscort
|
/// Implementation of AiEscort
|
||||||
|
@ -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();
|
||||||
|
|
|
@ -1,17 +1,15 @@
|
||||||
#ifndef GAME_MWMECHANICS_AIFACE_H
|
#ifndef GAME_MWMECHANICS_AIFACE_H
|
||||||
#define GAME_MWMECHANICS_AIFACE_H
|
#define GAME_MWMECHANICS_AIFACE_H
|
||||||
|
|
||||||
#include "aipackage.hpp"
|
#include "typedaipackage.hpp"
|
||||||
|
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
/// AiPackage which makes an actor face a certain direction.
|
/// AiPackage which makes an actor face a certain direction.
|
||||||
class AiFace final : public AiPackage {
|
class AiFace final : public TypedAiPackage<AiFace> {
|
||||||
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;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef GAME_MWMECHANICS_AIFOLLOW_H
|
#ifndef GAME_MWMECHANICS_AIFOLLOW_H
|
||||||
#define GAME_MWMECHANICS_AIFOLLOW_H
|
#define GAME_MWMECHANICS_AIFOLLOW_H
|
||||||
|
|
||||||
#include "aipackage.hpp"
|
#include "typedaipackage.hpp"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ namespace MWMechanics
|
||||||
/// \brief AiPackage for an actor to follow another actor/the PC
|
/// \brief AiPackage for an actor to follow another actor/the PC
|
||||||
/** The AI will follow the target until a condition (time, or position) are set. Both can be disabled to cause the actor to follow the other indefinitely
|
/** The AI will follow the target until a condition (time, or position) are set. Both can be disabled to cause the actor to follow the other indefinitely
|
||||||
**/
|
**/
|
||||||
class AiFollow final : public AiPackage
|
class AiFollow final : public TypedAiPackage<AiFollow>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AiFollow(const std::string &actorId, float duration, float x, float y, float z);
|
AiFollow(const std::string &actorId, float duration, float x, float y, float z);
|
||||||
|
@ -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())
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef GAME_MWMECHANICS_AIPURSUE_H
|
#ifndef GAME_MWMECHANICS_AIPURSUE_H
|
||||||
#define GAME_MWMECHANICS_AIPURSUE_H
|
#define GAME_MWMECHANICS_AIPURSUE_H
|
||||||
|
|
||||||
#include "aipackage.hpp"
|
#include "typedaipackage.hpp"
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ namespace MWMechanics
|
||||||
/** Used for arresting players. Causes the actor to run to the pursued actor and activate them, to arrest them.
|
/** Used for arresting players. Causes the actor to run to the pursued actor and activate them, to arrest them.
|
||||||
Note that while very similar to AiActivate, it will ONLY activate when evry close to target (Not also when the
|
Note that while very similar to AiActivate, it will ONLY activate when evry close to target (Not also when the
|
||||||
path is completed). **/
|
path is completed). **/
|
||||||
class AiPursue final : public AiPackage
|
class AiPursue final : public TypedAiPackage<AiPursue>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
///Constructor
|
///Constructor
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
|
|
@ -37,11 +37,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)
|
||||||
{
|
{
|
||||||
MWBase::MechanicsManager* mechMgr = MWBase::Environment::get().getMechanicsManager();
|
MWBase::MechanicsManager* mechMgr = MWBase::Environment::get().getMechanicsManager();
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef GAME_MWMECHANICS_AITRAVEL_H
|
#ifndef GAME_MWMECHANICS_AITRAVEL_H
|
||||||
#define GAME_MWMECHANICS_AITRAVEL_H
|
#define GAME_MWMECHANICS_AITRAVEL_H
|
||||||
|
|
||||||
#include "aipackage.hpp"
|
#include "typedaipackage.hpp"
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ namespace AiSequence
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
/// \brief Causes the AI to travel to the specified point
|
/// \brief Causes the AI to travel to the specified point
|
||||||
class AiTravel final : public AiPackage
|
class AiTravel final : public TypedAiPackage<AiTravel>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Default constructor
|
/// Default constructor
|
||||||
|
@ -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
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef GAME_MWMECHANICS_AIWANDER_H
|
#ifndef GAME_MWMECHANICS_AIWANDER_H
|
||||||
#define GAME_MWMECHANICS_AIWANDER_H
|
#define GAME_MWMECHANICS_AIWANDER_H
|
||||||
|
|
||||||
#include "aipackage.hpp"
|
#include "typedaipackage.hpp"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
@ -78,7 +78,7 @@ namespace MWMechanics
|
||||||
};
|
};
|
||||||
|
|
||||||
/// \brief Causes the Actor to wander within a specified range
|
/// \brief Causes the Actor to wander within a specified range
|
||||||
class AiWander final : public AiPackage
|
class AiWander final : public TypedAiPackage<AiWander>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
@ -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;
|
||||||
|
|
18
apps/openmw/mwmechanics/typedaipackage.hpp
Normal file
18
apps/openmw/mwmechanics/typedaipackage.hpp
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
#ifndef GAME_MWMECHANICS_TYPEDAIPACKAGE_H
|
||||||
|
#define GAME_MWMECHANICS_TYPEDAIPACKAGE_H
|
||||||
|
|
||||||
|
#include "aipackage.hpp"
|
||||||
|
|
||||||
|
namespace MWMechanics
|
||||||
|
{
|
||||||
|
template <class T>
|
||||||
|
struct TypedAiPackage : public AiPackage
|
||||||
|
{
|
||||||
|
virtual TypedAiPackage<T> *clone() const override
|
||||||
|
{
|
||||||
|
return new T(*static_cast<const T*>(this));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in a new issue