Use namespace block in aiactivate

pull/968/head
Allofich 9 years ago
parent f549b5fb7a
commit 4a38fb8650

@ -12,63 +12,67 @@
#include "steering.hpp" #include "steering.hpp"
#include "movement.hpp" #include "movement.hpp"
MWMechanics::AiActivate::AiActivate(const std::string &objectId) namespace MWMechanics
: mObjectId(objectId)
{ {
} AiActivate::AiActivate(const std::string &objectId)
MWMechanics::AiActivate *MWMechanics::AiActivate::clone() const : mObjectId(objectId)
{ {
return new AiActivate(*this); }
}
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
actor.getClass().getCreatureStats(actor).setDrawState(DrawState_Nothing); AiActivate *MWMechanics::AiActivate::clone() const
{
return new AiActivate(*this);
}
if(target == MWWorld::Ptr() || bool AiActivate::execute (const MWWorld::Ptr& actor, CharacterController& characterController, AiState& state, float duration)
!target.getRefData().getCount() || !target.getRefData().isEnabled() // Really we should be checking whether the target is currently registered {
// with the MechanicsManager 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
return true; //Target doesn't exist
//Set the target desition from the actor actor.getClass().getCreatureStats(actor).setDrawState(DrawState_Nothing);
ESM::Pathgrid::Point dest = target.getRefData().getPosition().pos;
if(distance(dest, pos.pos[0], pos.pos[1], pos.pos[2]) < 200) { //Stop when you get close if(target == MWWorld::Ptr() ||
actor.getClass().getMovementSettings(actor).mPosition[1] = 0; !target.getRefData().getCount() || !target.getRefData().isEnabled() // Really we should be checking whether the target is currently registered
MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(mObjectId,false); // with the MechanicsManager
)
return true; //Target doesn't exist
MWBase::Environment::get().getWorld()->activate(target, actor); //Set the target desition from the actor
ESM::Pathgrid::Point dest = target.getRefData().getPosition().pos;
return true; if(distance(dest, pos.pos[0], pos.pos[1], pos.pos[2]) < 200) { //Stop when you get close
} actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
else { MWWorld::Ptr target = MWBase::Environment::get().getWorld()->getPtr(mObjectId,false);
pathTo(actor, dest, duration); //Go to the destination
}
return false; MWBase::Environment::get().getWorld()->activate(target, actor);
}
int MWMechanics::AiActivate::getTypeId() const return true;
{ }
return TypeIdActivate; else {
} pathTo(actor, dest, duration); //Go to the destination
}
void MWMechanics::AiActivate::writeState(ESM::AiSequence::AiSequence &sequence) const return false;
{ }
std::auto_ptr<ESM::AiSequence::AiActivate> activate(new ESM::AiSequence::AiActivate());
activate->mTargetId = mObjectId;
ESM::AiSequence::AiPackageContainer package; int AiActivate::getTypeId() const
package.mType = ESM::AiSequence::Ai_Activate; {
package.mPackage = activate.release(); return TypeIdActivate;
sequence.mPackages.push_back(package); }
}
MWMechanics::AiActivate::AiActivate(const ESM::AiSequence::AiActivate *activate) void AiActivate::writeState(ESM::AiSequence::AiSequence &sequence) const
: mObjectId(activate->mTargetId) {
{ std::auto_ptr<ESM::AiSequence::AiActivate> activate(new ESM::AiSequence::AiActivate());
activate->mTargetId = mObjectId;
ESM::AiSequence::AiPackageContainer package;
package.mType = ESM::AiSequence::Ai_Activate;
package.mPackage = activate.release();
sequence.mPackages.push_back(package);
}
AiActivate::AiActivate(const ESM::AiSequence::AiActivate *activate)
: mObjectId(activate->mTargetId)
{
}
} }

Loading…
Cancel
Save