extend("fiskheroes:hero_basic");
loadTextures({
    "suit": "tgheroes:rider/spirit.tx.json",
	"base": "tgheroes:rider/the_rider",
	"jacket": "tgheroes:rider/jacket"
});

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

function init(renderer) {
    parent.init(renderer);
    renderer.setTexture((entity, renderLayer) => {
		if (!entity.isDisplayStand()) {
            var timer = entity.getInterpolatedData("tgheroes:dyn/doorman_timer");
            return timer == 0 ? "jacket" : timer < 1 ? "suit" : "base";
        }
        return "base";
    });


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

function initEffects(renderer) {
	var fire = renderer.createResource("ICON", "fiskheroes:fire_layer_%s");
    head_flames = flames.createHead(renderer, fire);
	
	utils.bindBeam(renderer, "fiskheroes:charged_beam", "fiskheroes:heat_vision", "head", 0xd7961b, [
        { "firstPerson": [2.2, 0.0, 2.0], "offset": [2.2, -3.3, -4.0], "size": [1.0, 0.5] },
        { "firstPerson": [-2.2, 0.0, 2.0], "offset": [-2.2, -3.3, -4.0], "size": [1.0, 0.5] }
    ]);
}

function render(entity, renderLayer, isFirstPersonArm) {
	if (renderLayer == "CHESTPLATE" && !entity.isDisplayStand() && entity.getInterpolatedData("tgheroes:dyn/doorman_timer")) {
        head_flames.render(1);  
    }
}