extend("fiskheroes:hero_basic");
loadTextures({
    "layer1": "soulhp:superman_redson_layer1",
    "layer2": "soulhp:superman_redson_layer2",
    "cape": "soulhp:superman_redson_cape",
});

var utils = implement("fiskheroes:external/utils");
var capes = implement("fiskheroes:external/capes");

var cape;
var overlay;

function initEffects(renderer) {
    var physics = renderer.createResource("CAPE_PHYSICS", null);
    physics.weight = 0.9;
    physics.maxFlare = 0.33;
    cape = capes.createDefault(renderer, 24, "fiskheroes:cape_default.mesh.json", physics);
    cape.effect.texture.set("cape");

renderer.setItemIcons("%s_0", "%s_1", "%s_2", "%s_3");
renderer.showModel("HELMET", "head", "headwear");
renderer.showModel("CHESTPLATE", "body", "rightArm", "leftArm");
renderer.showModel("LEGGINGS", "rightLeg", "leftLeg");
renderer.showModel("BOOTS", "rightLeg", "leftLeg");

utils.bindParticles(renderer, "fiskheroes:impact_antimatter").setCondition(entity => entity.getData("fiskheroes:flight_boost_timer") == 0.5);
//utils.bindParticles(renderer, "soulhp:windtrail").setCondition(entity => entity.getData("fiskheroes:flight_boost_timer") == 1);

}

function initAnimations(renderer) {
    parent.initAnimations(renderer);
    addAnimation(renderer, "iron_man.FLIGHT", "soulhp:supermanflight")
        .setData((entity, data) => {
            data.load(0, entity.getInterpolatedData("fiskheroes:flight_timer") * (1 - entity.getInterpolatedData("fiskheroes:dyn/superhero_landing_timer")));
            data.load(1, entity.getInterpolatedData("fiskheroes:flight_boost_timer"));
        })
        .priority = -10;
    
    addAnimationWithData(renderer, "iron_man.LAND", "soulhp:supermanland", "fiskheroes:dyn/superhero_landing_timer")
        .priority = -8;
    
    renderer.reprioritizeDefaultAnimation("PUNCH", -9);
    renderer.reprioritizeDefaultAnimation("AIM_BOW", -9);
}

function render(entity, renderLayer, isFirstPersonArm) {
    if (!isFirstPersonArm && renderLayer == "CHESTPLATE") {
        cape.render(entity);
    }
}