extend("fiskheroes:hero_basic");
loadTextures({
    "suit": "tgheroes:weapon_x/x23/x23_tors",
	"boots": "tgheroes:weapon_x/x23/x23_boots",
	"hair": "tgheroes:weapon_x/x23/x23_head",
    "leggings": "tgheroes:weapon_x/x23/x23_layer2",
	"claw": "tgheroes:weapon_x/claw",
	"claw2": "tgheroes:weapon_x/claw2"
});

var utils = implement("fiskheroes:external/utils");
var claw;
var claw2;
var chest;


function init(renderer) {
    parent.init(renderer);
    renderer.setTexture((entity, renderLayer) => {
        if (renderLayer == "CHESTPLATE") {
            return entity.getWornHelmet().suitType() == $SUIT_NAME ? "suit" : "suit";
        }
	    else if (renderLayer == "LEGGINGS") {
            return entity.getWornChestplate().suitType() == $SUIT_NAME ? "leggings" : "leggings";
		}
        return renderLayer == "HELMET" ? "hair" : "boots" 
    });

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

function initEffects(renderer) {
    chest = renderer.createEffect("fiskheroes:chest");
    chest.setExtrude(1).setYOffset(1);

	claw = renderer.createEffect("fiskheroes:shield");
    claw.texture.set("claw");
    claw.anchor.set("rightArm");
	
    claw2 = renderer.createEffect("fiskheroes:shield");
    claw2.texture.set("claw2");
    claw2.anchor.set("leftArm");

	
}


function render(entity, renderLayer, isFirstPersonArm) {
			chest.render();
	
			claw.unfold = entity.getInterpolatedData("fiskheroes:blade_timer");
			claw.render();
			
			claw2.unfold = entity.getInterpolatedData("fiskheroes:blade_timer");
			claw2.render();


			var f = Math.min(claw.unfold * 5, 1);
			claw.setOffset(2.9 + 0.1 * f, 6.0 + 3.0 * f, -1.0);
			claw.render();
			claw.setRotation(0, 90, 0);

			var f2 = Math.min(claw2.unfold * 5, 1);
			claw.setOffset(2.9 + 0.1 * f, 6.0 + 3.0 * f, 1.0);
			claw.render();
			claw.setRotation(0, 90, 0);			
			
			var f4 = Math.min(claw.unfold * 5, 1);
			claw2.setOffset(-2.9 - 0.1 * f, 6.0 + 3.0 * f, -1.0);
			claw2.render();
			claw2.setRotation(0, 90, 0);
			
			var f6 = Math.min(claw2.unfold * 5, 1);
			claw2.setOffset(-2.9 - 0.1 * f, 6.0 + 3.0 * f, 1.0);
			claw2.render();
			claw2.setRotation(0, 90, 0);
	
	
}