mirror of
https://github.com/TombEngine/TombEngine.git
synced 2025-05-10 20:46:47 +03:00
Add SOUND_SOURCE_INFO and AI_OBJECT names when loading in the level data. Implement remaining functions on the GameLogicScript side.
This commit is contained in:
parent
07d8a254b9
commit
9dd4bcf4ca
2 changed files with 38 additions and 4 deletions
|
@ -188,6 +188,18 @@ auto makeReadOnlyTable = [this](std::string const & tableName, auto const& conta
|
||||||
[this](std::string const& str) { return RemoveLuaNameSink(str); }
|
[this](std::string const& str) { return RemoveLuaNameSink(str); }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
GameScriptAIObject::Register(m_lua);
|
||||||
|
GameScriptAIObject::SetNameCallbacks(
|
||||||
|
[this](std::string const& str, AI_OBJECT & info) { return AddLuaNameAIObject(str, info); },
|
||||||
|
[this](std::string const& str) { return RemoveLuaNameAIObject(str); }
|
||||||
|
);
|
||||||
|
|
||||||
|
GameScriptSoundSourceInfo::Register(m_lua);
|
||||||
|
GameScriptSoundSourceInfo::SetNameCallbacks(
|
||||||
|
[this](std::string const& str, SOUND_SOURCE_INFO & info) { return AddLuaNameSoundSource(str, info); },
|
||||||
|
[this](std::string const& str) { return RemoveLuaNameSoundSource(str); }
|
||||||
|
);
|
||||||
|
|
||||||
GameScriptPosition::Register(m_lua);
|
GameScriptPosition::Register(m_lua);
|
||||||
GameScriptRotation::Register(m_lua);
|
GameScriptRotation::Register(m_lua);
|
||||||
GameScriptColor::Register(m_lua);
|
GameScriptColor::Register(m_lua);
|
||||||
|
@ -254,6 +266,25 @@ bool GameScript::AddLuaNameSink(std::string const& luaName, SINK_INFO& infoRef)
|
||||||
{
|
{
|
||||||
return m_sinksMapName.insert(std::pair<std::string, SINK_INFO&>(luaName, infoRef)).second;
|
return m_sinksMapName.insert(std::pair<std::string, SINK_INFO&>(luaName, infoRef)).second;
|
||||||
}
|
}
|
||||||
|
bool GameScript::RemoveLuaNameSoundSource(std::string const & luaName)
|
||||||
|
{
|
||||||
|
return m_soundSourcesMapName.erase(luaName);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameScript::AddLuaNameSoundSource(std::string const& luaName, SOUND_SOURCE_INFO& infoRef)
|
||||||
|
{
|
||||||
|
return m_soundSourcesMapName.insert(std::pair<std::string, SOUND_SOURCE_INFO&>(luaName, infoRef)).second;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameScript::RemoveLuaNameAIObject(std::string const & luaName)
|
||||||
|
{
|
||||||
|
return m_aiObjectsMapName.erase(luaName);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool GameScript::AddLuaNameAIObject(std::string const& luaName, AI_OBJECT & ref)
|
||||||
|
{
|
||||||
|
return m_aiObjectsMapName.insert(std::pair<std::string, AI_OBJECT&>(luaName, ref)).second;
|
||||||
|
}
|
||||||
|
|
||||||
void GameScript::FreeLevelScripts()
|
void GameScript::FreeLevelScripts()
|
||||||
{
|
{
|
||||||
|
|
|
@ -855,7 +855,8 @@ void LoadSoundEffects()
|
||||||
g_Level.SoundSources.resize(numSoundSources);
|
g_Level.SoundSources.resize(numSoundSources);
|
||||||
for (int i = 0; i < numSoundSources; i++)
|
for (int i = 0; i < numSoundSources; i++)
|
||||||
{
|
{
|
||||||
SOUND_SOURCE_INFO source;
|
g_Level.SoundSources.push_back(SOUND_SOURCE_INFO{});
|
||||||
|
auto & source = g_Level.SoundSources.back();
|
||||||
|
|
||||||
source.x = ReadInt32();
|
source.x = ReadInt32();
|
||||||
source.y = ReadInt32();
|
source.y = ReadInt32();
|
||||||
|
@ -870,6 +871,7 @@ void LoadSoundEffects()
|
||||||
source.luaName = std::string((const char*)buffer);
|
source.luaName = std::string((const char*)buffer);
|
||||||
|
|
||||||
g_Level.SoundSources.push_back(source);
|
g_Level.SoundSources.push_back(source);
|
||||||
|
g_GameScript->AddLuaNameSoundSource(source.luaName, source);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -926,7 +928,8 @@ void LoadAIObjects()
|
||||||
g_Level.AIObjects.resize(nAIObjects);
|
g_Level.AIObjects.resize(nAIObjects);
|
||||||
for (int i = 0; i < nAIObjects; i++)
|
for (int i = 0; i < nAIObjects; i++)
|
||||||
{
|
{
|
||||||
AI_OBJECT obj;
|
g_Level.AIObjects.push_back(AI_OBJECT{});
|
||||||
|
auto & obj = g_Level.AIObjects.back();
|
||||||
|
|
||||||
obj.objectNumber = (GAME_OBJECT_ID)ReadInt16();
|
obj.objectNumber = (GAME_OBJECT_ID)ReadInt16();
|
||||||
obj.roomNumber = ReadInt16();
|
obj.roomNumber = ReadInt16();
|
||||||
|
@ -943,8 +946,8 @@ void LoadAIObjects()
|
||||||
ZeroMemory(buffer, 256);
|
ZeroMemory(buffer, 256);
|
||||||
ReadBytes(buffer, numBytes);
|
ReadBytes(buffer, numBytes);
|
||||||
obj.luaName = std::string((const char*)buffer);
|
obj.luaName = std::string((const char*)buffer);
|
||||||
|
|
||||||
g_Level.AIObjects.push_back(obj);
|
g_GameScript->AddLuaNameAIObject(obj.luaName, obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue