1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 21:32:42 +00:00
OpenMW/apps/openmw/mwmechanics/aisequence.cpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

571 lines
18 KiB
C++
Raw Normal View History

#include "aisequence.hpp"
2022-02-12 23:50:41 +00:00
#include <algorithm>
2015-07-25 04:14:22 +02:00
#include <limits>
2018-08-14 23:05:43 +04:00
#include <components/debug/debuglog.hpp>
#include <components/esm3/aisequence.hpp>
2016-06-17 23:07:16 +09:00
#include "../mwworld/class.hpp"
#include "actorutil.hpp"
#include "aiactivate.hpp"
2013-09-25 18:01:36 +02:00
#include "aicombat.hpp"
2017-06-16 16:11:12 +04:00
#include "aicombataction.hpp"
2013-09-25 18:01:36 +02:00
#include "aiescort.hpp"
#include "aifollow.hpp"
#include "aipackage.hpp"
#include "aipursue.hpp"
2015-08-21 21:12:39 +12:00
#include "aitravel.hpp"
#include "aiwander.hpp"
2014-05-17 19:20:57 +04:00
namespace MWMechanics
{
void AiSequence::copy(const AiSequence& sequence)
{
2020-05-17 00:29:21 +02:00
for (const auto& package : sequence.mPackages)
mPackages.push_back(package->clone());
2022-02-12 23:50:41 +00:00
// We need to keep an AiWander storage, if present - it has a state machine.
// Not sure about another temporary storages
sequence.mAiState.copy<AiWanderStorage>(mAiState);
mNumCombatPackages = sequence.mNumCombatPackages;
mNumPursuitPackages = sequence.mNumPursuitPackages;
}
2014-09-26 17:12:48 +02:00
AiSequence::AiSequence()
: mDone(false)
, mLastAiPackage(AiPackageTypeId::None)
2022-09-22 21:26:05 +03:00
{
}
2014-05-17 19:20:57 +04:00
AiSequence::AiSequence(const AiSequence& sequence)
{
copy(sequence);
mDone = sequence.mDone;
2014-09-26 17:12:48 +02:00
mLastAiPackage = sequence.mLastAiPackage;
}
2014-06-12 23:27:04 +02:00
AiSequence& AiSequence::operator=(const AiSequence& sequence)
2022-09-22 21:26:05 +03:00
{
if (this != &sequence)
2022-09-22 21:26:05 +03:00
{
clear();
copy(sequence);
mDone = sequence.mDone;
2014-09-26 17:12:48 +02:00
mLastAiPackage = sequence.mLastAiPackage;
}
2014-05-17 19:20:57 +04:00
return *this;
}
2022-02-12 23:50:41 +00:00
AiSequence::~AiSequence()
{
clear();
2022-09-22 21:26:05 +03:00
}
2022-02-12 23:50:41 +00:00
void AiSequence::onPackageAdded(const AiPackage& package)
2022-09-22 21:26:05 +03:00
{
2022-02-12 23:50:41 +00:00
if (package.getTypeId() == AiPackageTypeId::Combat)
mNumCombatPackages++;
else if (package.getTypeId() == AiPackageTypeId::Pursue)
mNumPursuitPackages++;
assert(mNumCombatPackages >= 0);
assert(mNumPursuitPackages >= 0);
2022-09-22 21:26:05 +03:00
}
2022-02-12 23:50:41 +00:00
void AiSequence::onPackageRemoved(const AiPackage& package)
2022-09-22 21:26:05 +03:00
{
2022-02-12 23:50:41 +00:00
if (package.getTypeId() == AiPackageTypeId::Combat)
mNumCombatPackages--;
else if (package.getTypeId() == AiPackageTypeId::Pursue)
mNumPursuitPackages--;
assert(mNumCombatPackages >= 0);
assert(mNumPursuitPackages >= 0);
2022-09-22 21:26:05 +03:00
}
AiPackageTypeId AiSequence::getTypeId() const
2022-09-22 21:26:05 +03:00
{
if (mPackages.empty())
return AiPackageTypeId::None;
return mPackages.front()->getTypeId();
2022-09-22 21:26:05 +03:00
}
2020-05-17 00:29:21 +02:00
2016-02-16 19:17:04 +01:00
bool AiSequence::getCombatTarget(MWWorld::Ptr& targetActor) const
2022-09-22 21:26:05 +03:00
{
2016-02-16 19:17:04 +01:00
if (getTypeId() != AiPackageTypeId::Combat)
return false;
2014-05-16 00:03:48 +04:00
targetActor = mPackages.front()->getTarget();
2014-05-16 00:03:48 +04:00
return !targetActor.isEmpty();
}
bool AiSequence::getCombatTargets(std::vector<MWWorld::Ptr>& targetActors) const
2022-09-22 21:26:05 +03:00
{
for (auto it = mPackages.begin(); it != mPackages.end(); ++it)
2022-09-22 21:26:05 +03:00
{
if ((*it)->getTypeId() == MWMechanics::AiPackageTypeId::Combat)
targetActors.push_back((*it)->getTarget());
}
2022-02-12 23:50:41 +00:00
return !targetActors.empty();
2022-09-22 21:26:05 +03:00
}
2022-02-12 23:50:41 +00:00
AiPackages::iterator AiSequence::erase(AiPackages::iterator package)
2022-09-22 21:26:05 +03:00
{
2022-02-12 23:50:41 +00:00
// Not sure if manually terminated packages should trigger mDone, probably not?
auto& ptr = *package;
onPackageRemoved(*ptr);
2022-02-12 23:50:41 +00:00
return mPackages.erase(package);
}
bool AiSequence::isInCombat() const
{
return mNumCombatPackages > 0;
}
bool AiSequence::isInPursuit() const
{
2022-02-12 23:50:41 +00:00
return mNumPursuitPackages > 0;
2022-09-22 21:26:05 +03:00
}
2022-02-12 23:50:41 +00:00
2020-05-17 00:29:21 +02:00
bool AiSequence::isEngagedWithActor() const
{
if (!isInCombat())
return false;
2022-09-22 21:26:05 +03:00
for (auto it = mPackages.begin(); it != mPackages.end(); ++it)
{
if ((*it)->getTypeId() == AiPackageTypeId::Combat)
2022-09-22 21:26:05 +03:00
{
MWWorld::Ptr target2 = (*it)->getTarget();
if (!target2.isEmpty() && target2.getClass().isNpc())
2018-08-17 20:17:26 +01:00
return true;
2022-09-22 21:26:05 +03:00
}
}
2018-08-17 20:17:26 +01:00
return false;
}
bool AiSequence::hasPackage(AiPackageTypeId typeId) const
{
2022-02-12 23:50:41 +00:00
auto it = std::find_if(mPackages.begin(), mPackages.end(),
[typeId](const auto& package) { return package->getTypeId() == typeId; });
return it != mPackages.end();
}
2022-02-12 23:50:41 +00:00
2020-05-17 00:29:21 +02:00
bool AiSequence::isInCombat(const MWWorld::Ptr& actor) const
{
if (!isInCombat())
return false;
2022-09-22 21:26:05 +03:00
for (auto it = mPackages.begin(); it != mPackages.end(); ++it)
{
if ((*it)->getTypeId() == AiPackageTypeId::Combat)
2022-09-22 21:26:05 +03:00
{
2016-02-16 19:17:04 +01:00
if ((*it)->getTarget() == actor)
return true;
2022-09-22 21:26:05 +03:00
}
}
return false;
}
2022-02-12 23:50:41 +00:00
void AiSequence::removePackagesById(AiPackageTypeId id)
2014-01-14 16:22:50 +04:00
{
2022-02-12 23:50:41 +00:00
for (auto it = mPackages.begin(); it != mPackages.end();)
2016-03-10 20:38:14 +01:00
{
if ((*it)->getTypeId() == id)
2022-09-22 21:26:05 +03:00
{
2022-02-12 23:50:41 +00:00
it = erase(it);
2022-09-22 21:26:05 +03:00
}
else
++it;
2016-03-10 20:38:14 +01:00
}
2014-01-14 16:22:50 +04:00
}
2022-02-12 23:50:41 +00:00
void AiSequence::stopCombat()
{
removePackagesById(AiPackageTypeId::Combat);
}
void AiSequence::stopCombat(const std::vector<MWWorld::Ptr>& targets)
{
for (auto it = mPackages.begin(); it != mPackages.end();)
{
if ((*it)->getTypeId() == AiPackageTypeId::Combat
&& std::find(targets.begin(), targets.end(), (*it)->getTarget()) != targets.end())
2022-09-22 21:26:05 +03:00
{
2022-02-12 23:50:41 +00:00
it = erase(it);
2022-09-22 21:26:05 +03:00
}
else
++it;
}
}
2014-05-17 19:20:57 +04:00
void AiSequence::stopPursuit()
{
removePackagesById(AiPackageTypeId::Pursue);
}
bool AiSequence::isPackageDone() const
{
2022-02-12 23:50:41 +00:00
return mDone;
}
2014-05-16 00:03:48 +04:00
2022-02-12 23:50:41 +00:00
namespace
{
bool isActualAiPackage(AiPackageTypeId packageTypeId)
2022-09-22 21:26:05 +03:00
{
2022-02-12 23:50:41 +00:00
return (packageTypeId >= AiPackageTypeId::Wander && packageTypeId <= AiPackageTypeId::Activate);
2022-09-22 21:26:05 +03:00
}
2022-02-12 23:50:41 +00:00
}
2022-02-12 23:50:41 +00:00
void AiSequence::execute(
const MWWorld::Ptr& actor, CharacterController& characterController, float duration, bool outOfRange)
{
if (actor == getPlayer())
2022-09-22 21:26:05 +03:00
{
2022-02-12 23:50:41 +00:00
// Players don't use this.
return;
2022-09-22 21:26:05 +03:00
}
2014-05-16 00:03:48 +04:00
2022-02-12 23:50:41 +00:00
if (mPackages.empty())
2022-09-22 21:26:05 +03:00
{
2022-02-12 23:50:41 +00:00
mLastAiPackage = AiPackageTypeId::None;
return;
2022-09-22 21:26:05 +03:00
}
2014-05-16 00:03:48 +04:00
2022-02-12 23:50:41 +00:00
auto* package = mPackages.front().get();
if (!package->alwaysActive() && outOfRange)
2022-09-22 21:26:05 +03:00
return;
2017-06-16 16:11:12 +04:00
2022-02-12 23:50:41 +00:00
auto packageTypeId = package->getTypeId();
// workaround ai packages not being handled as in the vanilla engine
if (isActualAiPackage(packageTypeId))
mLastAiPackage = packageTypeId;
// if active package is combat one, choose nearest target
if (packageTypeId == AiPackageTypeId::Combat)
{
auto itActualCombat = mPackages.end();
2014-05-16 00:03:48 +04:00
2022-02-12 23:50:41 +00:00
float nearestDist = std::numeric_limits<float>::max();
osg::Vec3f vActorPos = actor.getRefData().getPosition().asVec3();
2014-05-18 23:15:22 +04:00
2022-02-12 23:50:41 +00:00
float bestRating = 0.f;
2022-09-22 21:26:05 +03:00
2022-02-12 23:50:41 +00:00
for (auto it = mPackages.begin(); it != mPackages.end();)
{
if ((*it)->getTypeId() != AiPackageTypeId::Combat)
break;
2017-06-16 16:11:12 +04:00
2022-02-12 23:50:41 +00:00
MWWorld::Ptr target = (*it)->getTarget();
2022-02-12 23:50:41 +00:00
// target disappeared (e.g. summoned creatures)
if (target.isEmpty())
2022-09-22 21:26:05 +03:00
{
2022-02-12 23:50:41 +00:00
it = erase(it);
2022-09-22 21:26:05 +03:00
}
else
{
2022-02-12 23:50:41 +00:00
float rating = MWMechanics::getBestActionRating(actor, target);
2022-02-12 23:50:41 +00:00
const ESM::Position& targetPos = target.getRefData().getPosition();
2014-05-16 00:03:48 +04:00
2022-02-12 23:50:41 +00:00
float distTo = (targetPos.asVec3() - vActorPos).length2();
2022-09-22 21:26:05 +03:00
2022-02-12 23:50:41 +00:00
// Small threshold for changing target
if (it == mPackages.begin())
distTo = std::max(0.f, distTo - 2500.f);
2022-09-22 21:26:05 +03:00
2022-02-12 23:50:41 +00:00
// if a target has higher priority than current target or has same priority but closer
if (rating > bestRating || ((distTo < nearestDist) && rating == bestRating))
{
nearestDist = distTo;
itActualCombat = it;
bestRating = rating;
2022-09-22 21:26:05 +03:00
}
++it;
2014-05-16 00:03:48 +04:00
}
}
2022-02-16 18:19:55 +02:00
if (mPackages.empty())
return;
2022-02-12 23:50:41 +00:00
if (nearestDist < std::numeric_limits<float>::max() && mPackages.begin() != itActualCombat)
{
assert(itActualCombat != mPackages.end());
// move combat package with nearest target to the front
std::rotate(mPackages.begin(), itActualCombat, std::next(itActualCombat));
}
2022-02-16 20:21:10 +02:00
package = mPackages.front().get();
2022-02-12 23:50:41 +00:00
packageTypeId = package->getTypeId();
}
try
{
2022-02-12 23:50:41 +00:00
if (package->execute(actor, characterController, mAiState, duration))
{
// Put repeating non-combat AI packages on the end of the stack so they can be used again
if (isActualAiPackage(packageTypeId) && package->getRepeat())
{
package->reset();
mPackages.push_back(package->clone());
}
// The active package is typically the first entry, this is however not always the case
// e.g. AiPursue executing a dialogue script that uses startCombat adds a combat package to the front
// due to the priority.
auto activePackageIt = std::find_if(
mPackages.begin(), mPackages.end(), [&](auto& entry) { return entry.get() == package; });
2020-05-17 00:29:21 +02:00
erase(activePackageIt);
2022-09-22 21:26:05 +03:00
2022-02-12 23:50:41 +00:00
if (isActualAiPackage(packageTypeId))
mDone = true;
2022-09-22 21:26:05 +03:00
}
else
{
2022-02-12 23:50:41 +00:00
mDone = false;
2022-09-22 21:26:05 +03:00
}
}
2022-02-12 23:50:41 +00:00
catch (std::exception& e)
{
2022-02-12 23:50:41 +00:00
Log(Debug::Error) << "Error during AiSequence::execute: " << e.what();
}
}
2022-09-22 21:26:05 +03:00
2022-02-12 23:50:41 +00:00
void AiSequence::clear()
{
mPackages.clear();
mNumCombatPackages = 0;
mNumPursuitPackages = 0;
}
void AiSequence::stack(const AiPackage& package, const MWWorld::Ptr& actor, bool cancelOther)
2018-06-01 09:30:44 +04:00
{
if (actor == getPlayer())
throw std::runtime_error("Can't add AI packages to player");
2022-09-22 21:26:05 +03:00
// Stop combat when a non-combat AI package is added
if (isActualAiPackage(package.getTypeId()))
stopCombat();
2022-09-22 21:26:05 +03:00
2018-06-01 09:30:44 +04:00
// We should return a wandering actor back after combat, casting or pursuit.
2018-06-01 12:05:10 +04:00
// The same thing for actors without AI packages.
// Also there is no point to stack return packages.
const auto currentTypeId = getTypeId();
const auto newTypeId = package.getTypeId();
if (currentTypeId <= MWMechanics::AiPackageTypeId::Wander
&& !hasPackage(MWMechanics::AiPackageTypeId::InternalTravel)
&& (newTypeId <= MWMechanics::AiPackageTypeId::Combat || newTypeId == MWMechanics::AiPackageTypeId::Pursue
|| newTypeId == MWMechanics::AiPackageTypeId::Cast))
2018-06-01 09:30:44 +04:00
{
osg::Vec3f dest;
if (currentTypeId == MWMechanics::AiPackageTypeId::Wander)
2022-09-22 21:26:05 +03:00
{
2020-05-17 00:29:21 +02:00
dest = getActivePackage().getDestination(actor);
2018-06-01 09:30:44 +04:00
}
else
{
dest = actor.getRefData().getPosition().asVec3();
}
MWMechanics::AiInternalTravel travelPackage(dest.x(), dest.y(), dest.z());
2018-06-01 09:30:44 +04:00
stack(travelPackage, actor, false);
}
// remove previous packages if required
if (cancelOther && package.shouldCancelPreviousAi())
{
for (auto it = mPackages.begin(); it != mPackages.end();)
2016-03-10 20:38:14 +01:00
{
if ((*it)->canCancel())
2022-09-22 21:26:05 +03:00
{
2022-02-12 23:50:41 +00:00
it = erase(it);
2022-09-22 21:26:05 +03:00
}
else
++it;
2016-03-10 20:38:14 +01:00
}
}
// insert new package in correct place depending on priority
2020-05-17 00:29:21 +02:00
for (auto it = mPackages.begin(); it != mPackages.end(); ++it)
{
2021-08-07 10:06:56 +02:00
// We should override current AiCast package, if we try to add a new one.
if ((*it)->getTypeId() == MWMechanics::AiPackageTypeId::Cast
&& package.getTypeId() == MWMechanics::AiPackageTypeId::Cast)
2022-09-22 21:26:05 +03:00
{
2021-08-07 10:06:56 +02:00
*it = package.clone();
2022-09-22 21:26:05 +03:00
return;
}
if ((*it)->getPriority() <= package.getPriority())
2022-09-22 21:26:05 +03:00
{
2022-02-12 23:50:41 +00:00
onPackageAdded(package);
2020-05-17 00:29:21 +02:00
mPackages.insert(it, package.clone());
2021-08-07 10:06:56 +02:00
return;
2022-09-22 21:26:05 +03:00
}
}
onPackageAdded(package);
mPackages.push_back(package.clone());
2022-09-22 21:26:05 +03:00
// Make sure that temporary storage is empty
if (cancelOther)
{
2022-02-12 23:50:41 +00:00
mAiState.moveIn(std::make_unique<AiCombatStorage>());
2020-05-17 00:29:21 +02:00
mAiState.moveIn(std::make_unique<AiFollowStorage>());
mAiState.moveIn(std::make_unique<AiWanderStorage>());
}
}
bool MWMechanics::AiSequence::isEmpty() const
{
return mPackages.empty();
}
2022-03-28 16:17:42 +03:00
const AiPackage& MWMechanics::AiSequence::getActivePackage() const
2014-01-12 14:01:54 +01:00
{
if (mPackages.empty())
throw std::runtime_error(std::string("No AI Package!"));
2020-05-17 00:29:21 +02:00
return *mPackages.front();
2014-01-12 14:01:54 +01:00
}
2014-05-17 19:20:57 +04:00
void AiSequence::fill(const ESM::AIPackageList& list)
{
for (const auto& esmPackage : list.mList)
{
2020-05-17 00:29:21 +02:00
std::unique_ptr<MWMechanics::AiPackage> package;
if (esmPackage.mType == ESM::AI_Wander)
2022-09-22 21:26:05 +03:00
{
ESM::AIWander data = esmPackage.mWander;
2014-06-12 23:27:04 +02:00
std::vector<unsigned char> idles;
idles.reserve(8);
for (int i = 0; i < 8; ++i)
idles.push_back(data.mIdle[i]);
2020-05-17 00:29:21 +02:00
package = std::make_unique<MWMechanics::AiWander>(
data.mDistance, data.mDuration, data.mTimeOfDay, idles, data.mShouldRepeat != 0);
2022-09-22 21:26:05 +03:00
}
else if (esmPackage.mType == ESM::AI_Escort)
2022-09-22 21:26:05 +03:00
{
ESM::AITarget data = esmPackage.mTarget;
package = std::make_unique<MWMechanics::AiEscort>(
data.mId.toStringView(), data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0);
2022-09-22 21:26:05 +03:00
}
else if (esmPackage.mType == ESM::AI_Travel)
2022-09-22 21:26:05 +03:00
{
ESM::AITravel data = esmPackage.mTravel;
package = std::make_unique<MWMechanics::AiTravel>(data.mX, data.mY, data.mZ, data.mShouldRepeat != 0);
}
else if (esmPackage.mType == ESM::AI_Activate)
{
ESM::AIActivate data = esmPackage.mActivate;
package = std::make_unique<MWMechanics::AiActivate>(data.mName.toStringView(), data.mShouldRepeat != 0);
}
else // if (esmPackage.mType == ESM::AI_Follow)
{
ESM::AITarget data = esmPackage.mTarget;
package = std::make_unique<MWMechanics::AiFollow>(
data.mId.toStringView(), data.mDuration, data.mX, data.mY, data.mZ, data.mShouldRepeat != 0);
}
2022-02-12 23:50:41 +00:00
onPackageAdded(*package);
2020-05-17 00:29:21 +02:00
mPackages.push_back(std::move(package));
2022-09-22 21:26:05 +03:00
}
}
2014-05-17 19:20:57 +04:00
2014-06-12 23:27:04 +02:00
void AiSequence::writeState(ESM::AiSequence::AiSequence& sequence) const
{
2020-05-17 00:29:21 +02:00
for (const auto& package : mPackages)
package->writeState(sequence);
2014-06-12 23:27:04 +02:00
sequence.mLastAiPackage = static_cast<int>(mLastAiPackage);
2022-09-22 21:26:05 +03:00
}
2014-06-12 23:27:04 +02:00
void AiSequence::readState(const ESM::AiSequence::AiSequence& sequence)
2014-06-12 23:27:04 +02:00
{
2022-05-29 13:24:48 +02:00
if (!sequence.mPackages.empty())
clear();
2022-09-22 21:26:05 +03:00
2022-05-29 13:24:48 +02:00
// Load packages
for (auto& container : sequence.mPackages)
2014-06-12 23:27:04 +02:00
{
std::unique_ptr<MWMechanics::AiPackage> package;
switch (container.mType)
2022-09-22 21:26:05 +03:00
{
2014-06-12 23:27:04 +02:00
case ESM::AiSequence::Ai_Wander:
2022-09-22 21:26:05 +03:00
{
2022-05-29 13:24:48 +02:00
package = std::make_unique<AiWander>(
&static_cast<const ESM::AiSequence::AiWander&>(*container.mPackage));
2022-09-22 21:26:05 +03:00
break;
}
2014-06-12 23:27:04 +02:00
case ESM::AiSequence::Ai_Travel:
2022-09-22 21:26:05 +03:00
{
const ESM::AiSequence::AiTravel& source
= static_cast<const ESM::AiSequence::AiTravel&>(*container.mPackage);
if (source.mHidden)
2022-05-29 13:24:48 +02:00
package = std::make_unique<AiInternalTravel>(&source);
2022-09-22 21:26:05 +03:00
else
2022-05-29 13:24:48 +02:00
package = std::make_unique<AiTravel>(&source);
2022-09-22 21:26:05 +03:00
break;
}
2014-06-12 23:27:04 +02:00
case ESM::AiSequence::Ai_Escort:
2022-09-22 21:26:05 +03:00
{
2022-05-29 13:24:48 +02:00
package = std::make_unique<AiEscort>(
&static_cast<const ESM::AiSequence::AiEscort&>(*container.mPackage));
2022-09-22 21:26:05 +03:00
break;
}
2014-06-12 23:27:04 +02:00
case ESM::AiSequence::Ai_Follow:
2022-09-22 21:26:05 +03:00
{
2022-05-29 13:24:48 +02:00
package = std::make_unique<AiFollow>(
&static_cast<const ESM::AiSequence::AiFollow&>(*container.mPackage));
2022-09-22 21:26:05 +03:00
break;
}
2014-06-12 23:27:04 +02:00
case ESM::AiSequence::Ai_Activate:
2022-09-22 21:26:05 +03:00
{
2022-05-29 13:24:48 +02:00
package = std::make_unique<AiActivate>(
&static_cast<const ESM::AiSequence::AiActivate&>(*container.mPackage));
2022-09-22 21:26:05 +03:00
break;
}
2014-06-12 23:27:04 +02:00
case ESM::AiSequence::Ai_Combat:
2022-09-22 21:26:05 +03:00
{
2022-05-29 13:24:48 +02:00
package = std::make_unique<AiCombat>(
&static_cast<const ESM::AiSequence::AiCombat&>(*container.mPackage));
2022-09-22 21:26:05 +03:00
break;
}
2014-06-12 23:27:04 +02:00
case ESM::AiSequence::Ai_Pursue:
2022-09-22 21:26:05 +03:00
{
2022-05-29 13:24:48 +02:00
package = std::make_unique<AiPursue>(
&static_cast<const ESM::AiSequence::AiPursue&>(*container.mPackage));
2014-06-12 23:27:04 +02:00
break;
}
default:
break;
}
2016-03-10 20:38:14 +01:00
if (!package.get())
continue;
2022-02-12 23:50:41 +00:00
onPackageAdded(*package);
2020-05-17 00:29:21 +02:00
mPackages.push_back(std::move(package));
2014-06-12 23:27:04 +02:00
}
2018-05-25 20:07:08 +04:00
mLastAiPackage = static_cast<AiPackageTypeId>(sequence.mLastAiPackage);
2014-06-12 23:27:04 +02:00
}
2018-06-27 12:48:34 +04:00
void AiSequence::fastForward(const MWWorld::Ptr& actor)
{
if (!mPackages.empty())
2022-09-22 21:26:05 +03:00
{
2020-05-17 00:29:21 +02:00
mPackages.front()->fastForward(actor, mAiState);
2022-09-22 21:26:05 +03:00
}
}
2014-05-17 19:20:57 +04:00
} // namespace MWMechanics