1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 22:19:54 +00:00
openmw-tes3mp/apps/openmw/mwworld/world.hpp

229 lines
6.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>
2011-10-25 18:06:44 +00:00
#include "../mwrender/debugging.hpp"
2011-10-20 19:02:19 +00:00
#include "../mwrender/renderingmanager.hpp"
#include "refdata.hpp"
#include "ptr.hpp"
#include "globals.hpp"
#include "scene.hpp"
2011-08-01 13:55:36 +00:00
#include "physicssystem.hpp"
#include "cells.hpp"
#include "localscripts.hpp"
2011-02-26 15:37:47 +00:00
#include <openengine/bullet/physic.hpp>
2011-02-19 16:59:40 +00:00
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;
}
2010-07-03 13:41:20 +00:00
namespace MWWorld
{
class Environment;
class Player;
/// \brief The game world and its visual representation
class World
{
public:
enum RenderMode
{
Render_CollisionDebug
};
private:
MWRender::RenderingManager mRendering;
MWWorld::Scene *mWorldScene;
MWWorld::Player *mPlayer;
ESM::ESMReader mEsm;
ESMS::ESMStore mStore;
LocalScripts mLocalScripts;
MWWorld::Globals *mGlobalVariables;
2011-08-01 13:55:36 +00:00
MWWorld::PhysicsSystem *mPhysics;
bool mSky;
Environment& mEnvironment;
int mNextDynamicRecord;
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 getDaysPerMonth (int month) const;
2011-09-04 07:48:50 +00:00
2011-08-02 17:46:21 +00:00
void moveObjectImp (Ptr ptr, float x, float y, float z);
2011-09-04 07:48:50 +00:00
public:
World (OEngine::Render::OgreRenderer& renderer, OEngine::Physic::PhysicEngine* physEng,
const Files::Collections& fileCollections,
2011-02-10 09:38:45 +00:00
const std::string& master, const boost::filesystem::path& resDir, bool newGame,
Environment& environment, const std::string& encoding);
~World();
2011-09-04 07:48:50 +00:00
Ptr::CellStore *getExterior (int x, int y);
2011-09-04 07:48:50 +00:00
Ptr::CellStore *getInterior (const std::string& name);
void adjustSky();
MWWorld::Player& getPlayer();
2011-04-21 08:49:45 +00:00
const ESMS::ESMStore& getStore() const;
2011-09-04 07:48:50 +00:00
ESM::ESMReader& getEsmReader();
LocalScripts& getLocalScripts();
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);
2011-04-21 09:00:00 +00:00
Globals::Data getGlobalVariable (const std::string& name) const;
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.
/// \todo enable reference in the OGRE scene
void enable (Ptr reference);
/// \todo 5disable reference in the OGRE scene
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);
bool toggleSky();
///< \return Resulting mode
int getMasserPhase() const;
int getSecundaPhase() const;
void setMoonColour (bool red);
float getTimeScaleFactor() const;
2011-02-10 09:38:45 +00:00
void changeToInteriorCell (const std::string& cellName, const ESM::Position& position);
///< Move to interior cell.
void changeToExteriorCell (const ESM::Position& position);
2011-02-10 09:38:45 +00:00
///< Move to exterior cell.
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
2011-01-29 16:39:34 +00:00
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.
bool toggleCollisionMode();
///< Toggle collision mode for player. If disabled player object should ignore
/// collisions and gravity.
///< \return Resulting mode
bool toggleRenderMode (RenderMode mode);
///< Toggle a render mode.
///< \return Resulting mode
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
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
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-05 00:47:06 +00:00
void setObjectPhysicsRotation(const std::string& handle,Ogre::Quaternion quat);
void setObjectPhysicsPosition(const std::string& handle,Ogre::Vector3 vector);
void update (float duration);
};
}
#endif