extend("fiskheroes:hero_basic");
loadTextures({
    "eyes": "fiskheroes:eyes_white",
    "layer1": "pkg:ghost_rider_layer1",
    "layer2": "pkg:null",
    "lights": "pkg:ghost_rider_lights"
});

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

var overlay
var eyes;
var hand_flames;
var head_flames;
var spell;

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

    parent.init(renderer);
}

function initEffects(renderer) {
    eyes = renderer.createEffect("fiskheroes:overlay");
    eyes.texture.set("eyes");

    var chain = utils.bindCloud(renderer, "fiskheroes:telekinesis_chain", "fiskheroes:shadow_smoke");
    chain.anchor.set("rightArm");
    chain.setOffset(-0.5, 10.0, 0.0);
    chain.setFirstPerson(-4.75, 4.0, -8.5);

    utils.bindBeam(renderer, "fiskheroes:charged_beam", "pkg:penance_stare", "head", 0x730D12, [
        { "firstPerson": [0, 0, 0], "offset": [0, 0.25, 1.0], "size": [2.0, 2.0] }
    ]);

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

    var magic = renderer.bindProperty("fiskheroes:spellcasting");
    magic.colorWhip.set(0x3A393B);
}

function render(entity, renderLayer, isFirstPersonArm) {
    if (renderLayer == "CHESTPLATE" && !entity.isDisplayStand() && entity.isWearingFullSuit()) {

        hand_flames.render(1);

        if (!isFirstPersonArm) {
            eyes.render();
            head_flames.render(1 - entity.getInterpolatedData("fiskheroes:mask_open_timer2"));
        }
    }
}
