extend("fiskheroes:hero_basic");
loadTextures({
    "layer1": "tgheroes:fantastic4/torch/torch_layer1",
    "layer2": "tgheroes:fantastic4/torch/torch_layer2",
	"fire": "tgheroes:fantastic4/torch/torch_overlay"
});

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

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

    utils.addCameraShake(renderer, 0.015, 1.5, "fiskheroes:flight_boost_timer");
    utils.bindParticles(renderer, "fiskheroes:firestorm").setCondition(entity => entity.getData("fiskheroes:flying"));
	
	overlay = renderer.createEffect("fiskheroes:overlay");
    overlay.texture.set("fire");	
}

function initAnimations(renderer) {
    parent.initAnimations(renderer);
    utils.addFlightAnimation(renderer, "firestorm.FLIGHT", "fiskheroes:flight/propelled_hands.anim.json");
    utils.addHoverAnimation(renderer, "firestorm.HOVER", "fiskheroes:flight/idle/propelled_hands");
}

function render(entity, renderLayer, isFirstPersonArm) {
	if (renderLayer == "HELMET" || renderLayer == "CHESTPLATE" || renderLayer == "LEGGINGS" || renderLayer == "BOOTS") {
        overlay.opacity = entity.getInterpolatedData("tgheroes:dyn/flame_on");
        overlay.render();
	}
	if (renderLayer == "CHESTPLATE" && !entity.isDisplayStand() && entity.getInterpolatedData("tgheroes:dyn/flame_on")) {
        hand_flames.render(1);

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

