mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-01 14:27:59 +03: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/ptr.hpp"
|
||||||
#include "../mwworld/actiontalk.hpp"
|
#include "../mwworld/actiontalk.hpp"
|
||||||
|
#include "../mwworld/environment.hpp"
|
||||||
|
|
||||||
#include "../mwrender/cellimp.hpp"
|
#include "../mwrender/cellimp.hpp"
|
||||||
|
|
||||||
|
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Creature::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
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
|
std::string Creature::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
ESMS::LiveCellRef<ESM::Creature, MWWorld::RefData> *ref =
|
||||||
|
|
|
@ -13,6 +13,12 @@ namespace MWClass
|
||||||
MWWorld::Environment& environment) const;
|
MWWorld::Environment& environment) const;
|
||||||
///< Add reference into a cell for rendering
|
///< 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;
|
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);
|
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||||
/// can return an empty string.
|
/// can return an empty string.
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
|
|
||||||
#include "../mwrender/cellimp.hpp"
|
#include "../mwrender/cellimp.hpp"
|
||||||
|
|
||||||
|
#include "../mwmechanics/mechanicsmanager.hpp"
|
||||||
|
|
||||||
namespace MWClass
|
namespace MWClass
|
||||||
{
|
{
|
||||||
void Npc::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
void Npc::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
|
||||||
|
@ -43,6 +45,16 @@ namespace MWClass
|
||||||
ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled()));
|
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
|
std::string Npc::getName (const MWWorld::Ptr& ptr) const
|
||||||
{
|
{
|
||||||
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
ESMS::LiveCellRef<ESM::NPC, MWWorld::RefData> *ref =
|
||||||
|
|
|
@ -13,6 +13,12 @@ namespace MWClass
|
||||||
MWWorld::Environment& environment) const;
|
MWWorld::Environment& environment) const;
|
||||||
///< Add reference into a cell for rendering
|
///< 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;
|
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);
|
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||||
/// can return an empty string.
|
/// can return an empty string.
|
||||||
|
|
|
@ -20,7 +20,11 @@ void insertCellRefList (CellRenderImp& cellRender, MWWorld::Environment& environ
|
||||||
it != cellRefList.list.end(); it++)
|
it != cellRefList.list.end(); it++)
|
||||||
{
|
{
|
||||||
if (it->mData.getCount())
|
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
|
MWMechanics::CreatureStats& Class::getCreatureStats (const Ptr& ptr) const
|
||||||
{
|
{
|
||||||
throw std::runtime_error ("class does not have creature stats");
|
throw std::runtime_error ("class does not have creature stats");
|
||||||
|
|
|
@ -46,6 +46,16 @@ namespace MWWorld
|
||||||
MWWorld::Environment& environment) const;
|
MWWorld::Environment& environment) const;
|
||||||
///< Add reference into a cell for rendering (default implementation: don't render anything).
|
///< 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;
|
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);
|
///< \return name (the one that is to be presented to the user; not the internal one);
|
||||||
/// can return an empty string.
|
/// can return an empty string.
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "ptr.hpp"
|
#include "ptr.hpp"
|
||||||
#include "environment.hpp"
|
#include "environment.hpp"
|
||||||
|
#include "class.hpp"
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -374,12 +375,8 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
render->enable (reference.getRefData().getHandle());
|
render->enable (reference.getRefData().getHandle());
|
||||||
|
|
||||||
if (mActiveCells.find (reference.getCell())!=mActiveCells.end() &&
|
if (mActiveCells.find (reference.getCell())!=mActiveCells.end())
|
||||||
(reference.getType()==typeid (ESMS::LiveCellRef<ESM::NPC, RefData>) ||
|
Class::get (reference).enable (reference, mEnvironment);
|
||||||
reference.getType()==typeid (ESMS::LiveCellRef<ESM::Creature, RefData>)))
|
|
||||||
{
|
|
||||||
mEnvironment.mMechanicsManager->addActor (reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -394,12 +391,8 @@ namespace MWWorld
|
||||||
{
|
{
|
||||||
render->disable (reference.getRefData().getHandle());
|
render->disable (reference.getRefData().getHandle());
|
||||||
|
|
||||||
if (mActiveCells.find (reference.getCell())!=mActiveCells.end() &&
|
if (mActiveCells.find (reference.getCell())!=mActiveCells.end())
|
||||||
(reference.getType()==typeid (ESMS::LiveCellRef<ESM::NPC, RefData>) ||
|
Class::get (reference).disable (reference, mEnvironment);
|
||||||
reference.getType()==typeid (ESMS::LiveCellRef<ESM::Creature, RefData>)))
|
|
||||||
{
|
|
||||||
mEnvironment.mMechanicsManager->removeActor (reference);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -626,12 +619,8 @@ namespace MWWorld
|
||||||
render->deleteObject (ptr.getRefData().getHandle());
|
render->deleteObject (ptr.getRefData().getHandle());
|
||||||
ptr.getRefData().setHandle ("");
|
ptr.getRefData().setHandle ("");
|
||||||
|
|
||||||
if (mActiveCells.find (ptr.getCell())!=mActiveCells.end() &&
|
if (mActiveCells.find (ptr.getCell())!=mActiveCells.end())
|
||||||
(ptr.getType()==typeid (ESMS::LiveCellRef<ESM::NPC, RefData>) ||
|
Class::get (ptr).disable (ptr, mEnvironment);
|
||||||
ptr.getType()==typeid (ESMS::LiveCellRef<ESM::Creature, RefData>)))
|
|
||||||
{
|
|
||||||
mEnvironment.mMechanicsManager->removeActor (ptr);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue