1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-03-26 03:49:45 +00:00

Merge pull request #400 from FunkinCrew/bugfix/minimal-mode-gameover

Fix several crashes when reaching a game over in minimal mode
This commit is contained in:
Cameron Taylor 2024-03-22 18:03:46 -04:00 committed by GitHub
commit a42524987e
2 changed files with 79 additions and 54 deletions

View file

@ -97,14 +97,14 @@ class GameOverSubState extends MusicBeatSubState
/** /**
* Reset the game over configuration to the default. * Reset the game over configuration to the default.
*/ */
public static function reset() public static function reset():Void
{ {
animationSuffix = ""; animationSuffix = '';
musicSuffix = ""; musicSuffix = '';
blueBallSuffix = ""; blueBallSuffix = '';
} }
override public function create() override public function create():Void
{ {
if (instance != null) if (instance != null)
{ {
@ -132,26 +132,27 @@ class GameOverSubState extends MusicBeatSubState
// Pluck Boyfriend from the PlayState and place him (in the same position) in the GameOverSubState. // Pluck Boyfriend from the PlayState and place him (in the same position) in the GameOverSubState.
// We can then play the character's `firstDeath` animation. // We can then play the character's `firstDeath` animation.
boyfriend = playState.currentStage.getBoyfriend(true); if (PlayState.instance.isMinimalMode) {}
boyfriend.isDead = true; else
add(boyfriend); {
boyfriend.resetCharacter(); boyfriend = PlayState.instance.currentStage.getBoyfriend(true);
boyfriend.isDead = true;
add(boyfriend);
boyfriend.resetCharacter();
// Cancel camera tweening if it's currently active. // Assign a camera follow point to the boyfriend's position.
playState.cancelAllCameraTweens(); cameraFollowPoint = new FlxObject(PlayState.instance.cameraFollowPoint.x, PlayState.instance.cameraFollowPoint.y, 1, 1);
cameraFollowPoint.x = boyfriend.getGraphicMidpoint().x;
cameraFollowPoint.y = boyfriend.getGraphicMidpoint().y;
var offsets:Array<Float> = boyfriend.getDeathCameraOffsets();
cameraFollowPoint.x += offsets[0];
cameraFollowPoint.y += offsets[1];
add(cameraFollowPoint);
// Assign a camera follow point to the boyfriend's position. FlxG.camera.target = null;
cameraFollowPoint = new FlxObject(playState.cameraFollowPoint.x, playState.cameraFollowPoint.y, 1, 1); FlxG.camera.follow(cameraFollowPoint, LOCKON, 0.01);
cameraFollowPoint.x = boyfriend.getGraphicMidpoint().x; targetCameraZoom = PlayState?.instance?.currentStage?.camZoom * boyfriend.getDeathCameraZoom();
cameraFollowPoint.y = boyfriend.getGraphicMidpoint().y; }
var offsets:Array<Float> = boyfriend.getDeathCameraOffsets();
cameraFollowPoint.x += offsets[0];
cameraFollowPoint.y += offsets[1];
add(cameraFollowPoint);
FlxG.camera.target = null;
FlxG.camera.follow(cameraFollowPoint, LOCKON, 0.01);
targetCameraZoom = PlayState?.instance?.currentStage?.camZoom * boyfriend.getDeathCameraZoom();
// //
// Set up the audio // Set up the audio
@ -169,21 +170,29 @@ class GameOverSubState extends MusicBeatSubState
var hasStartedAnimation:Bool = false; var hasStartedAnimation:Bool = false;
override function update(elapsed:Float) override function update(elapsed:Float):Void
{ {
if (!hasStartedAnimation) if (!hasStartedAnimation)
{ {
hasStartedAnimation = true; hasStartedAnimation = true;
if (boyfriend.hasAnimation('fakeoutDeath') && FlxG.random.bool((1 / 4096) * 100)) if (PlayState.instance.isMinimalMode)
{ {
boyfriend.playAnimation('fakeoutDeath', true, false); // Play the "blue balled" sound. May play a variant if one has been assigned.
playBlueBalledSFX();
} }
else else
{ {
boyfriend.playAnimation('firstDeath', true, false); // ignoreOther is set to FALSE since you WANT to be able to mash and confirm game over! if (boyfriend.hasAnimation('fakeoutDeath') && FlxG.random.bool((1 / 4096) * 100))
// Play the "blue balled" sound. May play a variant if one has been assigned. {
playBlueBalledSFX(); boyfriend.playAnimation('fakeoutDeath', true, false);
}
else
{
boyfriend.playAnimation('firstDeath', true, false); // ignoreOther is set to FALSE since you WANT to be able to mash and confirm game over!
// Play the "blue balled" sound. May play a variant if one has been assigned.
playBlueBalledSFX();
}
} }
} }
@ -246,27 +255,34 @@ class GameOverSubState extends MusicBeatSubState
} }
else else
{ {
// Music hasn't started yet. if (PlayState.instance.isMinimalMode)
switch (PlayStatePlaylist.campaignId)
{ {
// TODO: Make the behavior for playing Jeff's voicelines generic or un-hardcoded. // startDeathMusic(1.0, false);
// This will simplify the class and make it easier for mods to add death quotes. }
case "week7": else
if (boyfriend.getCurrentAnimation().startsWith('firstDeath') && boyfriend.isAnimationFinished() && !playingJeffQuote) {
{ // Music hasn't started yet.
playingJeffQuote = true; switch (PlayStatePlaylist.campaignId)
playJeffQuote(); {
// Start music at lower volume // TODO: Make the behavior for playing Jeff's voicelines generic or un-hardcoded.
startDeathMusic(0.2, false); // This will simplify the class and make it easier for mods to add death quotes.
boyfriend.playAnimation('deathLoop' + animationSuffix); case 'week7':
} if (boyfriend.getCurrentAnimation().startsWith('firstDeath') && boyfriend.isAnimationFinished() && !playingJeffQuote)
default: {
// Start music at normal volume once the initial death animation finishes. playingJeffQuote = true;
if (boyfriend.getCurrentAnimation().startsWith('firstDeath') && boyfriend.isAnimationFinished()) playJeffQuote();
{ // Start music at lower volume
startDeathMusic(1.0, false); startDeathMusic(0.2, false);
boyfriend.playAnimation('deathLoop' + animationSuffix); boyfriend.playAnimation('deathLoop' + animationSuffix);
} }
default:
// Start music at normal volume once the initial death animation finishes.
if (boyfriend.getCurrentAnimation().startsWith('firstDeath') && boyfriend.isAnimationFinished())
{
startDeathMusic(1.0, false);
boyfriend.playAnimation('deathLoop' + animationSuffix);
}
}
} }
} }
@ -284,7 +300,11 @@ class GameOverSubState extends MusicBeatSubState
isEnding = true; isEnding = true;
startDeathMusic(1.0, true); // isEnding changes this function's behavior. startDeathMusic(1.0, true); // isEnding changes this function's behavior.
boyfriend.playAnimation('deathConfirm' + animationSuffix, true); if (PlayState.instance.isMinimalMode) {}
else
{
boyfriend.playAnimation('deathConfirm' + animationSuffix, true);
}
// After the animation finishes... // After the animation finishes...
new FlxTimer().start(0.7, function(tmr:FlxTimer) { new FlxTimer().start(0.7, function(tmr:FlxTimer) {
@ -294,10 +314,14 @@ class GameOverSubState extends MusicBeatSubState
FlxG.camera.fade(FlxColor.BLACK, 1, true, null, true); FlxG.camera.fade(FlxColor.BLACK, 1, true, null, true);
PlayState.instance.needsReset = true; PlayState.instance.needsReset = true;
// Readd Boyfriend to the stage. if (PlayState.instance.isMinimalMode) {}
boyfriend.isDead = false; else
remove(boyfriend); {
PlayState.instance.currentStage.addCharacter(boyfriend, BF); // Readd Boyfriend to the stage.
boyfriend.isDead = false;
remove(boyfriend);
PlayState.instance.currentStage.addCharacter(boyfriend, BF);
}
// Snap reset the camera which may have changed because of the player character data. // Snap reset the camera which may have changed because of the player character data.
resetCameraZoom(); resetCameraZoom();

View file

@ -1550,6 +1550,7 @@ class PlayState extends MusicBeatSubState
public function resetCameraZoom():Void public function resetCameraZoom():Void
{ {
if (PlayState.instance.isMinimalMode) return;
// Apply camera zoom level from stage data. // Apply camera zoom level from stage data.
defaultCameraZoom = currentStage.camZoom; defaultCameraZoom = currentStage.camZoom;
currentCameraZoom = defaultCameraZoom; currentCameraZoom = defaultCameraZoom;