2012-01-22 10:00:40 +00:00
|
|
|
|
|
|
|
#include "refdata.hpp"
|
|
|
|
|
2012-07-03 13:32:38 +00:00
|
|
|
#include <OgreSceneNode.h>
|
|
|
|
|
2012-01-24 10:23:22 +00:00
|
|
|
#include "customdata.hpp"
|
2012-06-29 14:48:50 +00:00
|
|
|
#include "cellstore.hpp"
|
2012-01-24 10:23:22 +00:00
|
|
|
|
2013-01-13 17:05:12 +00:00
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwbase/world.hpp"
|
|
|
|
|
2012-01-22 10:00:40 +00:00
|
|
|
namespace MWWorld
|
|
|
|
{
|
2012-01-22 10:20:05 +00:00
|
|
|
void RefData::copy (const RefData& refData)
|
|
|
|
{
|
|
|
|
mBaseNode = refData.mBaseNode;
|
|
|
|
mLocals = refData.mLocals;
|
|
|
|
mHasLocals = refData.mHasLocals;
|
|
|
|
mEnabled = refData.mEnabled;
|
|
|
|
mCount = refData.mCount;
|
|
|
|
mPosition = refData.mPosition;
|
2013-04-16 19:17:19 +00:00
|
|
|
mLocalRotation = refData.mLocalRotation;
|
2012-01-22 10:20:05 +00:00
|
|
|
|
2012-01-24 10:23:22 +00:00
|
|
|
mCustomData = refData.mCustomData ? refData.mCustomData->clone() : 0;
|
2012-01-22 10:20:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void RefData::cleanup()
|
|
|
|
{
|
|
|
|
mBaseNode = 0;
|
2012-01-24 10:23:22 +00:00
|
|
|
|
|
|
|
delete mCustomData;
|
|
|
|
mCustomData = 0;
|
2012-01-22 10:20:05 +00:00
|
|
|
}
|
|
|
|
|
2012-01-27 13:55:58 +00:00
|
|
|
RefData::RefData (const ESM::CellRef& cellRef)
|
2012-09-17 07:37:50 +00:00
|
|
|
: mBaseNode(0), mHasLocals (false), mEnabled (true), mCount (1), mPosition (cellRef.mPos),
|
2012-01-24 10:23:22 +00:00
|
|
|
mCustomData (0)
|
2013-04-16 19:17:19 +00:00
|
|
|
{
|
|
|
|
mLocalRotation.rot[0]=0;
|
|
|
|
mLocalRotation.rot[1]=0;
|
|
|
|
mLocalRotation.rot[2]=0;
|
|
|
|
}
|
2012-01-22 10:00:40 +00:00
|
|
|
|
2012-01-22 10:20:05 +00:00
|
|
|
RefData::RefData (const RefData& refData)
|
2012-01-24 10:23:22 +00:00
|
|
|
: mBaseNode(0), mCustomData (0)
|
2012-01-22 10:20:05 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
copy (refData);
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
cleanup();
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-30 11:38:13 +00:00
|
|
|
RefData& RefData::operator= (const RefData& refData)
|
2012-01-22 10:20:05 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
cleanup();
|
|
|
|
copy (refData);
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{
|
|
|
|
cleanup();
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
RefData::~RefData()
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
cleanup();
|
|
|
|
}
|
|
|
|
catch (...)
|
|
|
|
{}
|
|
|
|
}
|
|
|
|
|
2013-04-29 06:44:44 +00:00
|
|
|
const std::string &RefData::getHandle()
|
2012-01-22 10:00:40 +00:00
|
|
|
{
|
2013-04-29 06:44:44 +00:00
|
|
|
if(!mBaseNode)
|
|
|
|
{
|
|
|
|
static const std::string empty;
|
|
|
|
return empty;
|
|
|
|
}
|
2012-09-04 13:08:59 +00:00
|
|
|
|
2012-01-22 10:00:40 +00:00
|
|
|
return mBaseNode->getName();
|
|
|
|
}
|
|
|
|
|
|
|
|
Ogre::SceneNode* RefData::getBaseNode()
|
|
|
|
{
|
|
|
|
return mBaseNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RefData::setBaseNode(Ogre::SceneNode* base)
|
|
|
|
{
|
|
|
|
mBaseNode = base;
|
|
|
|
}
|
|
|
|
|
|
|
|
int RefData::getCount() const
|
|
|
|
{
|
|
|
|
return mCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RefData::setLocals (const ESM::Script& script)
|
|
|
|
{
|
|
|
|
if (!mHasLocals)
|
|
|
|
{
|
|
|
|
mLocals.configure (script);
|
|
|
|
mHasLocals = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void RefData::setCount (int count)
|
|
|
|
{
|
2013-01-13 17:05:12 +00:00
|
|
|
if(count == 0)
|
|
|
|
MWBase::Environment::get().getWorld()->removeRefScript(this);
|
|
|
|
|
2012-01-22 10:00:40 +00:00
|
|
|
mCount = count;
|
|
|
|
}
|
|
|
|
|
|
|
|
MWScript::Locals& RefData::getLocals()
|
|
|
|
{
|
|
|
|
return mLocals;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool RefData::isEnabled() const
|
|
|
|
{
|
|
|
|
return mEnabled;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RefData::enable()
|
|
|
|
{
|
|
|
|
mEnabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RefData::disable()
|
|
|
|
{
|
2012-05-30 07:21:41 +00:00
|
|
|
mEnabled = false;
|
2012-01-22 10:00:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ESM::Position& RefData::getPosition()
|
|
|
|
{
|
|
|
|
return mPosition;
|
|
|
|
}
|
2012-01-24 10:23:22 +00:00
|
|
|
|
2013-04-16 19:17:19 +00:00
|
|
|
LocalRotation& RefData::getLocalRotation()
|
|
|
|
{
|
|
|
|
return mLocalRotation;
|
|
|
|
}
|
|
|
|
|
2012-01-24 10:23:22 +00:00
|
|
|
void RefData::setCustomData (CustomData *data)
|
|
|
|
{
|
|
|
|
delete mCustomData;
|
|
|
|
mCustomData = data;
|
|
|
|
}
|
|
|
|
|
|
|
|
CustomData *RefData::getCustomData()
|
|
|
|
{
|
|
|
|
return mCustomData;
|
|
|
|
}
|
2012-01-22 10:00:40 +00:00
|
|
|
}
|