OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
class.hpp
Go to the documentation of this file.
1 #ifndef GAME_MWWORLD_CLASS_H
2 #define GAME_MWWORLD_CLASS_H
3 
4 #include <map>
5 #include <string>
6 #include <vector>
7 
8 #include <boost/shared_ptr.hpp>
9 
10 #include "ptr.hpp"
11 
12 namespace ESM
13 {
14  struct ObjectState;
15 }
16 
17 namespace MWRender
18 {
19  class RenderingInterface;
20 }
21 
22 namespace MWPhysics
23 {
24  class PhysicsSystem;
25 }
26 
27 namespace MWMechanics
28 {
29  class CreatureStats;
30  class NpcStats;
31  struct Movement;
32 }
33 
34 namespace MWGui
35 {
36  struct ToolTipInfo;
37 }
38 
39 namespace ESM
40 {
41  struct Position;
42 }
43 
44 namespace MWWorld
45 {
46  class ContainerStore;
47  class InventoryStore;
48  class CellStore;
49  class Action;
50 
52  class Class
53  {
54  static std::map<std::string, boost::shared_ptr<Class> > sClasses;
55 
56  std::string mTypeName;
57 
58  // not implemented
59  Class (const Class&);
60  Class& operator= (const Class&);
61 
62  protected:
63 
64  Class();
65 
66  boost::shared_ptr<Action> defaultItemActivate(const Ptr &ptr, const Ptr &actor) const;
68 
69  virtual Ptr copyToCellImpl(const ConstPtr &ptr, CellStore &cell) const;
70 
71  public:
72 
73  virtual ~Class();
74 
75  const std::string& getTypeName() const {
76  return mTypeName;
77  }
78 
79  virtual void insertObjectRendering (const Ptr& ptr, const std::string& mesh, MWRender::RenderingInterface& renderingInterface) const;
80  virtual void insertObject(const Ptr& ptr, const std::string& mesh, MWPhysics::PhysicsSystem& physics) const;
82 
83  virtual std::string getName (const ConstPtr& ptr) const = 0;
86 
87  virtual void adjustPosition(const MWWorld::Ptr& ptr, bool force) const;
90 
91  virtual MWMechanics::CreatureStats& getCreatureStats (const Ptr& ptr) const;
94 
95  virtual bool hasToolTip (const ConstPtr& ptr) const;
97 
98  virtual MWGui::ToolTipInfo getToolTipInfo (const ConstPtr& ptr, int count) const;
100 
101  virtual bool showsInInventory (const ConstPtr& ptr) const;
105 
106  virtual MWMechanics::NpcStats& getNpcStats (const Ptr& ptr) const;
109 
110  virtual bool hasItemHealth (const ConstPtr& ptr) const;
112 
113  virtual int getItemHealth (const ConstPtr& ptr) const;
115 
116  virtual int getItemMaxHealth (const ConstPtr& ptr) const;
119 
120  virtual void hit(const Ptr& ptr, float attackStrength, int type=-1) const;
127 
128  virtual void onHit(const MWWorld::Ptr &ptr, float damage, bool ishealth, const MWWorld::Ptr &object, const MWWorld::Ptr &attacker, const osg::Vec3f &hitPosition, bool successful) const;
133 
134  virtual void block (const Ptr& ptr) const;
137 
138  virtual bool canBeActivated(const Ptr& ptr) const;
141 
142  virtual boost::shared_ptr<Action> activate (const Ptr& ptr, const Ptr& actor) const;
144 
145  virtual boost::shared_ptr<Action> use (const Ptr& ptr)
146  const;
149 
150  virtual ContainerStore& getContainerStore (const Ptr& ptr) const;
153 
154  virtual InventoryStore& getInventoryStore (const Ptr& ptr) const;
157 
158  virtual bool hasInventoryStore (const Ptr& ptr) const;
160 
161  virtual void lock (const Ptr& ptr, int lockLevel) const;
163 
164  virtual void unlock (const Ptr& ptr) const;
166 
167  virtual bool canLock (const ConstPtr& ptr) const;
168 
169  virtual void setRemainingUsageTime (const Ptr& ptr, float duration) const;
172 
173  virtual float getRemainingUsageTime (const ConstPtr& ptr) const;
176 
177  virtual std::string getScript (const ConstPtr& ptr) const;
180 
181  virtual float getSpeed (const Ptr& ptr) const;
183 
184  virtual float getJump(const MWWorld::Ptr &ptr) const;
186 
187  virtual MWMechanics::Movement& getMovementSettings (const Ptr& ptr) const;
189 
190  virtual osg::Vec3f getRotationVector (const Ptr& ptr) const;
192 
193  virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const ConstPtr& ptr) const;
198 
199  virtual int getEquipmentSkill (const ConstPtr& ptr)
200  const;
204 
205  virtual int getValue (const ConstPtr& ptr) const;
208 
209  virtual float getCapacity (const MWWorld::Ptr& ptr) const;
213 
214  virtual float getEncumbrance (const MWWorld::Ptr& ptr) const;
218 
219  virtual float getNormalizedEncumbrance (const MWWorld::Ptr& ptr) const;
221 
222  virtual bool apply (const MWWorld::Ptr& ptr, const std::string& id,
223  const MWWorld::Ptr& actor) const;
229 
230  virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType, float extraFactor=1.f) const;
234 
235  virtual bool isEssential (const MWWorld::ConstPtr& ptr) const;
239 
240  virtual std::string getUpSoundId (const ConstPtr& ptr) const;
243 
244  virtual std::string getDownSoundId (const ConstPtr& ptr) const;
247 
248  virtual std::string getSoundIdFromSndGen(const Ptr &ptr, const std::string &type) const;
250 
251  virtual float getArmorRating (const MWWorld::Ptr& ptr) const;
253 
254  virtual std::string getInventoryIcon (const MWWorld::ConstPtr& ptr) const;
256 
257  virtual std::string getEnchantment (const MWWorld::ConstPtr& ptr) const;
260 
261  virtual int getEnchantmentPoints (const MWWorld::ConstPtr& ptr) const;
263 
264  virtual void adjustScale(const MWWorld::ConstPtr& ptr, osg::Vec3f& scale, bool rendering) const;
266 
267  virtual bool canSell (const MWWorld::ConstPtr& item, int npcServices) const;
269 
270  virtual int getServices (const MWWorld::ConstPtr& actor) const;
271 
272  virtual std::string getModel(const MWWorld::ConstPtr &ptr) const;
273 
274  virtual void getModelsToPreload(const MWWorld::Ptr& ptr, std::vector<std::string>& models) const;
276 
277  virtual std::string applyEnchantment(const MWWorld::ConstPtr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
279 
280  virtual std::pair<int, std::string> canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const;
283 
284  virtual float getWeight (const MWWorld::ConstPtr& ptr) const;
285 
286  virtual bool isPersistent (const MWWorld::ConstPtr& ptr) const;
287 
288  virtual bool isKey (const MWWorld::ConstPtr& ptr) const { return false; }
289 
290  virtual bool isGold(const MWWorld::ConstPtr& ptr) const { return false; }
291 
292  virtual bool allowTelekinesis(const MWWorld::ConstPtr& ptr) const { return true; }
294 
296  virtual int getBloodTexture (const MWWorld::ConstPtr& ptr) const;
297 
298  virtual Ptr copyToCell(const ConstPtr &ptr, CellStore &cell, int count) const;
299 
300  virtual Ptr copyToCell(const ConstPtr &ptr, CellStore &cell, const ESM::Position &pos, int count) const;
301 
302  virtual bool isActor() const {
303  return false;
304  }
305 
306  virtual bool isNpc() const {
307  return false;
308  }
309 
310  virtual bool isBipedal(const MWWorld::ConstPtr& ptr) const;
311  virtual bool canFly(const MWWorld::ConstPtr& ptr) const;
312  virtual bool canSwim(const MWWorld::ConstPtr& ptr) const;
313  virtual bool canWalk(const MWWorld::ConstPtr& ptr) const;
314  bool isPureWaterCreature(const MWWorld::Ptr& ptr) const;
315  bool isPureFlyingCreature(const MWWorld::Ptr& ptr) const;
316  bool isPureLandCreature(const MWWorld::Ptr& ptr) const;
317  bool isMobile(const MWWorld::Ptr& ptr) const;
318 
319  virtual int getSkill(const MWWorld::Ptr& ptr, int skill) const;
320 
321  virtual void readAdditionalState (const MWWorld::Ptr& ptr, const ESM::ObjectState& state)
322  const;
324 
325  virtual void writeAdditionalState (const MWWorld::ConstPtr& ptr, ESM::ObjectState& state)
326  const;
328 
329  static const Class& get (const std::string& key);
331 
332  static void registerClass (const std::string& key, boost::shared_ptr<Class> instance);
333 
334  virtual int getBaseGold(const MWWorld::ConstPtr& ptr) const;
335 
336  virtual bool isClass(const MWWorld::ConstPtr& ptr, const std::string &className) const;
337 
339  virtual int getDoorState (const MWWorld::ConstPtr &ptr) const;
341  virtual void setDoorState (const MWWorld::Ptr &ptr, int state) const;
342 
343  virtual void respawn (const MWWorld::Ptr& ptr) const {}
344 
345  virtual void restock (const MWWorld::Ptr& ptr) const {}
346 
348  virtual std::string getSound(const MWWorld::ConstPtr& ptr) const;
349 
350  virtual int getBaseFightRating (const MWWorld::ConstPtr& ptr) const;
351 
352  virtual std::string getPrimaryFaction (const MWWorld::ConstPtr& ptr) const;
353  virtual int getPrimaryFactionRank (const MWWorld::ConstPtr& ptr) const;
354 
356  virtual int getEffectiveArmorRating(const MWWorld::ConstPtr& armor, const MWWorld::Ptr& actor) const;
357  };
358 }
359 
360 #endif
virtual bool canSell(const MWWorld::ConstPtr &item, int npcServices) const
Determine whether or not item can be sold to an npc with the given npcServices.
Definition: class.cpp:53
virtual std::string getDownSoundId(const ConstPtr &ptr) const
Definition: class.cpp:260
Definition: tooltips.hpp:18
static std::map< std::string, boost::shared_ptr< Class > > sClasses
Definition: class.hpp:54
virtual MWMechanics::CreatureStats & getCreatureStats(const Ptr &ptr) const
Definition: class.cpp:63
virtual int getSkill(const MWWorld::Ptr &ptr, int skill) const
Definition: class.cpp:423
virtual bool isEssential(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:221
virtual int getItemMaxHealth(const ConstPtr &ptr) const
Definition: class.cpp:86
virtual bool isBipedal(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:374
virtual void restock(const MWWorld::Ptr &ptr) const
Definition: class.hpp:345
virtual void adjustScale(const MWWorld::ConstPtr &ptr, osg::Vec3f &scale, bool rendering) const
Definition: class.cpp:298
virtual bool canWalk(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:389
virtual bool apply(const MWWorld::Ptr &ptr, const std::string &id, const MWWorld::Ptr &actor) const
Definition: class.cpp:43
Common creature stats.
Definition: creaturestats.hpp:25
virtual bool showsInInventory(const ConstPtr &ptr) const
Definition: class.cpp:280
virtual void readAdditionalState(const MWWorld::Ptr &ptr, const ESM::ObjectState &state) const
Read additional state from state into ptr.
Definition: class.cpp:433
virtual MWMechanics::NpcStats & getNpcStats(const Ptr &ptr) const
Definition: class.cpp:68
virtual boost::shared_ptr< Action > use(const Ptr &ptr) const
Definition: class.cpp:116
virtual void unlock(const Ptr &ptr) const
Unlock object (default implementation: throw an exception)
Definition: class.cpp:141
Definition: inventorystore.hpp:40
static void registerClass(const std::string &key, boost::shared_ptr< Class > instance)
Definition: class.cpp:249
virtual bool canSwim(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:384
virtual int getItemHealth(const ConstPtr &ptr) const
Return current item health or throw an exception if class does not have item health.
Definition: class.cpp:78
virtual bool isKey(const MWWorld::ConstPtr &ptr) const
Definition: class.hpp:288
virtual void setDoorState(const MWWorld::Ptr &ptr, int state) const
This does not actually cause the door to move. Use World::activateDoor instead.
Definition: class.cpp:452
Definition: renderinginterface.hpp:9
std::string mTypeName
Definition: class.hpp:56
virtual void getModelsToPreload(const MWWorld::Ptr &ptr, std::vector< std::string > &models) const
Get a list of models to preload that this object may use (directly or indirectly). default implementation: list getModel().
Definition: class.cpp:307
bool isPureFlyingCreature(const MWWorld::Ptr &ptr) const
Definition: class.cpp:402
virtual std::string applyEnchantment(const MWWorld::ConstPtr &ptr, const std::string &enchId, int enchCharge, const std::string &newName) const
Creates a new record using ptr as template, with the given name and the given enchantment applied to ...
Definition: class.cpp:314
Definition: physicssystem.hpp:51
virtual int getEquipmentSkill(const ConstPtr &ptr) const
Definition: class.cpp:196
virtual bool canLock(const ConstPtr &ptr) const
Definition: class.cpp:146
virtual std::string getName(const ConstPtr &ptr) const =0
Base class for referenceable esm records.
Definition: class.hpp:52
virtual bool isNpc() const
Definition: class.hpp:306
Class & operator=(const Class &)
virtual int getDoorState(const MWWorld::ConstPtr &ptr) const
0 = nothing, 1 = opening, 2 = closing
Definition: class.cpp:447
virtual osg::Vec3f getRotationVector(const Ptr &ptr) const
Return desired rotations, as euler angles.
Definition: class.cpp:186
virtual std::string getModel(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:302
virtual void hit(const Ptr &ptr, float attackStrength, int type=-1) const
Definition: class.cpp:91
virtual float getSpeed(const Ptr &ptr) const
Return movement speed.
Definition: class.cpp:166
virtual std::pair< std::vector< int >, bool > getEquipmentSlots(const ConstPtr &ptr) const
Definition: class.cpp:191
boost::shared_ptr< Action > defaultItemActivate(const Ptr &ptr, const Ptr &actor) const
Generate default action for activating inventory items.
Definition: class.cpp:328
virtual bool isClass(const MWWorld::ConstPtr &ptr, const std::string &className) const
Definition: class.cpp:442
virtual int getPrimaryFactionRank(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:480
virtual void onHit(const MWWorld::Ptr &ptr, float damage, bool ishealth, const MWWorld::Ptr &object, const MWWorld::Ptr &attacker, const osg::Vec3f &hitPosition, bool successful) const
Definition: class.cpp:106
virtual bool hasItemHealth(const ConstPtr &ptr) const
Definition: class.cpp:73
<
Definition: objectstate.hpp:19
virtual void insertObject(const Ptr &ptr, const std::string &mesh, MWPhysics::PhysicsSystem &physics) const
Add reference into a cell for rendering (default implementation: don't render anything).
Definition: class.cpp:38
Desired movement for an actor.
Definition: movement.hpp:9
virtual std::string getEnchantment(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:293
virtual float getArmorRating(const MWWorld::Ptr &ptr) const
Definition: class.cpp:226
bool isPureWaterCreature(const MWWorld::Ptr &ptr) const
Definition: class.cpp:394
virtual void lock(const Ptr &ptr, int lockLevel) const
Lock object (default implementation: throw an exception)
Definition: class.cpp:136
Mutable state of a cell.
Definition: cellstore.hpp:53
bool isMobile(const MWWorld::Ptr &ptr) const
Definition: class.cpp:418
virtual float getEncumbrance(const MWWorld::Ptr &ptr) const
Definition: class.cpp:216
virtual std::string getInventoryIcon(const MWWorld::ConstPtr &ptr) const
Return name of inventory icon.
Definition: class.cpp:270
virtual std::string getPrimaryFaction(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:476
virtual float getWeight(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:211
Pointer to a const LiveCellRef.
Definition: ptr.hpp:90
const std::string & getTypeName() const
Definition: class.hpp:75
virtual std::pair< int, std::string > canBeEquipped(const MWWorld::ConstPtr &ptr, const MWWorld::Ptr &npc) const
Definition: class.cpp:319
virtual void respawn(const MWWorld::Ptr &ptr) const
Definition: class.hpp:343
virtual bool isActor() const
Definition: class.hpp:302
virtual int getValue(const ConstPtr &ptr) const
Definition: class.cpp:201
Definition: containerstore.hpp:41
virtual boost::shared_ptr< Action > activate(const Ptr &ptr, const Ptr &actor) const
Generate action for activation (default implementation: return a null action).
Definition: class.cpp:111
virtual bool isPersistent(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:244
virtual float getRemainingUsageTime(const ConstPtr &ptr) const
Definition: class.cpp:156
virtual ContainerStore & getContainerStore(const Ptr &ptr) const
Definition: class.cpp:121
virtual std::string getScript(const ConstPtr &ptr) const
Definition: class.cpp:161
virtual std::string getUpSoundId(const ConstPtr &ptr) const
Definition: class.cpp:255
virtual int getBaseFightRating(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:471
virtual void setRemainingUsageTime(const Ptr &ptr, float duration) const
Definition: class.cpp:151
virtual bool isGold(const MWWorld::ConstPtr &ptr) const
Definition: class.hpp:290
virtual bool hasToolTip(const ConstPtr &ptr) const
Definition: class.cpp:288
Definition: defs.hpp:38
Additional stats for NPCs.
Definition: npcstats.hpp:21
virtual float getCapacity(const MWWorld::Ptr &ptr) const
Definition: class.cpp:206
virtual bool allowTelekinesis(const MWWorld::ConstPtr &ptr) const
Return whether this class of object can be activated with telekinesis.
Definition: class.hpp:292
virtual bool hasInventoryStore(const Ptr &ptr) const
Does this object have an inventory store, i.e. equipment slots? (default implementation: false) ...
Definition: class.cpp:131
virtual MWGui::ToolTipInfo getToolTipInfo(const ConstPtr &ptr, int count) const
Definition: class.cpp:275
virtual void block(const Ptr &ptr) const
Definition: class.cpp:96
virtual bool canBeActivated(const Ptr &ptr) const
Definition: class.cpp:101
virtual void skillUsageSucceeded(const MWWorld::Ptr &ptr, int skill, int usageType, float extraFactor=1.f) const
Definition: class.cpp:48
virtual int getEnchantmentPoints(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:176
virtual float getNormalizedEncumbrance(const MWWorld::Ptr &ptr) const
Returns encumbrance re-scaled to capacity.
Definition: class.cpp:457
virtual MWMechanics::Movement & getMovementSettings(const Ptr &ptr) const
Return desired movement.
Definition: class.cpp:181
Class()
Definition: class.cpp:29
bool isPureLandCreature(const MWWorld::Ptr &ptr) const
Definition: class.cpp:410
virtual int getEffectiveArmorRating(const MWWorld::ConstPtr &armor, const MWWorld::Ptr &actor) const
Get the effective armor rating, factoring in the actor's skills, for the given armor.
Definition: class.cpp:485
Pointer to a LiveCellRef.
Definition: ptr.hpp:19
virtual int getBaseGold(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:437
virtual void insertObjectRendering(const Ptr &ptr, const std::string &mesh, MWRender::RenderingInterface &renderingInterface) const
Definition: class.cpp:33
virtual std::string getSoundIdFromSndGen(const Ptr &ptr, const std::string &type) const
Returns the sound ID for ptr of the given soundgen type.
Definition: class.cpp:265
virtual Ptr copyToCellImpl(const ConstPtr &ptr, CellStore &cell) const
Definition: class.cpp:351
virtual int getBloodTexture(const MWWorld::ConstPtr &ptr) const
Get a blood texture suitable for ptr (see Blood Texture 0-2 in Morrowind.ini)
Definition: class.cpp:428
virtual std::string getSound(const MWWorld::ConstPtr &ptr) const
Returns sound id.
Definition: class.cpp:466
virtual void writeAdditionalState(const MWWorld::ConstPtr &ptr, ESM::ObjectState &state) const
Write additional state from ptr into state.
Definition: class.cpp:435
virtual Ptr copyToCell(const ConstPtr &ptr, CellStore &cell, int count) const
Definition: class.cpp:357
virtual InventoryStore & getInventoryStore(const Ptr &ptr) const
Definition: class.cpp:126
virtual bool canFly(const MWWorld::ConstPtr &ptr) const
Definition: class.cpp:379
virtual ~Class()
Definition: class.cpp:31
virtual float getJump(const MWWorld::Ptr &ptr) const
Return jump velocity (not accounting for movement)
Definition: class.cpp:171
virtual int getServices(const MWWorld::ConstPtr &actor) const
Definition: class.cpp:58
virtual void adjustPosition(const MWWorld::Ptr &ptr, bool force) const
Definition: class.cpp:324