extend("skarlet:ash_williams_base");
loadTextures({
    "layer1": "skarlet:ash_williams/ash_s_mart_layer1",
    "layer2": "skarlet:ash_williams/ash_s_mart_layer2",
    "shoes": "skarlet:ash_williams/ash_s_mart_shoes",
    "chest": "skarlet:ash_williams/ash_s_mart_chest",
    "pants": "skarlet:ash_williams/ash_s_mart_pants",
    "chainsaw_layer1": "skarlet:ash_williams/chainsaw_s_mart_layer1"
});

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

var boomstick_leg;

function init(renderer) {
    parent.init(renderer);
    renderer.setTexture((entity, renderLayer) => {
        if (renderLayer == "CHESTPLATE") {
			if (entity.getData('fiskheroes:blade_timer') >= 0.3) {
				return "chainsaw_layer1";
            } else {
                return entity.getWornLeggings().suitType() == $SUIT_NAME ? "layer1" : "chest";
            }
        }
        else if (renderLayer == "LEGGINGS") {
            return entity.getWornChestplate().suitType() == $SUIT_NAME ? "layer2" : "pants";
        }
        return "shoes";
    });

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

function initEffects(renderer) {
    parent.initEffects(renderer);
	
    var model_boomstick_back = renderer.createResource("MODEL", "skarlet:back_boomstick");
    model_boomstick_back.texture.set("boomstick");
	
    boomstick_leg = renderer.createEffect("fiskheroes:model").setModel(model_boomstick_back);
    boomstick_leg.anchor.set("rightLeg");
    boomstick_leg.setOffset(-1.0, -2.0, -1.0);
	boomstick_leg.setRotation(15.0, -90.0, 0.0);
	boomstick_leg.setScale(0.9);
}

function initAnimations(renderer) {
    parent.initAnimations(renderer);
}

function render(entity, renderLayer, isFirstPersonArm) {
    parent.render(entity, renderLayer, isFirstPersonArm);
    
	if (renderLayer == "LEGGINGS") {
		if (!entity.getData("fiskheroes:aiming")) {
			boomstick_leg.render();
		}
	}
}
