Commit b68f9d6a authored by Marc Zinnschlag's avatar Marc Zinnschlag

Issue #107: MechanicsManager is accessed only through the interface class from now on

parent f3edea77
......@@ -60,12 +60,12 @@ add_openmw_dir (mwclass
)
add_openmw_dir (mwmechanics
mechanicsmanager stat creaturestats magiceffects movement actors drawstate spells
mechanicsmanagerimp stat creaturestats magiceffects movement actors drawstate spells
activespells npcstats
)
add_openmw_dir (mwbase
environment world scriptmanager dialoguemanager journal soundmanager
environment world scriptmanager dialoguemanager journal soundmanager mechanicsmanager
)
# Main executable
......
......@@ -32,7 +32,7 @@
#include "mwdialogue/dialoguemanagerimp.hpp"
#include "mwdialogue/journalimp.hpp"
#include "mwmechanics/mechanicsmanager.hpp"
#include "mwmechanics/mechanicsmanagerimp.hpp"
void OMW::Engine::executeLocalScripts()
......
......@@ -5,13 +5,12 @@
#include "../mwinput/inputmanager.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "world.hpp"
#include "scriptmanager.hpp"
#include "dialoguemanager.hpp"
#include "journal.hpp"
#include "soundmanager.hpp"
#include "mechanicsmanager.hpp"
MWBase::Environment *MWBase::Environment::sThis = 0;
......@@ -49,7 +48,7 @@ void MWBase::Environment::setWindowManager (MWGui::WindowManager *windowManager)
mWindowManager = windowManager;
}
void MWBase::Environment::setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager)
void MWBase::Environment::setMechanicsManager (MechanicsManager *mechanicsManager)
{
mMechanicsManager = mechanicsManager;
}
......@@ -98,7 +97,7 @@ MWGui::WindowManager *MWBase::Environment::getWindowManager() const
return mWindowManager;
}
MWMechanics::MechanicsManager *MWBase::Environment::getMechanicsManager() const
MWBase::MechanicsManager *MWBase::Environment::getMechanicsManager() const
{
assert (mMechanicsManager);
return mMechanicsManager;
......
......@@ -6,11 +6,6 @@ namespace MWGui
class WindowManager;
}
namespace MWMechanics
{
class MechanicsManager;
}
namespace MWInput
{
struct MWInputManager;
......@@ -23,6 +18,7 @@ namespace MWBase
class DialogueManager;
class Journal;
class SoundManager;
class MechanicsManager;
/// \brief Central hub for mw-subsystems
///
......@@ -38,7 +34,7 @@ namespace MWBase
SoundManager *mSoundManager;
ScriptManager *mScriptManager;
MWGui::WindowManager *mWindowManager;
MWMechanics::MechanicsManager *mMechanicsManager;
MechanicsManager *mMechanicsManager;
DialogueManager *mDialogueManager;
Journal *mJournal;
MWInput::MWInputManager *mInputManager;
......@@ -64,7 +60,7 @@ namespace MWBase
void setWindowManager (MWGui::WindowManager *windowManager);
void setMechanicsManager (MWMechanics::MechanicsManager *mechanicsManager);
void setMechanicsManager (MechanicsManager *mechanicsManager);
void setDialogueManager (DialogueManager *dialogueManager);
......@@ -79,11 +75,11 @@ namespace MWBase
SoundManager *getSoundManager() const;
MWBase::ScriptManager *getScriptManager() const;
ScriptManager *getScriptManager() const;
MWGui::WindowManager *getWindowManager() const;
MWMechanics::MechanicsManager *getMechanicsManager() const;
MechanicsManager *getMechanicsManager() const;
DialogueManager *getDialogueManager() const;
......
#ifndef GAME_MWBASE_MECHANICSMANAGER_H
#define GAME_MWBASE_MECHANICSMANAGER_H
#include <string>
#include <vector>
namespace Ogre
{
class Vector3;
}
namespace ESM
{
struct Class;
}
namespace MWWorld
{
class Ptr;
class CellStore;
}
namespace MWBase
{
/// \brief Interface for game mechanics manager (implemented in MWMechanics)
class MechanicsManager
{
MechanicsManager (const MechanicsManager&);
///< not implemented
MechanicsManager& operator= (const MechanicsManager&);
///< not implemented
public:
MechanicsManager() {}
virtual ~MechanicsManager() {}
virtual void addActor (const MWWorld::Ptr& ptr) = 0;
///< Register an actor for stats management
virtual void removeActor (const MWWorld::Ptr& ptr) = 0;
///< Deregister an actor for stats management
virtual void dropActors (const MWWorld::CellStore *cellStore) = 0;
///< Deregister all actors in the given cell.
virtual void watchActor (const MWWorld::Ptr& ptr) = 0;
///< On each update look for changes in a previously registered actor and update the
/// GUI accordingly.
virtual void update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement,
float duration, bool paused) = 0;
///< Update actor stats and store desired velocity vectors in \a movement
///
/// \param paused In game type does not currently advance (this usually means some GUI
/// component is up).
virtual void setPlayerName (const std::string& name) = 0;
///< Set player name.
virtual void setPlayerRace (const std::string& id, bool male) = 0;
///< Set player race.
virtual void setPlayerBirthsign (const std::string& id) = 0;
///< Set player birthsign.
virtual void setPlayerClass (const std::string& id) = 0;
///< Set player class to stock class.
virtual void setPlayerClass (const ESM::Class& class_) = 0;
///< Set player class to custom class.
};
}
#endif
......@@ -4,10 +4,10 @@
#include <components/esm/loadcrea.hpp>
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwmechanics/magiceffects.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontalk.hpp"
......@@ -104,7 +104,7 @@ namespace MWClass
if (!model.empty()) {
return "meshes\\" + model;
}
return "";
return "";
}
std::string Creature::getName (const MWWorld::Ptr& ptr) const
......
......@@ -11,11 +11,11 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwmechanics/creaturestats.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "../mwmechanics/movement.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/actiontalk.hpp"
......
#ifndef GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
#define GAME_MWDIALOG_DIALOGUEMANAGERIMP_H
#include "../mwbase/dialoguemanager.hpp"
#include <components/esm/loadinfo.hpp>
#include <components/compiler/streamerrorhandler.hpp>
......@@ -8,8 +10,6 @@
#include "../mwscript/interpretercontext.hpp"
#include <components/compiler/output.hpp>
#include "../mwbase/dialoguemanager.hpp"
#include "../mwworld/ptr.hpp"
#include <map>
......
......@@ -10,6 +10,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
namespace
{
......
......@@ -7,7 +7,6 @@
#include "../mwbase/world.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwmechanics/stat.hpp"
namespace MWGui
......
......@@ -8,11 +8,12 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/player.hpp"
#include "../mwworld/class.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwmechanics/npcstats.hpp"
#include "window_manager.hpp"
#include "tooltips.hpp"
......
......@@ -21,10 +21,10 @@
#include "alchemywindow.hpp"
#include "spellwindow.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwinput/inputmanager.hpp"
#include "../mwbase/environment.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/ptr.hpp"
#include "../mwworld/cellstore.hpp"
......
#include "mechanicsmanager.hpp"
#include "mechanicsmanagerimp.hpp"
#include <components/esm_store/store.hpp>
......
#ifndef GAME_MWMECHANICS_MECHANICSMANAGER_H
#define GAME_MWMECHANICS_MECHANICSMANAGER_H
#ifndef GAME_MWMECHANICS_MECHANICSMANAGERIMP_H
#define GAME_MWMECHANICS_MECHANICSMANAGERIMP_H
#include <vector>
#include <string>
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwworld/ptr.hpp"
......@@ -22,7 +21,7 @@ namespace MWWorld
namespace MWMechanics
{
class MechanicsManager
class MechanicsManager : public MWBase::MechanicsManager
{
MWWorld::Ptr mWatched;
CreatureStats mWatchedCreature;
......@@ -38,43 +37,41 @@ namespace MWMechanics
public:
MechanicsManager ();
MechanicsManager();
void configureGUI();
void addActor (const MWWorld::Ptr& ptr);
virtual void addActor (const MWWorld::Ptr& ptr);
///< Register an actor for stats management
void removeActor (const MWWorld::Ptr& ptr);
virtual void removeActor (const MWWorld::Ptr& ptr);
///< Deregister an actor for stats management
void dropActors (const MWWorld::CellStore *cellStore);
virtual void dropActors (const MWWorld::CellStore *cellStore);
///< Deregister all actors in the given cell.
void watchActor (const MWWorld::Ptr& ptr);
virtual void watchActor (const MWWorld::Ptr& ptr);
///< On each update look for changes in a previously registered actor and update the
/// GUI accordingly.
void update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement, float duration,
bool paused);
virtual void update (std::vector<std::pair<std::string, Ogre::Vector3> >& movement,
float duration, bool paused);
///< Update actor stats and store desired velocity vectors in \a movement
///
/// \param paused In game type does not currently advance (this usually means some GUI
/// component is up).
void setPlayerName (const std::string& name);
virtual void setPlayerName (const std::string& name);
///< Set player name.
void setPlayerRace (const std::string& id, bool male);
virtual void setPlayerRace (const std::string& id, bool male);
///< Set player race.
void setPlayerBirthsign (const std::string& id);
virtual void setPlayerBirthsign (const std::string& id);
///< Set player birthsign.
void setPlayerClass (const std::string& id);
virtual void setPlayerClass (const std::string& id);
///< Set player class to stock class.
void setPlayerClass (const ESM::Class& class_);
virtual void setPlayerClass (const ESM::Class& class_);
///< Set player class to custom class.
};
}
......
......@@ -3,8 +3,7 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp" /// FIXME
#include "../mwbase/soundmanager.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwgui/window_manager.hpp"
......@@ -154,7 +153,7 @@ namespace MWWorld
}
world->getPlayer().setCell(cell);
MWMechanics::MechanicsManager *mechMgr =
MWBase::MechanicsManager *mechMgr =
MWBase::Environment::get().getMechanicsManager();
mechMgr->addActor(player);
......
......@@ -5,12 +5,11 @@
#include "../mwbase/environment.hpp"
#include "../mwbase/soundmanager.hpp"
#include "../mwbase/mechanicsmanager.hpp"
#include "../mwrender/sky.hpp"
#include "../mwrender/player.hpp"
#include "../mwmechanics/mechanicsmanager.hpp"
#include "../mwgui/window_manager.hpp"
#include "player.hpp"
......@@ -575,7 +574,7 @@ namespace MWWorld
mRendering->moveObjectToCell(copy, vec, currCell);
if (MWWorld::Class::get(ptr).isActor()) {
MWMechanics::MechanicsManager *mechMgr =
MWBase::MechanicsManager *mechMgr =
MWBase::Environment::get().getMechanicsManager();
mechMgr->removeActor(ptr);
......@@ -604,11 +603,11 @@ namespace MWWorld
if (cell->isExterior()) {
int cellX, cellY;
positionToIndex(x, y, cellX, cellY);
cell = getExterior(cellX, cellY);
}
moveObject(ptr, *cell, x, y, z);
return cell != ptr.getCell();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment