1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 15:35:23 +00:00
OpenMW/apps/openmw/mwworld/refdata.hpp

120 lines
3.0 KiB
C++
Raw Normal View History

2010-07-03 15:41:20 +02:00
#ifndef GAME_MWWORLD_REFDATA_H
#define GAME_MWWORLD_REFDATA_H
2010-07-02 14:00:28 +02:00
#include <string>
#include <boost/shared_ptr.hpp>
2010-07-03 15:41:20 +02:00
#include "../mwscript/locals.hpp"
2010-07-02 14:31:29 +02:00
2010-08-19 12:49:13 +02:00
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/movement.hpp"
2010-08-19 12:49:13 +02:00
2010-08-04 14:37:23 +02:00
#include "containerstore.hpp"
2010-07-02 14:31:29 +02:00
namespace ESM
{
class Script;
}
2010-07-03 15:41:20 +02:00
namespace MWWorld
{
2010-07-02 14:31:29 +02:00
class RefData
{
2010-07-02 14:31:29 +02:00
std::string mHandle;
2010-08-04 14:04:22 +02:00
2010-07-02 14:31:29 +02: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 17:21:27 +02:00
bool mHasLocals;
2010-07-09 16:07:03 +02:00
bool mEnabled;
2010-08-04 14:04:22 +02:00
int mCount; // 0: deleted
// 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 12:49:13 +02:00
boost::shared_ptr<MWMechanics::NpcStats> mNpcStats;
boost::shared_ptr<MWMechanics::Movement> mMovement;
2010-08-04 14:04:22 +02:00
2010-08-04 14:37:23 +02:00
boost::shared_ptr<ContainerStore<RefData> > mContainerStore;
2010-07-02 14:31:29 +02:00
public:
2010-08-04 14:04:22 +02:00
RefData() : mHasLocals (false), mEnabled (true), mCount (1) {}
2010-07-02 14:31:29 +02:00
std::string getHandle()
{
return mHandle;
}
2010-08-04 14:04:22 +02:00
int getCount() const
{
return mCount;
}
2010-07-02 14:31:29 +02:00
void setLocals (const ESM::Script& script)
{
2010-07-02 17:21:27 +02:00
if (!mHasLocals)
{
mLocals.configure (script);
mHasLocals = true;
}
2010-07-02 14:31:29 +02:00
}
2010-08-04 14:04:22 +02:00
2010-07-02 14:31:29 +02:00
void setHandle (const std::string& handle)
{
mHandle = handle;
}
2010-08-04 14:04:22 +02:00
void setCount (int count)
{
mCount = count;
}
2010-07-02 14:31:29 +02:00
MWScript::Locals& getLocals()
{
return mLocals;
}
2010-08-04 14:04:22 +02:00
2010-07-09 16:07:03 +02:00
bool isEnabled() const
{
return mEnabled;
}
2010-08-04 14:04:22 +02:00
2010-07-09 16:07:03 +02:00
void enable()
{
mEnabled = true;
}
2010-08-04 14:04:22 +02:00
2010-07-09 16:07:03 +02:00
void disable()
{
mEnabled = true;
}
2010-08-04 14:04:22 +02:00
boost::shared_ptr<MWMechanics::CreatureStats>& getCreatureStats()
{
2010-08-04 14:04:22 +02:00
return mCreatureStats;
}
2010-08-04 14:37:23 +02:00
2010-08-19 12:49:13 +02:00
boost::shared_ptr<MWMechanics::NpcStats>& getNpcStats()
{
return mNpcStats;
}
boost::shared_ptr<MWMechanics::Movement>& getMovement()
{
return mMovement;
}
2010-08-04 14:37:23 +02:00
boost::shared_ptr<ContainerStore<RefData> >& getContainerStore()
{
return mContainerStore;
}
2010-08-04 14:04:22 +02:00
};
}
#endif