extend("fiskheroes:hero_basic");
loadTextures({
    "layer1": "diminpack:firestorm_layer1",
    "layer2": "fiskheroes:firestorm_jax_layer2",
    "lights": "diminpack:firestorm_lights",
    "eyes": "fiskheroes:eyes_white",
    "cape": "fiskheroes:the_monitor_cape"
});
var capes = implement("fiskheroes:external/capes");
var cape;


var utils = implement("fiskheroes:external/utils");
var flames = implement("fiskheroes:external/flames");
var speedster = implement("fiskheroes:external/speedster_utils");
var eyes;
var hand_flames;
var head_flames;

function init(renderer) {
    parent.init(renderer);
    renderer.setLights((entity, renderLayer) => renderLayer == "CHESTPLATE" ? "lights" : null);

    renderer.showModel("CHESTPLATE", "head", "body", "rightArm", "leftArm");
}

function initEffects(renderer) {
    speedster.init(renderer, "diminpack:firestorm");
    var physics = renderer.createResource("CAPE_PHYSICS", null);
    physics.maxFlare = 0.2;
    cape = capes.createDefault(renderer, 21, "fiskheroes:cape_default.mesh.json", physics);
    cape.effect.texture.set("cape");
    
    eyes = renderer.createEffect("fiskheroes:overlay");
    eyes.texture.set("eyes");

    var fire = renderer.createResource("ICON", "fiskheroes:fire_layer_%s");
    hand_flames = flames.createHands(renderer, fire, true);
    head_flames = flames.createHead(renderer, fire);

    utils.addCameraShake(renderer, 0.015, 1.5, "fiskheroes:flight_boost_timer");
    utils.bindParticles(renderer, "fiskheroes:firestorm").setCondition(entity => entity.getData("fiskheroes:flying"));
    utils.bindCloud(renderer, "fiskheroes:teleportation", "diminpack:breach");
}

function initAnimations(renderer) {
    parent.initAnimations(renderer);
    utils.addFlightAnimation(renderer, "firestorm.FLIGHT", "fiskheroes:flight/propelled_hands.anim.json");
    utils.addHoverAnimation(renderer, "firestorm.HOVER", "fiskheroes:flight/idle/propelled_hands");
}

function render(entity, renderLayer, isFirstPersonArm) {
    if (renderLayer == "CHESTPLATE" && entity.isWearingFullSuit()) {
        if (!isFirstPersonArm && (!entity.is("DISPLAY") || entity.as("DISPLAY").isSkinShown())) {
            eyes.render();
        }
        if (!isFirstPersonArm && renderLayer == "CHESTPLATE") {
            cape.render(entity);
        }
        if (!entity.is("DISPLAY") || !entity.as("DISPLAY").isStatic()) {
            hand_flames.render(1 - entity.getInterpolatedData("fiskheroes:mask_open_timer2"));
            if (!isFirstPersonArm) {
                head_flames.render(1 - entity.getInterpolatedData("fiskheroes:mask_open_timer2"));
            }
        }
    }
}

