1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 22:23:51 +00:00

Derive all AI package classes from template to support CRTP features

This commit is contained in:
elsid 2020-05-17 22:10:36 +02:00
parent 61fbc1cd0b
commit 103188b61d
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
14 changed files with 37 additions and 31 deletions

View file

@ -1,7 +1,7 @@
#ifndef GAME_MWMECHANICS_AIACTIVATE_H
#define GAME_MWMECHANICS_AIACTIVATE_H
#include "aipackage.hpp"
#include "typedaipackage.hpp"
#include <string>
@ -19,7 +19,7 @@ namespace MWMechanics
{
/// \brief Causes actor to walk to activatable object and activate it
/** Will activate when close to object **/
class AiActivate final : public AiPackage
class AiActivate final : public TypedAiPackage<AiActivate>
{
public:
/// Constructor

View file

@ -16,7 +16,7 @@
static const int MAX_DIRECTIONS = 4;
MWMechanics::AiAvoidDoor::AiAvoidDoor(const MWWorld::ConstPtr& doorPtr)
: AiPackage(), mDuration(1), mDoorPtr(doorPtr), mDirection(0)
: mDuration(1), mDoorPtr(doorPtr), mDirection(0)
{
}

View file

@ -1,7 +1,7 @@
#ifndef GAME_MWMECHANICS_AIAVOIDDOOR_H
#define GAME_MWMECHANICS_AIAVOIDDOOR_H
#include "aipackage.hpp"
#include "typedaipackage.hpp"
#include <string>
@ -16,7 +16,7 @@ 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
**/
class AiAvoidDoor final : public AiPackage
class AiAvoidDoor final : public TypedAiPackage<AiAvoidDoor>
{
public:
/// Avoid door until the door is fully open

View file

@ -11,12 +11,6 @@
#include "movement.hpp"
#include "steering.hpp"
MWMechanics::AiBreathe::AiBreathe()
: AiPackage()
{
}
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();

View file

@ -1,17 +1,15 @@
#ifndef GAME_MWMECHANICS_AIBREATHE_H
#define GAME_MWMECHANICS_AIBREATHE_H
#include "aipackage.hpp"
#include "typedaipackage.hpp"
namespace MWMechanics
{
/// \brief AiPackage to have an actor resurface to breathe
// The AI will go up if lesser than half breath left
class AiBreathe final : public AiPackage
class AiBreathe final : public TypedAiPackage<AiBreathe>
{
public:
AiBreathe();
AiBreathe *clone() const final;
bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) final;

View file

@ -1,7 +1,7 @@
#ifndef GAME_MWMECHANICS_AICAST_H
#define GAME_MWMECHANICS_AICAST_H
#include "aipackage.hpp"
#include "typedaipackage.hpp"
namespace MWWorld
{
@ -11,7 +11,7 @@ namespace MWWorld
namespace MWMechanics
{
/// AiPackage which makes an actor to cast given spell.
class AiCast final : public AiPackage {
class AiCast final : public TypedAiPackage<AiCast> {
public:
AiCast(const std::string& targetId, const std::string& spellId, bool manualSpell=false);

View file

@ -1,7 +1,7 @@
#ifndef GAME_MWMECHANICS_AICOMBAT_H
#define GAME_MWMECHANICS_AICOMBAT_H
#include "aipackage.hpp"
#include "typedaipackage.hpp"
#include "../mwworld/cellstore.hpp" // for Doors
@ -91,7 +91,7 @@ namespace MWMechanics
};
/// \brief Causes the actor to fight another actor
class AiCombat final : public AiPackage
class AiCombat final : public TypedAiPackage<AiCombat>
{
public:
///Constructor

View file

@ -1,7 +1,7 @@
#ifndef GAME_MWMECHANICS_AIESCORT_H
#define GAME_MWMECHANICS_AIESCORT_H
#include "aipackage.hpp"
#include "typedaipackage.hpp"
#include <string>
@ -16,7 +16,7 @@ namespace AiSequence
namespace MWMechanics
{
/// \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:
/// Implementation of AiEscort

View file

@ -1,12 +1,12 @@
#ifndef GAME_MWMECHANICS_AIFACE_H
#define GAME_MWMECHANICS_AIFACE_H
#include "aipackage.hpp"
#include "typedaipackage.hpp"
namespace MWMechanics
{
/// AiPackage which makes an actor face a certain direction.
class AiFace final : public AiPackage {
class AiFace final : public TypedAiPackage<AiFace> {
public:
AiFace(float targetX, float targetY);

View file

@ -1,7 +1,7 @@
#ifndef GAME_MWMECHANICS_AIFOLLOW_H
#define GAME_MWMECHANICS_AIFOLLOW_H
#include "aipackage.hpp"
#include "typedaipackage.hpp"
#include <string>
@ -39,7 +39,7 @@ namespace MWMechanics
/// \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
**/
class AiFollow final : public AiPackage
class AiFollow final : public TypedAiPackage<AiFollow>
{
public:
AiFollow(const std::string &actorId, float duration, float x, float y, float z);

View file

@ -1,7 +1,7 @@
#ifndef GAME_MWMECHANICS_AIPURSUE_H
#define GAME_MWMECHANICS_AIPURSUE_H
#include "aipackage.hpp"
#include "typedaipackage.hpp"
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.
Note that while very similar to AiActivate, it will ONLY activate when evry close to target (Not also when the
path is completed). **/
class AiPursue final : public AiPackage
class AiPursue final : public TypedAiPackage<AiPursue>
{
public:
///Constructor

View file

@ -1,7 +1,7 @@
#ifndef GAME_MWMECHANICS_AITRAVEL_H
#define GAME_MWMECHANICS_AITRAVEL_H
#include "aipackage.hpp"
#include "typedaipackage.hpp"
namespace ESM
{
@ -14,7 +14,7 @@ namespace AiSequence
namespace MWMechanics
{
/// \brief Causes the AI to travel to the specified point
class AiTravel final : public AiPackage
class AiTravel final : public TypedAiPackage<AiTravel>
{
public:
/// Default constructor

View file

@ -1,7 +1,7 @@
#ifndef GAME_MWMECHANICS_AIWANDER_H
#define GAME_MWMECHANICS_AIWANDER_H
#include "aipackage.hpp"
#include "typedaipackage.hpp"
#include <vector>
@ -78,7 +78,7 @@ namespace MWMechanics
};
/// \brief Causes the Actor to wander within a specified range
class AiWander final : public AiPackage
class AiWander final : public TypedAiPackage<AiWander>
{
public:
/// Constructor

View 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