2021-06-29 05:28:17 +02:00
|
|
|
#include "framework.h"
|
|
|
|
#include "GameScriptRotation.h"
|
|
|
|
|
2021-07-01 19:25:44 +01:00
|
|
|
void GameScriptRotation::Register(sol::state* state)
|
|
|
|
{
|
|
|
|
state->new_usertype<GameScriptRotation>("Rotation",
|
|
|
|
sol::constructors<GameScriptRotation(int, int, int)>(),
|
|
|
|
"X", sol::property(&GameScriptRotation::GetX, &GameScriptRotation::SetX),
|
|
|
|
"Y", sol::property(&GameScriptRotation::GetY, &GameScriptRotation::SetY),
|
|
|
|
"Z", sol::property(&GameScriptRotation::GetZ, &GameScriptRotation::SetZ)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2021-06-29 05:28:17 +02:00
|
|
|
GameScriptRotation::GameScriptRotation(int x, int y, int z)
|
|
|
|
{
|
|
|
|
SetX(x);
|
|
|
|
SetY(y);
|
|
|
|
SetZ(z);
|
|
|
|
}
|
|
|
|
|
2021-07-01 19:25:44 +01:00
|
|
|
int GameScriptRotation::ConvertRotation(int a)
|
|
|
|
{
|
|
|
|
short component = std::clamp(a, -359, 359);
|
|
|
|
component = static_cast<int>(lround((component/360.0f) * std::numeric_limits<unsigned short>::max()));
|
|
|
|
component = component - std::numeric_limits<short>::max();
|
|
|
|
return component;
|
|
|
|
}
|
|
|
|
|
2021-06-30 14:08:46 +01:00
|
|
|
int GameScriptRotation::GetX() const
|
2021-06-29 05:28:17 +02:00
|
|
|
{
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameScriptRotation::SetX(int x)
|
|
|
|
{
|
2021-07-01 19:25:44 +01:00
|
|
|
this->x = ConvertRotation(x);
|
2021-06-29 05:28:17 +02:00
|
|
|
}
|
|
|
|
|
2021-06-30 14:08:46 +01:00
|
|
|
int GameScriptRotation::GetY() const
|
2021-06-29 05:28:17 +02:00
|
|
|
{
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameScriptRotation::SetY(int y)
|
|
|
|
{
|
2021-07-01 19:25:44 +01:00
|
|
|
this->y = ConvertRotation(y);
|
2021-06-29 05:28:17 +02:00
|
|
|
}
|
|
|
|
|
2021-06-30 14:08:46 +01:00
|
|
|
int GameScriptRotation::GetZ() const
|
2021-06-29 05:28:17 +02:00
|
|
|
{
|
|
|
|
return z;
|
|
|
|
}
|
|
|
|
|
|
|
|
void GameScriptRotation::SetZ(int z)
|
|
|
|
{
|
2021-07-01 19:25:44 +01:00
|
|
|
this->z = ConvertRotation(z);
|
2021-06-29 05:28:17 +02:00
|
|
|
}
|