2010-07-03 13:41:20 +00:00
|
|
|
#ifndef GAME_MWWORLD_REFDATA_H
|
|
|
|
#define GAME_MWWORLD_REFDATA_H
|
2010-07-02 11:48:48 +00:00
|
|
|
|
2010-07-02 12:00:28 +00:00
|
|
|
#include <string>
|
|
|
|
|
2010-07-26 10:52:32 +00:00
|
|
|
#include <boost/shared_ptr.hpp>
|
|
|
|
|
2010-07-03 13:41:20 +00:00
|
|
|
#include "../mwscript/locals.hpp"
|
2010-07-02 12:31:29 +00:00
|
|
|
|
2010-08-19 10:49:13 +00:00
|
|
|
#include "../mwmechanics/creaturestats.hpp"
|
|
|
|
#include "../mwmechanics/npcstats.hpp"
|
2011-02-03 10:37:17 +00:00
|
|
|
#include "../mwmechanics/movement.hpp"
|
2010-08-19 10:49:13 +00:00
|
|
|
|
2010-08-04 12:37:23 +00:00
|
|
|
#include "containerstore.hpp"
|
2011-10-30 21:31:49 +00:00
|
|
|
#include <Ogre.h>
|
2010-08-04 12:37:23 +00:00
|
|
|
|
2010-07-02 12:31:29 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
class Script;
|
|
|
|
}
|
|
|
|
|
2010-07-03 13:41:20 +00:00
|
|
|
namespace MWWorld
|
2010-07-02 11:48:48 +00:00
|
|
|
{
|
2010-07-02 12:31:29 +00:00
|
|
|
class RefData
|
2010-07-02 11:48:48 +00:00
|
|
|
{
|
2011-10-30 21:31:49 +00:00
|
|
|
Ogre::SceneNode* mBaseNode;
|
2011-10-30 20:59:40 +00:00
|
|
|
|
2010-08-04 12:04:22 +00:00
|
|
|
|
2010-07-02 12:31:29 +00:00
|
|
|
MWScript::Locals mLocals; // if we find the overhead of heaving a locals
|
|
|
|
// object in the refdata of refs without a script,
|
|
|
|
// we can make this a pointer later.
|
2010-07-02 15:21:27 +00:00
|
|
|
bool mHasLocals;
|
2010-07-09 14:07:03 +00:00
|
|
|
bool mEnabled;
|
2010-08-04 12:04:22 +00:00
|
|
|
int mCount; // 0: deleted
|
|
|
|
|
2010-07-26 10:52:32 +00:00
|
|
|
// we are using shared pointer here to avoid having to create custom copy-constructor,
|
|
|
|
// assignment operator and destructor. As a consequence though copying a RefData object
|
|
|
|
// manually will probably give unexcepted results. This is not a problem since RefData
|
|
|
|
// are never copied outside of container operations.
|
|
|
|
boost::shared_ptr<MWMechanics::CreatureStats> mCreatureStats;
|
2010-08-19 10:49:13 +00:00
|
|
|
boost::shared_ptr<MWMechanics::NpcStats> mNpcStats;
|
2011-02-03 10:37:17 +00:00
|
|
|
boost::shared_ptr<MWMechanics::Movement> mMovement;
|
2010-08-04 12:04:22 +00:00
|
|
|
|
2010-08-04 12:37:23 +00:00
|
|
|
boost::shared_ptr<ContainerStore<RefData> > mContainerStore;
|
|
|
|
|
2011-11-08 00:08:00 +00:00
|
|
|
ESM::Position mPosition;
|
2010-08-04 12:04:22 +00:00
|
|
|
|
2011-11-09 03:59:39 +00:00
|
|
|
|
2011-11-08 00:08:00 +00:00
|
|
|
public:
|
2011-11-11 11:25:01 +00:00
|
|
|
/// @param cr Used to copy constant data such as position into this class where it can
|
|
|
|
/// be altered without effecting the original data. This makes it possible
|
|
|
|
/// to reset the position as the orignal data is still held in the CellRef
|
2011-11-21 11:52:28 +00:00
|
|
|
RefData(const ESMS::CellRef& cr) : mBaseNode(0), mHasLocals (false), mEnabled (true),
|
2011-11-08 00:08:00 +00:00
|
|
|
mCount (1), mPosition(cr.pos) {}
|
2010-08-04 12:04:22 +00:00
|
|
|
|
|
|
|
|
2010-07-02 12:31:29 +00:00
|
|
|
std::string getHandle()
|
|
|
|
{
|
2011-10-30 21:31:49 +00:00
|
|
|
return mBaseNode->getName();
|
|
|
|
}
|
2011-11-11 05:20:53 +00:00
|
|
|
Ogre::SceneNode* getBaseNode(){
|
|
|
|
return mBaseNode;
|
|
|
|
}
|
2011-10-31 02:38:15 +00:00
|
|
|
void setBaseNode(Ogre::SceneNode* base){
|
2011-10-30 21:31:49 +00:00
|
|
|
mBaseNode = base;
|
2010-07-02 12:31:29 +00:00
|
|
|
}
|
2010-08-04 12:04:22 +00:00
|
|
|
|
|
|
|
int getCount() const
|
|
|
|
{
|
|
|
|
return mCount;
|
|
|
|
}
|
|
|
|
|
2010-07-02 12:31:29 +00:00
|
|
|
void setLocals (const ESM::Script& script)
|
|
|
|
{
|
2010-07-02 15:21:27 +00:00
|
|
|
if (!mHasLocals)
|
|
|
|
{
|
|
|
|
mLocals.configure (script);
|
|
|
|
mHasLocals = true;
|
|
|
|
}
|
2010-07-02 12:31:29 +00:00
|
|
|
}
|
2010-08-04 12:04:22 +00:00
|
|
|
|
|
|
|
|
|
|
|
void setCount (int count)
|
|
|
|
{
|
|
|
|
mCount = count;
|
|
|
|
}
|
|
|
|
|
2010-07-02 12:31:29 +00:00
|
|
|
MWScript::Locals& getLocals()
|
|
|
|
{
|
|
|
|
return mLocals;
|
|
|
|
}
|
2010-08-04 12:04:22 +00:00
|
|
|
|
2010-07-09 14:07:03 +00:00
|
|
|
bool isEnabled() const
|
|
|
|
{
|
|
|
|
return mEnabled;
|
|
|
|
}
|
2010-08-04 12:04:22 +00:00
|
|
|
|
2010-07-09 14:07:03 +00:00
|
|
|
void enable()
|
|
|
|
{
|
|
|
|
mEnabled = true;
|
|
|
|
}
|
2010-08-04 12:04:22 +00:00
|
|
|
|
2010-07-09 14:07:03 +00:00
|
|
|
void disable()
|
|
|
|
{
|
|
|
|
mEnabled = true;
|
|
|
|
}
|
2010-08-04 12:04:22 +00:00
|
|
|
|
2010-07-26 10:52:32 +00:00
|
|
|
boost::shared_ptr<MWMechanics::CreatureStats>& getCreatureStats()
|
|
|
|
{
|
2010-08-04 12:04:22 +00:00
|
|
|
return mCreatureStats;
|
2010-07-26 10:52:32 +00:00
|
|
|
}
|
2010-08-04 12:37:23 +00:00
|
|
|
|
2010-08-19 10:49:13 +00:00
|
|
|
boost::shared_ptr<MWMechanics::NpcStats>& getNpcStats()
|
|
|
|
{
|
|
|
|
return mNpcStats;
|
|
|
|
}
|
|
|
|
|
2011-02-03 10:37:17 +00:00
|
|
|
boost::shared_ptr<MWMechanics::Movement>& getMovement()
|
|
|
|
{
|
|
|
|
return mMovement;
|
|
|
|
}
|
|
|
|
|
2010-08-04 12:37:23 +00:00
|
|
|
boost::shared_ptr<ContainerStore<RefData> >& getContainerStore()
|
|
|
|
{
|
|
|
|
return mContainerStore;
|
|
|
|
}
|
2011-11-08 00:08:00 +00:00
|
|
|
|
|
|
|
ESM::Position& getPosition()
|
|
|
|
{
|
|
|
|
return mPosition;
|
|
|
|
}
|
2010-08-04 12:04:22 +00:00
|
|
|
};
|
2010-07-02 11:48:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|