TombEngine/TR5Main/Scripting/GameScriptPosition.cpp
hispidence e6c076eb41 Move GameScriptLevel, GameScriptAudioTrack, GameScriptInventoryObject, GameScriptSkyLayer, GameScriptSettings and GameScriptMirror into their own files. This could be changed later as this does create many small .h and .cpp files, but for now this cleans things up and makes it easier to check things class by class.
Treat functions as global that would previously be accessed through the GameFlow table. This does pollute the global environment in Lua a bit, but keeps it consistent with the functions in GameLogicScript, which are all accessed as globals.

Add some default member initialisers.

Remove WriteDefaults. Rename Intro to IntroImagePath and make it a std::string.

Add some documentation for the functions of GameFlowScript.

Fix some comments.
2021-07-28 18:44:24 +01:00

70 lines
1.3 KiB
C++

#include "framework.h"
#include "GameScriptPosition.h"
#include <sol.hpp>
#include "phd_global.h"
/***
Represents a position in the game world.
@classmod Position
@pragma nostrip
*/
void GameScriptPosition::Register(sol::state* state)
{
state->new_usertype<GameScriptPosition>("Position",
sol::constructors<GameScriptPosition(int, int, int)>(),
sol::meta_function::to_string, &GameScriptPosition::ToString,
/// (int) x coordinate
//@mem x
"x", &GameScriptPosition::x,
/// (int) y coordinate
//@mem y
"y", &GameScriptPosition::y,
/// (int) z coordinate
//@mem z
"z", &GameScriptPosition::z
);
}
/***
@int X x coordinate
@int Y y coordinate
@int Z z coordinate
@return A Position object.
@function Position.new
*/
GameScriptPosition::GameScriptPosition(int aX, int aY, int aZ)
{
x = aX;
y = aY;
z = aZ;
}
GameScriptPosition::GameScriptPosition(PHD_3DPOS const& pos)
{
x = pos.xPos;
y = pos.yPos;
z = pos.zPos;
}
void GameScriptPosition::StoreInPHDPos(PHD_3DPOS& pos) const
{
pos.xPos = x;
pos.yPos = y;
pos.zPos = z;
}
/***
@tparam Position position this position
@treturn string A string showing the x, y, and z values of the position
@function __tostring
*/
std::string GameScriptPosition::ToString() const
{
return "{" + std::to_string(x) + ", " + std::to_string(y) + ", " + std::to_string(z) + "}";
}