mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-09 03:58:19 +03:00
Move over GameScriptAIObject and some other things to Scripting. This won't build... yet.
This commit is contained in:
parent
52011310b5
commit
a499f878d2
8 changed files with 20 additions and 7 deletions
|
@ -21,10 +21,14 @@
|
|||
<ItemGroup>
|
||||
<ClInclude Include="framework.h" />
|
||||
<ClInclude Include="frameworkandsol.h" />
|
||||
<ClInclude Include="include\GameScriptAIObject.h" />
|
||||
<ClInclude Include="include\GameScriptCameraInfo.h" />
|
||||
<ClInclude Include="include\GameScriptColor.h" />
|
||||
<ClInclude Include="include\GameScriptNamedBase.h" />
|
||||
<ClInclude Include="include\GameScriptPosition.h" />
|
||||
<ClInclude Include="include\GameScriptRotation.h" />
|
||||
<ClInclude Include="include\ScriptAssert.h" />
|
||||
<ClInclude Include="include\ScriptUtil.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="frameworkandsol.cpp">
|
||||
|
@ -32,6 +36,7 @@
|
|||
<PrecompiledHeaderFile Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">frameworkandsol.h</PrecompiledHeaderFile>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GameScriptAIObject.cpp" />
|
||||
<ClCompile Include="src\GameScriptCameraInfo.cpp" />
|
||||
<ClCompile Include="src\GameScriptColor.cpp" />
|
||||
<ClCompile Include="src\GameScriptPosition.cpp" />
|
||||
|
|
|
@ -33,6 +33,18 @@
|
|||
<ClInclude Include="include\GameScriptCameraInfo.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\ScriptUtil.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\ScriptAssert.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\GameScriptNamedBase.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\GameScriptAIObject.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="frameworkandsol.cpp">
|
||||
|
@ -50,6 +62,9 @@
|
|||
<ClCompile Include="src\GameScriptColor.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\GameScriptAIObject.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="packages.config" />
|
||||
|
|
50
Scripting/include/GameScriptAIObject.h
Normal file
50
Scripting/include/GameScriptAIObject.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
|
||||
#include "GameScriptNamedBase.h"
|
||||
#include "Specific/level.h"
|
||||
|
||||
namespace sol {
|
||||
class state;
|
||||
}
|
||||
class GameScriptPosition;
|
||||
|
||||
class GameScriptAIObject : public GameScriptNamedBase<GameScriptAIObject, AI_OBJECT&>
|
||||
{
|
||||
public:
|
||||
GameScriptAIObject(AI_OBJECT& ref, bool temp);
|
||||
~GameScriptAIObject();
|
||||
|
||||
GameScriptAIObject& operator=(GameScriptAIObject const& other) = delete;
|
||||
GameScriptAIObject(GameScriptAIObject const& other) = delete;
|
||||
|
||||
static void Register(sol::state *);
|
||||
|
||||
GameScriptPosition GetPos() const;
|
||||
void SetPos(GameScriptPosition const& pos);
|
||||
|
||||
short GetRoom() const;
|
||||
void SetRoom(short Room);
|
||||
|
||||
std::string GetName() const;
|
||||
void SetName(std::string const &);
|
||||
|
||||
GAME_OBJECT_ID GetObjID() const;
|
||||
void SetObjID(GAME_OBJECT_ID);
|
||||
|
||||
short GetTriggerFlags() const;
|
||||
void SetTriggerFlags(short);
|
||||
|
||||
short GetFlags() const;
|
||||
void SetFlags(short);
|
||||
|
||||
short GetYRot() const;
|
||||
void SetYRot(short);
|
||||
|
||||
short GetBoxNumber() const;
|
||||
void SetBoxNumber(short);
|
||||
|
||||
private:
|
||||
AI_OBJECT & m_aiObject;
|
||||
bool m_temporary;
|
||||
};
|
||||
|
164
Scripting/src/GameScriptAIObject.cpp
Normal file
164
Scripting/src/GameScriptAIObject.cpp
Normal file
|
@ -0,0 +1,164 @@
|
|||
#pragma once
|
||||
#include "frameworkandsol.h"
|
||||
#include "GameScriptAIObject.h"
|
||||
#include "ScriptAssert.h"
|
||||
#include "GameScriptPosition.h"
|
||||
#include "ScriptUtil.h"
|
||||
/***
|
||||
AI object
|
||||
|
||||
@entityclass AIObject
|
||||
@pragma nostrip
|
||||
*/
|
||||
|
||||
|
||||
constexpr auto LUA_CLASS_NAME{ "AIObject" };
|
||||
|
||||
static auto index_error = index_error_maker(GameScriptAIObject, LUA_CLASS_NAME);
|
||||
static auto newindex_error = newindex_error_maker(GameScriptAIObject, LUA_CLASS_NAME);
|
||||
|
||||
GameScriptAIObject::GameScriptAIObject(AI_OBJECT & ref, bool temp) : m_aiObject{ref}, m_temporary{ temp }
|
||||
{};
|
||||
|
||||
GameScriptAIObject::~GameScriptAIObject() {
|
||||
if (m_temporary)
|
||||
{
|
||||
s_callbackRemoveName(m_aiObject.luaName);
|
||||
}
|
||||
}
|
||||
|
||||
void GameScriptAIObject::Register(sol::state* state)
|
||||
{
|
||||
state->new_usertype<GameScriptAIObject>(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(&GameScriptAIObject::GetPos, &GameScriptAIObject::SetPos),
|
||||
|
||||
/// (int) y-axis rotation
|
||||
// @mem yRot
|
||||
"yRot", sol::property(&GameScriptAIObject::GetYRot, &GameScriptAIObject::SetYRot),
|
||||
|
||||
/// (string) unique string identifier.
|
||||
// e.g. "door_back_room" or "cracked_greek_statue"
|
||||
// @mem name
|
||||
"name", sol::property(&GameScriptAIObject::GetName, &GameScriptAIObject::SetName),
|
||||
|
||||
/// (int) room number
|
||||
// @mem room
|
||||
"room", sol::property(&GameScriptAIObject::GetRoom, &GameScriptAIObject::SetRoom),
|
||||
|
||||
/// (@{ObjID}) object ID
|
||||
// @mem objID
|
||||
"objID", sol::property(&GameScriptAIObject::GetObjID, &GameScriptAIObject::SetObjID),
|
||||
|
||||
/// (short) flags
|
||||
// @mem flags
|
||||
"flags", sol::property(&GameScriptAIObject::GetFlags, &GameScriptAIObject::SetFlags),
|
||||
|
||||
/// (short) trigger flags
|
||||
// @mem triggerFlags
|
||||
"triggerFlags", sol::property(&GameScriptAIObject::GetTriggerFlags, &GameScriptAIObject::SetTriggerFlags),
|
||||
|
||||
/// (short) box number
|
||||
// @mem boxNumber
|
||||
"boxNumber", sol::property(&GameScriptAIObject::GetBoxNumber, &GameScriptAIObject::SetBoxNumber)
|
||||
);
|
||||
}
|
||||
|
||||
GameScriptPosition GameScriptAIObject::GetPos() const
|
||||
{
|
||||
return GameScriptPosition{ m_aiObject.x, m_aiObject.y, m_aiObject.z };
|
||||
}
|
||||
|
||||
void GameScriptAIObject::SetPos(GameScriptPosition const& pos)
|
||||
{
|
||||
m_aiObject.x = pos.x;
|
||||
m_aiObject.y = pos.y;
|
||||
m_aiObject.z = pos.z;
|
||||
}
|
||||
|
||||
GAME_OBJECT_ID GameScriptAIObject::GetObjID() const
|
||||
{
|
||||
return m_aiObject.objectNumber;
|
||||
}
|
||||
|
||||
void GameScriptAIObject::SetObjID(GAME_OBJECT_ID objNum)
|
||||
{
|
||||
m_aiObject.objectNumber = objNum;
|
||||
}
|
||||
|
||||
short GameScriptAIObject::GetYRot() const
|
||||
{
|
||||
return m_aiObject.yRot;
|
||||
}
|
||||
|
||||
void GameScriptAIObject::SetYRot(short yRot)
|
||||
{
|
||||
m_aiObject.yRot = yRot;
|
||||
}
|
||||
|
||||
std::string GameScriptAIObject::GetName() const
|
||||
{
|
||||
return m_aiObject.luaName;
|
||||
}
|
||||
|
||||
void GameScriptAIObject::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_aiObject.luaName);
|
||||
|
||||
// un-register any other objects using this name.
|
||||
// maybe we should throw an error if another object
|
||||
// already uses the name...
|
||||
s_callbackRemoveName(id);
|
||||
m_aiObject.luaName = id;
|
||||
// todo add error checking
|
||||
s_callbackSetName(id, m_aiObject);
|
||||
}
|
||||
|
||||
short GameScriptAIObject::GetRoom() const
|
||||
{
|
||||
return m_aiObject.roomNumber;
|
||||
}
|
||||
|
||||
void GameScriptAIObject::SetRoom(short room)
|
||||
{
|
||||
m_aiObject.roomNumber = room;
|
||||
}
|
||||
|
||||
short GameScriptAIObject::GetTriggerFlags() const
|
||||
{
|
||||
|
||||
return m_aiObject.triggerFlags;
|
||||
}
|
||||
|
||||
void GameScriptAIObject::SetTriggerFlags(short tf)
|
||||
{
|
||||
m_aiObject.triggerFlags = tf;
|
||||
}
|
||||
|
||||
short GameScriptAIObject::GetFlags() const
|
||||
{
|
||||
return m_aiObject.flags;
|
||||
}
|
||||
|
||||
void GameScriptAIObject::SetFlags(short tf)
|
||||
{
|
||||
m_aiObject.flags = tf;
|
||||
}
|
||||
|
||||
short GameScriptAIObject::GetBoxNumber() const
|
||||
{
|
||||
return m_aiObject.boxNumber;
|
||||
}
|
||||
|
||||
void GameScriptAIObject::SetBoxNumber(short bn)
|
||||
{
|
||||
m_aiObject.boxNumber = bn;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue