|
|
|
@ -26,27 +26,6 @@
|
|
|
|
|
#include "../mwrender/actors.hpp"
|
|
|
|
|
#include "../mwrender/renderinginterface.hpp"
|
|
|
|
|
|
|
|
|
|
namespace
|
|
|
|
|
{
|
|
|
|
|
struct LightCustomData : public MWWorld::CustomData
|
|
|
|
|
{
|
|
|
|
|
float mTime;
|
|
|
|
|
///< Time remaining
|
|
|
|
|
|
|
|
|
|
LightCustomData(MWWorld::Ptr ptr)
|
|
|
|
|
{
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
|
|
|
|
|
mTime = ref->mBase->mData.mTime;
|
|
|
|
|
}
|
|
|
|
|
///< Constructs this CustomData from the base values for Ptr.
|
|
|
|
|
|
|
|
|
|
virtual MWWorld::CustomData *clone() const
|
|
|
|
|
{
|
|
|
|
|
return new LightCustomData (*this);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
namespace MWClass
|
|
|
|
|
{
|
|
|
|
|
std::string Light::getId (const MWWorld::Ptr& ptr) const
|
|
|
|
@ -219,17 +198,16 @@ namespace MWClass
|
|
|
|
|
|
|
|
|
|
void Light::setRemainingUsageTime (const MWWorld::Ptr& ptr, float duration) const
|
|
|
|
|
{
|
|
|
|
|
ensureCustomData(ptr);
|
|
|
|
|
|
|
|
|
|
float &timeRemaining = dynamic_cast<LightCustomData&> (*ptr.getRefData().getCustomData()).mTime;
|
|
|
|
|
timeRemaining = duration;
|
|
|
|
|
ptr.getCellRef().setChargeFloat(duration);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
float Light::getRemainingUsageTime (const MWWorld::Ptr& ptr) const
|
|
|
|
|
{
|
|
|
|
|
ensureCustomData(ptr);
|
|
|
|
|
|
|
|
|
|
return dynamic_cast<LightCustomData&> (*ptr.getRefData().getCustomData()).mTime;
|
|
|
|
|
MWWorld::LiveCellRef<ESM::Light> *ref = ptr.get<ESM::Light>();
|
|
|
|
|
if (ptr.getCellRef().getCharge() == -1)
|
|
|
|
|
return ref->mBase->mData.mTime;
|
|
|
|
|
else
|
|
|
|
|
return ptr.getCellRef().getChargeFloat();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MWWorld::Ptr
|
|
|
|
@ -241,12 +219,6 @@ namespace MWClass
|
|
|
|
|
return MWWorld::Ptr(&cell.get<ESM::Light>().insert(*ref), &cell);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Light::ensureCustomData (const MWWorld::Ptr& ptr) const
|
|
|
|
|
{
|
|
|
|
|
if (!ptr.getRefData().getCustomData())
|
|
|
|
|
ptr.getRefData().setCustomData(new LightCustomData(ptr));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool Light::canSell (const MWWorld::Ptr& item, int npcServices) const
|
|
|
|
|
{
|
|
|
|
|
return npcServices & ESM::NPC::Lights;
|
|
|
|
@ -282,22 +254,6 @@ namespace MWClass
|
|
|
|
|
return std::make_pair(1,"");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Light::readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
|
|
|
|
|
const
|
|
|
|
|
{
|
|
|
|
|
ensureCustomData (ptr);
|
|
|
|
|
|
|
|
|
|
dynamic_cast<LightCustomData&> (*ptr.getRefData().getCustomData()).mTime = state.mTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Light::writeAdditionalState (const MWWorld::Ptr& ptr, ESM::ObjectState& state)
|
|
|
|
|
const
|
|
|
|
|
{
|
|
|
|
|
ensureCustomData (ptr);
|
|
|
|
|
|
|
|
|
|
state.mTime = dynamic_cast<LightCustomData&> (*ptr.getRefData().getCustomData()).mTime;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string Light::getSound(const MWWorld::Ptr& ptr) const
|
|
|
|
|
{
|
|
|
|
|
return ptr.get<ESM::Light>()->mBase->mSound;
|
|
|
|
|