implemented handling of disabled actors

actorid
Marc Zinnschlag 15 years ago committed by apreiml
parent 362605860b
commit fef6fc1340

@ -45,6 +45,11 @@ namespace MWMechanics
mActors.insert (ptr);
}
void MechanicsManager::removeActor (const MWWorld::Ptr& ptr)
{
mActors.erase (ptr);
}
void MechanicsManager::dropActors (const MWWorld::Ptr::CellStore *cellStore)
{
std::set<MWWorld::Ptr>::iterator iter = mActors.begin();

@ -31,7 +31,10 @@ namespace MWMechanics
void addActor (const MWWorld::Ptr& ptr);
///< Register an actor for stats management
void removeActor (const MWWorld::Ptr& ptr);
///< Deregister an actor for stats management
void dropActors (const MWWorld::Ptr::CellStore *cellStore);
///< Deregister all actors in the given cell.
};

@ -37,6 +37,12 @@ namespace MWWorld
return mPtr.empty();
}
const std::type_info& getType()
{
assert (!mPtr.empty());
return mPtr.type();
}
template<typename T>
Ptr (ESMS::LiveCellRef<T, RefData> *liveCellRef, CellStore *cell)
{

@ -275,6 +275,13 @@ namespace MWWorld
if (MWRender::CellRender *render = searchRender (reference.getCell()))
{
render->enable (reference.getRefData().getHandle());
if (mActiveCells.find (reference.getCell())!=mActiveCells.end() &&
(reference.getType()==typeid (ESMS::LiveCellRef<ESM::NPC, RefData>) ||
reference.getType()==typeid (ESMS::LiveCellRef<ESM::Creature, RefData>)))
{
mEnvironment.mMechanicsManager->addActor (reference);
}
}
}
}
@ -288,6 +295,13 @@ namespace MWWorld
if (MWRender::CellRender *render = searchRender (reference.getCell()))
{
render->disable (reference.getRefData().getHandle());
if (mActiveCells.find (reference.getCell())!=mActiveCells.end() &&
(reference.getType()==typeid (ESMS::LiveCellRef<ESM::NPC, RefData>) ||
reference.getType()==typeid (ESMS::LiveCellRef<ESM::Creature, RefData>)))
{
mEnvironment.mMechanicsManager->removeActor (reference);
}
}
}
}
@ -456,16 +470,22 @@ namespace MWWorld
cell->creatures.list.begin());
iter!=cell->creatures.list.end(); ++iter)
{
Ptr ptr (&*iter, cell);
mEnvironment.mMechanicsManager->addActor (ptr);
if (iter->mData.isEnabled())
{
Ptr ptr (&*iter, cell);
mEnvironment.mMechanicsManager->addActor (ptr);
}
}
for (ESMS::CellRefList<ESM::NPC, RefData>::List::iterator iter (
cell->npcs.list.begin());
iter!=cell->npcs.list.end(); ++iter)
{
Ptr ptr (&*iter, cell);
mEnvironment.mMechanicsManager->addActor (ptr);
if (iter->mData.isEnabled())
{
Ptr ptr (&*iter, cell);
mEnvironment.mMechanicsManager->addActor (ptr);
}
}
// Sky system

Loading…
Cancel
Save