1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 11:49:56 +00:00
openmw-tes3mp/apps/openmw/mwworld/worldimp.hpp

366 lines
13 KiB
C++
Raw Normal View History

#ifndef GAME_MWWORLD_WORLDIMP_H
#define GAME_MWWORLD_WORLDIMP_H
2011-10-25 18:06:44 +00:00
#include "../mwrender/debugging.hpp"
#include "ptr.hpp"
#include "scene.hpp"
2012-10-01 15:17:04 +00:00
#include "esmstore.hpp"
2011-08-01 13:55:36 +00:00
#include "physicssystem.hpp"
#include "cells.hpp"
#include "localscripts.hpp"
#include "timestamp.hpp"
#include "../mwbase/world.hpp"
namespace Ogre
{
class Vector3;
}
2010-07-22 10:29:23 +00:00
namespace ESM
{
struct Position;
}
namespace Files
{
class Collections;
}
namespace Render
{
class OgreRenderer;
}
namespace MWRender
{
class SkyManager;
class CellRender;
class Animation;
}
2010-07-03 13:41:20 +00:00
namespace MWWorld
{
class WeatherManager;
class Player;
/// \brief The game world and its visual representation
class World : public MWBase::World
{
MWRender::RenderingManager* mRendering;
MWWorld::WeatherManager* mWeatherManager;
MWWorld::Scene *mWorldScene;
MWWorld::Player *mPlayer;
ESM::ESMReader mEsm;
2012-10-01 15:17:04 +00:00
MWWorld::ESMStore mStore;
LocalScripts mLocalScripts;
MWWorld::Globals *mGlobalVariables;
2011-08-01 13:55:36 +00:00
MWWorld::PhysicsSystem *mPhysics;
bool mSky;
2011-09-04 07:48:50 +00:00
Cells mCells;
OEngine::Physic::PhysicEngine* mPhysEngine;
2011-02-19 16:59:40 +00:00
// not implemented
World (const World&);
World& operator= (const World&);
Ptr getPtrViaHandle (const std::string& handle, Ptr::CellStore& cellStore);
int mActivationDistanceOverride;
2012-03-25 18:52:56 +00:00
std::string mFacedHandle;
float mFacedDistance;
2012-03-25 18:52:56 +00:00
Ptr mFaced1;
Ptr mFaced2;
std::string mFaced1Name;
std::string mFaced2Name;
float mFaced1Distance;
float mFaced2Distance;
2012-03-25 18:52:56 +00:00
int mNumFacing;
std::map<std::string,std::string> mFallback;
unsigned long lastTick;
Ogre::Timer mTimer;
int getDaysPerMonth (int month) const;
2011-09-04 07:48:50 +00:00
bool moveObjectImp (const Ptr& ptr, float x, float y, float z);
///< @return true if the active cell (cell player is in) changed
2011-09-04 07:48:50 +00:00
virtual void
copyObjectToCell(const Ptr &ptr, CellStore &cell, const ESM::Position &pos);
void updateWindowManager ();
void performUpdateSceneQueries ();
void processFacedQueryResults (MWRender::OcclusionQuery* query);
void beginFacedQueryProcess (MWRender::OcclusionQuery* query);
void beginSingleFacedQueryProcess (MWRender::OcclusionQuery* query, std::vector < std::pair < float, std::string > > const & results);
void beginDoubleFacedQueryProcess (MWRender::OcclusionQuery* query, std::vector < std::pair < float, std::string > > const & results);
float getMaxActivationDistance ();
float getNpcActivationDistance ();
float getObjectActivationDistance ();
public:
World (OEngine::Render::OgreRenderer& renderer,
const Files::Collections& fileCollections,
const std::string& master, const boost::filesystem::path& resDir, const boost::filesystem::path& cacheDir, bool newGame,
ToUTF8::Utf8Encoder* encoder, std::map<std::string,std::string> fallbackMap, int mActivationDistanceOverride);
virtual ~World();
virtual OEngine::Render::Fader* getFader();
///< \ŧodo remove this function. Rendering details should not be exposed.
virtual CellStore *getExterior (int x, int y);
2011-09-04 07:48:50 +00:00
virtual CellStore *getInterior (const std::string& name);
2011-09-04 07:48:50 +00:00
virtual void setWaterHeight(const float height);
2012-03-29 13:49:24 +00:00
virtual void toggleWater();
virtual void adjustSky();
virtual void getTriangleBatchCount(unsigned int &triangles, unsigned int &batches);
virtual void setFallbackValues (const std::map<std::string,std::string>& fallbackMap);
virtual std::string getFallback (const std::string& key) const;
virtual std::string getFallback (const std::string& key, const std::string& def) const;
virtual Player& getPlayer();
2012-10-01 15:17:04 +00:00
virtual const MWWorld::ESMStore& getStore() const;
2011-09-04 07:48:50 +00:00
virtual ESM::ESMReader& getEsmReader();
virtual LocalScripts& getLocalScripts();
virtual bool hasCellChanged() const;
2010-07-03 10:12:13 +00:00
///< Has the player moved to a different cell, since the last frame?
virtual bool isCellExterior() const;
virtual bool isCellQuasiExterior() const;
virtual Ogre::Vector2 getNorthVector (CellStore* cell);
2012-03-28 01:15:10 +00:00
///< get north vector (OGRE coordinates) for given interior cell
2012-08-28 15:30:34 +00:00
virtual std::vector<DoorMarker> getDoorMarkers (MWWorld::CellStore* cell);
///< get a list of teleport door markers for a given cell, to be displayed on the local map
virtual void getInteriorMapPosition (Ogre::Vector2 position, float& nX, float& nY, int &x, int& y);
///< see MWRender::LocalMap::getInteriorMapPosition
virtual bool isPositionExplored (float nX, float nY, int x, int y, bool interior);
///< see MWRender::LocalMap::isPositionExplored
virtual Globals::Data& getGlobalVariable (const std::string& name);
virtual Globals::Data getGlobalVariable (const std::string& name) const;
2011-04-21 09:00:00 +00:00
virtual char getGlobalVariableType (const std::string& name) const;
///< Return ' ', if there is no global variable with this name.
virtual std::vector<std::string> getGlobals () const;
virtual std::string getCurrentCellName () const;
virtual Ptr getPtr (const std::string& name, bool activeOnly);
///< Return a pointer to a liveCellRef with the given name.
/// \param activeOnly do non search inactive cells.
2010-07-09 14:07:03 +00:00
virtual Ptr getPtrViaHandle (const std::string& handle);
///< Return a pointer to a liveCellRef with the given Ogre handle.
2012-10-19 17:48:02 +00:00
virtual Ptr searchPtrViaHandle (const std::string& handle);
///< Return a pointer to a liveCellRef with the given Ogre handle or Ptr() if not found
virtual void enable (const Ptr& ptr);
virtual void disable (const Ptr& ptr);
virtual void advanceTime (double hours);
///< Advance in-game time.
virtual void setHour (double hour);
///< Set in-game time hour.
virtual void setMonth (int month);
///< Set in-game time month.
virtual void setDay (int day);
///< Set in-game time day.
2012-09-18 18:53:32 +00:00
virtual int getDay();
virtual int getMonth();
virtual TimeStamp getTimeStamp() const;
///< Return current in-game time stamp.
virtual bool toggleSky();
///< \return Resulting mode
virtual void changeWeather (const std::string& region, unsigned int id);
virtual int getCurrentWeather() const;
virtual int getMasserPhase() const;
virtual int getSecundaPhase() const;
virtual void setMoonColour (bool red);
virtual float getTimeScaleFactor() const;
virtual void changeToInteriorCell (const std::string& cellName,
const ESM::Position& position);
2011-02-10 09:38:45 +00:00
///< Move to interior cell.
virtual void changeToExteriorCell (const ESM::Position& position);
2011-02-10 09:38:45 +00:00
///< Move to exterior cell.
virtual const ESM::Cell *getExterior (const std::string& cellName) const;
2010-09-11 09:55:28 +00:00
///< Return a cell matching the given name or a 0-pointer, if there is no such cell.
virtual void markCellAsUnchanged();
virtual MWWorld::Ptr getFacedObject();
///< Return pointer to the object the player is looking at, if it is within activation range
2010-08-07 18:25:17 +00:00
virtual void deleteObject (const Ptr& ptr);
virtual void moveObject (const Ptr& ptr, float x, float y, float z);
virtual void moveObject (const Ptr& ptr, CellStore &newCell, float x, float y, float z);
2012-07-09 16:47:59 +00:00
virtual void scaleObject (const Ptr& ptr, float scale);
2012-08-11 09:23:54 +00:00
/// Rotates object, uses degrees
/// \param adjust indicates rotation should be set or adjusted
virtual void rotateObject (const Ptr& ptr,float x,float y,float z, bool adjust = false);
2012-09-17 11:36:48 +00:00
virtual void safePlaceObject(const MWWorld::Ptr& ptr,MWWorld::CellStore &Cell,ESM::Position pos);
2012-12-23 19:23:24 +00:00
///< place an object in a "safe" location (ie not in the void, etc). Makes a copy of the Ptr.
2012-09-17 11:36:48 +00:00
virtual void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false)
const;
///< Convert cell numbers to position.
virtual void positionToIndex (float x, float y, int &cellX, int &cellY) const;
///< Convert position to cell numbers
2011-01-29 16:39:34 +00:00
virtual void doPhysics (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors,
float duration);
2011-01-29 16:39:34 +00:00
///< Run physics simulation and modify \a world accordingly.
virtual bool toggleCollisionMode();
///< Toggle collision mode for player. If disabled player object should ignore
/// collisions and gravity.
///< \return Resulting mode
virtual bool toggleRenderMode (RenderMode mode);
///< Toggle a render mode.
///< \return Resulting mode
virtual const ESM::Potion *createRecord (const ESM::Potion& record);
///< Create a new recrod (of type potion) in the ESM store.
2012-11-08 15:01:42 +00:00
/// \return pointer to created record
virtual const ESM::Spell *createRecord (const ESM::Spell& record);
2012-10-15 19:54:19 +00:00
///< Create a new recrod (of type spell) in the ESM store.
2012-11-08 15:01:42 +00:00
/// \return pointer to created record
virtual const ESM::Class *createRecord (const ESM::Class& record);
///< Create a new recrod (of type class) in the ESM store.
2012-11-08 15:01:42 +00:00
/// \return pointer to created record
virtual const ESM::Cell *createRecord (const ESM::Cell& record);
///< Create a new recrod (of type cell) in the ESM store.
2012-11-08 15:01:42 +00:00
/// \return pointer to created record
2012-11-08 12:37:57 +00:00
virtual const ESM::NPC *createRecord(const ESM::NPC &record);
///< Create a new recrod (of type npc) in the ESM store.
2012-11-08 15:01:42 +00:00
/// \return pointer to created record
2012-11-08 12:37:57 +00:00
virtual void playAnimationGroup (const MWWorld::Ptr& ptr, const std::string& groupName,
int mode, int number = 1);
///< Run animation for a MW-reference. Calls to this function for references that are
/// currently not in the rendered scene should be ignored.
///
/// \param mode: 0 normal, 1 immediate start, 2 immediate loop
/// \param number How offen the animation should be run
virtual void skipAnimation (const MWWorld::Ptr& ptr);
///< Skip the animation for the given MW-reference for one frame. Calls to this function for
/// references that are currently not in the rendered scene should be ignored.
virtual void update (float duration, bool paused);
2012-02-19 20:39:12 +00:00
virtual bool placeObject (const Ptr& object, float cursorX, float cursorY);
///< place an object into the gameworld at the specified cursor position
/// @param object
/// @param cursor X (relative 0-1)
/// @param cursor Y (relative 0-1)
/// @return true if the object was placed, or false if it was rejected because the position is too far away
virtual void dropObjectOnGround (const Ptr& actor, const Ptr& object);
virtual bool canPlaceObject(float cursorX, float cursorY);
///< @return true if it is possible to place on object at specified cursor location
2012-05-22 23:32:36 +00:00
virtual void processChangedSettings(const Settings::CategorySettingVector& settings);
virtual bool isSwimming(const MWWorld::Ptr &object);
virtual bool isUnderwater(const ESM::Cell &cell, const Ogre::Vector3 &pos);
2012-08-12 11:50:37 +00:00
virtual void togglePOV() {
mRendering->togglePOV();
}
2012-08-14 10:37:48 +00:00
virtual void togglePreviewMode(bool enable) {
mRendering->togglePreviewMode(enable);
}
virtual bool toggleVanityMode(bool enable, bool force) {
return mRendering->toggleVanityMode(enable, force);
}
virtual void allowVanityMode(bool allow) {
mRendering->allowVanityMode(allow);
}
2012-08-14 16:33:29 +00:00
virtual void togglePlayerLooking(bool enable) {
mRendering->togglePlayerLooking(enable);
}
2012-08-14 16:33:29 +00:00
virtual void renderPlayer();
2012-12-23 19:23:24 +00:00
virtual void setupExternalRendering (MWRender::ExternalRendering& rendering);
2012-09-18 18:53:32 +00:00
virtual int canRest();
///< check if the player is allowed to rest \n
/// 0 - yes \n
/// 1 - only waiting \n
/// 2 - player is underwater \n
/// 3 - enemies are nearby (not implemented)
2012-09-25 00:35:50 +00:00
/// \todo Probably shouldn't be here
virtual MWRender::Animation* getAnimation(const MWWorld::Ptr &ptr);
2012-09-25 00:35:50 +00:00
/// \todo this does not belong here
virtual void playVideo(const std::string& name, bool allowSkipping);
2012-12-12 00:13:53 +00:00
virtual void stopVideo();
};
}
#endif