extend("skarlet:gwenpool_base");
loadTextures({
    "layer1": "skarlet:gwenpool/gwenpool_future_layer1",
    "layer2": "skarlet:gwenpool/gwenpool_future_layer2",
    "katana": "skarlet:gwenpool/gwenpool_dark_katana",
    "scabbard": "skarlet:gwenpool/gwenpool_dark_scabbard",
	"guns": "skarlet:gwenpool/gwenpool_gun",
	"cape": "skarlet: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", "skarlet: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;
    renderer.bindProperty("fiskheroes:equipped_item").setItems([
        { "anchor": "body", "scale": 0.7, "offset": [-3.5, 0.0, 3.0], "rotation": [0.0, -90.0, 60.0] }
    ]).addOffset("QUIVER", 0.0, 0.0, 3.0).slotIndex = 2;
}

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