public void UnlockAllProgression() { foreach (var item in ModManager.Instance.ItemRegistry.Values) { UnlockProgression(item.Item, false); } var message = new ResearchProgressionMessage() { Progression = _progression, PlayerID = Game1.player.uniqueMultiplayerID.ToString() }; _helper.Multiplayer.SendMessage(message, MessageKeys.PROGRESSION_SAVE_REQUIRED, new[] { _modManifest.UniqueID }); }
private void OnMessageReceived(object sender, ModMessageReceivedEventArgs e) { if (e.FromModID != _modManifest.UniqueID) { return; } ResearchProgressionMessage researchProgressionMessage; ItemResearchedMessage itemResearchedMessage; var allowedTypes = new List <string> { "progression" }; if (!allowedTypes.Any(t => e.Type.ToLower().Contains(t))) { return; } switch (e.Type) { case MessageKeys.PROGRESSION_ITEM_RESEARCHED: if (!Context.IsMainPlayer) { break; } itemResearchedMessage = e.ReadAs <ItemResearchedMessage>(); SaveManager.Instance.CommitResearch(e.FromPlayerID.ToString(), itemResearchedMessage.Key, itemResearchedMessage.Progression); break; case MessageKeys.PROGRESSION_SAVE_REQUIRED: if (!Context.IsMainPlayer) { break; } researchProgressionMessage = e.ReadAs <ResearchProgressionMessage>(); SaveManager.Instance.CommitProgression(researchProgressionMessage.PlayerID, researchProgressionMessage.Progression); break; case MessageKeys.PROGRESSION_LOAD_REQUIRED: if (!Context.IsMainPlayer) { break; } var playerID = e.FromPlayerID.ToString(); researchProgressionMessage = new ResearchProgressionMessage { Progression = SaveManager.Instance.GetProgression(playerID), PlayerID = playerID }; _helper.Multiplayer.SendMessage(researchProgressionMessage, MessageKeys.PROGRESSION_LOAD_ACCEPTED, new[] { _modManifest.UniqueID }, new[] { long.Parse(researchProgressionMessage.PlayerID) }); break; case MessageKeys.PROGRESSION_LOAD_ACCEPTED: researchProgressionMessage = e.ReadAs <ResearchProgressionMessage>(); OnLoadProgression(researchProgressionMessage.Progression); break; case MessageKeys.PROGRESSION_DUMP_REQUIRED: if (Context.IsMainPlayer) { } else { researchProgressionMessage = new ResearchProgressionMessage { Progression = _progression, PlayerID = Game1.player.UniqueMultiplayerID.ToString() }; _helper.Multiplayer.SendMessage(researchProgressionMessage, MessageKeys.PROGRESSION_DUMP_ACCEPTED, new[] { _modManifest.UniqueID }); } break; case MessageKeys.PROGRESSION_DUMP_ACCEPTED: if (!Context.IsMainPlayer) { break; } researchProgressionMessage = e.ReadAs <ResearchProgressionMessage>(); var farmer = Game1.getAllFarmers() .FirstOrDefault(f => f.UniqueMultiplayerID.ToString().Equals(researchProgressionMessage.PlayerID)); DumpPlayerProgression(farmer, researchProgressionMessage.Progression); break; case MessageKeys.PROGRESSION_MANAGER_SYNC: OnLoad(null, null); break; } }