mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-18 13:12:50 +00:00
90 lines
2.9 KiB
C++
90 lines
2.9 KiB
C++
|
|
#include "statsextensions.hpp"
|
|
|
|
#include <boost/algorithm/string.hpp>
|
|
|
|
#include <components/esm_store/store.hpp>
|
|
|
|
#include <components/compiler/extensions.hpp>
|
|
|
|
#include <components/interpreter/interpreter.hpp>
|
|
#include <components/interpreter/runtime.hpp>
|
|
#include <components/interpreter/opcodes.hpp>
|
|
|
|
#include "../mwbase/environment.hpp"
|
|
|
|
#include "../mwworld/class.hpp"
|
|
|
|
#include "interpretercontext.hpp"
|
|
#include "ref.hpp"
|
|
|
|
namespace MWScript
|
|
{
|
|
namespace Transformation
|
|
{
|
|
template<class R>
|
|
class OpSetScale : public Interpreter::Opcode0
|
|
{
|
|
public:
|
|
|
|
virtual void execute (Interpreter::Runtime& runtime)
|
|
{
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
Interpreter::Type_Float scale = runtime[0].mInteger;
|
|
runtime.pop();
|
|
|
|
MWBase::Environment::get().getWorld()->scaleObject(ptr,scale);
|
|
}
|
|
};
|
|
|
|
template<class R>
|
|
class OpSetAngle : public Interpreter::Opcode0
|
|
{
|
|
public:
|
|
|
|
virtual void execute (Interpreter::Runtime& runtime)
|
|
{
|
|
MWWorld::Ptr ptr = R()(runtime);
|
|
|
|
std::string axis = runtime.getStringLiteral (runtime[0].mInteger);
|
|
runtime.pop();
|
|
Interpreter::Type_Float angle = runtime[0].mInteger;
|
|
runtime.pop();
|
|
|
|
if(axis == "X")
|
|
{
|
|
MWBase::Environment::get().getWorld()->rotateObject(ptr,angle,0,0);
|
|
}
|
|
if(axis == "Y")
|
|
{
|
|
MWBase::Environment::get().getWorld()->rotateObject(ptr,0,angle,0);
|
|
}
|
|
if(axis == "Z")
|
|
{
|
|
MWBase::Environment::get().getWorld()->rotateObject(ptr,0,0,angle);
|
|
}
|
|
}
|
|
};
|
|
|
|
const int opcodeSetScale = 0x2000164;
|
|
const int opcodeSetScaleExplicit = 0x2000165;
|
|
const int opcodeSetAngle = 0x2000166;
|
|
const int opcodeSetAngleExplicit = 0x2000167;
|
|
|
|
void registerExtensions (Compiler::Extensions& extensions)
|
|
{
|
|
extensions.registerInstruction("setscale","f",opcodeSetScale,opcodeSetScaleExplicit);
|
|
extensions.registerInstruction("setangle","Sl",opcodeSetAngle,opcodeSetAngleExplicit);
|
|
}
|
|
|
|
void installOpcodes (Interpreter::Interpreter& interpreter)
|
|
{
|
|
interpreter.installSegment5(opcodeSetScale,new OpSetScale<ImplicitRef>);
|
|
interpreter.installSegment5(opcodeSetScaleExplicit,new OpSetScale<ExplicitRef>);
|
|
interpreter.installSegment5(opcodeSetAngle,new OpSetAngle<ImplicitRef>);
|
|
interpreter.installSegment5(opcodeSetAngleExplicit,new OpSetAngle<ExplicitRef>);
|
|
}
|
|
}
|
|
}
|