1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 06:35:30 +00:00
OpenMW/apps/openmw/mwscript/globalscripts.cpp

42 lines
1.1 KiB
C++
Raw Normal View History

2010-07-04 10:43:34 +02:00
#include "globalscripts.hpp"
#include "interpretercontext.hpp"
#include "scriptmanager.hpp"
namespace MWScript
{
GlobalScripts::GlobalScripts (const ESMS::ESMStore& store, ScriptManager& scriptManager)
: mStore (store), mScriptManager (scriptManager)
{
addScript ("Main");
}
void GlobalScripts::addScript (const std::string& name)
{
if (mScripts.find (name)==mScripts.end())
if (const ESM::Script *script = mStore.scripts.find (name))
{
Locals locals;
locals.configure (*script);
mScripts.insert (std::make_pair (name, locals));
}
}
void GlobalScripts::run (MWWorld::Environment& environment)
{
std::map<std::string, Locals>::iterator iter = mScripts.begin();
while (iter!=mScripts.end())
{
MWScript::InterpreterContext interpreterContext (environment,
&iter->second, MWWorld::Ptr());
mScriptManager.run (iter->first, interpreterContext);
++iter;
}
}
}