diff --git a/src/SMAPI/Constants.cs b/src/SMAPI/Constants.cs index d733ce46..5bacb003 100644 --- a/src/SMAPI/Constants.cs +++ b/src/SMAPI/Constants.cs @@ -20,7 +20,7 @@ namespace StardewModdingAPI ** Public ****/ /// SMAPI's current semantic version. - public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.4.1"); + public static ISemanticVersion ApiVersion { get; } = new Toolkit.SemanticVersion("3.4.1.1", allowNonStandard: true); /// The minimum supported version of Stardew Valley. public static ISemanticVersion MinimumGameVersion { get; } = new GameVersion("1.4.5"); diff --git a/src/SMAPI/Framework/RewriteFacades/Game1Methods.cs b/src/SMAPI/Framework/RewriteFacades/Game1Methods.cs index 900f731a..e83738ca 100644 --- a/src/SMAPI/Framework/RewriteFacades/Game1Methods.cs +++ b/src/SMAPI/Framework/RewriteFacades/Game1Methods.cs @@ -92,5 +92,19 @@ namespace StardewModdingAPI.Framework.RewriteFacades return true; }); } + + public static void randomizeDebrisWeatherPositions(List debris) + { + if (debris != null) + { + using (List.Enumerator enumerator = debris.GetEnumerator()) + { + while (enumerator.MoveNext()) + { + enumerator.Current.position = Utility.getRandomPositionOnScreen(); + } + } + } + } } } diff --git a/src/SMAPI/Framework/RewriteFacades/SaveGameMethods.cs b/src/SMAPI/Framework/RewriteFacades/SaveGameMethods.cs new file mode 100644 index 00000000..0ef1087f --- /dev/null +++ b/src/SMAPI/Framework/RewriteFacades/SaveGameMethods.cs @@ -0,0 +1,13 @@ +using System.Collections.Generic; +using StardewValley; + +namespace StardewModdingAPI.Framework.RewriteFacades +{ + public class SaveGameMethods : SaveGame + { + public static IEnumerator Save() + { + return SaveGame.Save(false, false); + } + } +} diff --git a/src/SMAPI/Framework/SCore.cs b/src/SMAPI/Framework/SCore.cs index 210cbe4e..b0768f58 100644 --- a/src/SMAPI/Framework/SCore.cs +++ b/src/SMAPI/Framework/SCore.cs @@ -273,6 +273,7 @@ namespace StardewModdingAPI.Framework new ScheduleErrorPatch(this.MonitorForGame), new SaveBackupPatch(this.EventManager), new JunimoHarvesterPatch(this.Monitor), + new LocationSwitchPatch(this.Monitor), new SpriteFontPatch(this.Monitor) ); diff --git a/src/SMAPI/Metadata/InstructionMetadata.cs b/src/SMAPI/Metadata/InstructionMetadata.cs index d05008ec..e529f5f5 100644 --- a/src/SMAPI/Metadata/InstructionMetadata.cs +++ b/src/SMAPI/Metadata/InstructionMetadata.cs @@ -88,6 +88,7 @@ namespace StardewModdingAPI.Metadata yield return new MethodParentRewriter(typeof(NPC), typeof(NPCMethods)); yield return new MethodParentRewriter(typeof(Utility), typeof(UtilityMethods)); yield return new MethodParentRewriter(typeof(DayTimeMoneyBox), typeof(DayTimeMoneyBoxMethods)); + yield return new MethodParentRewriter(typeof(SaveGame), typeof(SaveGameMethods)); //Constructor Rewrites yield return new MethodParentRewriter(typeof(HUDMessage), typeof(HUDMessageMethods)); diff --git a/src/SMAPI/Patches/LocationSwitchPatch.cs b/src/SMAPI/Patches/LocationSwitchPatch.cs new file mode 100644 index 00000000..06c041a0 --- /dev/null +++ b/src/SMAPI/Patches/LocationSwitchPatch.cs @@ -0,0 +1,83 @@ +using System; +using System.Diagnostics.CodeAnalysis; +using Harmony; +using StardewModdingAPI.Framework.Patching; +using StardewValley; +using StardewValley.Characters; + +namespace StardewModdingAPI.Patches +{ + /// A Harmony patch for which detect location switch and add tapToMove if possible. + /// Patch methods must be static for Harmony to work correctly. See the Harmony documentation before renaming patch arguments. + [SuppressMessage("ReSharper", "InconsistentNaming", Justification = "Argument names are defined by Harmony and methods are named for clarity.")] + [SuppressMessage("ReSharper", "IdentifierTypo", Justification = "Argument names are defined by Harmony and methods are named for clarity.")] + internal class LocationSwitchPatch : IHarmonyPatch + { + /********* + ** Fields + *********/ + + /********* + ** Fields + *********/ + /// Writes messages to the console and log file. + private static IMonitor Monitor; + + /********* + ** Accessors + *********/ + /// A unique name for this patch. + public string Name => nameof(LocationSwitchPatch); + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// Writes messages to the console and log file on behalf of the game. + public LocationSwitchPatch(IMonitor monitor) + { + Monitor = monitor; + } + + /// Apply the Harmony patch. + /// The Harmony instance. + public void Apply(HarmonyInstance harmony) + { + harmony.Patch( + original: AccessTools.Property(typeof(Game1), "currentLocation").SetMethod, + prefix: new HarmonyMethod(this.GetType(), nameof(LocationSwitchPatch.Before_currentLocation_set)) + ); + } + + + /********* + ** Private methods + *********/ + /// The method to call instead of . + /// The instance being patched. + /// The method being wrapped. + /// Returns whether to execute the original method. + private static void Before_currentLocation_set(GameLocation value) + { + try + { + if (value.tapToMove == null) + { + if (value.map != null) + { + value.tapToMove = new StardewValley.Mobile.TapToMove(value); + } + else + { + value.tapToMove = Game1.currentLocation.tapToMove; + } + } + } + catch (Exception ex) + { + LocationSwitchPatch.Monitor.Log($"Failed to add tapToMove for currentLocation {value.Name}:\n{ex.InnerException ?? ex}", LogLevel.Error); + } + } + } +} diff --git a/src/SMAPI/SMAPI.csproj b/src/SMAPI/SMAPI.csproj index aada4903..fba30c51 100644 --- a/src/SMAPI/SMAPI.csproj +++ b/src/SMAPI/SMAPI.csproj @@ -24,7 +24,7 @@ portable false bin\Debug\ - TRACE;DEBUG + TRACE;DEBUG;ANDROID_TARGET_SAMSUNG prompt 4 latest @@ -321,6 +321,7 @@ + @@ -398,6 +399,7 @@ +