OpenMW
apps/openmw/mwbase/world.hpp
Go to the documentation of this file.
00001 #ifndef GAME_MWBASE_WORLD_H
00002 #define GAME_MWBASE_WORLD_H
00003 
00004 #include <vector>
00005 
00006 #include <components/settings/settings.hpp>
00007 
00008 #include "../mwworld/globals.hpp"
00009 #include "../mwworld/ptr.hpp"
00010 
00011 namespace Ogre
00012 {
00013     class Vector2;
00014     class Vector3;
00015 }
00016 
00017 namespace OEngine
00018 {
00019     namespace Render
00020     {
00021         class Fader;
00022     }
00023 
00024     namespace Physic
00025     {
00026         class PhysicEngine;
00027     }
00028 }
00029 
00030 namespace ESM
00031 {
00032     class ESMReader;
00033     struct Position;
00034     struct Cell;
00035     struct Class;
00036     struct Potion;
00037     struct Spell;
00038     struct NPC;
00039 }
00040 
00041 namespace MWRender
00042 {
00043     class ExternalRendering;
00044     class Animation;
00045 }
00046 
00047 namespace MWMechanics
00048 {
00049     class Movement;
00050 }
00051 
00052 namespace MWWorld
00053 {
00054     class Fallback;
00055     class CellStore;
00056     class Player;
00057     class LocalScripts;
00058     class TimeStamp;
00059     class ESMStore;
00060     class RefData;
00061 
00062     typedef std::vector<std::pair<MWWorld::Ptr,MWMechanics::Movement> > PtrMovementList;
00063 }
00064 
00065 namespace MWBase
00066 {
00068     class World
00069     {
00070             World (const World&);
00072 
00073             World& operator= (const World&);
00075 
00076         public:
00077 
00078             enum RenderMode
00079             {
00080                 Render_CollisionDebug,
00081                 Render_Wireframe,
00082                 Render_Pathgrid,
00083                 Render_BoundingBoxes
00084             };
00085 
00086             struct DoorMarker
00087             {
00088                 std::string name;
00089                 float x, y; // world position
00090             };
00091 
00092             World() {}
00093 
00094             virtual ~World() {}
00095 
00096             virtual void startNewGame() = 0;
00097 
00098             virtual OEngine::Render::Fader* getFader() = 0;
00100 
00101             virtual MWWorld::CellStore *getExterior (int x, int y) = 0;
00102 
00103             virtual MWWorld::CellStore *getInterior (const std::string& name) = 0;
00104 
00105             virtual void setWaterHeight(const float height) = 0;
00106 
00107             virtual void toggleWater() = 0;
00108 
00109             virtual void adjustSky() = 0;
00110 
00111             virtual void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches) = 0;
00112 
00113             virtual const MWWorld::Fallback *getFallback () const = 0;
00114 
00115             virtual MWWorld::Player& getPlayer() = 0;
00116 
00117             virtual const MWWorld::ESMStore& getStore() const = 0;
00118 
00119             virtual std::vector<ESM::ESMReader>& getEsmReader() = 0;
00120 
00121             virtual MWWorld::LocalScripts& getLocalScripts() = 0;
00122 
00123             virtual bool hasCellChanged() const = 0;
00125 
00126             virtual bool isCellExterior() const = 0;
00127 
00128             virtual bool isCellQuasiExterior() const = 0;
00129 
00130             virtual Ogre::Vector2 getNorthVector (MWWorld::CellStore* cell) = 0;
00132 
00133             virtual void getDoorMarkers (MWWorld::CellStore* cell, std::vector<DoorMarker>& out) = 0;
00135 
00136             virtual void getInteriorMapPosition (Ogre::Vector2 position, float& nX, float& nY, int &x, int& y) = 0;
00138 
00139             virtual bool isPositionExplored (float nX, float nY, int x, int y, bool interior) = 0;
00141 
00142             virtual MWWorld::Globals::Data& getGlobalVariable (const std::string& name) = 0;
00143 
00144             virtual MWWorld::Globals::Data getGlobalVariable (const std::string& name) const = 0;
00145 
00146             virtual char getGlobalVariableType (const std::string& name) const = 0;
00148 
00149             virtual std::vector<std::string> getGlobals () const = 0;
00150 
00151             virtual std::string getCurrentCellName() const = 0;
00152 
00153             virtual void removeRefScript (MWWorld::RefData *ref) = 0;
00154             //< Remove the script attached to ref from mLocalScripts
00155 
00156             virtual MWWorld::Ptr getPtr (const std::string& name, bool activeOnly) = 0;
00159 
00160             virtual MWWorld::Ptr getPtrViaHandle (const std::string& handle) = 0;
00162 
00163             virtual MWWorld::Ptr searchPtrViaHandle (const std::string& handle) = 0;
00165 
00167             virtual void enable (const MWWorld::Ptr& ptr) = 0;
00168 
00170             virtual void disable (const MWWorld::Ptr& ptr) = 0;
00171 
00172             virtual void advanceTime (double hours) = 0;
00174 
00175             virtual void setHour (double hour) = 0;
00177 
00178             virtual void setMonth (int month) = 0;
00180 
00181             virtual void setDay (int day) = 0;
00183 
00184             virtual int getDay() = 0;
00185             virtual int getMonth() = 0;
00186 
00187             virtual MWWorld::TimeStamp getTimeStamp() const = 0;
00189 
00190             virtual bool toggleSky() = 0;
00192 
00193             virtual void changeWeather(const std::string& region, unsigned int id) = 0;
00194 
00195             virtual int getCurrentWeather() const = 0;
00196 
00197             virtual int getMasserPhase() const = 0;
00198 
00199             virtual int getSecundaPhase() const = 0;
00200 
00201             virtual void setMoonColour (bool red) = 0;
00202 
00203             virtual void modRegion(const std::string &regionid, const std::vector<char> &chances) = 0;
00204 
00205             virtual float getTimeScaleFactor() const = 0;
00206 
00207             virtual void changeToInteriorCell (const std::string& cellName,
00208                 const ESM::Position& position) = 0;
00210 
00211             virtual void changeToExteriorCell (const ESM::Position& position) = 0;
00213 
00214             virtual const ESM::Cell *getExterior (const std::string& cellName) const = 0;
00216 
00217             virtual void markCellAsUnchanged() = 0;
00218 
00219             virtual MWWorld::Ptr  getFacedObject() = 0;
00221 
00225             virtual std::pair<MWWorld::Ptr,Ogre::Vector3> getHitContact(const MWWorld::Ptr &ptr, float distance) = 0;
00226 
00227             virtual void adjustPosition (const MWWorld::Ptr& ptr) = 0;
00229 
00230             virtual void deleteObject (const MWWorld::Ptr& ptr) = 0;
00231 
00232             virtual void moveObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0;
00233 
00234             virtual void
00235             moveObject(const MWWorld::Ptr &ptr, MWWorld::CellStore &newCell, float x, float y, float z) = 0;
00236 
00237             virtual void scaleObject (const MWWorld::Ptr& ptr, float scale) = 0;
00238 
00239             virtual void rotateObject(const MWWorld::Ptr& ptr,float x,float y,float z, bool adjust = false) = 0;
00240 
00241             virtual void localRotateObject (const MWWorld::Ptr& ptr, float x, float y, float z) = 0;
00242 
00243             virtual MWWorld::Ptr safePlaceObject(const MWWorld::Ptr& ptr,MWWorld::CellStore &Cell,ESM::Position pos) = 0;
00245 
00246             virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false)
00247                 const = 0;
00249 
00250             virtual void positionToIndex (float x, float y, int &cellX, int &cellY) const = 0;
00252 
00253             virtual void queueMovement(const MWWorld::Ptr &ptr, const Ogre::Vector3 &velocity) = 0;
00256 
00257             virtual bool castRay (float x1, float y1, float z1, float x2, float y2, float z2) = 0;
00259 
00260             virtual bool toggleCollisionMode() = 0;
00264 
00265             virtual bool toggleRenderMode (RenderMode mode) = 0;
00268 
00269             virtual const ESM::Potion *createRecord (const ESM::Potion& record) = 0;
00272 
00273             virtual const ESM::Spell *createRecord (const ESM::Spell& record) = 0;
00276 
00277             virtual const ESM::Class *createRecord (const ESM::Class& record) = 0;
00280 
00281             virtual const ESM::Cell *createRecord (const ESM::Cell& record) = 0;
00284 
00285             virtual const ESM::NPC *createRecord(const ESM::NPC &record) = 0;
00288 
00289             virtual const ESM::Armor *createRecord (const ESM::Armor& record) = 0;
00292 
00293             virtual const ESM::Weapon *createRecord (const ESM::Weapon& record) = 0;
00296 
00297             virtual const ESM::Clothing *createRecord (const ESM::Clothing& record) = 0;
00300 
00301             virtual const ESM::Enchantment *createRecord (const ESM::Enchantment& record) = 0;
00304 
00305             virtual const ESM::Book *createRecord (const ESM::Book& record) = 0;
00308 
00309             virtual void update (float duration, bool paused) = 0;
00310 
00311             virtual bool placeObject (const MWWorld::Ptr& object, float cursorX, float cursorY, int amount) = 0;
00318 
00319             virtual void dropObjectOnGround (const MWWorld::Ptr& actor, const MWWorld::Ptr& object, int amount) = 0;
00324 
00325             virtual bool canPlaceObject (float cursorX, float cursorY) = 0;
00327 
00328             virtual void processChangedSettings (const Settings::CategorySettingVector& settings) = 0;
00329 
00330             virtual bool isFlying(const MWWorld::Ptr &ptr) const = 0;
00331             virtual bool isSlowFalling(const MWWorld::Ptr &ptr) const = 0;
00332             virtual bool isSwimming(const MWWorld::Ptr &object) const = 0;
00334             virtual bool isSubmerged(const MWWorld::Ptr &object) const = 0;
00335             virtual bool isUnderwater(const MWWorld::Ptr::CellStore* cell, const Ogre::Vector3 &pos) const = 0;
00336             virtual bool isOnGround(const MWWorld::Ptr &ptr) const = 0;
00337 
00338             virtual void togglePOV() = 0;
00339             virtual void togglePreviewMode(bool enable) = 0;
00340             virtual bool toggleVanityMode(bool enable) = 0;
00341             virtual void allowVanityMode(bool allow) = 0;
00342             virtual void togglePlayerLooking(bool enable) = 0;
00343             virtual void changeVanityModeScale(float factor) = 0;
00344             virtual bool vanityRotateCamera(float * rot) = 0;
00345             virtual void setCameraDistance(float dist, bool adjust = false, bool override = true)=0;
00346 
00347             virtual void setupPlayer() = 0;
00348             virtual void renderPlayer() = 0;
00349 
00350             virtual bool getOpenOrCloseDoor(const MWWorld::Ptr& door) = 0;
00352             virtual void activateDoor(const MWWorld::Ptr& door) = 0;
00354 
00355             virtual bool getPlayerStandingOn (const MWWorld::Ptr& object) = 0; 
00356             virtual bool getActorStandingOn (const MWWorld::Ptr& object) = 0; 
00357             virtual float getWindSpeed() = 0;
00358 
00359             virtual void getContainersOwnedBy (const MWWorld::Ptr& npc, std::vector<MWWorld::Ptr>& out) = 0;
00361             virtual void getItemsOwnedBy (const MWWorld::Ptr& npc, std::vector<MWWorld::Ptr>& out) = 0;
00363 
00364             virtual bool getLOS(const MWWorld::Ptr& npc,const MWWorld::Ptr& targetNpc) = 0;
00366 
00367             virtual void enableActorCollision(const MWWorld::Ptr& actor, bool enable) = 0;
00368 
00369             virtual void setupExternalRendering (MWRender::ExternalRendering& rendering) = 0;
00370 
00371             virtual int canRest() = 0;
00377 
00379             virtual MWRender::Animation* getAnimation(const MWWorld::Ptr &ptr) = 0;
00380 
00382             virtual void playVideo(const std::string& name, bool allowSkipping) = 0;
00383             virtual void stopVideo() = 0;
00384             virtual void frameStarted (float dt, bool paused) = 0;
00385 
00388             virtual bool findExteriorPosition(const std::string &name, ESM::Position &pos) = 0;
00389 
00392             virtual bool findInteriorPosition(const std::string &name, ESM::Position &pos) = 0;
00393 
00395             virtual void enableTeleporting(bool enable) = 0;
00396 
00398             virtual bool isTeleportingEnabled() const = 0;
00399 
00401             virtual void enableLevitation(bool enable) = 0;
00402 
00404             virtual bool isLevitationEnabled() const = 0;
00405 
00407             virtual void setWerewolf(const MWWorld::Ptr& actor, bool werewolf) = 0;
00408 
00411             virtual void applyWerewolfAcrobatics(const MWWorld::Ptr& actor) = 0;
00412 
00413             virtual bool getGodModeState() = 0;
00414 
00415             virtual bool toggleGodMode() = 0;
00416 
00422             virtual bool startSpellCast (const MWWorld::Ptr& actor) = 0;
00423 
00424             virtual void castSpell (const MWWorld::Ptr& actor) = 0;
00425 
00426             virtual void launchProjectile (const std::string& id, bool stack, const ESM::EffectList& effects,
00427                                            const MWWorld::Ptr& actor, const std::string& sourceName) = 0;
00428 
00429             virtual void breakInvisibility (const MWWorld::Ptr& actor) = 0;
00430 
00431             // Are we in an exterior or pseudo-exterior cell and it's night?
00432             virtual bool isDark() const = 0;
00433 
00434             virtual bool findInteriorPositionInWorldSpace(MWWorld::CellStore* cell, Ogre::Vector3& result) = 0;
00435 
00439             virtual void teleportToClosestMarker (const MWWorld::Ptr& ptr,
00440                                                   const std::string& id, Ogre::Vector3 worldPos) = 0;
00441 
00442             enum DetectionType
00443             {
00444                 Detect_Enchantment,
00445                 Detect_Key,
00446                 Detect_Creature
00447             };
00451             virtual void listDetectedReferences (const MWWorld::Ptr& ptr, std::vector<MWWorld::Ptr>& out,
00452                                                   DetectionType type) = 0;
00453     };
00454 }
00455 
00456 #endif