From 964e2ad55bde0a12f4482cb98600c1d522f7faf9 Mon Sep 17 00:00:00 2001 From: NeeEoo Date: Mon, 14 Aug 2023 16:53:52 +0200 Subject: [PATCH] Rewrote Anim Suffix system --- .../backend/system/macros/ScriptsMacro.hx | 1 + source/funkin/backend/utils/NdllUtil.hx | 4 ++-- source/funkin/game/PlayState.hx | 4 ++-- source/funkin/game/Strum.hx | 7 ++++++- source/funkin/game/StrumLine.hx | 19 ++++++++++++++++++- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/source/funkin/backend/system/macros/ScriptsMacro.hx b/source/funkin/backend/system/macros/ScriptsMacro.hx index 45fd902f..53ddccd7 100644 --- a/source/funkin/backend/system/macros/ScriptsMacro.hx +++ b/source/funkin/backend/system/macros/ScriptsMacro.hx @@ -20,6 +20,7 @@ class ScriptsMacro { "flixel.addons.plugin", "flixel.addons.text", "flixel.addons.tile", "flixel.addons.transition", "flixel.addons.util", // OTHER LIBRARIES & STUFF + "funkin", "away3d", "flx3d", #if VIDEO_CUTSCENES "hxcodec.flixel", "hxcodec.openfl", "hxcodec.lime", #end // BASE HAXE diff --git a/source/funkin/backend/utils/NdllUtil.hx b/source/funkin/backend/utils/NdllUtil.hx index 0c75ca77..07885a60 100644 --- a/source/funkin/backend/utils/NdllUtil.hx +++ b/source/funkin/backend/utils/NdllUtil.hx @@ -31,7 +31,7 @@ class NdllUtil { * @param name Name of the function. * @param args Number of arguments of that function. */ - public static function getFunction(ndll:String, name:String, args:Int) { + public static function getFunction(ndll:String, name:String, args:Int):Dynamic { #if NDLLS_SUPPORTED return getFunctionFromPath(Paths.ndll('$ndll-$os'), name, args); #else @@ -47,7 +47,7 @@ class NdllUtil { * @param name Name of the function. * @param args Number of arguments of that function. */ - public static function getFunctionFromPath(ndll:String, name:String, args:Int) { + public static function getFunctionFromPath(ndll:String, name:String, args:Int):Dynamic { #if NDLLS_SUPPORTED if (!Assets.exists(ndll)) { Logs.trace('Couldn\'t find ndll at ${ndll}.', WARNING); diff --git a/source/funkin/game/PlayState.hx b/source/funkin/game/PlayState.hx index 67bcc3ed..4cdb4b35 100644 --- a/source/funkin/game/PlayState.hx +++ b/source/funkin/game/PlayState.hx @@ -1456,9 +1456,9 @@ class PlayState extends MusicBeatState var event:NoteHitEvent; if (strumLine != null && !strumLine.cpu) - event = scripts.event("onPlayerHit", EventManager.get(NoteHitEvent).recycle(false, !note.isSustainNote, !note.isSustainNote, note, strumLine.characters, true, note.noteType, note.animSuffix.getDefault(strumLine.altAnim ? "-alt" : ""), "game/score/", "", note.strumID, score, note.isSustainNote ? null : accuracy, 0.023, daRating, Options.splashesEnabled && !note.isSustainNote && daRating == "sick")); + event = scripts.event("onPlayerHit", EventManager.get(NoteHitEvent).recycle(false, !note.isSustainNote, !note.isSustainNote, note, strumLine.characters, true, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, score, note.isSustainNote ? null : accuracy, 0.023, daRating, Options.splashesEnabled && !note.isSustainNote && daRating == "sick")); else - event = scripts.event("onDadHit", EventManager.get(NoteHitEvent).recycle(false, false, false, note, strumLine.characters, false, note.noteType, note.animSuffix.getDefault(strumLine.altAnim ? "-alt" : ""), "game/score/", "", note.strumID, 0, null, 0, daRating, false)); + event = scripts.event("onDadHit", EventManager.get(NoteHitEvent).recycle(false, false, false, note, strumLine.characters, false, note.noteType, note.animSuffix.getDefault(note.strumID < strumLine.members.length ? strumLine.members[note.strumID].animSuffix : strumLine.animSuffix), "game/score/", "", note.strumID, 0, null, 0, daRating, false)); strumLine.onHit.dispatch(event); scripts.event("onNoteHit", event); diff --git a/source/funkin/game/Strum.hx b/source/funkin/game/Strum.hx index cd5a8caf..6226376b 100644 --- a/source/funkin/game/Strum.hx +++ b/source/funkin/game/Strum.hx @@ -6,7 +6,12 @@ import funkin.backend.system.Conductor; class Strum extends FlxSprite { public var extra:Map = []; - public var cpu = false; + /** + * Which animation suffix on characters that should be used when hitting notes. + */ + public var animSuffix:String = ""; + + public var cpu = false; // Unused public var lastHit:Float = -5000; public var scrollSpeed:Null = null; // custom scroll speed per strum diff --git a/source/funkin/game/StrumLine.hx b/source/funkin/game/StrumLine.hx index c44097db..7b951dd0 100644 --- a/source/funkin/game/StrumLine.hx +++ b/source/funkin/game/StrumLine.hx @@ -65,7 +65,11 @@ class StrumLine extends FlxTypedGroup { /** * Whenever alt animation is enabled on this strumline. */ - public var altAnim:Bool = false; + public var altAnim(get, set):Bool; + /** + * Which animation suffix on characters that should be used when hitting notes. + */ + public var animSuffix(default, set):String = ""; /** * TODO: Write documention about this being a variable that can help when making multi key */ @@ -353,5 +357,18 @@ class StrumLine extends FlxTypedGroup { s.cpu = b; return cpu = b; } + private inline function set_animSuffix(str:String):String { + for(s in members) + if (s != null) + s.animSuffix = str; + return animSuffix = str; + } + private inline function set_altAnim(b:Bool):Bool { + animSuffix = b ? "-alt" : ""; + return b; + } + private inline function get_altAnim():Bool { + return animSuffix == "-alt"; + } #end } \ No newline at end of file