2010-08-03 13:24:44 +00:00
|
|
|
|
|
|
|
#include "creaturelevlist.hpp"
|
|
|
|
|
|
|
|
#include <components/esm/loadlevlist.hpp>
|
|
|
|
|
2014-01-18 06:26:27 +00:00
|
|
|
#include "../mwmechanics/levelledlist.hpp"
|
|
|
|
|
|
|
|
#include "../mwworld/customdata.hpp"
|
|
|
|
|
|
|
|
namespace
|
|
|
|
{
|
2014-03-16 22:38:51 +00:00
|
|
|
struct CreatureLevListCustomData : public MWWorld::CustomData
|
2014-01-18 06:26:27 +00:00
|
|
|
{
|
|
|
|
// TODO: save the creature we spawned here
|
|
|
|
virtual MWWorld::CustomData *clone() const;
|
|
|
|
};
|
|
|
|
|
2014-03-16 22:38:51 +00:00
|
|
|
MWWorld::CustomData *CreatureLevListCustomData::clone() const
|
2014-01-18 06:26:27 +00:00
|
|
|
{
|
2014-03-16 22:38:51 +00:00
|
|
|
return new CreatureLevListCustomData (*this);
|
2014-01-18 06:26:27 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-08-03 13:24:44 +00:00
|
|
|
namespace MWClass
|
|
|
|
{
|
2010-08-03 15:11:41 +00:00
|
|
|
std::string CreatureLevList::getName (const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2010-08-03 13:24:44 +00:00
|
|
|
void CreatureLevList::registerSelf()
|
|
|
|
{
|
|
|
|
boost::shared_ptr<Class> instance (new CreatureLevList);
|
|
|
|
|
|
|
|
registerClass (typeid (ESM::CreatureLevList).name(), instance);
|
|
|
|
}
|
2014-01-18 06:26:27 +00:00
|
|
|
|
|
|
|
void CreatureLevList::insertObjectRendering(const MWWorld::Ptr &ptr, MWRender::RenderingInterface &renderingInterface) const
|
|
|
|
{
|
|
|
|
ensureCustomData(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CreatureLevList::ensureCustomData(const MWWorld::Ptr &ptr) const
|
|
|
|
{
|
|
|
|
if (!ptr.getRefData().getCustomData())
|
|
|
|
{
|
2014-03-16 22:38:51 +00:00
|
|
|
std::auto_ptr<CreatureLevListCustomData> data (new CreatureLevListCustomData);
|
2014-01-18 06:26:27 +00:00
|
|
|
|
|
|
|
MWWorld::LiveCellRef<ESM::CreatureLevList> *ref =
|
|
|
|
ptr.get<ESM::CreatureLevList>();
|
|
|
|
|
|
|
|
std::string id = MWMechanics::getLevelledItem(ref->mBase, true);
|
|
|
|
|
|
|
|
if (!id.empty())
|
|
|
|
{
|
|
|
|
const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
|
|
|
|
MWWorld::ManualRef ref(store, id);
|
|
|
|
ref.getPtr().getCellRef().mPos = ptr.getCellRef().mPos;
|
|
|
|
// TODO: hold on to this for respawn purposes later
|
2014-03-07 05:11:00 +00:00
|
|
|
MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(), ptr.getCell() , ptr.getCellRef().mPos);
|
2014-01-18 06:26:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ptr.getRefData().setCustomData(data.release());
|
|
|
|
}
|
|
|
|
}
|
2010-08-03 13:24:44 +00:00
|
|
|
}
|