easier to softcode healthicons

This commit is contained in:
Frakits
2024-08-03 14:28:21 +03:00
parent e7ddb10c64
commit 21bf0c0a37
+13 -1
View File
@@ -24,6 +24,11 @@ class HealthIcon extends FlxSprite
*/
public var healthSteps:Map<Int, Int> = null;
/**
* current animation state
*/
public var curAnimState:Int = -1;
/**
* Helper for HScript who can't make maps
* @param steps Something like this: `[[0, 1], [20, 0]]`
@@ -91,7 +96,14 @@ class HealthIcon extends FlxSprite
i = icon;
}
}
if (i >= 0) animation.curAnim.curFrame = i;
if (i >= 0 && curAnimState != i) {
var event = EventManager.get(funkin.backend.scripting.events.AmountEvent).recycle(i);
funkin.backend.scripting.GlobalScript.event("onHealthIconAnimChange", event);
if (!event.cancelled)
animation.curAnim.curFrame = event.amount;
curAnimState = event.amount;
}
}
}
}