From 930510a3dea0170e0411adf35b240fafc4d5008d Mon Sep 17 00:00:00 2001 From: MaybeMaru <97055307+MaybeMaru@users.noreply.github.com> Date: Mon, 27 May 2024 01:31:02 +0200 Subject: [PATCH] move some strum logic to ``StrumLineGroup`` --- source/funkin/objects/NotesGroup.hx | 47 ++----------------- source/funkin/objects/note/StrumLineGroup.hx | 42 ++++++++++++++++- source/funkin/substates/CharSelectSubstate.hx | 11 +++-- 3 files changed, 52 insertions(+), 48 deletions(-) diff --git a/source/funkin/objects/NotesGroup.hx b/source/funkin/objects/NotesGroup.hx index 205d0d0c..a1124b6a 100644 --- a/source/funkin/objects/NotesGroup.hx +++ b/source/funkin/objects/NotesGroup.hx @@ -597,52 +597,13 @@ class NotesGroup extends Group inline function checkStrumAnims():Void { if (!inBotplay) { - checkStrums(playerStrums.members); - checkOverSinging(boyfriend, playerStrums); + playerStrums.checkStrums(); + playerStrums.checkCharSinging(boyfriend); } if (!dadBotplay) { - checkStrums(opponentStrums.members); - checkOverSinging(dad, opponentStrums); - } - } - - function checkStrums(array:Array):Void - { - array.fastForEach((strum, i) -> { - if (strum.animation.curAnim != null) // Lil null check - { - if (strum.getControl(JUST_PRESSED)) if (!strum.animation.curAnim.name.startsWith('confirm')) - strum.playStrumAnim('pressed'); - - if (!strum.getControl()) - strum.playStrumAnim('static'); - } - }); - } - - function checkOverSinging(char:Character, strums:StrumLineGroup):Void - { - if (char == null) return; - if (char.animation.curAnim == null) return; - - var name:String = char.animation.curAnim.name; - var overSinging:Bool = - (char.holdTimer > (Conductor.stepCrochetMills * Conductor.STEPS_PER_BEAT) - && name.startsWith('sing') - && !name.endsWith('miss')); - - if (overSinging) { - var isHolding:Bool = false; - strums.members.fastForEach((strum, i) -> { - if (strum.animation.curAnim.name.startsWith('confirm')) { - isHolding = true; - break; - } - }); - - if (!isHolding) - char.restartDance(); + opponentStrums.checkStrums(); + opponentStrums.checkCharSinging(dad); } } diff --git a/source/funkin/objects/note/StrumLineGroup.hx b/source/funkin/objects/note/StrumLineGroup.hx index 462ead86..4d8caeab 100644 --- a/source/funkin/objects/note/StrumLineGroup.hx +++ b/source/funkin/objects/note/StrumLineGroup.hx @@ -1,6 +1,7 @@ package funkin.objects.note; -class StrumLineGroup extends TypedSpriteGroup { +class StrumLineGroup extends TypedSpriteGroup +{ public var initPos:Array = []; public static var strumLineY:Float = 50; @@ -47,6 +48,45 @@ class StrumLineGroup extends TypedSpriteGroup { }); } + public function checkStrums():Void { + members.fastForEach((strum, i) -> { + if (strum.animation.curAnim != null) // Lil null check + { + if (strum.getControl(JUST_PRESSED)) if (!strum.animation.curAnim.name.startsWith('confirm')) + strum.playStrumAnim('pressed'); + + if (!strum.getControl()) + strum.playStrumAnim('static'); + } + }); + } + + public function checkCharSinging(char:Character):Void { + if (char == null) return; + if (char.animation.curAnim == null) return; + + if (char.holdTimer > (Conductor.stepCrochetMills * Conductor.STEPS_PER_BEAT)) + { + final name:String = char.animation.curAnim.name; + + // Character is over-singing + if (name.startsWith('sing')) if (!name.endsWith('miss')) + { + var isHolding:Bool = false; + members.fastForEach((strum, i) -> + { + if (strum.animation.curAnim != null) if (strum.animation.curAnim.name.startsWith('confirm')) { + isHolding = true; + break; + } + }); + + if (!isHolding) + char.restartDance(); + } + } + } + public function addStrum(noteData:Int = 0) { if (members.length >= 9) return null; // STOP final strumX:Float = startX + seperateWidth * noteData; diff --git a/source/funkin/substates/CharSelectSubstate.hx b/source/funkin/substates/CharSelectSubstate.hx index 93eb45c8..9a752234 100644 --- a/source/funkin/substates/CharSelectSubstate.hx +++ b/source/funkin/substates/CharSelectSubstate.hx @@ -71,10 +71,13 @@ class CharSelectSubstate extends MusicBeatSubstate override public function update(elapsed:Float):Void { super.update(elapsed); - if (getKey('UI_UP', JUST_PRESSED)) changeSelection(-1); - if (getKey('UI_DOWN', JUST_PRESSED)) changeSelection(1); - if (getKey('UI_LEFT', JUST_PRESSED)) changeFolder(-1); - if (getKey('UI_RIGHT', JUST_PRESSED)) changeFolder(1); + + if (getKey('UI_UP', JUST_PRESSED)) changeSelection(-1); + else if (getKey('UI_DOWN', JUST_PRESSED)) changeSelection(1); + + if (getKey('UI_LEFT', JUST_PRESSED)) changeFolder(-1); + else if (getKey('UI_RIGHT', JUST_PRESSED)) changeFolder(1); + if (getKey('ACCEPT', JUST_PRESSED)) selectChar(); else if (getKey('BACK', JUST_PRESSED)) close(); }