mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 07:53:52 +00:00
Keep track of the state in the character controller, and don't remove dead actors from the map
This commit is contained in:
parent
4890d901a2
commit
94b24f07e1
2 changed files with 31 additions and 7 deletions
|
@ -165,10 +165,13 @@ namespace MWMechanics
|
|||
|
||||
void Actors::addActor (const MWWorld::Ptr& ptr)
|
||||
{
|
||||
if (!MWWorld::Class::get (ptr).getCreatureStats (ptr).isDead())
|
||||
mActors.insert(std::make_pair(ptr, CharacterController(ptr)));
|
||||
if(!MWWorld::Class::get(ptr).getCreatureStats(ptr).isDead())
|
||||
mActors.insert(std::make_pair(ptr, CharacterController(ptr, CharState_Idle)));
|
||||
else
|
||||
{
|
||||
mActors.insert(std::make_pair(ptr, CharacterController(ptr, CharState_Dead)));
|
||||
MWBase::Environment::get().getWorld()->playAnimationGroup (ptr, "death1", 2);
|
||||
}
|
||||
}
|
||||
|
||||
void Actors::removeActor (const MWWorld::Ptr& ptr)
|
||||
|
@ -205,6 +208,9 @@ namespace MWMechanics
|
|||
{
|
||||
if(!MWWorld::Class::get(iter->first).getCreatureStats(iter->first).isDead())
|
||||
{
|
||||
if(iter->second.getState() == CharState_Dead)
|
||||
iter->second.setState(CharState_Idle);
|
||||
|
||||
updateActor(iter->first, totalDuration);
|
||||
if(iter->first.getTypeName() == typeid(ESM::NPC).name())
|
||||
updateNpc(iter->first, totalDuration, paused);
|
||||
|
@ -234,15 +240,20 @@ namespace MWMechanics
|
|||
continue;
|
||||
}
|
||||
|
||||
++mDeathCount[MWWorld::Class::get(iter->first).getId(iter->first)];
|
||||
if(iter->second.getState() == CharState_Dead)
|
||||
{
|
||||
iter++;
|
||||
continue;
|
||||
}
|
||||
|
||||
iter->second.setState(CharState_Dead);
|
||||
MWBase::Environment::get().getWorld()->playAnimationGroup(iter->first, "death1", 0);
|
||||
|
||||
++mDeathCount[MWWorld::Class::get(iter->first).getId(iter->first)];
|
||||
|
||||
if(MWWorld::Class::get(iter->first).isEssential(iter->first))
|
||||
MWBase::Environment::get().getWindowManager()->messageBox(
|
||||
"#{sKilledEssential}", std::vector<std::string>());
|
||||
|
||||
mActors.erase(iter++);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,14 +6,27 @@
|
|||
namespace MWMechanics
|
||||
{
|
||||
|
||||
enum CharacterState {
|
||||
CharState_Idle,
|
||||
CharState_Dead
|
||||
};
|
||||
|
||||
class CharacterController
|
||||
{
|
||||
MWWorld::Ptr mPtr;
|
||||
|
||||
CharacterState mState;
|
||||
|
||||
public:
|
||||
CharacterController(const MWWorld::Ptr &ptr)
|
||||
: mPtr(ptr)
|
||||
CharacterController(const MWWorld::Ptr &ptr, CharacterState state)
|
||||
: mPtr(ptr), mState(state)
|
||||
{ }
|
||||
|
||||
CharacterState getState() const
|
||||
{ return mState; }
|
||||
|
||||
void setState(CharacterState state)
|
||||
{ mState = state; }
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue