1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 21:42:13 +00:00
OpenMW/apps/openmw/mwworld/world.hpp

169 lines
4.9 KiB
C++
Raw Normal View History

2010-07-03 13:41:20 +00:00
#ifndef GAME_MWWORLD_WORLD_H
#define GAME_MWWORLD_WORLD_H
#include <vector>
#include <map>
#include <boost/filesystem.hpp>
2010-07-03 13:41:20 +00:00
#include <components/esm_store/cell_store.hpp>
2010-07-03 13:41:20 +00:00
#include "../mwrender/playerpos.hpp"
#include "../mwrender/mwscene.hpp"
#include "refdata.hpp"
#include "ptr.hpp"
#include "globals.hpp"
2010-07-22 10:29:23 +00:00
namespace ESM
{
struct Position;
}
namespace Render
{
class OgreRenderer;
}
namespace MWRender
{
class SkyManager;
class CellRender;
}
2010-07-03 13:41:20 +00:00
namespace MWWorld
{
class Environment;
/// \brief The game world and its visual representation
class World
{
public:
2010-08-21 09:43:07 +00:00
typedef std::list<std::pair<std::string, Ptr> > ScriptList;
private:
typedef std::map<Ptr::CellStore *, MWRender::CellRender *> CellRenderCollection;
MWRender::SkyManager* mSkyManager;
MWRender::MWScene mScene;
MWRender::PlayerPos *mPlayerPos;
Ptr::CellStore *mCurrentCell; // the cell, the player is in
CellRenderCollection mActiveCells;
CellRenderCollection mBufferedCells; // loaded, but not active (buffering not implementd yet)
ESM::ESMReader mEsm;
ESMS::ESMStore mStore;
std::map<std::string, Ptr::CellStore> mInteriors;
std::map<std::pair<int, int>, Ptr::CellStore> mExteriors;
ScriptList mLocalScripts;
MWWorld::Globals *mGlobalVariables;
bool mSky;
2010-07-22 10:29:23 +00:00
bool mCellChanged;
Environment& mEnvironment;
// not implemented
World (const World&);
World& operator= (const World&);
2010-07-03 13:41:20 +00:00
void insertInteriorScripts (ESMS::CellStore<RefData>& cell);
Ptr getPtr (const std::string& name, Ptr::CellStore& cellStore);
Ptr getPtrViaHandle (const std::string& handle, Ptr::CellStore& cellStore);
MWRender::CellRender *searchRender (Ptr::CellStore *store);
int getDaysPerMonth (int month) const;
2010-08-21 09:43:07 +00:00
void removeScripts (Ptr::CellStore *cell);
void unloadCell (CellRenderCollection::iterator iter);
2010-08-22 18:55:22 +00:00
void loadCell (Ptr::CellStore *cell, MWRender::CellRender *render);
void playerCellChange (Ptr::CellStore *cell, const ESM::Position& position);
void adjustSky();
public:
World (OEngine::Render::OgreRenderer& renderer, const boost::filesystem::path& master,
const std::string& dataDir, bool newGame, Environment& environment);
~World();
MWRender::PlayerPos& getPlayerPos();
ESMS::ESMStore& getStore();
const ScriptList& getLocalScripts() const;
///< Names and local variable state of all local scripts in active cells.
2010-07-03 10:12:13 +00:00
bool hasCellChanged() const;
///< Has the player moved to a different cell, since the last frame?
Globals::Data& getGlobalVariable (const std::string& name);
char getGlobalVariableType (const std::string& name) const;
///< Return ' ', if there is no global variable with this name.
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
Ptr getPtrViaHandle (const std::string& handle);
///< Return a pointer to a liveCellRef with the given Ogre handle.
void enable (Ptr reference);
void disable (Ptr reference);
2010-07-18 16:29:16 +00:00
void advanceTime (double hours);
2010-07-18 16:29:16 +00:00
void setHour (double hour);
void setMonth (int month);
2010-07-18 16:29:16 +00:00
void setDay (int day);
void toggleSky();
int getMasserPhase() const;
int getSecundaPhase() const;
void setMoonColour (bool red);
float getTimeScaleFactor() const;
2010-07-22 10:29:23 +00:00
void changeCell (const std::string& cellName, const ESM::Position& position);
///< works only for interior cells currently.
void changeCell (int X, int Y, const ESM::Position& position);
void changeToExteriorCell (const ESM::Position& position);
2010-09-11 09:55:28 +00: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 10:29:23 +00:00
void markCellAsUnchanged();
std::string getFacedHandle();
///< Return handle of the object the player is looking at
2010-08-07 18:25:17 +00:00
void deleteObject (Ptr ptr);
void moveObject (Ptr ptr, float x, float y, float z);
void indexToPosition (int cellX, int cellY, float &x, float &y, bool centre = false) const;
///< Convert cell numbers to position.
void positionToIndex (float x, float y, int &cellX, int &cellY) const;
///< Convert position to cell numbers
};
}
#endif