better default forced
FINALLY i had the best idea to fix this shit
This commit is contained in:
@@ -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);
|
||||
playAnim(anim.name, anim.forced);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package funkin.backend.utils;
|
||||
|
||||
import funkin.backend.FunkinSprite;
|
||||
import funkin.game.Character;
|
||||
import funkin.backend.system.ErrorCode;
|
||||
import funkin.backend.FunkinSprite.XMLAnimType;
|
||||
import flixel.util.FlxColor;
|
||||
@@ -170,8 +171,7 @@ class XMLUtil {
|
||||
animType: spr.spriteAnimType,
|
||||
x: 0,
|
||||
y: 0,
|
||||
indices: [for(i in 0...spr.frames.frames.length) i],
|
||||
forced: (node.has.forced && node.att.forced == "true") || (!node.has.forced && spr.spriteAnimType == BEAT)
|
||||
indices: [for(i in 0...spr.frames.frames.length) i]
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -188,7 +188,7 @@ class XMLUtil {
|
||||
return loadSpriteFromXML(Type.createInstance(cl, args), node, parentFolder, defaultAnimType);
|
||||
}
|
||||
|
||||
public static function extractAnimFromXML(anim:Access, animType:XMLAnimType = NONE, loop:Bool = false):AnimData {
|
||||
public static function extractAnimFromXML(anim:Access, animType:XMLAnimType = NONE, loop:Bool = false, ?sprite:FunkinSprite):AnimData {
|
||||
var animData:AnimData = {
|
||||
name: null,
|
||||
anim: null,
|
||||
@@ -197,8 +197,7 @@ class XMLUtil {
|
||||
animType: animType,
|
||||
x: 0,
|
||||
y: 0,
|
||||
indices: [],
|
||||
forced: false,
|
||||
indices: []
|
||||
};
|
||||
|
||||
if (anim.has.name) animData.name = anim.att.name;
|
||||
@@ -254,24 +253,28 @@ class XMLUtil {
|
||||
|
||||
if (sprite is FunkinSprite) {
|
||||
var xmlSpr = cast(sprite, FunkinSprite);
|
||||
var name = animData.name;
|
||||
switch(animData.animType) {
|
||||
case BEAT:
|
||||
xmlSpr.beatAnims.push({
|
||||
name: animData.name,
|
||||
forced: animData.forced.getDefault(false)
|
||||
name: name,
|
||||
forced: animData.forced.getDefault(defaultForcedCheck(name, xmlSpr))
|
||||
});
|
||||
case LOOP:
|
||||
xmlSpr.animation.play(animData.name, animData.forced.getDefault(false));
|
||||
xmlSpr.animation.play(name, animData.forced.getDefault(defaultForcedCheck(name, xmlSpr)));
|
||||
default:
|
||||
// nothing
|
||||
}
|
||||
xmlSpr.animDatas.set(animData.name, animData);
|
||||
xmlSpr.animDatas.set(name, animData);
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
return MISSING_PROPERTY;
|
||||
}
|
||||
|
||||
public static inline function defaultForcedCheck(animName:String, sprite:FunkinSprite):Bool
|
||||
return sprite is Character && (animName.startsWith("idle") || animName.startsWith("danceLeft") || animName.startsWith("danceRight")) ? false : sprite.spriteAnimType == BEAT;
|
||||
|
||||
public static inline function fixXMLText(text:String) {
|
||||
var v:String;
|
||||
return [for(l in text.split("\n")) if ((v = l.trim()) != "") v].join("\n");
|
||||
|
||||
@@ -283,6 +283,7 @@ class Character extends FunkinSprite implements IBeatReceiver implements IOffset
|
||||
public inline function buildCharacter(xml:Access) {
|
||||
this.xml = xml; // Modders wassup :D
|
||||
sprite = curCharacter;
|
||||
spriteAnimType = BEAT;
|
||||
|
||||
if (xml.x.exists("isPlayer")) playerOffsets = (xml.x.get("isPlayer") == "true");
|
||||
if (xml.x.exists("x")) globalOffset.x = Std.parseFloat(xml.x.get("x"));
|
||||
|
||||
Reference in New Issue
Block a user