mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 22:15:32 +00:00
extract function isPackageFinished().
This commit is contained in:
parent
ad0d807103
commit
5e519ef550
2 changed files with 27 additions and 14 deletions
|
@ -211,21 +211,9 @@ namespace MWMechanics
|
||||||
bool AiWander::reactionTimeActions(const MWWorld::Ptr& actor, AiWanderStorage& storage,
|
bool AiWander::reactionTimeActions(const MWWorld::Ptr& actor, AiWanderStorage& storage,
|
||||||
const MWWorld::CellStore*& currentCell, bool cellChange, ESM::Position& pos)
|
const MWWorld::CellStore*& currentCell, bool cellChange, ESM::Position& pos)
|
||||||
{
|
{
|
||||||
if(mDuration)
|
if (isPackageCompleted(actor, storage))
|
||||||
{
|
{
|
||||||
// End package if duration is complete or mid-night hits:
|
return true;
|
||||||
MWWorld::TimeStamp currentTime = MWBase::Environment::get().getWorld()->getTimeStamp();
|
|
||||||
if((currentTime.getHour() >= mStartTime.getHour() + mDuration) ||
|
|
||||||
(int(currentTime.getHour()) == 0 && currentTime.getDay() != mStartTime.getDay()))
|
|
||||||
{
|
|
||||||
if(!mRepeat)
|
|
||||||
{
|
|
||||||
stopWalking(actor, storage);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
mStartTime = currentTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialization to discover & store allowed node points for this actor.
|
// Initialization to discover & store allowed node points for this actor.
|
||||||
|
@ -286,6 +274,30 @@ namespace MWMechanics
|
||||||
return false; // AiWander package not yet completed
|
return false; // AiWander package not yet completed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AiWander::isPackageCompleted(const MWWorld::Ptr& actor, AiWanderStorage& storage)
|
||||||
|
{
|
||||||
|
if (mDuration)
|
||||||
|
{
|
||||||
|
// End package if duration is complete or mid-night hits:
|
||||||
|
MWWorld::TimeStamp currentTime = MWBase::Environment::get().getWorld()->getTimeStamp();
|
||||||
|
if ((currentTime.getHour() >= mStartTime.getHour() + mDuration) ||
|
||||||
|
(int(currentTime.getHour()) == 0 && currentTime.getDay() != mStartTime.getDay()))
|
||||||
|
{
|
||||||
|
if (!mRepeat)
|
||||||
|
{
|
||||||
|
stopWalking(actor, storage);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mStartTime = currentTime;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// if get here, not yet completed
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void AiWander::doPerFrameActionsForState(const MWWorld::Ptr& actor, float duration, AiWanderStorage& storage, ESM::Position& pos)
|
void AiWander::doPerFrameActionsForState(const MWWorld::Ptr& actor, float duration, AiWanderStorage& storage, ESM::Position& pos)
|
||||||
{
|
{
|
||||||
switch (storage.mState)
|
switch (storage.mState)
|
||||||
|
|
|
@ -89,6 +89,7 @@ namespace MWMechanics
|
||||||
void onChooseActionStatePerFrameActions(const MWWorld::Ptr& actor, AiWanderStorage& storage);
|
void onChooseActionStatePerFrameActions(const MWWorld::Ptr& actor, AiWanderStorage& storage);
|
||||||
bool reactionTimeActions(const MWWorld::Ptr& actor, AiWanderStorage& storage,
|
bool reactionTimeActions(const MWWorld::Ptr& actor, AiWanderStorage& storage,
|
||||||
const MWWorld::CellStore*& currentCell, bool cellChange, ESM::Position& pos);
|
const MWWorld::CellStore*& currentCell, bool cellChange, ESM::Position& pos);
|
||||||
|
bool isPackageCompleted(const MWWorld::Ptr& actor, AiWanderStorage& storage);
|
||||||
|
|
||||||
int mDistance; // how far the actor can wander from the spawn point
|
int mDistance; // how far the actor can wander from the spawn point
|
||||||
int mDuration;
|
int mDuration;
|
||||||
|
|
Loading…
Reference in a new issue