/// <summary> /// Before a save, simulate any lightning the previous night should have had safely. /// </summary> private void BeforeSave(object sender, EventArgs e) { if (this.previousDayRNGInfo == null) { return; } //Fix Game1.wasRainingYesterday Game1.wasRainingYesterday = Game1.wasRainingYesterday || this.previousDayRNGInfo.isLightning; int num = (2400 - this.previousDayRNGInfo.time) / 100; this.Monitor.Log($"Running overnight lightning {num} times.", LogLevel.Trace); for (int i = 0; i < num; i++) { if (SDVLightningMimic.GetSDVLightningStrikePositionAt(this.previousDayRNGInfo, out KeyValuePair <Vector2, TerrainFeature> item)) { this.SaveFeature(item.Key, item.Value); this.Monitor.Log($"{item.Value.GetType().Name} at {item.Key} will be hit next.", LogLevel.Trace); } SDVLightningMimic.CauseVanillaStrike(this.previousDayRNGInfo); this.RestoreLocationAndIgnoreErrors(Game1.getFarm(), this.featuresBeforeTheyWereHit); } this.previousDayRNGInfo = null; }
/********* * Overnight Handling *********/ /// <summary> /// If there will be lightning tonight, prevent it and save the conditions that decide which /// <see cref="TerrainFeature" />s get hit. /// </summary> private void PrepareForOvernightLightning() { if (Game1.isLightning) { this.previousDayRNGInfo = new LightningStrikeRNGInfo(); Game1.isLightning = false; this.Monitor.Log($"Turned off lightning. Player went to bed at {Game1.timeOfDay}.", LogLevel.Trace); } }