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:
hispidence 2021-07-24 12:45:33 +01:00
parent b763c9a632
commit 783d344185
2 changed files with 38 additions and 4 deletions

View file

@ -188,6 +188,18 @@ auto makeReadOnlyTable = [this](std::string const & tableName, auto const& conta
[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);
GameScriptRotation::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;
}
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()
{