OpenMW
apps/openmw/mwworld/class.hpp
Go to the documentation of this file.
00001 #ifndef GAME_MWWORLD_CLASS_H
00002 #define GAME_MWWORLD_CLASS_H
00003 
00004 #include <map>
00005 #include <string>
00006 #include <vector>
00007 
00008 #include <boost/shared_ptr.hpp>
00009 
00010 #include "ptr.hpp"
00011 
00012 namespace Ogre
00013 {
00014     class Vector3;
00015 }
00016 
00017 namespace MWRender
00018 {
00019     class RenderingInterface;
00020 }
00021 
00022 namespace MWMechanics
00023 {
00024     class CreatureStats;
00025     class NpcStats;
00026     struct Movement;
00027 }
00028 
00029 namespace MWGui
00030 {
00031     struct ToolTipInfo;
00032 }
00033 
00034 namespace ESM
00035 {
00036     struct Position;
00037 }
00038 
00039 namespace MWWorld
00040 {
00041     class Ptr;
00042     class ContainerStore;
00043     class InventoryStore;
00044     class PhysicsSystem;
00045     class CellStore;
00046     class Action;
00047 
00049     class Class
00050     {
00051             static std::map<std::string, boost::shared_ptr<Class> > sClasses;
00052 
00053             std::string mTypeName;
00054 
00055             // not implemented
00056             Class (const Class&);
00057             Class& operator= (const Class&);
00058 
00059         protected:
00060 
00061             Class();
00062 
00063             boost::shared_ptr<Action> defaultItemActivate(const Ptr &ptr, const Ptr &actor) const;
00065 
00066             virtual Ptr copyToCellImpl(const Ptr &ptr, CellStore &cell) const;
00067 
00068         public:
00069 
00071             enum Stance
00072             {
00073                 Run, Sneak, Combat
00074             };
00075 
00076             virtual ~Class();
00077 
00078             const std::string& getTypeName() const {
00079                 return mTypeName;
00080             }
00081 
00082             virtual std::string getId (const Ptr& ptr) const;
00085 
00086             virtual void insertObjectRendering (const Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const;
00087             virtual void insertObject(const Ptr& ptr, MWWorld::PhysicsSystem& physics) const;
00089 
00090             virtual std::string getName (const Ptr& ptr) const = 0;
00093 
00094             virtual void adjustPosition(const MWWorld::Ptr& ptr) const;
00096 
00097             virtual MWMechanics::CreatureStats& getCreatureStats (const Ptr& ptr) const;
00100 
00101             virtual bool hasToolTip (const Ptr& ptr) const;
00103 
00104             virtual MWGui::ToolTipInfo getToolTipInfo (const Ptr& ptr) const;
00106 
00107             virtual MWMechanics::NpcStats& getNpcStats (const Ptr& ptr) const;
00110 
00111             virtual bool hasItemHealth (const Ptr& ptr) const;
00113 
00114             virtual int getItemMaxHealth (const Ptr& ptr) const;
00117 
00118             virtual void hit(const Ptr& ptr, int type=-1) const;
00124 
00125             virtual void onHit(const MWWorld::Ptr &ptr, float damage, bool ishealth, const MWWorld::Ptr &object, const MWWorld::Ptr &attacker, bool successful) const;
00130 
00131             virtual void setActorHealth(const Ptr& ptr, float health, const Ptr& attacker=Ptr()) const;
00136 
00137             virtual boost::shared_ptr<Action> activate (const Ptr& ptr, const Ptr& actor) const;
00139 
00140             virtual boost::shared_ptr<Action> use (const Ptr& ptr)
00141                 const;
00144 
00145             virtual ContainerStore& getContainerStore (const Ptr& ptr) const;
00148 
00149             virtual InventoryStore& getInventoryStore (const Ptr& ptr) const;
00152 
00153             virtual void lock (const Ptr& ptr, int lockLevel) const;
00155 
00156             virtual void unlock (const Ptr& ptr) const;
00158 
00159             virtual void setRemainingUsageTime (const Ptr& ptr, float duration) const;
00162 
00163             virtual float getRemainingUsageTime (const Ptr& ptr) const;
00166 
00167             virtual std::string getScript (const Ptr& ptr) const;
00170 
00171             virtual void setForceStance (const Ptr& ptr, Stance stance, bool force) const;
00173 
00174             virtual void setStance (const Ptr& ptr, Stance stance, bool set) const;
00176 
00177             virtual bool getStance (const Ptr& ptr, Stance stance, bool ignoreForce = false) const;
00179 
00180             virtual float getSpeed (const Ptr& ptr) const;
00182 
00183             virtual float getJump(const MWWorld::Ptr &ptr) const;
00185 
00186             virtual float getFallDamage(const MWWorld::Ptr &ptr, float fallHeight) const;
00188 
00189             virtual MWMechanics::Movement& getMovementSettings (const Ptr& ptr) const;
00191 
00192             virtual Ogre::Vector3 getMovementVector (const Ptr& ptr) const;
00195 
00196             virtual Ogre::Vector3 getRotationVector (const Ptr& ptr) const;
00198 
00199             virtual std::pair<std::vector<int>, bool> getEquipmentSlots (const Ptr& ptr) const;
00204 
00205             virtual int getEquipmentSkill (const Ptr& ptr)
00206                 const;
00210 
00211             virtual int getValue (const Ptr& ptr) const;
00214 
00215             virtual float getCapacity (const MWWorld::Ptr& ptr) const;
00219 
00220             virtual float getEncumbrance (const MWWorld::Ptr& ptr) const;
00224 
00225             virtual bool apply (const MWWorld::Ptr& ptr, const std::string& id,
00226                 const MWWorld::Ptr& actor) const;
00232 
00233             virtual void skillUsageSucceeded (const MWWorld::Ptr& ptr, int skill, int usageType) const;
00237 
00238             virtual bool isEssential (const MWWorld::Ptr& ptr) const;
00242 
00243             virtual bool hasDetected (const MWWorld::Ptr& ptr, const MWWorld::Ptr& ptr2) const;
00247 
00248             virtual std::string getUpSoundId (const Ptr& ptr) const;
00251 
00252             virtual std::string getDownSoundId (const Ptr& ptr) const;
00255 
00256             virtual std::string getSoundIdFromSndGen(const Ptr &ptr, const std::string &type) const;
00258 
00259             virtual float getArmorRating (const MWWorld::Ptr& ptr) const;
00261 
00262             virtual std::string getInventoryIcon (const MWWorld::Ptr& ptr) const;
00264 
00265             virtual std::string getEnchantment (const MWWorld::Ptr& ptr) const;
00268 
00269             virtual float getEnchantmentPoints (const MWWorld::Ptr& ptr) const;
00271 
00272             virtual void adjustScale(const MWWorld::Ptr& ptr,float& scale) const;
00273 
00274             virtual void adjustRotation(const MWWorld::Ptr& ptr,float& x,float& y,float& z) const;
00275 
00276             virtual bool canSell (const MWWorld::Ptr& item, int npcServices) const;
00278 
00279             virtual int getServices (const MWWorld::Ptr& actor) const;
00280 
00281             virtual std::string getModel(const MWWorld::Ptr &ptr) const;
00282 
00283             virtual void applyEnchantment(const MWWorld::Ptr &ptr, const std::string& enchId, int enchCharge, const std::string& newName) const;
00284 
00285             virtual std::pair<int, std::string> canBeEquipped(const MWWorld::Ptr &ptr, const MWWorld::Ptr &npc) const;
00288 
00289             virtual float getWeight (const MWWorld::Ptr& ptr) const;
00290 
00291             virtual bool isPersistent (const MWWorld::Ptr& ptr) const;
00292 
00293             virtual bool isKey (const MWWorld::Ptr& ptr) const { return false; }
00294 
00295             virtual Ptr
00296             copyToCell(const Ptr &ptr, CellStore &cell) const;
00297 
00298             virtual Ptr
00299             copyToCell(const Ptr &ptr, CellStore &cell, const ESM::Position &pos) const;
00300 
00301             virtual bool isActor() const {
00302                 return false;
00303             }
00304 
00305             virtual bool isNpc() const {
00306                 return false;
00307             }
00308 
00309             static const Class& get (const std::string& key);
00311 
00312             static const Class& get (const Ptr& ptr)
00313             {
00314                 return ptr.getClass();
00315             }
00317 
00318             static void registerClass (const std::string& key,  boost::shared_ptr<Class> instance);
00319     };
00320 }
00321 
00322 #endif