extend("fiskheroes:hero_basic");
loadTextures({
	"layer1": "tgheroes:guardians/nebula_layer1",
    "layer2": "tgheroes:guardians/nebula_layer2",
	"baton": "tgheroes:guardians/nebula_baton"
});

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

function initEffects(renderer) {
    chest = renderer.createEffect("fiskheroes:chest");
    chest.setExtrude(1).setYOffset(1);
	
    var model_batton = renderer.createResource("MODEL", "tgheroes:nebulabaton");
    model_batton.texture.set("baton");
    model_batton.generateMirror();

    baton = renderer.createEffect("fiskheroes:model").setModel(model_batton);
    baton.anchor.set("rightArm");
    baton.setScale(1);
    baton.mirror = true;

	var model_back1 = renderer.createResource("MODEL", "tgheroes:nebulahandle");
    model_back1.texture.set("baton");

    back1 = renderer.createEffect("fiskheroes:model").setModel(model_back1);
    back1.anchor.set("body");
    back1.setScale(1);	

	var model_back2 = renderer.createResource("MODEL", "tgheroes:nebulahandle");
    model_back2.texture.set("baton");

    back2 = renderer.createEffect("fiskheroes:model").setModel(model_back2);
    back2.anchor.set("rightArm");
    back2.setScale(1);	

}

function render(entity, renderLayer, isFirstPersonArm) {
    if (!isFirstPersonArm && renderLayer == "CHESTPLATE") {
        chest.render();
    }
        if (entity.getData("fiskheroes:blade_timer") > 0.3) {
            var blade_anchor = baton.anchor.set("rightArm");
            var blade_offSet = baton.setOffset(1.0, 9.0, -4.0);
            var blade_rot = baton.setRotation(90, 0, 0);

            baton.anchor = blade_anchor, blade_offSet, blade_rot;
            baton.render();
        }
        else {
            var back_anchor = back1.anchor.set("body");
            var back_offSet = back1.setOffset(4.0, 10.0, 4.0);
            var back_rot = back1.setRotation(-90, 0, 0);
			var back_anchor = back2.anchor.set("body");
            var back_offSet = back2.setOffset(-4.0, 10.0, 4.0);
            var back_rot = back2.setRotation(-90, 0, 0);

            back2.anchor = back_anchor, back_offSet, back_rot;
            back2.render();
            back1.anchor = back_anchor, back_offSet, back_rot;
            back1.render();
        }
}
