mirror of
https://github.com/TES3MP/TES3MP.git
synced 2025-09-27 23:21:20 -04:00
Derive all AI package classes from template to support CRTP features
This commit is contained in:
parent
61fbc1cd0b
commit
103188b61d
@ -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
|
||||||
|
@ -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)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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,7 +16,7 @@ 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
|
||||||
|
@ -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();
|
||||||
|
@ -1,17 +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;
|
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;
|
||||||
|
@ -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,7 +11,7 @@ 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);
|
||||||
|
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#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);
|
||||||
|
|
||||||
|
@ -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);
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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
|
||||||
|
14
apps/openmw/mwmechanics/typedaipackage.hpp
Normal file
14
apps/openmw/mwmechanics/typedaipackage.hpp
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#ifndef GAME_MWMECHANICS_TYPEDAIPACKAGE_H
|
||||||
|
#define GAME_MWMECHANICS_TYPEDAIPACKAGE_H
|
||||||
|
|
||||||
|
#include "aipackage.hpp"
|
||||||
|
|
||||||
|
namespace MWMechanics
|
||||||
|
{
|
||||||
|
template <class T>
|
||||||
|
struct TypedAiPackage : public AiPackage
|
||||||
|
{
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user