/// <summary> /// Handles events that fire at sleep. /// </summary> /// <param name="f"></param> public void HandleMoonAtSleep(Farm f) { if (f == null) { return; } if (Dice.NextDoublePositive() < .20) { return; } int cropsAffected = 0; //moon processing if (CurrentPhase == MoonPhase.FullMoon) { foreach (var TF in f.terrainFeatures.Pairs) { if (TF.Value is HoeDirt curr && curr.crop != null && Dice.NextDouble() < CropGrowthChance) { SDVUtilities.AdvanceArbitrarySteps(f, curr, TF.Key); } } if (cropsAffected > 0) { Game1.addHUDMessage(new HUDMessage(Translations.Get("moon-text.fullmoon_eff", new { cropsAffected }))); } } if (CurrentPhase == MoonPhase.NewMoon && ModConfig.HazardousMoonEvents) { if (f != null) { foreach (KeyValuePair <Vector2, TerrainFeature> TF in f.terrainFeatures.Pairs) { if (TF.Value is HoeDirt curr && curr.crop != null) { if (Dice.NextDouble() < CropNoGrowthChance) { cropsAffected++; curr.state.Value = HoeDirt.dry; } } } } if (cropsAffected > 0) { Game1.addHUDMessage(new HUDMessage(Translations.Get("moon-text.newmoon_eff", new { cropsAffected }))); } } }
/// <summary> /// Handles events that fire at sleep. /// </summary> /// <param name="f"></param> public int HandleMoonAtSleep(Farm f, IMonitor Logger) { if (f == null) { return(0); } int cropsAffected = 0; if (CurrentPhase == MoonPhase.FullMoon) { foreach (var TF in f.terrainFeatures.Pairs) { if (TF.Value is HoeDirt curr && curr.crop != null && Dice.NextDouble() < ModConfig.CropGrowthChance) { if (ModConfig.Verbose) { Logger.Log($"Advancing crop at {TF.Key}", LogLevel.Trace); } SDVUtilities.AdvanceArbitrarySteps(f, curr, TF.Key); } } return(cropsAffected); } if (CurrentPhase == MoonPhase.NewMoon && ModConfig.HazardousMoonEvents) { if (f != null) { foreach (KeyValuePair <Vector2, TerrainFeature> TF in f.terrainFeatures.Pairs) { if (TF.Value is HoeDirt curr && curr.crop != null) { if (Dice.NextDouble() < ModConfig.CropHaltChance) { //SDVUtilities.DeAdvanceCrop(f, curr, TF.Key, 1); curr.state.Value = 0; cropsAffected++; if (ModConfig.Verbose) { Logger.Log($"Deadvancing crop at {TF.Key}", LogLevel.Trace); } } } } } return(cropsAffected); } return(cropsAffected); }