2010-08-03 13:24:44 +00:00
|
|
|
|
|
|
|
#include "container.hpp"
|
|
|
|
|
|
|
|
#include <components/esm/loadcont.hpp>
|
|
|
|
|
2010-08-03 15:11:41 +00:00
|
|
|
#include <components/esm_store/cell_store.hpp>
|
|
|
|
|
|
|
|
#include "../mwworld/ptr.hpp"
|
|
|
|
|
2010-08-03 13:24:44 +00:00
|
|
|
namespace MWClass
|
|
|
|
{
|
2011-11-12 04:01:12 +00:00
|
|
|
void Container::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const
|
2010-08-14 08:02:54 +00:00
|
|
|
{
|
|
|
|
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
|
|
|
ptr.get<ESM::Container>();
|
|
|
|
|
|
|
|
assert (ref->base != NULL);
|
|
|
|
const std::string &model = ref->base->model;
|
2011-11-12 04:01:12 +00:00
|
|
|
|
2010-08-14 08:02:54 +00:00
|
|
|
if (!model.empty())
|
|
|
|
{
|
2011-11-12 04:01:12 +00:00
|
|
|
MWRender::Objects objects = renderingInterface.getObjects();
|
|
|
|
objects.insertBegin(ptr, ptr.getRefData().isEnabled(), false);
|
|
|
|
objects.insertMesh(ptr, "meshes\\" + model);
|
2010-08-14 08:02:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-11-12 04:01:12 +00:00
|
|
|
void Container::insertObject(const MWWorld::Ptr& ptr, MWWorld::PhysicsSystem& physics, MWWorld::Environment& environment) const
|
|
|
|
{
|
|
|
|
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
|
|
|
ptr.get<ESM::Container>();
|
|
|
|
|
|
|
|
|
|
|
|
const std::string &model = ref->base->model;
|
|
|
|
assert (ref->base != NULL);
|
|
|
|
if(!model.empty()){
|
|
|
|
physics.insertObjectPhysics(ptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-08-03 15:11:41 +00:00
|
|
|
std::string Container::getName (const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
|
|
|
ptr.get<ESM::Container>();
|
|
|
|
|
|
|
|
return ref->base->name;
|
|
|
|
}
|
|
|
|
|
2010-08-04 12:37:23 +00:00
|
|
|
MWWorld::ContainerStore<MWWorld::RefData>& Container::getContainerStore (const MWWorld::Ptr& ptr)
|
|
|
|
const
|
|
|
|
{
|
|
|
|
if (!ptr.getRefData().getContainerStore().get())
|
|
|
|
{
|
|
|
|
boost::shared_ptr<MWWorld::ContainerStore<MWWorld::RefData> > store (
|
|
|
|
new MWWorld::ContainerStore<MWWorld::RefData>);
|
|
|
|
|
|
|
|
// TODO add initial content
|
|
|
|
|
|
|
|
ptr.getRefData().getContainerStore() = store;
|
|
|
|
}
|
|
|
|
|
|
|
|
return *ptr.getRefData().getContainerStore();
|
|
|
|
}
|
|
|
|
|
2010-08-05 13:40:03 +00:00
|
|
|
std::string Container::getScript (const MWWorld::Ptr& ptr) const
|
|
|
|
{
|
|
|
|
ESMS::LiveCellRef<ESM::Container, MWWorld::RefData> *ref =
|
|
|
|
ptr.get<ESM::Container>();
|
|
|
|
|
|
|
|
return ref->base->script;
|
|
|
|
}
|
|
|
|
|
2010-08-03 13:24:44 +00:00
|
|
|
void Container::registerSelf()
|
|
|
|
{
|
|
|
|
boost::shared_ptr<Class> instance (new Container);
|
|
|
|
|
|
|
|
registerClass (typeid (ESM::Container).name(), instance);
|
|
|
|
}
|
|
|
|
}
|