extend("fiskheroes:hero_basic");
loadTextures({
    "layer1": "pkg:sabbac_layer1",
    "layer2": "pkg:sabbac_layer2",
    "lights": "pkg:sabbac_lights",
});

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

var overlay;

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

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

function initEffects(renderer) {
    utils.addCameraShake(renderer, 0.015, 1.5, "fiskheroes:flight_boost_timer");

    overlay = renderer.createEffect("fiskheroes:overlay");
    overlay.texture.set(null, "head");

    utils.bindBeam(renderer, "fiskheroes:charged_beam", "pkg:low_beam", "body", 0xDE391B, [
        { "firstPerson": [0.0, 7.0, 0.0], "offset": [0.0, 3.5, -2.0], "size": [7.0, 6.0] }
    ]).setParticles(renderer.createResource("PARTICLE_EMITTER", "fiskheroes:impact_charged_beam"));

}

function initAnimations(renderer) {
    parent.initAnimations(renderer);
    utils.addFlightAnimationWithLanding(renderer, "teth_adam.FLIGHT", "fiskheroes:flight/iron_man.anim.json");
    utils.addHoverAnimation(renderer, "teth_adam.HOVER", "fiskheroes:flight/idle/iron_man");
    addAnimationWithData(renderer, "iron_man.LAND", "fiskheroes:superhero_landing", "fiskheroes:dyn/superhero_landing_timer")
        .priority = -8;

    addAnimationWithData(renderer, "teth_adam.ROLL", "fiskheroes:flight/barrel_roll", "fiskheroes:barrel_roll_timer")
        .priority = 10;
}


function render(entity, renderLayer, isFirstPersonArm) {
    if (renderLayer == "CHESTPLATE" && !entity.isDisplayStand() && entity.isWearingFullSuit()) {
        //hand_flames.render(1);
    }
    overlay.opacity = entity.getInterpolatedData("fiskheroes:beam_charge");
    overlay.render();
}
