mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 06:35:30 +00:00
Store a pointer to the character controller in the map
This commit is contained in:
parent
a3c67389df
commit
7883087586
@ -172,16 +172,19 @@ namespace MWMechanics
|
||||
|
||||
MWRender::Animation *anim = MWBase::Environment::get().getWorld()->getAnimation(ptr);
|
||||
if(!MWWorld::Class::get(ptr).getCreatureStats(ptr).isDead())
|
||||
mActors.insert(std::make_pair(ptr, CharacterController(ptr, anim, CharState_Idle)));
|
||||
mActors.insert(std::make_pair(ptr, new CharacterController(ptr, anim, CharState_Idle)));
|
||||
else
|
||||
mActors.insert(std::make_pair(ptr, CharacterController(ptr, anim, CharState_Death1)));
|
||||
mActors.insert(std::make_pair(ptr, new CharacterController(ptr, anim, CharState_Death1)));
|
||||
}
|
||||
|
||||
void Actors::removeActor (const MWWorld::Ptr& ptr)
|
||||
{
|
||||
PtrControllerMap::iterator iter = mActors.find(ptr);
|
||||
if(iter != mActors.end())
|
||||
{
|
||||
delete iter->second;
|
||||
mActors.erase(iter);
|
||||
}
|
||||
}
|
||||
|
||||
void Actors::updateActor(const MWWorld::Ptr &old, const MWWorld::Ptr &ptr)
|
||||
@ -189,10 +192,10 @@ namespace MWMechanics
|
||||
PtrControllerMap::iterator iter = mActors.find(old);
|
||||
if(iter != mActors.end())
|
||||
{
|
||||
CharacterController ctrl = iter->second;
|
||||
CharacterController *ctrl = iter->second;
|
||||
mActors.erase(iter);
|
||||
|
||||
ctrl.updatePtr(ptr);
|
||||
ctrl->updatePtr(ptr);
|
||||
mActors.insert(std::make_pair(ptr, ctrl));
|
||||
}
|
||||
}
|
||||
@ -203,7 +206,10 @@ namespace MWMechanics
|
||||
while(iter != mActors.end())
|
||||
{
|
||||
if(iter->first.getCell()==cellStore)
|
||||
{
|
||||
delete iter->second;
|
||||
mActors.erase(iter++);
|
||||
}
|
||||
else
|
||||
++iter;
|
||||
}
|
||||
@ -222,8 +228,8 @@ namespace MWMechanics
|
||||
{
|
||||
if(!MWWorld::Class::get(iter->first).getCreatureStats(iter->first).isDead())
|
||||
{
|
||||
if(iter->second.getState() >= CharState_Death1)
|
||||
iter->second.setState(CharState_Idle);
|
||||
if(iter->second->getState() >= CharState_Death1)
|
||||
iter->second->setState(CharState_Idle);
|
||||
|
||||
updateActor(iter->first, totalDuration);
|
||||
if(iter->first.getTypeName() == typeid(ESM::NPC).name())
|
||||
@ -250,10 +256,10 @@ namespace MWMechanics
|
||||
continue;
|
||||
}
|
||||
|
||||
if(iter->second.getState() >= CharState_Death1)
|
||||
if(iter->second->getState() >= CharState_Death1)
|
||||
continue;
|
||||
|
||||
iter->second.setState(CharState_Death1);
|
||||
iter->second->setState(CharState_Death1);
|
||||
|
||||
++mDeathCount[MWWorld::Class::get(iter->first).getId(iter->first)];
|
||||
|
||||
@ -270,7 +276,7 @@ namespace MWMechanics
|
||||
for(PtrControllerMap::iterator iter(mActors.begin());iter != mActors.end();++iter)
|
||||
{
|
||||
Movement movement;
|
||||
iter->second.update(duration, movement);
|
||||
iter->second->update(duration, movement);
|
||||
mMovement.push_back(std::make_pair(iter->first, movement));
|
||||
}
|
||||
MWBase::Environment::get().getWorld()->doPhysics(mMovement, duration);
|
||||
@ -297,27 +303,27 @@ namespace MWMechanics
|
||||
{
|
||||
PtrControllerMap::iterator iter = mActors.find(ptr);
|
||||
if(iter != mActors.end())
|
||||
iter->second.forceStateUpdate();
|
||||
iter->second->forceStateUpdate();
|
||||
}
|
||||
|
||||
void Actors::playAnimationGroup(const MWWorld::Ptr& ptr, const std::string& groupName, int mode, int number)
|
||||
{
|
||||
PtrControllerMap::iterator iter = mActors.find(ptr);
|
||||
if(iter != mActors.end())
|
||||
iter->second.playGroup(groupName, mode, number);
|
||||
iter->second->playGroup(groupName, mode, number);
|
||||
}
|
||||
void Actors::skipAnimation(const MWWorld::Ptr& ptr)
|
||||
{
|
||||
PtrControllerMap::iterator iter = mActors.find(ptr);
|
||||
if(iter != mActors.end())
|
||||
iter->second.skipAnim();
|
||||
iter->second->skipAnim();
|
||||
}
|
||||
|
||||
bool Actors::checkAnimationPlaying(const MWWorld::Ptr& ptr, const std::string& groupName)
|
||||
{
|
||||
PtrControllerMap::iterator iter = mActors.find(ptr);
|
||||
if(iter != mActors.end())
|
||||
return iter->second.isAnimPlaying(groupName);
|
||||
return iter->second->isAnimPlaying(groupName);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -25,7 +25,7 @@ namespace MWMechanics
|
||||
{
|
||||
class Actors
|
||||
{
|
||||
typedef std::map<MWWorld::Ptr,CharacterController> PtrControllerMap;
|
||||
typedef std::map<MWWorld::Ptr,CharacterController*> PtrControllerMap;
|
||||
PtrControllerMap mActors;
|
||||
|
||||
MWWorld::PtrMovementList mMovement;
|
||||
|
Loading…
x
Reference in New Issue
Block a user