extend("fiskheroes:hero_basic");
loadTextures({
    "base": "tgheroes:doorman/doorman_suit",
	"sweatshort": "tgheroes:doorman/demarr_davis_sweatshort",
    "suit": "tgheroes:doorman/doorman_suit.tx.json",
    "cape": "tgheroes:doorman/doorman_cape.tx.json"
});

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

var cape;

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


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

function initEffects(renderer) {
    var physics = renderer.createResource("CAPE_PHYSICS", null);
    physics.weight = 1.0;
    physics.maxFlare = 0.5;
    cape = capes.createDefault(renderer, 24, "fiskheroes:cape_default.mesh.json", physics);
    cape.effect.texture.set("cape");
	
    utils.setOpacityWithData(renderer, 0.5, 1.0, "fiskheroes:intangibility_timer");
	utils.bindCloud(renderer, "fiskheroes:teleportation", "tgheroes:doorman_teleport");
}

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

function render(entity, renderLayer, isFirstPersonArm) {
    if (!isFirstPersonArm && renderLayer == "CHESTPLATE") {
        cape.render(entity);
    }
}