diff --git a/source/funkin/play/character/BaseCharacter.hx b/source/funkin/play/character/BaseCharacter.hx index 4ef86c6a9f..98fc08eb7a 100644 --- a/source/funkin/play/character/BaseCharacter.hx +++ b/source/funkin/play/character/BaseCharacter.hx @@ -346,6 +346,16 @@ class BaseCharacter extends Bopper } } + /** + * Stored the direction of the last note that was hit by this player. + */ + var lastNoteDirection:Null = null; + + /** + * Stores the time at which the player should stop looping the sing animation when pressing a hold note. + */ + var lastHoldFinish:Null = null; + public override function onUpdate(event:UpdateScriptEvent):Void { super.onUpdate(event); @@ -388,6 +398,17 @@ class BaseCharacter extends Bopper // Without this check here, the player character would only play the `sing` animation // for one beat, as opposed to holding it as long as the player is holding the button. + + // Repeat the sing animation when pressing a hold note just like in the old input system. + if ((this.characterType != BF || isHoldingNote()) + && this.animation.curAnim.curFrame >= 3 + && lastNoteDirection != null + && (lastHoldFinish != null && lastHoldFinish >= Conductor.instance.songPosition)) + { + this.playSingAnimation(lastNoteDirection, false); + holdTimer = 0; + } + var shouldStopSinging:Bool = (this.characterType == BF) ? !isHoldingNote() : true; FlxG.watch.addQuick('singTimeSec-${characterId}', singTimeSec); @@ -479,6 +500,15 @@ class BaseCharacter extends Bopper return false; } + /** + * Resets the hold data values to stop the animation from looping + */ + function stopHolding() + { + lastNoteDirection = null; + lastHoldFinish = null; + } + /** * Every time a note is hit, check if the note is from the same strumline. * If it is, then play the sing animation. @@ -487,17 +517,16 @@ class BaseCharacter extends Bopper { super.onNoteHit(event); - if (event.note.noteData.getMustHitNote() && characterType == BF) - { - // If the note is from the same strumline, play the sing animation. - this.playSingAnimation(event.note.noteData.getDirection(), false); - holdTimer = 0; - } - else if (!event.note.noteData.getMustHitNote() && characterType == DAD) + var noteDirection:NoteDirection = event.note.noteData.getDirection(); + + if ((event.note.noteData.getMustHitNote() && characterType == BF) || (!event.note.noteData.getMustHitNote() && characterType == DAD)) { // If the note is from the same strumline, play the sing animation. - this.playSingAnimation(event.note.noteData.getDirection(), false); + this.playSingAnimation(noteDirection, false); holdTimer = 0; + + lastNoteDirection = noteDirection; + if (event.note.noteData.isHoldNote) lastHoldFinish = event.note.strumTime + event.note.noteData.length; } } @@ -540,6 +569,8 @@ class BaseCharacter extends Bopper this.playAnimation(dropAnim, true, true); } } + + stopHolding(); } /** @@ -561,6 +592,8 @@ class BaseCharacter extends Bopper // trace('Playing ghost miss animation...'); this.playSingAnimation(event.dir, true); } + + stopHolding(); } public override function onDestroy(event:ScriptEvent):Void diff --git a/source/funkin/play/notes/Strumline.hx b/source/funkin/play/notes/Strumline.hx index 0e4b6645f1..05097f0992 100644 --- a/source/funkin/play/notes/Strumline.hx +++ b/source/funkin/play/notes/Strumline.hx @@ -445,7 +445,8 @@ class Strumline extends FlxSpriteGroup else if (conductorInUse.songPosition > holdNote.strumTime && holdNote.hitNote) { // Hold note is currently being hit, clip it off. - holdConfirm(holdNote.noteDirection); + /* holdConfirm(holdNote.noteDirection); */ + playConfirmHold(holdNote.noteDirection); holdNote.visible = true; holdNote.sustainLength = (holdNote.strumTime + holdNote.fullSustainLength) - conductorInUse.songPosition; @@ -643,6 +644,11 @@ class Strumline extends FlxSpriteGroup getByDirection(direction).playConfirm(); } + public function playConfirmHold(direction:NoteDirection):Void + { + getByDirection(direction).playConfirmHold(); + } + public function holdConfirm(direction:NoteDirection):Void { getByDirection(direction).holdConfirm(); diff --git a/source/funkin/play/notes/StrumlineNote.hx b/source/funkin/play/notes/StrumlineNote.hx index 40d893255e..c17d34d2a3 100644 --- a/source/funkin/play/notes/StrumlineNote.hx +++ b/source/funkin/play/notes/StrumlineNote.hx @@ -111,6 +111,15 @@ class StrumlineNote extends FlxSprite this.playAnimation('confirm', true); } + public function playConfirmHold():Void + { + if (getCurrentAnimationFrame() >= 3) + { + this.active = true; + this.playAnimation('confirm', true); + } + } + public function isConfirm():Bool { return getCurrentAnimation().startsWith('confirm'); @@ -138,6 +147,11 @@ class StrumlineNote extends FlxSprite } } + public function getCurrentAnimationFrame():Int + { + return this.animation.curAnim.curFrame; + } + /** * Returns the name of the animation that is currently playing. * If no animation is playing (usually this means the sprite is BROKEN!),