feat: Scoped Modules

This commit is contained in:
Abnormal
2025-08-13 13:15:26 -04:00
committed by Eric
parent 4268462d90
commit 842ec2c1cd
2 changed files with 21 additions and 1 deletions
@@ -6,6 +6,7 @@ import funkin.modding.events.ScriptEvent;
import funkin.modding.events.ScriptEventDispatcher;
import funkin.modding.module.Module;
import funkin.modding.module.ScriptedModule;
import flixel.FlxG;
/**
* Utility functions for loading and manipulating active modules.
@@ -145,6 +146,14 @@ class ModuleHandler
// The module needs to be active to receive events.
if (module != null && module.active)
{
if (module.state != null)
{
// Only call the event if the current state is what the module's state is.
if (!(Type.getClass(FlxG.state) == module.state) && !(Type.getClass(FlxG.state?.subState) == module.state))
{
continue;
}
}
ScriptEventDispatcher.callEvent(module, event);
}
}