mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-09 21:42:13 +00:00
12de0afb03
Fix a bug in copyObjectToCell. Make actor rotations more consistent.
67 lines
1.8 KiB
C++
67 lines
1.8 KiB
C++
|
|
#include "creaturelevlist.hpp"
|
|
|
|
#include <components/esm/loadlevlist.hpp>
|
|
|
|
#include "../mwmechanics/levelledlist.hpp"
|
|
|
|
#include "../mwworld/customdata.hpp"
|
|
|
|
namespace
|
|
{
|
|
struct CustomData : public MWWorld::CustomData
|
|
{
|
|
// TODO: save the creature we spawned here
|
|
virtual MWWorld::CustomData *clone() const;
|
|
};
|
|
|
|
MWWorld::CustomData *CustomData::clone() const
|
|
{
|
|
return new CustomData (*this);
|
|
}
|
|
}
|
|
|
|
namespace MWClass
|
|
{
|
|
std::string CreatureLevList::getName (const MWWorld::Ptr& ptr) const
|
|
{
|
|
return "";
|
|
}
|
|
|
|
void CreatureLevList::registerSelf()
|
|
{
|
|
boost::shared_ptr<Class> instance (new CreatureLevList);
|
|
|
|
registerClass (typeid (ESM::CreatureLevList).name(), instance);
|
|
}
|
|
|
|
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())
|
|
{
|
|
std::auto_ptr<CustomData> data (new CustomData);
|
|
|
|
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
|
|
MWBase::Environment::get().getWorld()->safePlaceObject(ref.getPtr(), ptr.getCell() , ptr.getCellRef().mPos);
|
|
}
|
|
|
|
ptr.getRefData().setCustomData(data.release());
|
|
}
|
|
}
|
|
}
|