1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-01-06 04:08:42 +00:00

Fix substate lifecycle script events not dispatching.

This commit is contained in:
EliteMasterEric 2024-05-02 04:08:51 -04:00
parent 4d7f3a3643
commit 88c7ed7949

View file

@ -5,6 +5,7 @@ import flixel.FlxSubState;
import flixel.text.FlxText;
import funkin.ui.mainmenu.MainMenuState;
import flixel.util.FlxColor;
import funkin.audio.FunkinSound;
import funkin.modding.events.ScriptEvent;
import funkin.modding.IScriptedClass.IEventHandler;
import funkin.modding.module.ModuleHandler;
@ -162,4 +163,54 @@ class MusicBeatSubState extends FlxSubState implements IEventHandler
this.close();
this._parentState.openSubState(substate);
}
override function startOutro(onComplete:() -> Void):Void
{
var event = new StateChangeScriptEvent(STATE_CHANGE_BEGIN, null, true);
dispatchEvent(event);
if (event.eventCanceled)
{
return;
}
else
{
FunkinSound.stopAllAudio();
onComplete();
}
}
public override function openSubState(targetSubState:FlxSubState):Void
{
var event = new SubStateScriptEvent(SUBSTATE_OPEN_BEGIN, targetSubState, true);
dispatchEvent(event);
if (event.eventCanceled) return;
super.openSubState(targetSubState);
}
function onOpenSubStateComplete(targetState:FlxSubState):Void
{
dispatchEvent(new SubStateScriptEvent(SUBSTATE_OPEN_END, targetState, true));
}
public override function closeSubState():Void
{
var event = new SubStateScriptEvent(SUBSTATE_CLOSE_BEGIN, this.subState, true);
dispatchEvent(event);
if (event.eventCanceled) return;
super.closeSubState();
}
function onCloseSubStateComplete(targetState:FlxSubState):Void
{
dispatchEvent(new SubStateScriptEvent(SUBSTATE_CLOSE_END, targetState, true));
}
}