/// <summary> /// Call this method to update the mail box with new letters. /// </summary> public static void UpdateMailBox() { List <Letter> newLetters = MailDao.GetValidatedLetters(); newLetters.RemoveAll((l) => Letters.Contains(l)); try { while (Game1.mailbox.Contains(null)) { Game1.mailbox.Remove(null); } if (newLetters.Count > 0) { IList <string> mailbox = new List <string>(Game1.mailbox); newLetters.ForEach((l) => { mailbox.Insert(0, CustomMailId); Letters.Add(l); }); Game1.player.mailbox.Set(mailbox); } } finally { UpdateNextLetterId(); } }
/// <summary> /// Call this method to update the mail box with new letters. /// </summary> public static void UpdateMailBox() { List <Letter> newLetters = MailDao.GetValidatedLetters(); newLetters.RemoveAll((l) => Letters.Value.Contains(l)); try { while (Game1.player.mailbox.Contains(null)) { Game1.player.mailbox.Remove(null); } while (Game1.player.mailbox.Contains(CustomMailId)) { Game1.player.mailbox.Remove(CustomMailId); } IList <string> mailbox = new List <string>(Game1.player.mailbox); newLetters.ForEach((l) => { if (l.AutoOpen) { if (l.Recipe != null) { GetAndLearnRecipe(l.Recipe, out var s, out var i, out var t); } l.Callback?.Invoke(l); } else { Letters.Value.Add(l); } }); Letters.Value.ForEach((l) => { mailbox.Insert(0, CustomMailId); }); Game1.player.mailbox.Set(mailbox); } finally { UpdateNextLetterId(); } }