Pass the CharacterController to AiPackage::execute

c++11
scrawl 10 years ago
parent a44be148d8
commit 59db9664ba

@ -1124,7 +1124,7 @@ namespace MWMechanics
{
CreatureStats &stats = iter->first.getClass().getCreatureStats(iter->first);
if (isConscious(iter->first))
stats.getAiSequence().execute(iter->first,iter->second->getAiState(), duration);
stats.getAiSequence().execute(iter->first, *iter->second->getCharacterController(), iter->second->getAiState(), duration);
if (stats.getAiSequence().isInCombat() && !stats.isDead()) hostilesCount++;
}

@ -21,7 +21,7 @@ MWMechanics::AiActivate *MWMechanics::AiActivate::clone() const
{
return new AiActivate(*this);
}
bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
bool MWMechanics::AiActivate::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
{
ESM::Position pos = actor.getRefData().getPosition(); //position of the actor
const MWWorld::Ptr target = MWBase::Environment::get().getWorld()->searchPtr(mObjectId, false); //The target to follow

@ -28,7 +28,7 @@ namespace MWMechanics
AiActivate(const ESM::AiSequence::AiActivate* activate);
virtual AiActivate *clone() const;
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
virtual int getTypeId() const;
virtual void writeState(ESM::AiSequence::AiSequence& sequence) const;

@ -17,7 +17,7 @@ MWMechanics::AiAvoidDoor::AiAvoidDoor(const MWWorld::Ptr& doorPtr)
}
bool MWMechanics::AiAvoidDoor::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
bool MWMechanics::AiAvoidDoor::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
{
ESM::Position pos = actor.getRefData().getPosition();

@ -20,7 +20,7 @@ namespace MWMechanics
virtual AiAvoidDoor *clone() const;
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
virtual int getTypeId() const;

@ -181,7 +181,7 @@ namespace MWMechanics
* Use the Observer Pattern to co-ordinate attacks, provide intelligence on
* whether the target was hit, etc.
*/
bool AiCombat::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
bool AiCombat::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
{
// get or create temporary storage
AiCombatStorage& storage = state.get<AiCombatStorage>();

@ -40,7 +40,7 @@ namespace MWMechanics
virtual AiCombat *clone() const;
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
virtual int getTypeId() const;

@ -63,7 +63,7 @@ namespace MWMechanics
return new AiEscort(*this);
}
bool AiEscort::execute (const MWWorld::Ptr& actor, 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
// and the duration is not infinite, the package is complete.

@ -33,7 +33,7 @@ namespace MWMechanics
virtual AiEscort *clone() const;
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
virtual int getTypeId() const;

@ -54,7 +54,7 @@ AiFollow::AiFollow(const ESM::AiSequence::AiFollow *follow)
}
bool AiFollow::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
bool AiFollow::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
{
MWWorld::Ptr target = getTarget();

@ -35,7 +35,7 @@ namespace MWMechanics
virtual AiFollow *clone() const;
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
virtual int getTypeId() const;

@ -25,6 +25,8 @@ namespace ESM
namespace MWMechanics
{
class CharacterController;
/// \brief Base class for AI packages
class AiPackage
{
@ -53,7 +55,7 @@ namespace MWMechanics
/// Updates and runs the package (Should run every frame)
/// \return Package completed?
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration) = 0;
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration) = 0;
/// Returns the TypeID of the AiPackage
/// \see enum TypeId

@ -30,7 +30,7 @@ AiPursue *MWMechanics::AiPursue::clone() const
{
return new AiPursue(*this);
}
bool AiPursue::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
bool AiPursue::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
{
if(actor.getClass().getCreatureStats(actor).isDead())
return true;

@ -31,7 +31,7 @@ namespace MWMechanics
AiPursue(const ESM::AiSequence::AiPursue* pursue);
virtual AiPursue *clone() const;
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
virtual int getTypeId() const;
MWWorld::Ptr getTarget() const;

@ -150,7 +150,7 @@ bool AiSequence::isPackageDone() const
return mDone;
}
void AiSequence::execute (const MWWorld::Ptr& actor, AiState& state,float duration)
void AiSequence::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
{
if(actor != MWBase::Environment::get().getWorld()->getPlayerPtr())
{
@ -211,7 +211,7 @@ void AiSequence::execute (const MWWorld::Ptr& actor, AiState& state,float durati
}
}
if (package->execute (actor,state,duration))
if (package->execute (actor,characterController,state,duration))
{
// To account for the rare case where AiPackage::execute() queued another AI package
// (e.g. AiPursue executing a dialogue script that uses startCombat)

@ -24,6 +24,7 @@ namespace ESM
namespace MWMechanics
{
class AiPackage;
class CharacterController;
template< class Base > class DerivedClassStorage;
struct AiTemporaryBase;
@ -95,7 +96,7 @@ namespace MWMechanics
void stopPursuit();
/// Execute current package, switching if needed.
void execute (const MWWorld::Ptr& actor, MWMechanics::AiState& state, float duration);
void execute (const MWWorld::Ptr& actor, CharacterController& characterController, MWMechanics::AiState& state, float duration);
/// Simulate the passing of time using the currently active AI package
void fastForward(const MWWorld::Ptr &actor, AiState &state);

@ -47,7 +47,7 @@ namespace MWMechanics
return new AiTravel(*this);
}
bool AiTravel::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
bool AiTravel::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
{
ESM::Position pos = actor.getRefData().getPosition();

@ -30,7 +30,7 @@ namespace MWMechanics
virtual AiTravel *clone() const;
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
virtual int getTypeId() const;

@ -168,7 +168,7 @@ namespace MWMechanics
* actors will enter combat (i.e. no longer wandering) and different pathfinding
* will kick in.
*/
bool AiWander::execute (const MWWorld::Ptr& actor, AiState& state, float duration)
bool AiWander::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
{
// get or create temporary storage
AiWanderStorage& storage = state.get<AiWanderStorage>();

@ -46,7 +46,7 @@ namespace MWMechanics
virtual AiPackage *clone() const;
virtual bool execute (const MWWorld::Ptr& actor, AiState& state, float duration);
virtual bool execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration);
virtual int getTypeId() const;

Loading…
Cancel
Save