extend("skarredheroes:gwenpool_base");
loadTextures({
    "layer1": "skarredheroes:gwenpool/gwenpool_future_layer1",
    "layer2": "skarredheroes:gwenpool/gwenpool_future_layer2",
    "katana": "skarredheroes:gwenpool/gwenpool_dark_katana",
    "scabbard": "skarredheroes:gwenpool/gwenpool_dark_scabbard",
	"guns": "skarredheroes:gwenpool/gwenpool_gun",
	"cape": "skarredheroes:gwenpool/gwenpool_cape"
});
var utils = implement("fiskheroes:external/utils");
var capes = implement("fiskheroes:external/capes");

var chest;
var scabbard;
var cape;

function init(renderer) {
    parent.init(renderer);
    renderer.setTexture((entity, renderLayer) => renderLayer == "LEGGINGS" ? "layer2" : "layer1");

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

function initEffects(renderer) {
	parent.initEffects(renderer);
	
    var model = renderer.createResource("MODEL", "skarredheroes:single_scabbard");
    model.texture.set("scabbard");
    scabbard = renderer.createEffect("fiskheroes:model").setModel(model);
    scabbard.anchor.set("body");
	
    var physics = renderer.createResource("CAPE_PHYSICS", null);
    physics.maxFlare = 0.4;
    cape = capes.createDefault(renderer, 24, "fiskheroes:cape_default.mesh.json", physics);
    cape.effect.texture.set("cape");
	
    chest = renderer.createEffect("fiskheroes:chest");
    chest.setExtrude(1.25).setYOffset(1);
	
    utils.addLivery(renderer, "KATANA", "katana");
    utils.addLivery(renderer, "DESERT_EAGLE", "guns");
	
    renderer.bindProperty("fiskheroes:equipped_item").setItems([
        { "anchor": "body", "scale": 0.535, "offset": [-3.05, 0.52, 3.0], "rotation": [-148.0, 90.0, 0.0] }
    ]).slotIndex = 0;
    renderer.bindProperty("fiskheroes:equipped_item").setItems([
        { "anchor": "rightLeg", "scale": 0.7, "offset": [-2.0, 0.5, 1.0], "rotation": [90.0, 0.0, -7.0] }
    ]).slotIndex = 1;
}

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