[EventPriority(EventPriority.Low)] //use low priority to run after most asset updates private static void DayStarted_SetupIslandSchedules(object sender, StardewModdingAPI.Events.DayStartedEventArgs e) { if (!Context.IsMainPlayer) //if this is NOT the main player { return; //do nothing } ExcludedVisitors = new HashSet <string>(StringComparer.OrdinalIgnoreCase); //create a new case-insensitive set and enable scheduling foreach (KeyValuePair <string, List <string> > data in ModEntry.GetAllNPCExclusions(forceCacheUpdate: true)) //for each NPC's set of exclusion data { if (data.Value.Exists(entry => entry.StartsWith("All", StringComparison.OrdinalIgnoreCase) || //if this NPC is excluded from everything entry.StartsWith("IslandEvent", StringComparison.OrdinalIgnoreCase) || //OR if this NPC is excluded from island events entry.StartsWith("IslandVisit", StringComparison.OrdinalIgnoreCase) //OR if this NPC is excluded from visting the island resort )) { ExcludedVisitors.Add(data.Key); //add this NPC's name to the excluded set } } if (ExcludedVisitors.Count > 0 && ModEntry.Instance.Monitor.IsVerbose) //if any NPCs were excluded { string logMessage = string.Join(", ", ExcludedVisitors); ModEntry.Instance.Monitor.Log($"Excluded NPCs from possible island visit: {logMessage}", LogLevel.Trace); } IslandSouth.SetupIslandSchedules(); //set up visitors' schedules ExcludedVisitors = null; //clear the set and disable scheduling }
/********* ** Private methods *********/ private void createCritterLocationList(object sender, StardewModdingAPI.Events.DayStartedEventArgs args) { Log.debug("in create critter day start event"); SeasonalCritters = AllCritters.Where(c => c.SpawnConditions.Seasons.Contains(Game1.currentSeason)).ToList(); CritterLocations Farm = new CritterLocations(Game1.getFarm()); Farm.buildAllPossibleHomes(); Farm.balanceSpawning(); AllCritterLocations.AddOrReplace(Farm); //Helper.Events.GameLoop.DayStarted -= createCritterLocationList; }
private void GameLoop_DayStartedSlow(object sender, StardewModdingAPI.Events.DayStartedEventArgs e) { Monitor.Log($"[{timer.Elapsed.TotalMilliseconds:N}][Slow] Day Started", LogLevel.Info); }
void GameLoop_DayStarted(object sender, StardewModdingAPI.Events.DayStartedEventArgs e) { Composting.OnNewDay(); Pests.OnNewDay(); Cultivation.OnNewDay(); }