OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
cellref.hpp
Go to the documentation of this file.
1 #ifndef OPENMW_MWWORLD_CELLREF_H
2 #define OPENMW_MWWORLD_CELLREF_H
3 
5 
6 namespace ESM
7 {
8  struct ObjectState;
9 }
10 
11 namespace MWWorld
12 {
13 
15  class CellRef
16  {
17  public:
18 
19  CellRef (const ESM::CellRef& ref)
20  : mCellRef(ref)
21  {
22  mChanged = false;
23  }
24 
25  // Note: Currently unused for items in containers
26  const ESM::RefNum& getRefNum() const;
27 
28  // Set RefNum to its default state.
29  void unsetRefNum();
30 
32  bool hasContentFile() const;
33 
34  // Id of object being referenced
35  std::string getRefId() const;
36 
37  // For doors - true if this door teleports to somewhere else, false
38  // if it should open through animation.
39  bool getTeleport() const;
40 
41  // Teleport location for the door, if this is a teleporting door.
42  ESM::Position getDoorDest() const;
43 
44  // Destination cell for doors (optional)
45  std::string getDestCell() const;
46 
47  // Scale applied to mesh
48  float getScale() const;
49  void setScale(float scale);
50 
51  // The *original* position and rotation as it was given in the Construction Set.
52  // Current position and rotation of the object is stored in RefData.
53  ESM::Position getPosition() const;
54  void setPosition (const ESM::Position& position);
55 
56  // Remaining enchantment charge. This could be -1 if the charge was not touched yet (i.e. full).
57  float getEnchantmentCharge() const;
58 
59  void setEnchantmentCharge(float charge);
60 
61  // For weapon or armor, this is the remaining item health.
62  // For tools (lockpicks, probes, repair hammer) it is the remaining uses.
63  // If this returns int(-1) it means full health.
64  int getCharge() const;
65  float getChargeFloat() const; // Implemented as union with int charge
66  void setCharge(int charge);
67  void setChargeFloat(float charge);
68  void applyChargeRemainderToBeSubtracted(float chargeRemainder); // Stores remainders and applies if > 1
69 
70  // The NPC that owns this object (and will get angry if you steal it)
71  std::string getOwner() const;
72  void setOwner(const std::string& owner);
73 
74  // Name of a global variable. If the global variable is set to '1', using the object is temporarily allowed
75  // even if it has an Owner field.
76  // Used by bed rent scripts to allow the player to use the bed for the duration of the rent.
77  std::string getGlobalVariable() const;
78 
79  void resetGlobalVariable();
80 
81  // ID of creature trapped in this soul gem
82  std::string getSoul() const;
83  void setSoul(const std::string& soul);
84 
85  // The faction that owns this object (and will get angry if
86  // you take it and are not a faction member)
87  std::string getFaction() const;
88  void setFaction (const std::string& faction);
89 
90  // PC faction rank required to use the item. Sometimes is -1, which means "any rank".
91  void setFactionRank(int factionRank);
92  int getFactionRank() const;
93 
94  // Lock level for doors and containers
95  // Positive for a locked door. 0 for a door that was never locked.
96  // For an unlocked door, it is set to -(previous locklevel)
97  int getLockLevel() const;
98  void setLockLevel(int lockLevel);
99  // Key and trap ID names, if any
100  std::string getKey() const;
101  std::string getTrap() const;
102  void setTrap(const std::string& trap);
103 
104  // This is 5 for Gold_005 references, 100 for Gold_100 and so on.
105  int getGoldValue() const;
106  void setGoldValue(int value);
107 
108  // Write the content of this CellRef into the given ObjectState
109  void writeState (ESM::ObjectState& state) const;
110 
111  // Has this CellRef changed since it was originally loaded?
112  bool hasChanged() const;
113 
114  private:
115  bool mChanged;
117  };
118 
119 }
120 
121 #endif
void applyChargeRemainderToBeSubtracted(float chargeRemainder)
Definition: cellref.cpp:96
void setLockLevel(int lockLevel)
Definition: cellref.cpp:203
Encapsulated variant of ESM::CellRef with change tracking.
Definition: cellref.hpp:15
void setPosition(const ESM::Position &position)
Definition: cellref.cpp:62
std::string getRefId() const
Definition: cellref.cpp:23
void setSoul(const std::string &soul)
Definition: cellref.cpp:175
int getGoldValue() const
Definition: cellref.cpp:231
void setGoldValue(int value)
Definition: cellref.cpp:236
int getFactionRank() const
Definition: cellref.cpp:156
std::string getKey() const
Definition: cellref.cpp:212
void writeState(ESM::ObjectState &state) const
Definition: cellref.cpp:245
bool mChanged
Definition: cellref.hpp:115
std::string getFaction() const
Definition: cellref.cpp:184
int getLockLevel() const
Definition: cellref.cpp:198
void setChargeFloat(float charge)
Definition: cellref.cpp:119
void setTrap(const std::string &trap)
Definition: cellref.cpp:222
std::string getSoul() const
Definition: cellref.cpp:170
Definition: cellref.hpp:14
CellRef(const ESM::CellRef &ref)
Definition: cellref.hpp:19
void setScale(float scale)
Definition: cellref.cpp:48
ESM::Position getPosition() const
Definition: cellref.cpp:57
<
Definition: objectstate.hpp:19
void setEnchantmentCharge(float charge)
Definition: cellref.cpp:73
void setFaction(const std::string &faction)
Definition: cellref.cpp:189
float getScale() const
Definition: cellref.cpp:43
Definition: cellref.hpp:34
std::string getTrap() const
Definition: cellref.cpp:217
float getChargeFloat() const
Definition: cellref.cpp:114
Definition: defs.hpp:38
void setFactionRank(int factionRank)
Definition: cellref.cpp:147
float getEnchantmentCharge() const
Definition: cellref.cpp:68
const ESM::RefNum & getRefNum() const
Definition: cellref.cpp:8
bool hasChanged() const
Definition: cellref.cpp:250
std::string getDestCell() const
Definition: cellref.cpp:38
bool hasContentFile() const
Does the RefNum have a content file?
Definition: cellref.cpp:13
bool getTeleport() const
Definition: cellref.cpp:28
void setCharge(int charge)
Definition: cellref.cpp:87
int getCharge() const
Definition: cellref.cpp:82
std::string getOwner() const
Definition: cellref.cpp:128
void unsetRefNum()
Definition: cellref.cpp:18
ESM::Position getDoorDest() const
Definition: cellref.cpp:33
void setOwner(const std::string &owner)
Definition: cellref.cpp:161
std::string getGlobalVariable() const
Definition: cellref.cpp:133
ESM::CellRef mCellRef
Definition: cellref.hpp:116
void resetGlobalVariable()
Definition: cellref.cpp:138