mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-12-12 08:25:13 +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:
commit
a42524987e
|
@ -97,14 +97,14 @@ class GameOverSubState extends MusicBeatSubState
|
|||
/**
|
||||
* Reset the game over configuration to the default.
|
||||
*/
|
||||
public static function reset()
|
||||
public static function reset():Void
|
||||
{
|
||||
animationSuffix = "";
|
||||
musicSuffix = "";
|
||||
blueBallSuffix = "";
|
||||
animationSuffix = '';
|
||||
musicSuffix = '';
|
||||
blueBallSuffix = '';
|
||||
}
|
||||
|
||||
override public function create()
|
||||
override public function create():Void
|
||||
{
|
||||
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.
|
||||
// We can then play the character's `firstDeath` animation.
|
||||
boyfriend = playState.currentStage.getBoyfriend(true);
|
||||
boyfriend.isDead = true;
|
||||
add(boyfriend);
|
||||
boyfriend.resetCharacter();
|
||||
if (PlayState.instance.isMinimalMode) {}
|
||||
else
|
||||
{
|
||||
boyfriend = PlayState.instance.currentStage.getBoyfriend(true);
|
||||
boyfriend.isDead = true;
|
||||
add(boyfriend);
|
||||
boyfriend.resetCharacter();
|
||||
|
||||
// Cancel camera tweening if it's currently active.
|
||||
playState.cancelAllCameraTweens();
|
||||
// Assign a camera follow point to the boyfriend's position.
|
||||
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.
|
||||
cameraFollowPoint = new FlxObject(playState.cameraFollowPoint.x, playState.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);
|
||||
|
||||
FlxG.camera.target = null;
|
||||
FlxG.camera.follow(cameraFollowPoint, LOCKON, 0.01);
|
||||
targetCameraZoom = PlayState?.instance?.currentStage?.camZoom * boyfriend.getDeathCameraZoom();
|
||||
FlxG.camera.target = null;
|
||||
FlxG.camera.follow(cameraFollowPoint, LOCKON, 0.01);
|
||||
targetCameraZoom = PlayState?.instance?.currentStage?.camZoom * boyfriend.getDeathCameraZoom();
|
||||
}
|
||||
|
||||
//
|
||||
// Set up the audio
|
||||
|
@ -169,21 +170,29 @@ class GameOverSubState extends MusicBeatSubState
|
|||
|
||||
var hasStartedAnimation:Bool = false;
|
||||
|
||||
override function update(elapsed:Float)
|
||||
override function update(elapsed:Float):Void
|
||||
{
|
||||
if (!hasStartedAnimation)
|
||||
{
|
||||
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
|
||||
{
|
||||
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();
|
||||
if (boyfriend.hasAnimation('fakeoutDeath') && FlxG.random.bool((1 / 4096) * 100))
|
||||
{
|
||||
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
|
||||
{
|
||||
// Music hasn't started yet.
|
||||
switch (PlayStatePlaylist.campaignId)
|
||||
if (PlayState.instance.isMinimalMode)
|
||||
{
|
||||
// TODO: Make the behavior for playing Jeff's voicelines generic or un-hardcoded.
|
||||
// This will simplify the class and make it easier for mods to add death quotes.
|
||||
case "week7":
|
||||
if (boyfriend.getCurrentAnimation().startsWith('firstDeath') && boyfriend.isAnimationFinished() && !playingJeffQuote)
|
||||
{
|
||||
playingJeffQuote = true;
|
||||
playJeffQuote();
|
||||
// Start music at lower volume
|
||||
startDeathMusic(0.2, false);
|
||||
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);
|
||||
}
|
||||
// startDeathMusic(1.0, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Music hasn't started yet.
|
||||
switch (PlayStatePlaylist.campaignId)
|
||||
{
|
||||
// TODO: Make the behavior for playing Jeff's voicelines generic or un-hardcoded.
|
||||
// This will simplify the class and make it easier for mods to add death quotes.
|
||||
case 'week7':
|
||||
if (boyfriend.getCurrentAnimation().startsWith('firstDeath') && boyfriend.isAnimationFinished() && !playingJeffQuote)
|
||||
{
|
||||
playingJeffQuote = true;
|
||||
playJeffQuote();
|
||||
// Start music at lower volume
|
||||
startDeathMusic(0.2, false);
|
||||
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;
|
||||
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...
|
||||
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);
|
||||
PlayState.instance.needsReset = true;
|
||||
|
||||
// Readd Boyfriend to the stage.
|
||||
boyfriend.isDead = false;
|
||||
remove(boyfriend);
|
||||
PlayState.instance.currentStage.addCharacter(boyfriend, BF);
|
||||
if (PlayState.instance.isMinimalMode) {}
|
||||
else
|
||||
{
|
||||
// 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.
|
||||
resetCameraZoom();
|
||||
|
|
|
@ -1550,6 +1550,7 @@ class PlayState extends MusicBeatSubState
|
|||
|
||||
public function resetCameraZoom():Void
|
||||
{
|
||||
if (PlayState.instance.isMinimalMode) return;
|
||||
// Apply camera zoom level from stage data.
|
||||
defaultCameraZoom = currentStage.camZoom;
|
||||
currentCameraZoom = defaultCameraZoom;
|
||||
|
|
Loading…
Reference in a new issue