/// <summary> /// Clears save-specific data for villager reactions, sunscreen, and sunburn. Raised when the player returns to title screen. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void onReturnedToTitle(object sender, ReturnedToTitleEventArgs e) { //clear any previous data from other saves? Initialize zeros and all? IsSaveReady = false; Reacts = null; Sunscreen = null; Burn = null; }
/// <summary> /// Re-initialize reacts, lotions, sunscreen and burn data. Refresh TV channel data. Raised when a save is loaded. /// </summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event arguments.</param> private void onSaveLoaded(object sender, SaveLoadedEventArgs e) { //initialize new instances of Burn and Sunscreen Reacts = new Reactions(); Lotion = new Lotions(); Sunscreen = new SunscreenProtection(); Burn = new Sunburn(); Helper.Content.InvalidateCache("Strings\\StringsFromCSFiles"); //Refresh TV weather info IsSaveReady = true; }
/// <summary>Apply aloe vera gel to the specified player, reducing burn level and healing accordingly with an HUD message.</summary> /// <param name="who">The player to be treated with aloe gel</param> public void ApplyAloeGel(Farmer who = null) { who = who ?? Game1.player; Sunburn burn = ModEntry.Instance.Burn; int initialLevel = burn.SunburnLevel; //apply the gel's effects burn.SunburnLevel -= 1; //if the gel had an effect if (initialLevel != burn.SunburnLevel) { who.health = Math.Min(who.maxHealth, who.health + Config.HealthLossPerLevel); who.Stamina += (float)Config.EnergyLossPerLevel; if (Config.DebugMode) { Monitor.Log($"Current health: {who.health}/{who.maxHealth} | Current stamina: {who.Stamina}/{who.MaxStamina}", LogLevel.Info); } Item gel = Game1.player.ActiveObject; string messagetext = i18n.Get("Apply.AloeGel", new { lotionName = gel.DisplayName }); Game1.addHUDMessage(new HUDMessage(messagetext, 4)); //stamina_type HUD message Monitor.Log($"Applied aloe gel: {messagetext}", LogLevel.Info); burn.DisplaySunburnStatus(); //Info: new sunburn level, or healed if healed } else { string messagetext = i18n.Get("Apply.AloeNoEffect"); Game1.addHUDMessage(new HUDMessage(messagetext, 2)); //Exclamation mark message type Monitor.Log($"Applied aloe gel: {messagetext}", LogLevel.Info); } //TODO: make skin briefly green???? //Prevent using aloe again today HasAppliedAloeToday = true; }