extend("skarlet:ash_williams_base");
loadTextures({
    "layer1": "skarlet:ash_williams/ash_layer1",
    "layer2": "skarlet:ash_williams/ash_layer2",
    "chest": "skarlet:ash_williams/ash_chest",
    "lights": "skarlet:ash_williams/ash_lights",
    "chainsaw_layer1": "skarlet:ash_williams/chainsaw_layer1",
	"holster": "skarlet:ash_williams/holster"
});

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

var boomstick_back;
var holster;

function init(renderer) {
    parent.init(renderer);
    renderer.setLights((entity, renderLayer) => renderLayer == "CHESTPLATE" ? "lights" : null);
}

function initEffects(renderer) {
    parent.initEffects(renderer);

    var model_holster = renderer.createResource("MODEL", "skarlet:holster");
    model_holster.texture.set("holster");
	
    holster = renderer.createEffect("fiskheroes:model").setModel(model_holster);
    holster.anchor.set("body");
    holster.setOffset(-0.6, 0.0, 0.0);
	
    var model_boomstick_back = renderer.createResource("MODEL", "skarlet:back_boomstick");
    model_boomstick_back.texture.set("boomstick");

    boomstick_back = renderer.createEffect("fiskheroes:model").setModel(model_boomstick_back);
    boomstick_back.anchor.set("body");
    boomstick_back.setOffset(-0.4, 0.0, 0.4);
	boomstick_back.setScale(0.9);
}

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

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