
#include "static.hpp"

#include <components/esm/loadstat.hpp>

#include "../mwworld/ptr.hpp"

#include "../mwrender/cellimp.hpp"

namespace MWClass
{
    void Static::insertObj (const MWWorld::Ptr& ptr, MWRender::CellRenderImp& cellRender,
        MWWorld::Environment& environment) const
    {
        ESMS::LiveCellRef<ESM::Static, MWWorld::RefData> *ref =
            ptr.get<ESM::Static>();

        assert (ref->base != NULL);
        const std::string &model = ref->base->model;
        if (!model.empty())
        {
            cellRender.insertBegin (ref->ref);
            cellRender.insertMesh ("meshes\\" + model);
            ref->mData.setHandle (cellRender.insertEnd (ref->mData.isEnabled()));
        }
    }

    std::string Static::getName (const MWWorld::Ptr& ptr) const
    {
        return "";
    }

    void Static::registerSelf()
    {
        boost::shared_ptr<Class> instance (new Static);

        registerClass (typeid (ESM::Static).name(), instance);
    }
}
