/// <summary> /// Applies server config data to the player /// </summary> /// <param name="player"></param> public void ApplyToPlayer(Player player) { try { player.statLife = this.Health; player.statLifeMax = this.MaxHealth; player.statMana = this.Mana; player.statManaMax = this.MaxMana; player.SpawnX = this.SpawnX; player.SpawnY = this.SpawnY; player.hideVisual = this.HideVisual; player.hairDye = this.HairDye; player.hair = this.Hair; player.difficulty = this.Difficulty; player.hairColor = this.HairColor; player.skinColor = this.SkinColor; player.eyeColor = this.EyeColor; player.shirtColor = this.ShirtColor; player.underShirtColor = this.UnderShirtColor; player.pantsColor = this.PantsColor; player.shoeColor = this.ShoeColor; player.anglerQuestsFinished = this.AnglerQuests; //Trash player.trashItem = new Item(); player.trashItem.name = String.Empty; player.trashItem.SetDefaults(0); if (this.Trash != null) { player.trashItem.netDefaults(this.Trash.NetId); player.trashItem.stack = this.Trash.Stack; player.trashItem.Prefix(this.Trash.Prefix); player.trashItem.favorited = this.Trash.Favorite; } } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player settings"); } try { ApplyItems(ref player.inventory, this.Inventory); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player inventory"); } try { ApplyItems(ref player.armor, this.Armor); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player armor"); } try { ApplyItems(ref player.dye, this.Dye); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player dye"); } try { ApplyItems(ref player.miscEquips, this.Equipment); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player equipment"); } try { ApplyItems(ref player.miscDyes, this.MiscDyes); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player misc dyes"); } try { ApplyItems(ref player.bank.item, this.Bank); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player bank items"); } try { ApplyItems(ref player.bank2.item, this.Bank2); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player bank (2) items"); } // try // { // //Reset and populate inventory // // player.inventory = Enumerable.Repeat(new Item(){ name = String.Empty }, player.inventory.Length).ToArray(); // player.inventory = new Item[player.inventory.Length]; // for (var i = 0; i < player.inventory.Length; i++) // { // player.inventory[i] = new Item(); // player.inventory[i].name = String.Empty; // player.inventory[i].SetDefaults(0); // } // // if (this.Inventory != null) // foreach (var slotItem in this.Inventory) // { // var item = player.inventory[slotItem.Slot]; // // item.netDefaults(slotItem.NetId); // item.stack = slotItem.Stack; // item.Prefix(slotItem.Prefix); // item.favorited = slotItem.Favorite; // // player.inventory[slotItem.Slot] = item; // } // } // catch (Exception e) // { // ProgramLog.Log(e, "Failed to apply player inventory"); // } // // try // { // //Reset and populate dye // // player.dye = Enumerable.Repeat(new Item(){ name = String.Empty }, player.dye.Length).ToArray(); // player.dye = new Item[player.dye.Length]; // for (var i = 0; i < player.dye.Length; i++) // { // player.dye[i] = new Item(); // player.dye[i].name = String.Empty; // player.dye[i].SetDefaults(0); // } // if (this.Dye != null) // foreach (var slotItem in this.Dye) // { // var item = player.dye[slotItem.Slot]; // // item.netDefaults(slotItem.NetId); // item.stack = slotItem.Stack; // item.Prefix(slotItem.Prefix); // item.favorited = slotItem.Favorite; // // player.dye[slotItem.Slot] = item; // } // } // catch (Exception e) // { // ProgramLog.Log(e, "Failed to apply player dye"); // } // // try // { // //Reset and populate armor // // player.armor = Enumerable.Repeat(new Item(){ name = String.Empty }, player.armor.Length).ToArray(); // player.armor = new Item[player.armor.Length]; // for (var i = 0; i < player.armor.Length; i++) // { // player.armor[i] = new Item(); // player.armor[i].name = String.Empty; // player.armor[i].SetDefaults(0); // } // if (this.Armor != null) // foreach (var slotItem in this.Armor) // { // var item = player.armor[slotItem.Slot]; // // item.netDefaults(slotItem.NetId); // item.stack = slotItem.Stack; // item.Prefix(slotItem.Prefix); // item.favorited = slotItem.Favorite; // // player.armor[slotItem.Slot] = item; // } // } // catch (Exception e) // { // ProgramLog.Log(e, "Failed to apply player armor"); // } try { //Update client this.Send(player); } catch (Exception e) { ProgramLog.Log(e, "Failed to send player data"); } player.SetSSCReadyForSave(true); }
/// <summary> /// Applies server config data to the player /// </summary> /// <param name="player"></param> public void ApplyToPlayer(Player player) { try { player.statLife = this.Health; player.statLifeMax = this.MaxHealth; player.statMana = this.Mana; player.statManaMax = this.MaxMana; player.SpawnX = this.SpawnX; player.SpawnY = this.SpawnY; player.hideVisual = this.HideVisual; player.hairDye = this.HairDye; player.hair = this.Hair; player.difficulty = this.Difficulty; player.hairColor = this.HairColor; player.skinColor = this.SkinColor; player.eyeColor = this.EyeColor; player.shirtColor = this.ShirtColor; player.underShirtColor = this.UnderShirtColor; player.pantsColor = this.PantsColor; player.shoeColor = this.ShoeColor; player.anglerQuestsFinished = this.AnglerQuests; //Trash player.trashItem = new Item(); player.trashItem.name = String.Empty; player.trashItem.SetDefaults(0); if (this.Trash != null) { player.trashItem.netDefaults(this.Trash.NetId); player.trashItem.stack = this.Trash.Stack; player.trashItem.Prefix(this.Trash.Prefix); player.trashItem.favorited = this.Trash.Favorite; } } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player settings"); } try { ApplyItems(ref player.inventory, this.Inventory); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player inventory"); } try { ApplyItems(ref player.armor, this.Armor); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player armor"); } try { ApplyItems(ref player.dye, this.Dye); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player dye"); } try { ApplyItems(ref player.miscEquips, this.Equipment); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player equipment"); } try { ApplyItems(ref player.miscDyes, this.MiscDyes); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player misc dyes"); } try { ApplyItems(ref player.bank.item, this.Bank); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player bank items"); } try { ApplyItems(ref player.bank2.item, this.Bank2); } catch (Exception e) { ProgramLog.Log(e, "Failed to apply player bank (2) items"); } try { //Update client this.Send(player); } catch (Exception e) { ProgramLog.Log(e, "Failed to send player data"); } player.SetSSCReadyForSave(true); }