2010-07-03 15:41:20 +02:00
|
|
|
#ifndef GAME_MWWORLD_WORLD_H
|
|
|
|
#define GAME_MWWORLD_WORLD_H
|
2010-07-02 09:38:22 +02:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <map>
|
|
|
|
|
|
|
|
#include <boost/filesystem.hpp>
|
|
|
|
|
2010-07-03 15:41:20 +02:00
|
|
|
#include <components/esm_store/cell_store.hpp>
|
2010-07-02 09:38:22 +02:00
|
|
|
|
2011-10-25 14:06:44 -04:00
|
|
|
#include "../mwrender/debugging.hpp"
|
2011-10-20 15:02:19 -04:00
|
|
|
#include "../mwrender/renderingmanager.hpp"
|
2010-07-03 15:04:00 +02:00
|
|
|
|
2010-07-02 16:18:25 +02:00
|
|
|
#include "refdata.hpp"
|
2010-07-03 17:46:55 +02:00
|
|
|
#include "ptr.hpp"
|
2010-07-18 16:48:01 +02:00
|
|
|
#include "globals.hpp"
|
2011-07-31 17:07:11 +02:00
|
|
|
#include "scene.hpp"
|
2011-08-01 15:55:36 +02:00
|
|
|
#include "physicssystem.hpp"
|
2011-09-08 11:02:55 +02:00
|
|
|
#include "cells.hpp"
|
2011-10-06 12:29:59 +02:00
|
|
|
#include "localscripts.hpp"
|
2012-05-19 09:31:45 +02:00
|
|
|
#include "timestamp.hpp"
|
2010-07-02 13:48:48 +02:00
|
|
|
|
2011-02-26 16:37:47 +01:00
|
|
|
#include <openengine/bullet/physic.hpp>
|
2012-02-18 18:25:28 +01:00
|
|
|
#include <openengine/ogre/fader.hpp>
|
2011-02-19 17:59:40 +01:00
|
|
|
|
2012-04-30 23:55:22 +02:00
|
|
|
#include <OgreTimer.h>
|
|
|
|
|
2011-02-01 10:11:41 +01:00
|
|
|
namespace Ogre
|
|
|
|
{
|
|
|
|
class Vector3;
|
|
|
|
}
|
|
|
|
|
2010-07-22 12:29:23 +02:00
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
struct Position;
|
|
|
|
}
|
|
|
|
|
2011-05-05 19:32:42 +02:00
|
|
|
namespace Files
|
|
|
|
{
|
|
|
|
class Collections;
|
|
|
|
}
|
|
|
|
|
2010-07-02 09:38:22 +02:00
|
|
|
namespace Render
|
|
|
|
{
|
|
|
|
class OgreRenderer;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace MWRender
|
|
|
|
{
|
|
|
|
class SkyManager;
|
|
|
|
class CellRender;
|
|
|
|
}
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2010-07-03 15:41:20 +02:00
|
|
|
namespace MWWorld
|
2010-07-02 09:38:22 +02:00
|
|
|
{
|
2012-02-21 20:22:46 +01:00
|
|
|
class WeatherManager;
|
2011-01-04 15:58:22 +01:00
|
|
|
class Player;
|
2010-07-27 14:05:05 +02:00
|
|
|
|
2010-07-02 09:38:22 +02:00
|
|
|
/// \brief The game world and its visual representation
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2010-07-02 09:38:22 +02:00
|
|
|
class World
|
|
|
|
{
|
2010-07-02 16:18:25 +02:00
|
|
|
public:
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2011-03-16 09:09:45 +01:00
|
|
|
enum RenderMode
|
|
|
|
{
|
2012-02-18 16:06:03 +01:00
|
|
|
Render_CollisionDebug,
|
2012-03-08 01:03:46 +04:00
|
|
|
Render_Wireframe,
|
2012-04-29 03:33:10 +02:00
|
|
|
Render_Pathgrid,
|
|
|
|
Render_Compositors
|
2011-03-16 09:09:45 +01:00
|
|
|
};
|
|
|
|
|
2010-07-02 16:18:25 +02:00
|
|
|
private:
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2012-01-29 20:51:20 +02:00
|
|
|
MWRender::RenderingManager* mRendering;
|
2012-03-08 01:03:46 +04:00
|
|
|
|
2012-02-21 20:22:46 +01:00
|
|
|
MWWorld::WeatherManager* mWeatherManager;
|
2011-11-21 14:08:44 +01:00
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
MWWorld::Scene *mWorldScene;
|
2011-01-04 15:58:22 +01:00
|
|
|
MWWorld::Player *mPlayer;
|
2010-07-02 09:38:22 +02:00
|
|
|
ESM::ESMReader mEsm;
|
|
|
|
ESMS::ESMStore mStore;
|
2011-10-06 12:29:59 +02:00
|
|
|
LocalScripts mLocalScripts;
|
2010-07-18 16:48:01 +02:00
|
|
|
MWWorld::Globals *mGlobalVariables;
|
2011-08-01 15:55:36 +02:00
|
|
|
MWWorld::PhysicsSystem *mPhysics;
|
2010-07-18 19:48:02 +02:00
|
|
|
bool mSky;
|
2011-07-22 15:56:54 +02:00
|
|
|
int mNextDynamicRecord;
|
2011-09-04 09:48:50 +02:00
|
|
|
|
2011-09-08 11:02:55 +02:00
|
|
|
Cells mCells;
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2011-04-01 23:35:56 +02:00
|
|
|
OEngine::Physic::PhysicEngine* mPhysEngine;
|
2011-02-19 17:59:40 +01:00
|
|
|
|
2010-07-02 09:38:22 +02:00
|
|
|
// not implemented
|
|
|
|
World (const World&);
|
|
|
|
World& operator= (const World&);
|
2010-08-03 20:01:52 +02:00
|
|
|
|
|
|
|
Ptr getPtrViaHandle (const std::string& handle, Ptr::CellStore& cellStore);
|
|
|
|
|
2012-03-25 20:52:56 +02:00
|
|
|
std::string mFacedHandle;
|
|
|
|
Ptr mFaced1;
|
|
|
|
Ptr mFaced2;
|
|
|
|
std::string mFaced1Name;
|
|
|
|
std::string mFaced2Name;
|
|
|
|
int mNumFacing;
|
2012-04-02 20:47:09 +02:00
|
|
|
std::map<std::string,std::string> mFallback;
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2012-04-30 23:55:22 +02:00
|
|
|
unsigned long lastTick;
|
|
|
|
Ogre::Timer mTimer;
|
|
|
|
|
2010-07-22 11:48:27 +02:00
|
|
|
int getDaysPerMonth (int month) const;
|
2011-09-04 09:48:50 +02:00
|
|
|
|
2012-04-30 23:55:22 +02:00
|
|
|
bool moveObjectImp (Ptr ptr, float x, float y, float z);
|
|
|
|
///< @return true if the active cell (cell player is in) changed
|
2011-09-04 09:48:50 +02:00
|
|
|
|
2010-07-02 09:38:22 +02:00
|
|
|
public:
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2012-01-29 20:51:20 +02:00
|
|
|
World (OEngine::Render::OgreRenderer& renderer,
|
2011-05-05 19:32:42 +02:00
|
|
|
const Files::Collections& fileCollections,
|
2011-02-10 10:38:45 +01:00
|
|
|
const std::string& master, const boost::filesystem::path& resDir, bool newGame,
|
2012-04-23 15:27:03 +02:00
|
|
|
const std::string& encoding, std::map<std::string,std::string> fallbackMap);
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2010-07-02 09:38:22 +02:00
|
|
|
~World();
|
2012-03-08 01:03:46 +04:00
|
|
|
|
2012-02-18 18:25:28 +01:00
|
|
|
OEngine::Render::Fader* getFader();
|
2011-09-04 09:48:50 +02:00
|
|
|
|
2011-08-01 14:34:50 +02:00
|
|
|
Ptr::CellStore *getExterior (int x, int y);
|
2011-09-04 09:48:50 +02:00
|
|
|
|
2011-09-08 11:02:55 +02:00
|
|
|
Ptr::CellStore *getInterior (const std::string& name);
|
2012-03-29 15:49:24 +02:00
|
|
|
|
|
|
|
void setWaterHeight(const float height);
|
2012-03-29 18:33:08 +02:00
|
|
|
void toggleWater();
|
2012-03-30 02:46:05 +04:00
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
void adjustSky();
|
|
|
|
|
2012-04-03 02:14:39 +02:00
|
|
|
void setFallbackValues(std::map<std::string,std::string> fallbackMap);
|
2012-04-02 20:47:09 +02:00
|
|
|
|
|
|
|
std::string getFallback(std::string key);
|
|
|
|
|
2012-04-04 16:15:15 +02:00
|
|
|
std::string getFallback(std::string key, std::string def);
|
|
|
|
|
2011-01-04 15:58:22 +01:00
|
|
|
MWWorld::Player& getPlayer();
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2011-04-21 10:49:45 +02:00
|
|
|
const ESMS::ESMStore& getStore() const;
|
2011-09-04 09:48:50 +02:00
|
|
|
|
2011-07-31 17:07:11 +02:00
|
|
|
ESM::ESMReader& getEsmReader();
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2011-10-06 12:29:59 +02:00
|
|
|
LocalScripts& getLocalScripts();
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2010-07-03 12:12:13 +02:00
|
|
|
bool hasCellChanged() const;
|
|
|
|
///< Has the player moved to a different cell, since the last frame?
|
2012-03-08 01:03:46 +04:00
|
|
|
|
2012-02-23 21:12:06 +01:00
|
|
|
bool isCellExterior() const;
|
|
|
|
bool isCellQuasiExterior() const;
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2012-03-28 03:15:10 +02:00
|
|
|
Ogre::Vector2 getNorthVector(Ptr::CellStore* cell);
|
|
|
|
///< get north vector (OGRE coordinates) for given interior cell
|
|
|
|
|
2010-07-18 16:48:01 +02:00
|
|
|
Globals::Data& getGlobalVariable (const std::string& name);
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2011-04-21 11:00:00 +02:00
|
|
|
Globals::Data getGlobalVariable (const std::string& name) const;
|
|
|
|
|
2010-07-21 15:01:35 +02:00
|
|
|
char getGlobalVariableType (const std::string& name) const;
|
|
|
|
///< Return ' ', if there is no global variable with this name.
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2010-07-10 13:19:04 +02:00
|
|
|
Ptr getPtr (const std::string& name, bool activeOnly);
|
2010-07-05 12:09:04 +02:00
|
|
|
///< Return a pointer to a liveCellRef with the given name.
|
|
|
|
/// \param activeOnly do non search inactive cells.
|
2010-07-09 16:07:03 +02:00
|
|
|
|
2010-08-03 20:01:52 +02:00
|
|
|
Ptr getPtrViaHandle (const std::string& handle);
|
|
|
|
///< Return a pointer to a liveCellRef with the given Ogre handle.
|
2011-11-21 14:08:44 +01:00
|
|
|
|
2011-11-15 23:31:18 -05:00
|
|
|
/// \todo enable reference in the OGRE scene
|
2010-07-10 13:19:04 +02:00
|
|
|
void enable (Ptr reference);
|
2011-11-21 14:08:44 +01:00
|
|
|
|
2011-11-15 23:31:18 -05:00
|
|
|
/// \todo 5disable reference in the OGRE scene
|
2010-07-10 13:19:04 +02:00
|
|
|
void disable (Ptr reference);
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2010-07-18 18:29:16 +02:00
|
|
|
void advanceTime (double hours);
|
2012-01-23 14:55:00 +01:00
|
|
|
///< Advance in-game time.
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2010-07-18 18:29:16 +02:00
|
|
|
void setHour (double hour);
|
2012-01-23 14:55:00 +01:00
|
|
|
///< Set in-game time hour.
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2010-07-22 11:48:27 +02:00
|
|
|
void setMonth (int month);
|
2012-01-23 14:55:00 +01:00
|
|
|
///< Set in-game time month.
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2010-07-18 18:29:16 +02:00
|
|
|
void setDay (int day);
|
2012-01-23 14:55:00 +01:00
|
|
|
///< Set in-game time day.
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2012-05-19 09:31:45 +02:00
|
|
|
TimeStamp getTimeStamp() const;
|
|
|
|
///< Return current in-game time stamp.
|
|
|
|
|
2011-04-26 21:38:21 +02:00
|
|
|
bool toggleSky();
|
|
|
|
///< \return Resulting mode
|
2012-03-08 01:03:46 +04:00
|
|
|
|
2012-02-26 11:51:02 +01:00
|
|
|
void changeWeather(const std::string& region, const unsigned int id);
|
2012-03-08 01:03:46 +04:00
|
|
|
|
2012-02-25 21:34:38 +01:00
|
|
|
int getCurrentWeather() const;
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2010-07-18 19:48:02 +02:00
|
|
|
int getMasserPhase() const;
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2010-07-18 19:48:02 +02:00
|
|
|
int getSecundaPhase() const;
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2010-07-18 19:48:02 +02:00
|
|
|
void setMoonColour (bool red);
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2010-07-21 14:10:52 +02:00
|
|
|
float getTimeScaleFactor() const;
|
2010-08-03 20:01:52 +02:00
|
|
|
|
2011-02-10 10:38:45 +01:00
|
|
|
void changeToInteriorCell (const std::string& cellName, const ESM::Position& position);
|
|
|
|
///< Move to interior cell.
|
2010-08-20 13:33:03 +02:00
|
|
|
|
|
|
|
void changeToExteriorCell (const ESM::Position& position);
|
2011-02-10 10:38:45 +01:00
|
|
|
///< Move to exterior cell.
|
2010-08-20 13:33:03 +02:00
|
|
|
|
2010-09-11 11:55:28 +02:00
|
|
|
const ESM::Cell *getExterior (const std::string& cellName) const;
|
|
|
|
///< Return a cell matching the given name or a 0-pointer, if there is no such cell.
|
|
|
|
|
2010-07-22 12:29:23 +02:00
|
|
|
void markCellAsUnchanged();
|
2010-08-05 13:29:49 +02:00
|
|
|
|
|
|
|
std::string getFacedHandle();
|
|
|
|
///< Return handle of the object the player is looking at
|
2010-08-07 20:25:17 +02:00
|
|
|
|
|
|
|
void deleteObject (Ptr ptr);
|
2010-08-21 12:31:04 +02:00
|
|
|
|
|
|
|
void moveObject (Ptr ptr, float x, float y, float z);
|
2010-08-22 21:30:48 +02:00
|
|
|
|
2010-09-11 12:21:55 +02:00
|
|
|
void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false) const;
|
2010-08-22 21:30:48 +02:00
|
|
|
///< Convert cell numbers to position.
|
|
|
|
|
|
|
|
void positionToIndex (float x, float y, int &cellX, int &cellY) const;
|
|
|
|
///< Convert position to cell numbers
|
2011-01-29 17:39:34 +01:00
|
|
|
|
2011-02-01 10:11:41 +01:00
|
|
|
void doPhysics (const std::vector<std::pair<std::string, Ogre::Vector3> >& actors,
|
|
|
|
float duration);
|
2011-01-29 17:39:34 +01:00
|
|
|
///< Run physics simulation and modify \a world accordingly.
|
2011-03-13 22:33:55 +01:00
|
|
|
|
2011-04-26 21:38:21 +02:00
|
|
|
bool toggleCollisionMode();
|
2011-03-13 22:33:55 +01:00
|
|
|
///< Toggle collision mode for player. If disabled player object should ignore
|
|
|
|
/// collisions and gravity.
|
2011-04-26 21:38:21 +02:00
|
|
|
///< \return Resulting mode
|
2011-03-16 09:09:45 +01:00
|
|
|
|
2011-04-26 21:38:21 +02:00
|
|
|
bool toggleRenderMode (RenderMode mode);
|
2011-03-16 09:09:45 +01:00
|
|
|
///< Toggle a render mode.
|
2011-04-26 21:38:21 +02:00
|
|
|
///< \return Resulting mode
|
2011-07-22 15:56:54 +02:00
|
|
|
|
|
|
|
std::pair<std::string, const ESM::Potion *> createRecord (const ESM::Potion& record);
|
|
|
|
///< Create a new recrod (of type potion) in the ESM store.
|
|
|
|
/// \return ID, pointer to created record
|
|
|
|
|
|
|
|
std::pair<std::string, const ESM::Class *> createRecord (const ESM::Class& record);
|
|
|
|
///< Create a new recrod (of type class) in the ESM store.
|
|
|
|
/// \return ID, pointer to created record
|
2011-09-26 11:11:30 +02:00
|
|
|
|
|
|
|
const ESM::Cell *createRecord (const ESM::Cell& record);
|
|
|
|
///< Create a new recrod (of type cell) in the ESM store.
|
|
|
|
/// \return ID, pointer to created record
|
2011-11-21 14:08:44 +01:00
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
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.
|
2012-01-23 14:33:06 +01:00
|
|
|
|
|
|
|
void update (float duration);
|
2012-02-19 15:39:12 -05:00
|
|
|
|
2012-05-15 16:47:23 +02:00
|
|
|
bool placeObject(MWWorld::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
|
|
|
|
|
|
|
|
void dropObjectOnGround(MWWorld::Ptr object);
|
|
|
|
|
|
|
|
bool canPlaceObject(float cursorX, float cursorY);
|
|
|
|
///< @return true if it is possible to place on object at specified cursor location
|
2010-07-02 09:38:22 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|