1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-19 20:53:50 +00:00

get all actors following a given actor

This commit is contained in:
gus 2014-01-12 14:02:15 +01:00
parent 2446abe076
commit dd870e35db
5 changed files with 33 additions and 0 deletions

View file

@ -3,6 +3,7 @@
#include <string>
#include <vector>
#include <list>
namespace Ogre
{
@ -151,6 +152,9 @@ namespace MWBase
virtual void toggleAI() = 0;
virtual bool isAIActive() = 0;
///return the list of actors which are following the given actor (ie AiFollow is active and the target is the actor)
virtual std::list<MWWorld::Ptr> getActorsFollowing(const MWWorld::Ptr& actor) = 0;
};
}

View file

@ -27,6 +27,7 @@
#include "../mwbase/mechanicsmanager.hpp"
#include "aicombat.hpp"
#include "aifollow.hpp"
namespace
{
@ -877,4 +878,22 @@ namespace MWMechanics
return iter->second->isAnimPlaying(groupName);
return false;
}
std::list<MWWorld::Ptr> Actors::getActorsFollowing(const MWWorld::Ptr& actor)
{
std::list<MWWorld::Ptr> list;
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();iter++)
{
const MWWorld::Class &cls = MWWorld::Class::get(iter->first);
CreatureStats &stats = cls.getCreatureStats(iter->first);
if(stats.getAiSequence().getTypeId() == 3)
{
MWMechanics::AiFollow* package = static_cast<MWMechanics::AiFollow*>(stats.getAiSequence().getActivePackage());
if(package->getFollowedActor() == actor.getCellRef().mRefID)
list.push_front(iter->first);
}
}
return list;
}
}

View file

@ -91,6 +91,9 @@ namespace MWMechanics
void skipAnimation(const MWWorld::Ptr& ptr);
bool checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName);
std::list<MWWorld::Ptr> getActorsFollowing(const MWWorld::Ptr& actor);
///<return the list of actors which are following the given actor (ie AiFollow is active and the target is the actor)
private:
PtrControllerMap mActors;

View file

@ -918,4 +918,9 @@ namespace MWMechanics
return (roll >= target);
}
std::list<MWWorld::Ptr> MechanicsManager::getActorsFollowing(const MWWorld::Ptr& actor)
{
return mActors.getActorsFollowing(actor);
}
}

View file

@ -129,6 +129,8 @@ namespace MWMechanics
virtual void toggleAI();
virtual bool isAIActive();
virtual std::list<MWWorld::Ptr> getActorsFollowing(const MWWorld::Ptr& actor);
};
}