internal override void show(TV tv) { NightEventType currentEvent = getCurrentEvent(); if (currentEvent == NightEventType.None) { throw new Exception("No night event found."); } TemporaryAnimatedSprite background = loadBackground(tv, 0); TemporaryAnimatedSprite portrait = loadPortrait(tv, "Governor", 1, 0); bool newYear = currentEvent == NightEventType.NewYear; // Opening scene: the governor greets the viewer. queueScene(new Scene (Helper.Translation.Get($"nightEvents.{currentEvent}.opening"), background, portrait) { soundCue = "Cowboy_Secret", soundAsset = newYear ? "nightEvents_newYear" : "nightEvents_opening" }); // The governor reacts to the event. TemporaryAnimatedSprite reactionBackground = background; string reactionSound = null; Point reactionIndex = new Point(0, newYear ? 0 : 1); if (currentEvent == NightEventType.StrangeCapsule) { reactionBackground = loadBackground(tv, 0, 1); reactionSound = "UFO"; reactionIndex = new Point(1, 1); } queueScene(new Scene(Helper.Translation.Get($"nightEvents.{currentEvent}.reaction"), reactionBackground, loadPortrait(tv, "Governor", reactionIndex)) { soundCue = reactionSound }); // Closing scene: the governor signs off. queueScene(new Scene(Helper.Translation.Get($"nightEvents.{currentEvent}.closing"), background, portrait)); runProgram(tv); }
// Lists the next several night events to occur on or after the given // date, up to the given limit, optionally of a given type. public static List <NightEventPrediction> ListNextEventsForDate (WorldDate fromDate, uint limit, NightEventType?onlyType = null) { Utilities.CheckWorldReady(); // Logic from StardewValley.Utility.<>c.<pickFarmEvent>b__146_0() // as implemented in Stardew Predictor by MouseyPounds. List <NightEventPrediction> predictions = new List <NightEventPrediction> (); for (int days = fromDate.TotalDays; predictions.Count < limit && days < fromDate.TotalDays + Utilities.MaxHorizon; ++days) { WorldDate tonight = Utilities.TotalDaysToWorldDate(days); WorldDate tomorrow = Utilities.TotalDaysToWorldDate(days + 1); // No event if there is a wedding tomorrow. foreach (Farmer farmer in Game1.getAllFarmers()) { Friendship spouse = farmer.GetSpouseFriendship(); if (spouse != null && spouse.WeddingDate == tomorrow) { continue; } } NightEventType type = NightEventType.None; Random rng = new Random(((int)Game1.uniqueIDForThisGame / 2) + days + 2); if (days == 29) { type = NightEventType.Earthquake; } // Ignoring the possibility of bundle completion here. else if (rng.NextDouble() < 0.01 && tomorrow.Season != "winter") { type = NightEventType.Fairy; } else if (rng.NextDouble() < 0.01) { type = NightEventType.Witch; } else if (rng.NextDouble() < 0.01) { type = NightEventType.Meteorite; } else if (rng.NextDouble() < 0.01 && tomorrow.Year > 1) { type = NightEventType.StrangeCapsule; } else if (rng.NextDouble() < 0.01) { type = NightEventType.StoneOwl; } if (type == NightEventType.None || (onlyType != null && type != onlyType)) { continue; } predictions.Add(new NightEventPrediction { date = tonight, type = type }); } return(predictions); }