mirror of
https://github.com/OpenMW/openmw.git
synced 2025-01-22 12:23:53 +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,11 +165,14 @@ namespace MWMechanics
|
||||||
|
|
||||||
void Actors::addActor (const MWWorld::Ptr& ptr)
|
void Actors::addActor (const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
if (!MWWorld::Class::get (ptr).getCreatureStats (ptr).isDead())
|
if(!MWWorld::Class::get(ptr).getCreatureStats(ptr).isDead())
|
||||||
mActors.insert(std::make_pair(ptr, CharacterController(ptr)));
|
mActors.insert(std::make_pair(ptr, CharacterController(ptr, CharState_Idle)));
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
mActors.insert(std::make_pair(ptr, CharacterController(ptr, CharState_Dead)));
|
||||||
MWBase::Environment::get().getWorld()->playAnimationGroup (ptr, "death1", 2);
|
MWBase::Environment::get().getWorld()->playAnimationGroup (ptr, "death1", 2);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Actors::removeActor (const MWWorld::Ptr& ptr)
|
void Actors::removeActor (const MWWorld::Ptr& ptr)
|
||||||
{
|
{
|
||||||
|
@ -205,6 +208,9 @@ namespace MWMechanics
|
||||||
{
|
{
|
||||||
if(!MWWorld::Class::get(iter->first).getCreatureStats(iter->first).isDead())
|
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);
|
updateActor(iter->first, totalDuration);
|
||||||
if(iter->first.getTypeName() == typeid(ESM::NPC).name())
|
if(iter->first.getTypeName() == typeid(ESM::NPC).name())
|
||||||
updateNpc(iter->first, totalDuration, paused);
|
updateNpc(iter->first, totalDuration, paused);
|
||||||
|
@ -234,15 +240,20 @@ namespace MWMechanics
|
||||||
continue;
|
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);
|
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))
|
if(MWWorld::Class::get(iter->first).isEssential(iter->first))
|
||||||
MWBase::Environment::get().getWindowManager()->messageBox(
|
MWBase::Environment::get().getWindowManager()->messageBox(
|
||||||
"#{sKilledEssential}", std::vector<std::string>());
|
"#{sKilledEssential}", std::vector<std::string>());
|
||||||
|
|
||||||
mActors.erase(iter++);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,27 @@
|
||||||
namespace MWMechanics
|
namespace MWMechanics
|
||||||
{
|
{
|
||||||
|
|
||||||
|
enum CharacterState {
|
||||||
|
CharState_Idle,
|
||||||
|
CharState_Dead
|
||||||
|
};
|
||||||
|
|
||||||
class CharacterController
|
class CharacterController
|
||||||
{
|
{
|
||||||
MWWorld::Ptr mPtr;
|
MWWorld::Ptr mPtr;
|
||||||
|
|
||||||
|
CharacterState mState;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CharacterController(const MWWorld::Ptr &ptr)
|
CharacterController(const MWWorld::Ptr &ptr, CharacterState state)
|
||||||
: mPtr(ptr)
|
: mPtr(ptr), mState(state)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
|
CharacterState getState() const
|
||||||
|
{ return mState; }
|
||||||
|
|
||||||
|
void setState(CharacterState state)
|
||||||
|
{ mState = state; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue