extend("fiskheroes:hero_basic");
loadTextures({
    "layer1": "pkg:vibe_suit",
    "layer2": "pkg:vibe_layer2",
    "lights": "pkg:vibe_mask",
    "mask2": "pkg:vibe_mask2",
    "mask": "pkg:vibe_mask.tx.json"
});

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

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

    // renderer.setLights((entity, renderLayer) => renderLayer == "" ? "" : "mask");

    renderer.setLights((entity, renderLayer) => {
        if (!entity.isDisplayStand() && !entity.getData("fiskheroes:mask_open_timer2") > 0) {
            var timer = entity.getInterpolatedData("fiskheroes:mask_open_timer2");
            return timer == 0 ? "mask2" : timer < 1 ? "lights" : "mask2";
        }
        if (renderLayer == "HELMET" && entity.getData("fiskheroes:mask_open_timer2") > 0) {
            return "mask";
        }
        return "lights";
    });

    renderer.setTexture((entity, renderLayer) => {
        if (renderLayer == "HELMET" && entity.getData("fiskheroes:mask_open_timer2") > 0) {
            return "layer1";
        }
        return renderLayer == "LEGGINGS" ? "mask2" : "layer1";
    });

    renderer.showModel("CHESTPLATE", "head", "headwear", "body", "rightArm", "leftArm", "rightLeg", "leftLeg");
    renderer.fixHatLayer("HELMET", "CHESTPLATE");
}


function initEffects(renderer) {

    utils.bindCloud(renderer, "fiskheroes:teleportation", "fiskheroes:breach");

    // Aim
    utils.bindBeam(renderer, "fiskheroes:repulsor_blast", "pkg:bifrost", "rightArm", 0x2564F0, [
        { "firstPerson": [-4.5, 3.75, -7.0], "offset": [-0.5, 9.0, 0.0], "size": [1.5, 1.5] }
    ]);

    // Vibrational Blasts
    utils.bindBeam(renderer, "fiskheroes:charged_beam", "pkg:bifrost", "rightArm", 0x2564F0, [
        { "firstPerson": [-4.5, 3.75, -8.0], "offset": [-0.5, 9.0, 0.0], "size": [3.0, 3.0] }
    ]).setParticles(renderer.createResource("PARTICLE_EMITTER", "fiskheroes:impact_antimatter"));
}

function initAnimations(renderer) {
    parent.initAnimations(renderer);
    renderer.removeCustomAnimation("basic.BLOCKING");
    renderer.removeCustomAnimation("basic.CHARGED_BEAM");

    addAnimationWithData(renderer, "antimonitor.ANTIBLAST", "fiskheroes:aiming", "fiskheroes:beam_charge");
}
