/// <summary> /// Generates schedules for everyone. /// </summary> internal static void GenerateAllSchedules() { Game1.netWorldState.Value.IslandVisitors.Clear(); if (Game1.getLocationFromName("IslandSouth") is not IslandSouth island || !island.resortRestored.Value || !island.resortOpenToday.Value || Game1.IsRainingHere(island) || Utility.isFestivalDay(Game1.Date.DayOfMonth, Game1.Date.Season) || (Game1.Date.DayOfMonth >= 15 && Game1.Date.DayOfMonth <= 17 && Game1.IsWinter)) { return; } Random random = new((int)(Game1.uniqueIDForThisGame * 1.21f) + (int)(Game1.stats.DaysPlayed * 2.5f)); HashSet <NPC> explorers = GenerateExplorerGroup(random); if (explorers.Count > 0) { Globals.ModMonitor.DebugOnlyLog($"Found explorer group: {string.Join(", ", explorers.Select((NPC npc) => npc.Name))}."); IslandNorthScheduler.Schedule(random, explorers); } // Resort capacity set to zero, can skip everything else. if (Globals.Config.Capacity == 0 && (Globals.SaveDataModel is null || Globals.SaveDataModel.NPCsForTomorrow.Count == 0)) { IslandSouthPatches.ClearCache(); GIScheduler.ClearCache(); return; } List <NPC> visitors = GenerateVistorList(random, Globals.Config.Capacity, explorers); Dictionary <string, string> animationDescriptions = Globals.ContentHelper.Load <Dictionary <string, string> >("Data/animationDescriptions", ContentSource.GameContent); GIScheduler.Bartender = SetBartender(visitors); GIScheduler.Musician = SetMusician(random, visitors, animationDescriptions); List <GingerIslandTimeSlot> activities = AssignIslandSchedules(random, visitors, animationDescriptions); Dictionary <NPC, string> schedules = RenderIslandSchedules(random, visitors, activities); foreach (NPC visitor in schedules.Keys) { Globals.ModMonitor.Log($"Calculated island schedule for {visitor.Name}"); visitor.islandScheduleName.Value = "island"; ScheduleUtilities.ParseMasterScheduleAdjustedForChild2NPC(visitor, schedules[visitor]); Game1.netWorldState.Value.IslandVisitors[visitor.Name] = true; ConsoleCommands.IslandSchedules[visitor.Name] = schedules[visitor]; } IslandSouthPatches.ClearCache(); GIScheduler.ClearCache(); #if DEBUG Globals.ModMonitor.Log($"Current memory usage {GC.GetTotalMemory(false):N0}", LogLevel.Alert); GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; GC.Collect(); Globals.ModMonitor.Log($"Post-collection memory usage {GC.GetTotalMemory(true):N0}", LogLevel.Alert); #endif }
private static bool OverRideSetUpIslandSchedules() { if (Globals.Config.UseThisScheduler) { Globals.ModMonitor.DebugOnlyLog("GI schedules being generated by mod."); try { GIScheduler.GenerateAllSchedules(); return(false); } catch (Exception ex) { Globals.ModMonitor.Log($"Errors generating ginger island schedules, defaulting to vanilla code\n\n{ex}"); } } return(true); }
/// <summary> /// Clear all caches at the end of the day and if the player exits to menu. /// </summary> private void ClearCaches() { DialoguePatches.ClearTalkRecord(); DialogueUtilities.ClearDialogueLog(); if (Context.IsSplitScreen && Context.ScreenId != 0) { return; } this.haveFixedSchedulesToday = false; MidDayScheduleEditor.Reset(); IslandSouthPatches.ClearCache(); GIScheduler.ClearCache(); GIScheduler.DayEndReset(); ConsoleCommands.ClearCache(); ScheduleUtilities.ClearCache(); }