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:
parent
2446abe076
commit
dd870e35db
5 changed files with 33 additions and 0 deletions
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -918,4 +918,9 @@ namespace MWMechanics
|
|||
|
||||
return (roll >= target);
|
||||
}
|
||||
|
||||
std::list<MWWorld::Ptr> MechanicsManager::getActorsFollowing(const MWWorld::Ptr& actor)
|
||||
{
|
||||
return mActors.getActorsFollowing(actor);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -129,6 +129,8 @@ namespace MWMechanics
|
|||
|
||||
virtual void toggleAI();
|
||||
virtual bool isAIActive();
|
||||
|
||||
virtual std::list<MWWorld::Ptr> getActorsFollowing(const MWWorld::Ptr& actor);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue