extend("fiskheroes:hero_basic");
loadTextures({
    "layer1": "soulhp:magneto_layer1",
    "layer2": "soulhp:magneto_layer2",
    "cape": "soulhp:magneto_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");

    utils.bindCloud(renderer, "fiskheroes:teleportation", "soulhp:magneto");
    utils.bindCloud(renderer, "fiskheroes:telekinesis", "soulhp:telekinesis_magneto");

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");

var forcefield = renderer.bindProperty("fiskheroes:forcefield");
forcefield.color.set(0xA36DB2);
forcefield.setShape(36, 18).setOffset(0.0, 6.0, 0.0).setScale(1.25);
forcefield.setCondition(entity => {
    forcefield.opacity = entity.getInterpolatedData("fiskheroes:shield_blocking_timer") * 0.15;
    return true;
});

}

function initAnimations(renderer) {
    parent.initAnimations(renderer);
    addAnimationWithData(renderer, "basic.BLOCKING", "fiskheroes:dual_aiming", "fiskheroes:shield_blocking_timer");
    addAnimation(renderer, "iron_man.FLIGHT", "soulhp:blackadamflight")
        .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);
    }
}