1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-04 03:40:14 +00:00

50 lines
1.2 KiB
C++
Raw Normal View History

#ifndef GAME_MWSCRIPT_REF_H
#define GAME_MWSCRIPT_REF_H
#include <string>
#include <components/interpreter/runtime.hpp>
#include "../mwbase/environment.hpp"
#include "../mwbase/world.hpp"
#include "../mwworld/ptr.hpp"
#include "interpretercontext.hpp"
namespace MWScript
{
struct ExplicitRef
{
2014-10-15 16:27:03 +02:00
static const bool implicit = false;
2014-10-15 16:12:57 +02:00
MWWorld::Ptr operator() (Interpreter::Runtime& runtime, bool required=true,
bool activeOnly = false) const
{
std::string id = runtime.getStringLiteral (runtime[0].mInteger);
runtime.pop();
2014-10-15 16:12:57 +02:00
if (required)
return MWBase::Environment::get().getWorld()->getPtr (id, activeOnly);
else
return MWBase::Environment::get().getWorld()->searchPtr (id, activeOnly);
}
};
struct ImplicitRef
{
2014-10-15 16:27:03 +02:00
static const bool implicit = true;
2014-10-15 16:12:57 +02:00
MWWorld::Ptr operator() (Interpreter::Runtime& runtime, bool required=true,
bool activeOnly = false) const
{
MWScript::InterpreterContext& context
= static_cast<MWScript::InterpreterContext&> (runtime.getContext());
return context.getReference(required);
}
};
}
#endif