mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-08 11:38:08 +03:00
Move GameScriptMirror, GameScriptSinkInfo and GameScriptSkyLayer to Scripting.
This commit is contained in:
parent
e0cbde2135
commit
7df2b154a3
9 changed files with 24 additions and 12 deletions
|
@ -27,9 +27,12 @@
|
|||
<ClInclude Include="include\GameScriptColor.h" />
|
||||
<ClInclude Include="include\GameScriptInventoryObject.h" />
|
||||
<ClInclude Include="include\GameScriptMeshInfo.h" />
|
||||
<ClInclude Include="include\GameScriptMirror.h" />
|
||||
<ClInclude Include="include\GameScriptNamedBase.h" />
|
||||
<ClInclude Include="include\GameScriptPosition.h" />
|
||||
<ClInclude Include="include\GameScriptRotation.h" />
|
||||
<ClInclude Include="include\GameScriptSinkInfo.h" />
|
||||
<ClInclude Include="include\GameScriptSkyLayer.h" />
|
||||
<ClInclude Include="include\ItemEnumPair.h" />
|
||||
<ClInclude Include="include\ScriptAssert.h" />
|
||||
<ClInclude Include="include\ScriptUtil.h" />
|
||||
|
@ -46,8 +49,11 @@
|
|||
<ClCompile Include="src\GameScriptColor.cpp" />
|
||||
<ClCompile Include="src\GameScriptInventoryObject.cpp" />
|
||||
<ClCompile Include="src\GameScriptMeshInfo.cpp" />
|
||||
<ClCompile Include="src\GameScriptMirror.cpp" />
|
||||
<ClCompile Include="src\GameScriptPosition.cpp" />
|
||||
<ClCompile Include="src\GameScriptRotation.cpp" />
|
||||
<ClCompile Include="src\GameScriptSinkInfo.cpp" />
|
||||
<ClCompile Include="src\GameScriptSkyLayer.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
|
|
@ -57,6 +57,15 @@
|
|||
<ClInclude Include="include\GameScriptMeshInfo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\GameScriptSkyLayer.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\GameScriptSinkInfo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\GameScriptMirror.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="frameworkandsol.cpp">
|
||||
|
@ -86,6 +95,15 @@
|
|||
<ClCompile Include="src\GameScriptMeshInfo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GameScriptSkyLayer.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GameScriptSinkInfo.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GameScriptMirror.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
|
21
Scripting/include/GameScriptMirror.h
Normal file
21
Scripting/include/GameScriptMirror.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
#pragma once
|
||||
|
||||
namespace sol {
|
||||
class state;
|
||||
}
|
||||
|
||||
struct GameScriptMirror
|
||||
{
|
||||
short Room{ -1 };
|
||||
int StartX{ 0 };
|
||||
int EndX{ 0 };
|
||||
int StartZ{ 0 };
|
||||
int EndZ{ 0 };
|
||||
|
||||
static void Register(sol::state* lua);
|
||||
GameScriptMirror() = default;
|
||||
|
||||
GameScriptMirror(short room, int startX, int endX, int startZ, int endZ);
|
||||
};
|
||||
|
||||
|
36
Scripting/include/GameScriptSinkInfo.h
Normal file
36
Scripting/include/GameScriptSinkInfo.h
Normal file
|
@ -0,0 +1,36 @@
|
|||
#pragma once
|
||||
|
||||
#include "GameScriptNamedBase.h"
|
||||
#include "Specific/phd_global.h"
|
||||
|
||||
namespace sol {
|
||||
class state;
|
||||
}
|
||||
class GameScriptPosition;
|
||||
|
||||
class GameScriptSinkInfo : public GameScriptNamedBase<GameScriptSinkInfo, SINK_INFO &>
|
||||
{
|
||||
public:
|
||||
using IdentifierType = std::reference_wrapper<SINK_INFO>;
|
||||
GameScriptSinkInfo(SINK_INFO& ref, bool temp);
|
||||
~GameScriptSinkInfo();
|
||||
GameScriptSinkInfo& operator=(GameScriptSinkInfo const& other) = delete;
|
||||
GameScriptSinkInfo(GameScriptSinkInfo const& other) = delete;
|
||||
|
||||
static void Register(sol::state *);
|
||||
GameScriptPosition GetPos() const;
|
||||
void SetPos(GameScriptPosition const& pos);
|
||||
|
||||
int GetStrength() const;
|
||||
void SetStrength(int strength);
|
||||
|
||||
int GetBoxIndex() const;
|
||||
void SetBoxIndex(int Room);
|
||||
|
||||
std::string GetName() const;
|
||||
void SetName(std::string const &);
|
||||
|
||||
private:
|
||||
SINK_INFO & m_sink;
|
||||
bool m_temporary;
|
||||
};
|
23
Scripting/include/GameScriptSkyLayer.h
Normal file
23
Scripting/include/GameScriptSkyLayer.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
#pragma once
|
||||
|
||||
#include "GameScriptColor.h"
|
||||
|
||||
namespace sol {
|
||||
class state;
|
||||
}
|
||||
|
||||
struct GameScriptSkyLayer
|
||||
{
|
||||
bool Enabled{ false };
|
||||
byte R{ 0 };
|
||||
byte G{ 0 };
|
||||
byte B{ 0 };
|
||||
short CloudSpeed{ 0 };
|
||||
|
||||
GameScriptSkyLayer() = default;
|
||||
GameScriptSkyLayer(GameScriptColor const & col, short speed);
|
||||
void SetColor(GameScriptColor const & col);
|
||||
|
||||
static void Register(sol::state *);
|
||||
};
|
||||
|
33
Scripting/src/GameScriptMirror.cpp
Normal file
33
Scripting/src/GameScriptMirror.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include "frameworkandsol.h"
|
||||
#include "GameScriptMirror.h"
|
||||
|
||||
/***
|
||||
A mirror effect.
|
||||
As seen in TR4's Coastal Ruins and Sacred Lake levels.
|
||||
|
||||
__Not currently implemented.__
|
||||
|
||||
@pregameclass Mirror
|
||||
@pragma nostrip
|
||||
*/
|
||||
|
||||
void GameScriptMirror::Register(sol::state* lua)
|
||||
{
|
||||
lua->new_usertype<GameScriptMirror>("Mirror",
|
||||
sol::constructors<GameScriptMirror(short, int, int, int, int)>(),
|
||||
"room", &GameScriptMirror::Room,
|
||||
"startX", &GameScriptMirror::StartX,
|
||||
"endX", &GameScriptMirror::EndX,
|
||||
"startZ", &GameScriptMirror::StartZ,
|
||||
"endZ", &GameScriptMirror::EndZ
|
||||
);
|
||||
}
|
||||
|
||||
GameScriptMirror::GameScriptMirror(short room, int startX, int endX, int startZ, int endZ)
|
||||
{
|
||||
Room = room;
|
||||
StartX = startX;
|
||||
EndX = endX;
|
||||
StartZ = startZ;
|
||||
EndZ = endZ;
|
||||
}
|
109
Scripting/src/GameScriptSinkInfo.cpp
Normal file
109
Scripting/src/GameScriptSinkInfo.cpp
Normal file
|
@ -0,0 +1,109 @@
|
|||
#pragma once
|
||||
#include "frameworkandsol.h"
|
||||
#include "ScriptAssert.h"
|
||||
#include "GameScriptSinkInfo.h"
|
||||
#include "GameScriptPosition.h"
|
||||
#include "ScriptUtil.h"
|
||||
/***
|
||||
Sink info
|
||||
|
||||
@entityclass SinkInfo
|
||||
@pragma nostrip
|
||||
*/
|
||||
|
||||
constexpr auto LUA_CLASS_NAME{ "SinkInfo" };
|
||||
|
||||
static auto index_error = index_error_maker(GameScriptSinkInfo, LUA_CLASS_NAME);
|
||||
static auto newindex_error = newindex_error_maker(GameScriptSinkInfo, LUA_CLASS_NAME);
|
||||
|
||||
GameScriptSinkInfo::GameScriptSinkInfo(SINK_INFO & ref, bool temp) : m_sink{ref}, m_temporary{ temp }
|
||||
{};
|
||||
|
||||
GameScriptSinkInfo::~GameScriptSinkInfo() {
|
||||
if (m_temporary)
|
||||
{
|
||||
s_callbackRemoveName(m_sink.luaName);
|
||||
}
|
||||
}
|
||||
|
||||
void GameScriptSinkInfo::Register(sol::state* state)
|
||||
{
|
||||
state->new_usertype<GameScriptSinkInfo>(LUA_CLASS_NAME,
|
||||
sol::meta_function::index, index_error,
|
||||
sol::meta_function::new_index, newindex_error,
|
||||
|
||||
/// (@{Position}) position in level
|
||||
// @mem pos
|
||||
"pos", sol::property(&GameScriptSinkInfo::GetPos, &GameScriptSinkInfo::SetPos),
|
||||
|
||||
/// (string) unique string identifier.
|
||||
// e.g. "strong\_river\_current" or "propeller\_death\_sink"
|
||||
// @mem name
|
||||
"name", sol::property(&GameScriptSinkInfo::GetName, &GameScriptSinkInfo::SetName),
|
||||
|
||||
/// (int) strength.
|
||||
// Strength of the sink, with higher numbers providing stronger currents. Will be clamped to [1, 32].
|
||||
// @mem strength
|
||||
"strength", sol::property(&GameScriptSinkInfo::GetStrength, &GameScriptSinkInfo::SetStrength),
|
||||
|
||||
/// (int) box index.
|
||||
// I don't know what this does and it's not actually in the engine yet
|
||||
// @mem boxIndex
|
||||
"boxIndex", sol::property(&GameScriptSinkInfo::GetBoxIndex, &GameScriptSinkInfo::SetBoxIndex)
|
||||
);
|
||||
}
|
||||
|
||||
GameScriptPosition GameScriptSinkInfo::GetPos() const
|
||||
{
|
||||
return GameScriptPosition{ m_sink.x, m_sink.y, m_sink.z };
|
||||
}
|
||||
|
||||
void GameScriptSinkInfo::SetPos(GameScriptPosition const& pos)
|
||||
{
|
||||
m_sink.x = pos.x;
|
||||
m_sink.y = pos.y;
|
||||
m_sink.z = pos.z;
|
||||
}
|
||||
|
||||
std::string GameScriptSinkInfo::GetName() const
|
||||
{
|
||||
return m_sink.luaName;
|
||||
}
|
||||
|
||||
void GameScriptSinkInfo::SetName(std::string const & id)
|
||||
{
|
||||
ScriptAssert(!id.empty(), "Name cannot be blank", ERROR_MODE::TERMINATE);
|
||||
|
||||
// remove the old name if we have one
|
||||
s_callbackRemoveName(m_sink.luaName);
|
||||
|
||||
// un-register any other sinks using this name.
|
||||
// maybe we should throw an error if another sink
|
||||
// already uses the name...
|
||||
s_callbackRemoveName(id);
|
||||
m_sink.luaName = id;
|
||||
// todo add error checking
|
||||
s_callbackSetName(id, m_sink);
|
||||
}
|
||||
|
||||
int GameScriptSinkInfo::GetStrength() const
|
||||
{
|
||||
return m_sink.strength;
|
||||
}
|
||||
|
||||
void GameScriptSinkInfo::SetStrength(int str)
|
||||
{
|
||||
m_sink.strength = std::clamp(str, 1, 32);
|
||||
}
|
||||
|
||||
int GameScriptSinkInfo::GetBoxIndex() const
|
||||
{
|
||||
|
||||
return m_sink.boxIndex;
|
||||
}
|
||||
|
||||
void GameScriptSinkInfo::SetBoxIndex(int b)
|
||||
{
|
||||
m_sink.boxIndex = b;
|
||||
}
|
||||
|
53
Scripting/src/GameScriptSkyLayer.cpp
Normal file
53
Scripting/src/GameScriptSkyLayer.cpp
Normal file
|
@ -0,0 +1,53 @@
|
|||
#include "frameworkandsol.h"
|
||||
#include "GameScriptSkyLayer.h"
|
||||
|
||||
/*** Describes a layer of moving clouds.
|
||||
As seen in TR4's City of the Dead.
|
||||
|
||||
@pregameclass SkyLayer
|
||||
@pragma nostrip
|
||||
*/
|
||||
|
||||
void GameScriptSkyLayer::Register(sol::state* lua)
|
||||
{
|
||||
lua->new_usertype<GameScriptSkyLayer>("SkyLayer",
|
||||
sol::constructors<GameScriptSkyLayer(GameScriptColor const &, short)>(),
|
||||
|
||||
/// (@{Color}) RGB sky color
|
||||
//@mem color
|
||||
"color", sol::property(&GameScriptSkyLayer::SetColor),
|
||||
|
||||
/*** (int) cloud speed.
|
||||
|
||||
Values can be between [-32768, 32767], with positive numbers resulting in a sky that scrolls from
|
||||
west to east, and negative numbers resulting in one that travels east to west.
|
||||
|
||||
Please note that speeds outside of the range of about [-1000, 1000] will cause the
|
||||
sky to scroll so fast that it will no longer appear as a coherent stream of clouds.
|
||||
Less is more. City of The Dead, for example, uses a speed value of 16.
|
||||
|
||||
@mem speed*/
|
||||
"speed", &GameScriptSkyLayer::CloudSpeed
|
||||
);
|
||||
}
|
||||
|
||||
/***
|
||||
@tparam Color color RGB color
|
||||
@tparam int speed cloud speed
|
||||
@return A SkyLayer object.
|
||||
@function SkyLayer.new
|
||||
*/
|
||||
GameScriptSkyLayer::GameScriptSkyLayer(GameScriptColor const& col, short speed)
|
||||
{
|
||||
SetColor(col);
|
||||
CloudSpeed = speed;
|
||||
Enabled = true;
|
||||
}
|
||||
|
||||
void GameScriptSkyLayer::SetColor(GameScriptColor const & col)
|
||||
{
|
||||
R = col.GetR();
|
||||
G = col.GetG();
|
||||
B = col.GetB();
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue