diff --git a/source/funkin/play/notes/NoteSplash.hx b/source/funkin/play/notes/NoteSplash.hx index 85f2d549d..740ab4b56 100644 --- a/source/funkin/play/notes/NoteSplash.hx +++ b/source/funkin/play/notes/NoteSplash.hx @@ -36,15 +36,6 @@ class NoteSplash extends FlxSprite { if (frames == null) noteStyle.buildSplashSprite(this); - // this.animation.addByPrefix('splash1Left', 'note impact 1 purple0', FRAMERATE_DEFAULT, false, false, false); - // this.animation.addByPrefix('splash1Down', 'note impact 1 blue0', FRAMERATE_DEFAULT, false, false, false); - // this.animation.addByPrefix('splash1Up', 'note impact 1 green0', FRAMERATE_DEFAULT, false, false, false); - // this.animation.addByPrefix('splash1Right', 'note impact 1 red0', FRAMERATE_DEFAULT, false, false, false); - // this.animation.addByPrefix('splash2Left', 'note impact 2 purple0', FRAMERATE_DEFAULT, false, false, false); - // this.animation.addByPrefix('splash2Down', 'note impact 2 blue0', FRAMERATE_DEFAULT, false, false, false); - // this.animation.addByPrefix('splash2Up', 'note impact 2 green0', FRAMERATE_DEFAULT, false, false, false); - // this.animation.addByPrefix('splash2Right', 'note impact 2 red0', FRAMERATE_DEFAULT, false, false, false); - if (this.animation.getAnimationList().length < 8) { trace('WARNING: NoteSplash failed to initialize all animations.'); @@ -58,20 +49,16 @@ class NoteSplash extends FlxSprite public function play(direction:NoteDirection, variant:Int = null):Void { - if (variant == null) variant = FlxG.random.int(0, 1); - - switch (direction) + if (variant == null) { - case NoteDirection.LEFT: - this.playAnimation('splashLeft${variant}'); - case NoteDirection.DOWN: - this.playAnimation('splashDown${variant}'); - case NoteDirection.UP: - this.playAnimation('splashUp${variant}'); - case NoteDirection.RIGHT: - this.playAnimation('splashRight${variant}'); + var animationAmount:Int = this.animation.getAnimationList().filter(function(anim) return anim.name.startsWith('splash${direction.nameUpper}')).length + - 1; + variant = FlxG.random.int(0, animationAmount); } + // splashUP0, splashUP1, splashRIGHT0, etc. + this.playAnimation('splash${direction.nameUpper}${variant}'); + if (animation.curAnim == null) return; // Vary the speed of the animation a bit. diff --git a/source/funkin/play/notes/notestyle/NoteStyle.hx b/source/funkin/play/notes/notestyle/NoteStyle.hx index a84e53d67..174fa657c 100644 --- a/source/funkin/play/notes/notestyle/NoteStyle.hx +++ b/source/funkin/play/notes/notestyle/NoteStyle.hx @@ -950,40 +950,19 @@ class NoteStyle implements IRegistryEntry function buildSplashAnimations(target:NoteSplash):Void { - var leftData:Null> = fetchSplashAnimationData(LEFT); - if (leftData != null) - { - for (anim in leftData) + final addSplashAnim:NoteDirection->Void = function(dir:NoteDirection) { + var animData:Null> = fetchSplashAnimationData(dir); + if (animData != null) { - FlxAnimationUtil.addAtlasAnimation(target, anim); + for (anim in animData) + FlxAnimationUtil.addAtlasAnimation(target, anim); } - } + }; - var rightData:Null> = fetchSplashAnimationData(RIGHT); - if (rightData != null) - { - for (anim in rightData) - { - FlxAnimationUtil.addAtlasAnimation(target, anim); - } - } - - var upData:Null> = fetchSplashAnimationData(UP); - if (upData != null) - { - for (anim in upData) - { - FlxAnimationUtil.addAtlasAnimation(target, anim); - } - } - var downData:Null> = fetchSplashAnimationData(DOWN); - if (downData != null) - { - for (anim in downData) - { - FlxAnimationUtil.addAtlasAnimation(target, anim); - } - } + addSplashAnim(LEFT); + addSplashAnim(RIGHT); + addSplashAnim(UP); + addSplashAnim(DOWN); } public function isSplashAnimated():Bool @@ -1000,10 +979,10 @@ class NoteStyle implements IRegistryEntry { var result:Null> = switch (dir) { - case LEFT: _data.assets?.noteSplash?.data?.leftSplashes?.toNamedArray("splashLeft"); - case DOWN: _data.assets?.noteSplash?.data?.downSplashes?.toNamedArray("splashDown"); - case UP: _data.assets?.noteSplash?.data?.upSplashes?.toNamedArray("splashUp"); - case RIGHT: _data.assets?.noteSplash?.data?.rightSplashes?.toNamedArray("splashRight"); + case LEFT: _data.assets?.noteSplash?.data?.leftSplashes?.toNamedArray("splashLEFT"); + case DOWN: _data.assets?.noteSplash?.data?.downSplashes?.toNamedArray("splashDOWN"); + case UP: _data.assets?.noteSplash?.data?.upSplashes?.toNamedArray("splashUP"); + case RIGHT: _data.assets?.noteSplash?.data?.rightSplashes?.toNamedArray("splashRIGHT"); }; return result ?? fallback?.fetchSplashAnimationData(dir); }