From ae5fc555a815cf5c8d9081bc84c477e2e3a91195 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=8D=9A=7ENex?= <87421482+NexIsDumb@users.noreply.github.com> Date: Sun, 8 Sep 2024 16:30:27 +0200 Subject: [PATCH] "forced" anim attribute finally working big changes here maybe --- assets/data/stages/philly.hx | 1 + source/funkin/backend/FunkinSprite.hx | 11 ++++++++--- .../funkin/backend/scripting/events/NoteHitEvent.hx | 4 ++-- .../funkin/backend/scripting/events/NoteMissEvent.hx | 4 ++-- .../funkin/backend/scripting/events/PlayAnimEvent.hx | 4 ++-- source/funkin/game/Character.hx | 4 ++-- source/funkin/game/cutscenes/dialogue/DialogueBox.hx | 2 +- .../game/cutscenes/dialogue/DialogueCharacter.hx | 2 +- 8 files changed, 19 insertions(+), 13 deletions(-) diff --git a/assets/data/stages/philly.hx b/assets/data/stages/philly.hx index 989b29b5..6b120b51 100644 --- a/assets/data/stages/philly.hx +++ b/assets/data/stages/philly.hx @@ -1,3 +1,4 @@ +// import funkin.game.PlayState; // phillyTrain is automatically added by Stage.hx diff --git a/source/funkin/backend/FunkinSprite.hx b/source/funkin/backend/FunkinSprite.hx index 0d59650d..23304ce7 100644 --- a/source/funkin/backend/FunkinSprite.hx +++ b/source/funkin/backend/FunkinSprite.hx @@ -101,7 +101,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I if (!debugMode && isAnimFinished()) { var name = getAnimName() + '-loop'; if (hasAnimation(name)) - playAnim(name, false, lastAnimContext); + playAnim(name, null, lastAnimContext); } } @@ -133,7 +133,7 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I // TODO: find a solution without countedBeat var anim = beatAnims[FlxMath.wrap(countedBeat++, 0, beatAnims.length - 1)]; if (anim.name != null && anim.name != "null" && anim.name != "none") - playAnim(anim.name, anim.forced); + playAnim(anim.name); } } @@ -292,11 +292,16 @@ class FunkinSprite extends FlxSkewedSprite implements IBeatReceiver implements I #if REGION public var lastAnimContext:PlayAnimContext = DANCE; - public function playAnim(AnimName:String, Force:Bool = false, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0):Void + public function playAnim(AnimName:String, ?Force:Null, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0):Void { if (AnimName == null) return; + if (Force == null) { + var anim = animDatas.get(AnimName); + Force = anim != null && anim.forced; + } + if (animateAtlas != null) { @:privateAccess diff --git a/source/funkin/backend/scripting/events/NoteHitEvent.hx b/source/funkin/backend/scripting/events/NoteHitEvent.hx index e3c8bbc0..7a20fed0 100644 --- a/source/funkin/backend/scripting/events/NoteHitEvent.hx +++ b/source/funkin/backend/scripting/events/NoteHitEvent.hx @@ -100,9 +100,9 @@ final class NoteHitEvent extends CancellableEvent { */ public var ratingAntialiasing:Bool = true; /** - * Whenever the animation should be forced to play. + * Whenever the animation should be forced to play (if it's null it will be forced based on the sprite's data xml, if it has one). */ - public var forceAnim:Bool = true; + public var forceAnim:Null = true; /** * Prevents the default sing animation from being played. diff --git a/source/funkin/backend/scripting/events/NoteMissEvent.hx b/source/funkin/backend/scripting/events/NoteMissEvent.hx index 1b7d0901..d2aa971d 100644 --- a/source/funkin/backend/scripting/events/NoteMissEvent.hx +++ b/source/funkin/backend/scripting/events/NoteMissEvent.hx @@ -29,9 +29,9 @@ final class NoteMissEvent extends CancellableEvent { public var gfSadAnim:String; public var forceGfAnim:Bool; /** - * Whenever the animation should be forced to play. + * Whenever the animation should be forced to play (if it's null it will be forced based on the sprite's data xml, if it has one). */ - public var forceAnim:Bool; + public var forceAnim:Null; /** * Suffix of the animation. "miss" for miss notes, "-alt" for alt notes, "" for normal ones. */ diff --git a/source/funkin/backend/scripting/events/PlayAnimEvent.hx b/source/funkin/backend/scripting/events/PlayAnimEvent.hx index ca88c408..34dd998b 100644 --- a/source/funkin/backend/scripting/events/PlayAnimEvent.hx +++ b/source/funkin/backend/scripting/events/PlayAnimEvent.hx @@ -7,9 +7,9 @@ final class PlayAnimEvent extends CancellableEvent { public var animName:String; /** - Whenever the animation will be forced or not. + Whenever the animation will be forced or not (if it's null it will be forced based on the sprite's data xml, if it has one). **/ - public var force:Bool; + public var force:Null; /** Whenever the animation will play in reverse or not diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index d35e930d..da2c6282 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -207,14 +207,14 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset } public var singAnims = ["singLEFT", "singDOWN", "singUP", "singRIGHT"]; - public function playSingAnim(direction:Int, suffix:String = "", Context:PlayAnimContext = SING, Force:Bool = true, Reversed:Bool = false, Frame:Int = 0) { + public function playSingAnim(direction:Int, suffix:String = "", Context:PlayAnimContext = SING, ?Force:Bool = true, Reversed:Bool = false, Frame:Int = 0) { var event = EventManager.get(DirectionAnimEvent).recycle(singAnims[direction % singAnims.length] + suffix, direction, suffix, Context, Reversed, Frame, Force); script.call("onPlaySingAnim", [event]); if (!event.cancelled) playAnim(event.animName, event.force, event.context, event.reversed, event.frame); } - public override function playAnim(AnimName:String, Force:Bool = false, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0) { + public override function playAnim(AnimName:String, ?Force:Bool, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0) { var event = EventManager.get(PlayAnimEvent).recycle(AnimName, Force, Reversed, Frame, Context); script.call("onPlayAnim", [event]); if (event.cancelled) return; diff --git a/source/funkin/game/cutscenes/dialogue/DialogueBox.hx b/source/funkin/game/cutscenes/dialogue/DialogueBox.hx index caf45949..b4bb958b 100644 --- a/source/funkin/game/cutscenes/dialogue/DialogueBox.hx +++ b/source/funkin/game/cutscenes/dialogue/DialogueBox.hx @@ -97,7 +97,7 @@ class DialogueBox extends FunkinSprite { dialogueBoxScript.call("postCreate"); } - public override function playAnim(AnimName:String, Force:Bool = false, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0) { + public override function playAnim(AnimName:String, ?Force:Bool, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0) { var event = EventManager.get(PlayAnimEvent).recycle(AnimName, Force, Reversed, Frame, Context); dialogueBoxScript.call("onPlayAnim", [event]); if(event.cancelled) return; diff --git a/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx b/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx index 97701e1f..03139a4c 100644 --- a/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx +++ b/source/funkin/game/cutscenes/dialogue/DialogueCharacter.hx @@ -61,7 +61,7 @@ class DialogueCharacter extends FunkinSprite { dialogueCharScript.call("postCreate"); } - public override function playAnim(AnimName:String, Force:Bool = false, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0) { + public override function playAnim(AnimName:String, ?Force:Bool, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0) { var event = EventManager.get(PlayAnimEvent).recycle(AnimName, Force, Reversed, Frame, Context); dialogueCharScript.call("playAnim", [event]); if(event.cancelled) return;