extend("fiskheroes:hero_basic");
loadTextures({
    "layer1": "tgheroes:surfer/surfer_layer1",
    "layer2": "tgheroes:surfer/surfer_layer2",
    "surf": "tgheroes:surfer/silver"
});

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

function initEffects(renderer) {	
	var model_surf = renderer.createResource("MODEL", "tgheroes:surfboard");
    model_surf.texture.set("surf");
    surf = renderer.createEffect("fiskheroes:model").setModel(model_surf);
    surf.anchor.set("body");
    surf.setScale(1);
	
    utils.bindBeam(renderer, "fiskheroes:charged_beam", "tgheroes:not_spin_beam", "body", 0xe5e5e5, [
        { "firstPerson": [-3.75, 3.0, -8.0], "offset": [0.5, 12.0, 0.0], "size": [3.0, 3.0], "anchor": "leftArm" },
        { "firstPerson": [3.75, 3.0, -8.0], "offset": [-0.5, 12.0, 0.0], "size": [3.0, 3.0], "anchor": "rightArm" }
    ]);
	
    glow = renderer.createEffect("fiskheroes:glowerlay");
    glow.color.set(0xffffff);
	utils.bindParticles(renderer, "fiskheroes:harbinger_glow");

	utils.bindCloud(renderer, "fiskheroes:telekinesis", "tgheroes:telekinesis_kang");
}
function initAnimations(renderer) {
    parent.initAnimations(renderer);
    renderer.removeCustomAnimation("basic.AIMING");
    renderer.removeCustomAnimation("basic.CHARGED_BEAM");

    addAnimation(renderer, "basic.AIMING", "fiskheroes:dual_aiming").setData((entity, data) => {
        var charge = entity.getInterpolatedData("fiskheroes:beam_charge");
        data.load(Math.max(entity.getInterpolatedData("fiskheroes:aiming_timer"), entity.getData("fiskheroes:beam_charging") ? Math.min(charge * 3, 1) : Math.max(charge * 5 - 4, 0)));
    });

   utils.addFlightAnimation(renderer, "surf.FLIGHT", "tgheroes:surfing");
    utils.addHoverAnimation(renderer, "surf.HOVER", "tgheroes:surfing");
}

function render(entity, renderLayer, isFirstPersonArm) {
    if (renderLayer == "CHESTPLATE") {
        if (entity.getData("tgheroes:dyn/surf_board") > 0.5) {
            var glider_anchor = surf.anchor.set("body");
            var glider_offSet = surf.setOffset(3.0, 24.0, -25.0);      			
            surf.anchor = glider_anchor, glider_offSet;
            surf.render();
        }
}
    glow.opacity = entity.getInterpolatedData("fiskheroes:teleport_timer");
    glow.render();
}