mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 15:15:31 +00:00
added enable and disable functions to class hierarchy; fixed a bug regarding actors in cellings being actived
This commit is contained in:
parent
967f85875d
commit
d57c984517
8 changed files with 69 additions and 19 deletions
|
@ -7,9 +7,12 @@
|
|||
|
||||
#include "../mwworld/ptr.hpp"
|
||||
#include "../mwworld/actiontalk.hpp"
|
||||
#include "../mwworld/environment.hpp"
|
||||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Creature::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
|
@ -28,6 +31,16 @@ namespace MWClass
|
|||
}
|
||||
}
|
||||
|
||||
void Creature::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
|
||||
{
|
||||
environment.mMechanicsManager->addActor (ptr);
|
||||
}
|
||||
|
||||
void Creature::disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
|
||||
{
|
||||
environment.mMechanicsManager->removeActor (ptr);
|
||||
}
|
||||
|
||||
std::string Creature::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -13,6 +13,12 @@ namespace MWClass
|
|||
MWWorld::Environment& environment) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
|
||||
///< Enable reference; only does the non-rendering part
|
||||
|
||||
virtual void disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
|
||||
///< Enable reference; only does the non-rendering part
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -12,6 +12,8 @@
|
|||
|
||||
#include "../mwrender/cellimp.hpp"
|
||||
|
||||
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||
|
||||
namespace MWClass
|
||||
{
|
||||
void Npc::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||
|
@ -43,6 +45,16 @@ namespace MWClass
|
|||
ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled()));
|
||||
}
|
||||
|
||||
void Npc::enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
|
||||
{
|
||||
environment.mMechanicsManager->addActor (ptr);
|
||||
}
|
||||
|
||||
void Npc::disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const
|
||||
{
|
||||
environment.mMechanicsManager->removeActor (ptr);
|
||||
}
|
||||
|
||||
std::string Npc::getName (const MWWorld::Ptr& ptr) const
|
||||
{
|
||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
||||
|
|
|
@ -13,6 +13,12 @@ namespace MWClass
|
|||
MWWorld::Environment& environment) const;
|
||||
///< Add reference into a cell for rendering
|
||||
|
||||
virtual void enable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
|
||||
///< Enable reference; only does the non-rendering part
|
||||
|
||||
virtual void disable (const MWWorld::Ptr& ptr, MWWorld::Environment& environment) const;
|
||||
///< Enable reference; only does the non-rendering part
|
||||
|
||||
virtual std::string getName (const MWWorld::Ptr& ptr) const;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -20,7 +20,11 @@ void insertCellRefList (CellRenderImp& cellRender, MWWorld::Environment& environ
|
|||
it != cellRefList.list.end(); it++)
|
||||
{
|
||||
if (it->mData.getCount())
|
||||
class_.insertObj (MWWorld::Ptr (&*it, &cell), cellRender, environment);
|
||||
{
|
||||
MWWorld::Ptr ptr (&*it, &cell);
|
||||
class_.insertObj (ptr, cellRender, environment);
|
||||
class_.enable (ptr, environment);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,16 @@ namespace MWWorld
|
|||
|
||||
}
|
||||
|
||||
void Class::enable (const Ptr& ptr, MWWorld::Environment& environment) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Class::disable (const Ptr& ptr, MWWorld::Environment& environment) const
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const
|
||||
{
|
||||
throw std::runtime_error ("class does not have creature stats");
|
||||
|
|
|
@ -46,6 +46,16 @@ namespace MWWorld
|
|||
MWWorld::Environment& environment) const;
|
||||
///< Add reference into a cell for rendering (default implementation: don't render anything).
|
||||
|
||||
virtual void enable (const Ptr& ptr, MWWorld::Environment& environment) const;
|
||||
///< Enable reference; only does the non-rendering part (default implementation: ignore)
|
||||
/// \attention This is not the same as the script instruction with the same name. References
|
||||
/// should only be enabled while in an active cell.
|
||||
|
||||
virtual void disable (const Ptr& ptr, MWWorld::Environment& environment) const;
|
||||
///< Enable reference; only does the non-rendering part (default implementation: ignore)
|
||||
/// \attention This is not the same as the script instruction with the same name. References
|
||||
/// should only be enabled while in an active cell.
|
||||
|
||||
virtual std::string getName (const Ptr& ptr) const = 0;
|
||||
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||
/// can return an empty string.
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include "ptr.hpp"
|
||||
#include "environment.hpp"
|
||||
#include "class.hpp"
|
||||
|
||||
namespace
|
||||
{
|
||||
|
@ -374,12 +375,8 @@ namespace MWWorld
|
|||
{
|
||||
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);
|
||||
}
|
||||
if (mActiveCells.find (reference.getCell())!=mActiveCells.end())
|
||||
Class::get (reference).enable (reference, mEnvironment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -394,12 +391,8 @@ namespace MWWorld
|
|||
{
|
||||
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);
|
||||
}
|
||||
if (mActiveCells.find (reference.getCell())!=mActiveCells.end())
|
||||
Class::get (reference).disable (reference, mEnvironment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -626,12 +619,8 @@ namespace MWWorld
|
|||
render->deleteObject (ptr.getRefData().getHandle());
|
||||
ptr.getRefData().setHandle ("");
|
||||
|
||||
if (mActiveCells.find (ptr.getCell())!=mActiveCells.end() &&
|
||||
(ptr.getType()==typeid (ESMS::LiveCellRef<ESM::NPC, RefData>) ||
|
||||
ptr.getType()==typeid (ESMS::LiveCellRef<ESM::Creature, RefData>)))
|
||||
{
|
||||
mEnvironment.mMechanicsManager->removeActor (ptr);
|
||||
}
|
||||
if (mActiveCells.find (ptr.getCell())!=mActiveCells.end())
|
||||
Class::get (ptr).disable (ptr, mEnvironment);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue