extend("fiskheroes:hero_basic");
loadTextures({
    "layer1": "tgheroes:electro/electro_layer1",
    "layer2": "tgheroes:electro/electro_layer2"
});

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

function initEffects(renderer) {
    utils.bindBeam(renderer, "fiskheroes:energy_projection", "tgheroes:electro_beam", "body", 0xe7dc12, [
        { "firstPerson": [0.0, 6.0, 0.0], "offset": [0.0, 5.0, -4.0], "size": [4.0, 4.0] }
    ]);

    utils.bindBeam(renderer, "fiskheroes:charged_beam", "tgheroes:electro_blast","body", 0xe7dc12, [
        { "firstPerson": [-4.5, 3.75, -8.0], "offset": [-0.5, 9.0, 0.0], "size": [3.0, 3.0],"anchor": "rightArm" },
        { "firstPerson": [4.5, 3.75, -8.0], "offset": [0.5, 9.0, 0.0], "size": [3.0, 3.0], "anchor": "leftArm" }

    ]);
	var trail = renderer.bindProperty("fiskheroes:trail");
    trail.setTrail(renderer.createResource("TRAIL", "fiskheroes:lightning_comics_yellow"));
    trail.setCondition(entity => entity.getData("fiskheroes:flying"));    
	
	utils.bindBeam(renderer, "fiskheroes:lightning_cast", "fiskheroes:lightning_cast", "rightArm", 0xe7dc12, [
        { "firstPerson": [-8.0, 4.5, -10.0], "offset": [-0.5, 9.0, 0.0], "size": [0.75, 0.75] }
    ]);
	
	var beam = renderer.createResource("BEAM_RENDERER", "tgheroes:electro_beam");
    lightning1 = utils.createLines(renderer, beam, 0xe7dc12, [
        {"start": [0, 0.7, 0], "end": [0.0, -1.0, 0.0], "size": [5.0, 4.0, 5.0]},
    ]);
    lightning1.setOffset(1.0, 8.0, 0.0).setScale(5.0);
    lightning1.anchor.set("rightArm");
    lightning1.mirror = true;
}
function initAnimations(renderer) {
    parent.initAnimations(renderer);
    renderer.removeCustomAnimation("basic.CHARGED_BEAM");
    
	addAnimationWithData(renderer, "basic.AIMING", "fiskheroes:dual_aiming", "fiskheroes:beam_charge");
    utils.addFlightAnimation(renderer, "lightning1.FLIGHT", "fiskheroes:flight/propelled_hands.anim.json");
    utils.addHoverAnimation(renderer, "lightning1.HOVER", "fiskheroes:flight/idle/propelled_hands");

}

function render(entity, renderLayer, isFirstPersonArm) {
    if (renderLayer == "CHESTPLATE") {
        lightning1.progress = entity.getInterpolatedData("fiskheroes:beam_charge") || entity.getInterpolatedData("fiskheroes:energy_projection");
        lightning1.render();
    }
}