new gamover event for scripts

This commit is contained in:
⍚~Nex
2025-03-03 14:16:34 +01:00
parent 047e2fc551
commit cda9311a90
+22 -24
View File
@@ -100,30 +100,8 @@ class GameOverSubstate extends MusicBeatSubstate
if (__cancelDefault)
return;
if (controls.ACCEPT)
{
endBullshit();
}
if (controls.BACK)
{
if (PlayState.chartingMode && Charter.undos.unsaved)
game.saveWarn(false);
else {
PlayState.resetSongInfos();
if (Charter.instance != null) Charter.instance.__clearStatics();
if (FlxG.sound.music != null)
FlxG.sound.music.stop();
FlxG.sound.music = null;
if (PlayState.isStoryMode)
FlxG.switchState(new StoryMenuState());
else
FlxG.switchState(new FreeplayState());
}
}
if (controls.ACCEPT) endBullshit();
if (controls.BACK) exit();
if (!isEnding && ((!lossSFX.playing) || (character.getAnimName() == "firstDeath" && character.isAnimFinished())) && (FlxG.sound.music == null || !FlxG.sound.music.playing))
{
@@ -192,6 +170,26 @@ class GameOverSubstate extends MusicBeatSubstate
});
}
function exit()
{
var event = new CancellableEvent();
gameoverScript.call('onReturnToMenu', [event]);
if (event.cancelled)
return;
if (PlayState.chartingMode && Charter.undos.unsaved) game.saveWarn(false);
else {
PlayState.resetSongInfos();
if (Charter.instance != null) Charter.instance.__clearStatics();
if (FlxG.sound.music != null) FlxG.sound.music.stop();
FlxG.sound.music = null;
FlxG.switchState(PlayState.isStoryMode ? new StoryMenuState() : new FreeplayState());
}
}
override function destroy()
{
gameoverScript.call("destroy");