Add cancelConductorUpdate, deathStart

This commit is contained in:
Ralty
2025-08-06 05:13:17 +07:00
parent 16b080bf84
commit 17539a6f39
5 changed files with 31 additions and 12 deletions
+2 -1
View File
@@ -11,13 +11,14 @@ import funkin.backend.system.Controls;
import funkin.backend.system.GraphicCacheSprite;
import funkin.backend.system.framerate.Framerate;
import funkin.backend.system.interfaces.IBeatReceiver;
import funkin.backend.system.interfaces.IBeatCancellableReceiver;
import funkin.options.PlayerSettings;
/**
* Base class for all the states.
* Handles the scripts, the transitions, and the beat and step events.
**/
class MusicBeatState extends FlxState implements IBeatReceiver
class MusicBeatState extends FlxState implements IBeatCancellableReceiver
{
private var lastBeat:Float = 0;
private var lastStep:Float = 0;
+7 -1
View File
@@ -9,17 +9,23 @@ import funkin.backend.scripting.events.*;
import funkin.backend.system.Conductor;
import funkin.backend.system.Controls;
import funkin.backend.system.interfaces.IBeatReceiver;
import funkin.backend.system.interfaces.IBeatCancellableReceiver;
import funkin.options.PlayerSettings;
/**
* Base class for all the sub states.
* Handles the scripts, the transitions, and the beat and step events.
**/
class MusicBeatSubstate extends FlxSubState implements IBeatReceiver
class MusicBeatSubstate extends FlxSubState implements IBeatCancellableReceiver
{
private var lastBeat:Float = 0;
private var lastStep:Float = 0;
/**
* Whenever the Conductor auto update should be enabled or not.
*/
public var cancelConductorUpdate:Bool = false;
/**
* Whether this specific substate can open custom transitions
*/
+9 -2
View File
@@ -4,6 +4,7 @@ import flixel.FlxState;
import flixel.util.FlxSignal.FlxTypedSignal;
import funkin.backend.chart.ChartData;
import funkin.backend.system.interfaces.IBeatReceiver;
import funkin.backend.system.interfaces.IBeatCancellableReceiver;
import funkin.editors.charter.Charter;
enum BeatType {
@@ -371,8 +372,14 @@ final class Conductor
private static var __updateMeasure:Bool;
private static function update() {
if (FlxG.state != null && FlxG.state is MusicBeatState && cast(FlxG.state, MusicBeatState).cancelConductorUpdate) return;
if (FlxG.state == null) return;
else {
var state = FlxG.state;
while (state != null) {
if (state is IBeatCancellableReceiver && cast(FlxG.state, IBeatCancellableReceiver).cancelConductorUpdate) return;
state = state.subState;
}
}
__updateSongPos(FlxG.elapsed);
var oldStep = curStep, oldBeat = curBeat, oldMeasure = curMeasure, oldChangeIndex = curChangeIndex;
@@ -0,0 +1,5 @@
package funkin.backend.system.interfaces;
interface IBeatCancellableReceiver extends IBeatReceiver {
public var cancelConductorUpdate:Bool;
}
+8 -8
View File
@@ -87,6 +87,7 @@ class GameOverSubstate extends MusicBeatSubstate
lossSFX = FlxG.sound.play(Paths.sound(lossSFXName));
Conductor.changeBPM(gameOverSongBPM);
cancelConductorUpdate = true;
DiscordUtil.call("onGameOver", []);
gameoverScript.call("postCreate");
@@ -106,22 +107,21 @@ class GameOverSubstate extends MusicBeatSubstate
if (!isEnding && ((!lossSFX.playing) || (character.getAnimName() == "firstDeath" && character.isAnimFinished())) && (FlxG.sound.music == null || !FlxG.sound.music.playing))
{
var event = new CancellableEvent();
gameoverScript.call("deathStart", [event]);
if (event.cancelled) return;
CoolUtil.playMusic(Paths.music(gameOverSong), false, 1, true, Flags.DEFAULT_BPM);
beatHit(0);
character.playAnim("deathLoop", true, DANCE);
cancelConductorUpdate = false;
}
}
override function beatHit(curBeat:Int)
{
super.beatHit(curBeat);
gameoverScript.call("beatHit", [curBeat]);
if (__cancelDefault)
return;
if (FlxG.sound.music != null && FlxG.sound.music.playing)
character.playAnim("deathLoop", true, DANCE);
}
override function stepHit(curStep:Int)