1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 22:49:55 +00:00
openmw-tes3mp/apps/openmw/mwworld/refdata.hpp

148 lines
4.4 KiB
C++
Raw Normal View History

2010-07-03 13:41:20 +00:00
#ifndef GAME_MWWORLD_REFDATA_H
#define GAME_MWWORLD_REFDATA_H
#include <components/esm/defs.hpp>
#include <components/esm/animationstate.hpp>
2010-07-02 12:31:29 +00:00
#include "../mwscript/locals.hpp"
#include "../mwworld/customdata.hpp"
2010-08-04 12:37:23 +00:00
2016-01-25 13:13:16 +00:00
#include <string>
#include <memory>
2015-04-19 15:55:56 +00:00
namespace SceneUtil
{
class PositionAttitudeTransform;
}
2010-07-02 12:31:29 +00:00
namespace ESM
{
class Script;
class CellRef;
struct ObjectState;
2010-07-02 12:31:29 +00:00
}
2010-07-03 13:41:20 +00:00
namespace MWWorld
{
2013-04-16 19:17:19 +00:00
class CustomData;
2010-07-02 12:31:29 +00:00
class RefData
{
SceneUtil::PositionAttitudeTransform* mBaseNode;
2010-08-04 12:04:22 +00:00
MWScript::Locals mLocals;
/// separate delete flag used for deletion by a content file
/// @note not stored in the save game file.
2015-12-12 21:37:23 +00:00
bool mDeletedByContentFile;
2010-07-09 14:07:03 +00:00
bool mEnabled;
2010-08-04 12:04:22 +00:00
/// 0: deleted
int mCount;
ESM::Position mPosition;
ESM::AnimationState mAnimationState;
std::unique_ptr<CustomData> mCustomData;
void copy (const RefData& refData);
void cleanup();
2010-08-04 12:04:22 +00:00
bool mChanged;
unsigned int mFlags;
public:
RefData();
/// @param cellRef Used to copy constant data such as position into this class where it can
/// be altered without affecting the original data. This makes it possible
/// to reset the position as the original data is still held in the CellRef
RefData (const ESM::CellRef& cellRef);
2015-12-12 21:37:23 +00:00
RefData (const ESM::ObjectState& objectState, bool deletedByContentFile);
///< Ignores local variables and custom data (not enough context available here to
/// perform these operations).
RefData (const RefData& refData);
RefData (RefData&& other) noexcept = default;
~RefData();
void write (ESM::ObjectState& objectState, const std::string& scriptId = "") const;
///< Ignores custom data (not enough context available here to
/// perform this operations).
RefData& operator= (const RefData& refData);
RefData& operator= (RefData&& other) noexcept = default;
/// Return base node (can be a null pointer).
SceneUtil::PositionAttitudeTransform* getBaseNode();
2015-12-18 17:02:57 +00:00
/// Return base node (can be a null pointer).
const SceneUtil::PositionAttitudeTransform* getBaseNode() const;
/// Set base node (can be a null pointer).
void setBaseNode (SceneUtil::PositionAttitudeTransform* base);
int getCount(bool absolute = true) const;
void setLocals (const ESM::Script& script);
void setCount (int count);
///< Set object count (an object pile is a simple object with a count >1).
///
/// \warning Do not call setCount() to add or remove objects from a
/// container or an actor's inventory. Call ContainerStore::add() or
/// ContainerStore::remove() instead.
/// This flag is only used for content stack loading and will not be stored in the savegame.
/// If the object was deleted by gameplay, then use setCount(0) instead.
2015-12-12 21:37:23 +00:00
void setDeletedByContentFile(bool deleted);
/// Returns true if the object was either deleted by the content file or by gameplay.
bool isDeleted() const;
/// Returns true if the object was deleted by a content file.
bool isDeletedByContentFile() const;
MWScript::Locals& getLocals();
bool isEnabled() const;
void enable();
void disable();
void setPosition (const ESM::Position& pos);
2015-12-07 02:51:03 +00:00
const ESM::Position& getPosition() const;
void setCustomData(std::unique_ptr<CustomData>&& value) noexcept;
2014-06-15 13:58:01 +00:00
///< Set custom data (potentially replacing old custom data). The ownership of \a data is
/// transferred to this.
CustomData *getCustomData();
///< May return a 0-pointer. The ownership of the return data object is not transferred.
const CustomData *getCustomData() const;
bool activate();
bool onActivate();
bool activateByScript();
bool hasChanged() const;
///< Has this RefData changed since it was originally loaded?
const ESM::AnimationState& getAnimationState() const;
ESM::AnimationState& getAnimationState();
2010-08-04 12:04:22 +00:00
};
}
#endif