mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 21:23:52 +00:00
Trim unneeded code
This commit is contained in:
parent
432723bfe6
commit
c57d177f1c
4 changed files with 4 additions and 19 deletions
|
@ -68,7 +68,6 @@ namespace MWMechanics
|
||||||
if (mRemainingDuration <= 0)
|
if (mRemainingDuration <= 0)
|
||||||
{
|
{
|
||||||
mRemainingDuration = mDuration;
|
mRemainingDuration = mDuration;
|
||||||
mStarted = false; // Reset to false so this package will build path again when repeating
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -100,7 +99,6 @@ namespace MWMechanics
|
||||||
if(pathTo(actor,point,duration)) //Returns true on path complete
|
if(pathTo(actor,point,duration)) //Returns true on path complete
|
||||||
{
|
{
|
||||||
mRemainingDuration = mDuration;
|
mRemainingDuration = mDuration;
|
||||||
mStarted = false; // Reset to false so this package will build path again when repeating
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
mMaxDist = 450;
|
mMaxDist = 450;
|
||||||
|
|
|
@ -51,7 +51,7 @@ bool MWMechanics::AiPackage::getRepeat() const
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
MWMechanics::AiPackage::AiPackage() : mTimer(0.26f), mStarted(false) { //mTimer starts at .26 to force initial pathbuild
|
MWMechanics::AiPackage::AiPackage() : mTimer(0.26f) { //mTimer starts at .26 to force initial pathbuild
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,13 +80,7 @@ bool MWMechanics::AiPackage::pathTo(const MWWorld::Ptr& actor, ESM::Pathgrid::Po
|
||||||
if(mTimer > 0.25)
|
if(mTimer > 0.25)
|
||||||
{
|
{
|
||||||
const ESM::Cell *cell = actor.getCell()->getCell();
|
const ESM::Cell *cell = actor.getCell()->getCell();
|
||||||
// If repeating an AI package (mStarted has been set to false again), build a new path if needed so package doesn't immediately end
|
if (doesPathNeedRecalc(dest, cell)) { //Only rebuild path if it's moved
|
||||||
if (!mStarted && distance(pos.pos, dest) > 10) {
|
|
||||||
mStarted = true;
|
|
||||||
mPathFinder.buildSyncedPath(pos.pos, dest, actor.getCell(), true); //Rebuild path, in case the target has moved
|
|
||||||
mPrevDest = dest;
|
|
||||||
}
|
|
||||||
else if (doesPathNeedRecalc(dest, cell)) { //Only rebuild path if it's moved
|
|
||||||
mPathFinder.buildSyncedPath(pos.pos, dest, actor.getCell(), true); //Rebuild path, in case the target has moved
|
mPathFinder.buildSyncedPath(pos.pos, dest, actor.getCell(), true); //Rebuild path, in case the target has moved
|
||||||
mPrevDest = dest;
|
mPrevDest = dest;
|
||||||
}
|
}
|
||||||
|
@ -146,7 +140,7 @@ void MWMechanics::AiPackage::evadeObstacles(const MWWorld::Ptr& actor, float dur
|
||||||
|
|
||||||
bool MWMechanics::AiPackage::doesPathNeedRecalc(ESM::Pathgrid::Point dest, const ESM::Cell *cell)
|
bool MWMechanics::AiPackage::doesPathNeedRecalc(ESM::Pathgrid::Point dest, const ESM::Cell *cell)
|
||||||
{
|
{
|
||||||
return distance(mPrevDest, dest) > 10;
|
return mPathFinder.getPath().empty() || (distance(mPrevDest, dest) > 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool MWMechanics::AiPackage::isTargetMagicallyHidden(const MWWorld::Ptr& target)
|
bool MWMechanics::AiPackage::isTargetMagicallyHidden(const MWWorld::Ptr& target)
|
||||||
|
|
|
@ -108,9 +108,6 @@ namespace MWMechanics
|
||||||
|
|
||||||
float mTimer;
|
float mTimer;
|
||||||
|
|
||||||
// Set to true once package starts actually being executed
|
|
||||||
bool mStarted;
|
|
||||||
|
|
||||||
ESM::Pathgrid::Point mPrevDest;
|
ESM::Pathgrid::Point mPrevDest;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -58,13 +58,9 @@ namespace MWMechanics
|
||||||
if (!isWithinMaxRange(osg::Vec3f(mX, mY, mZ), pos.asVec3()))
|
if (!isWithinMaxRange(osg::Vec3f(mX, mY, mZ), pos.asVec3()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!mStarted)
|
|
||||||
mStarted = true;
|
|
||||||
|
|
||||||
if (pathTo(actor, ESM::Pathgrid::Point(static_cast<int>(mX), static_cast<int>(mY), static_cast<int>(mZ)), duration))
|
if (pathTo(actor, ESM::Pathgrid::Point(static_cast<int>(mX), static_cast<int>(mY), static_cast<int>(mZ)), duration))
|
||||||
{
|
{
|
||||||
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
actor.getClass().getMovementSettings(actor).mPosition[1] = 0;
|
||||||
mStarted = false; // Reset to false so this package will build path again when repeating
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Reference in a new issue