1
0
mirror of synced 2024-11-24 07:40:17 +01:00

fix: C# OnLoad method not being run correctly

This commit is contained in:
WerWolv 2024-05-17 09:27:00 +02:00
parent a6277533e8
commit 275774a10a

View File

@ -261,17 +261,21 @@ namespace hex::script::loader {
if (!std::fs::exists(scriptPath))
continue;
if (m_methodExists("Main", scriptPath)) {
const bool hasMain = m_methodExists("Main", scriptPath);
const bool hasOnLoad = m_methodExists("OnLoad", scriptPath);
if (hasMain) {
this->addScript(entry.path().stem().string(), false, [this, scriptPath] {
hex::unused(m_runMethod("Main", false, scriptPath));
});
} else if (hasOnLoad) {
this->addScript(entry.path().stem().string(), true, [] {});
}
if (m_methodExists("OnLoad", scriptPath)) {
this->addScript(entry.path().stem().string(), true, [this, scriptPath] {
hex::unused(m_runMethod("OnLoad", true, scriptPath));
});
if (hasOnLoad) {
hex::unused(m_runMethod("OnLoad", true, scriptPath));
}
}
}