extend("fiskheroes:hero_basic");
loadTextures({
	"hair": "tgheroes:psylocke/psylocke_hair",
	"suit": "tgheroes:psylocke/psylocke_suit",
    "boots": "tgheroes:psylocke/psylocke_boots",
    "boots_belt": "tgheroes:psylocke/psylocke_boots_belt",
	"suit_hair": "tgheroes:psylocke/psylocke_suit_hair",
    "scabbard": "fiskheroes:deadpool_xmen_scabbard",
	"katana": "tgheroes:psylocke/psylocke_katana"
});

var utils = implement("fiskheroes:external/utils");
var eldritch_sword = implement("fiskheroes:external/eldritch_sword");
var chest
var sword;
var scabbard;

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

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

function initEffects(renderer) {
    scabbard = renderer.createEffect("fiskheroes:model");
    scabbard.setModel(utils.createModel(renderer, "tgheroes:psylocke_scabbard", "scabbard"));
    scabbard.anchor.set("body");
	
	var chain = utils.bindCloud(renderer, "fiskheroes:telekinesis_chain", "tgheroes:doom_2099_teleport");
    chain.anchor.set("rightArm");
    chain.setOffset(-0.5, 10.0, 0.0);
    chain.setFirstPerson(-4.75, 4.0, -8.5);

    var color = 0xd60068;
    var beam = renderer.createResource("BEAM_RENDERER", "fiskheroes:line");
    sword = eldritch_sword.create(renderer, color, beam);
    sword.setOffset(1.0, 9.4, -4.0).setRotation(10.0, 0.0, 0.0).setScale(16.0);
	
	chest = renderer.createEffect("fiskheroes:chest");
    chest.setExtrude(1).setYOffset(1);
	
    utils.addLivery(renderer, "KATANA", "katana");
    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;
}

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

    addAnimationWithData(renderer, "strange.SWORD_POSE", "fiskheroes:sword_pose", "fiskheroes:blade_timer");
}

function render(entity, renderLayer, isFirstPersonArm) {
    if (renderLayer == "CHESTPLATE") {
		scabbard.render();
        sword.render(entity.getInterpolatedData("fiskheroes:blade_timer"));
		chest.render();
    }
}