/// <summary>Read parsed data about a fish pond's item drops for a specific fish.</summary> /// <param name="data">The fish pond data.</param> public IEnumerable <FishPondDropData> GetFishPondDrops(FishPondData data) { foreach (FishPondReward drop in data.ProducedItems) { yield return(new FishPondDropData(drop.RequiredPopulation, drop.ItemID, drop.MinQuantity, drop.MaxQuantity, drop.Chance)); } }
/// <summary>Patch for Aquarist increased max fish pond capacity.</summary> private static void FishPondUpdateMaximumOccupancyPostfix(ref FishPond __instance, ref FishPondData ____fishPondData) { if (__instance == null || ____fishPondData == null) return; try { var owner = Game1.getFarmer(__instance.owner.Value); if (Utility.SpecificPlayerHasProfession("Aquarist", owner) && __instance.lastUnlockedPopulationGate.Value >= ____fishPondData.PopulationGates.Keys.Max()) __instance.maxOccupants.Set(12); } catch (Exception ex) { Monitor.Log($"Failed in {nameof(FishPondUpdateMaximumOccupancyPostfix)}:\n{ex}"); } }
/// <summary>Read parsed data about a fish pond's population gates for a specific fish.</summary> /// <param name="data">The fish pond data.</param> public IEnumerable <FishPondPopulationGateData> GetFishPondPopulationGates(FishPondData data) { foreach (var gate in data.PopulationGates) { // get required items FishPondPopulationGateQuestItemData[] questItems = gate.Value .Select(entry => { // parse ID string[] parts = entry.Split(' '); int id; if (parts.Length < 1 || parts.Length > 3 || !int.TryParse(parts[0], out id)) { return(null); } // parse counts int minCount = 1; int maxCount = 1; if (parts.Length >= 2) { int.TryParse(parts[1], out minCount); } if (parts.Length >= 3) { int.TryParse(parts[1], out maxCount); } // normalize counts minCount = Math.Max(1, minCount); maxCount = Math.Max(1, maxCount); if (maxCount < minCount) { maxCount = minCount; } // build entry return(new FishPondPopulationGateQuestItemData(id, minCount, maxCount)); }) .Where(p => p != null) .ToArray(); // build entry yield return(new FishPondPopulationGateData(gate.Key, questItems)); } }
public static bool FishPond_HasUnresolvedNeeds_Prefix(FishPond __instance, ref bool __result) { if (__instance.currentOccupants.Value < (int)__instance.maxOccupants) { return(true); } FishPondData f = __instance.GetFishPondData(); if (f is null) { SMonitor.Log($"FishPond.HasUnresolvedNeeds: GetFishPondData did not return data", LogLevel.Warn); SMonitor.Log($"FishPond.HasUnresolvedNeeds: trying to recover by telling SDV the pond has no neededItem or unresolved needs", LogLevel.Warn); __instance.neededItem.Value = null; __result = false; return(false); } return(true); }
/// <summary>Read parsed data about a fish pond's item drops for a specific fish.</summary> /// <param name="data">The fish pond data.</param> public IEnumerable <FishPondDropData> GetFishPondDrops(FishPondData data) { return(this.DataParser.GetFishPondDrops(data)); }
/// <summary>Read parsed data about a fish pond's population gates for a specific fish.</summary> /// <param name="data">The fish pond data.</param> public IEnumerable <FishPondPopulationGateData> GetFishPondPopulationGates(FishPondData data) { return(this.DataParser.GetFishPondPopulationGates(data)); }
/// <summary>Get a fish pond's population gates for display.</summary> /// <param name="pond">The fish pond.</param> /// <param name="data">The fish pond data.</param> private IEnumerable <KeyValuePair <IFormattedText[], bool> > GetPopulationGates(FishPond pond, FishPondData data) { bool foundNextQuest = false; foreach (FishPondPopulationGateData gate in this.GameHelper.GetFishPondPopulationGates(data)) { int newPopulation = gate.NewPopulation; // done if (pond.lastUnlockedPopulationGate.Value >= gate.RequiredPopulation) { yield return(new KeyValuePair <IFormattedText[], bool>( key: new IFormattedText[] { new FormattedText(L10n.Building.FishPondQuestsDone(count: newPopulation)) }, value: true )); continue; } // get required items string[] requiredItems = gate.RequiredItems .Select(drop => { // build display string SObject obj = this.GameHelper.GetObjectBySpriteIndex(drop.ItemID); string summary = obj.DisplayName; if (drop.MinCount != drop.MaxCount) { summary += $" ({L10n.Generic.Range(min: drop.MinCount, max: drop.MaxCount)})"; } else if (drop.MinCount > 1) { summary += $" ({drop.MinCount})"; } // track requirement return(summary); }) .ToArray(); // display requirements string itemList = string.Join(", ", requiredItems); string result = requiredItems.Length > 1 ? L10n.Building.FishPondQuestsIncompleteRandom(newPopulation, itemList) : L10n.Building.FishPondQuestsIncompleteOne(newPopulation, requiredItems[0]); // show next quest if (!foundNextQuest) { foundNextQuest = true; int nextQuestDays = data.SpawnTime + (data.SpawnTime * (pond.maxOccupants.Value - pond.currentOccupants.Value)) - pond.daysSinceSpawn.Value; result += $"; {L10n.Building.FishPondQuestsAvailable(relativeDate: this.GetRelativeDateStr(nextQuestDays))}"; } yield return(new KeyValuePair <IFormattedText[], bool>(key: new IFormattedText[] { new FormattedText(result) }, value: false)); } }