From f4d0958982453fa6d441daeb9509cccbe7c8ad5d Mon Sep 17 00:00:00 2001 From: lunarcleint <88809950+lunarcleint@users.noreply.github.com> Date: Fri, 12 Apr 2024 21:47:39 -0700 Subject: [PATCH] add back character extra --- source/funkin/game/Character.hx | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/source/funkin/game/Character.hx b/source/funkin/game/Character.hx index ad11614a..6c36a26e 100644 --- a/source/funkin/game/Character.hx +++ b/source/funkin/game/Character.hx @@ -280,12 +280,25 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset for (anim in xml.nodes.anim) XMLUtil.addXMLAnimation(this, anim); + for (attribute in xml.x.attributes()) + if (!characterProperties.contains(attribute)) + extra[attribute] = xml.x.get(attribute); + fixChar(true, !hasInterval); dance(); } + public static var characterProperties:Array = [ + "x", "y", "sprite", "scale", "antialiasing", + "flipX", "camx", "camy", "isPlayer", "icon", + "color", "gameOverChar", "holdTime" + ]; + public static var characterAnimProperties:Array = [ + "name", "anim", "x", "y", "fps", "loop", "indices" + ]; public inline function buildXML(?animsOrder:Array):Xml { var xml:Xml = Xml.createElement("character"); + xml.attributeOrder = characterProperties.copy(); xml.set("x", Std.string(FlxMath.roundDecimal(globalOffset.x, 2))); xml.set("y", Std.string(FlxMath.roundDecimal(globalOffset.y, 2))); @@ -307,8 +320,6 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset xml.set("isPlayer", playerOffsets == true ? "true" : "false"); - xml.attributeOrder = ["x", "y", "sprite", "scale", "antialiasing", "flipX", "camx", "camy", "isPlayer", "icon", "color", "gameOverChar", "holdTime"]; - var anims:Array = []; if (animsOrder != null) { for (name in animsOrder) @@ -318,6 +329,8 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset for (anim in anims) { var animXml:Xml = Xml.createElement('anim'); + animXml.attributeOrder = characterAnimProperties; + animXml.set("name", anim.name); animXml.set("anim", anim.anim); animXml.set("loop", Std.string(anim.loop)); @@ -326,16 +339,20 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset var offset:FlxPoint = getAnimOffset(anim.name); animXml.set("x", Std.string(FlxMath.roundDecimal(offset.x, 2))); animXml.set("y", Std.string(FlxMath.roundDecimal(offset.y, 2))); + offset.putWeak(); if (anim.indices.length > 0) animXml.set("indices", anim.indices.join(",")); - animXml.attributeOrder = ["name", "anim", "x", "y", "fps", "loop", "indices"]; xml.addChild(animXml); - - offset.putWeak(); } + for (name => val in extra) + if (!xml.attributeOrder.contains(name)) { + xml.attributeOrder.push(name); + xml.set(name, Std.string(val)); + } + this.xml = new Access(xml); return xml; }