diff --git a/CheatMod.Core/CheatMod.Core.csproj b/CheatMod.Core/CheatMod.Core.csproj index 51d3b19..a8f8464 100644 --- a/CheatMod.Core/CheatMod.Core.csproj +++ b/CheatMod.Core/CheatMod.Core.csproj @@ -109,6 +109,7 @@ + diff --git a/CheatMod.Core/CheatOptions.cs b/CheatMod.Core/CheatOptions.cs index e169e8a..5b0e936 100644 --- a/CheatMod.Core/CheatOptions.cs +++ b/CheatMod.Core/CheatOptions.cs @@ -5,7 +5,7 @@ public class CheatOptions #region Game options public static bool IsEasyFishingEnabled { get; set; } = true; public static bool IsInfiniteFluteEnabled { get; set; } = true; - public static bool IsSkipAttuneMinigameEnabled { get; set; } = true; + public static bool IsEasyAnimalsEnabled { get; set; } = true; public static bool IsInfiniteSeedsEnabled { get; set; } = true; public static bool IsInfiniteStaminaEnabled { get; set; } = true; public static bool IsInfiniteWaterToolEnabled { get; set; } = true; diff --git a/CheatMod.Core/PachaCheats.cs b/CheatMod.Core/PachaCheats.cs index 647a246..aafd189 100644 --- a/CheatMod.Core/PachaCheats.cs +++ b/CheatMod.Core/PachaCheats.cs @@ -309,7 +309,7 @@ public void DestroyHittableResources(float range = 3f) { if (!caveRoom.Stage.GetComponent().OverlapPoint(psc.transform.position)) continue; - foreach (var hittableEntity in caveRoom.CurrentHittables.ToList()) + foreach (var hittableEntity in caveRoom.CurrentHittables.Where(ch => ch is not null).ToList()) { if (Vector2.Distance(hittableEntity.transform.position, psc.transform.position) < range) { @@ -318,7 +318,7 @@ public void DestroyHittableResources(float range = 3f) } } - foreach (var shim in caveRoom.CurrentCaveOresShams.ToList()) + foreach (var shim in caveRoom.CurrentCaveOresShams.Where(sh => sh is not null).ToList()) { if (Vector2.Distance(shim.transform.position, psc.transform.position) < range && shim.Health.CurrentHealth > 0f) diff --git a/CheatMod.Core/Patches/EasyAnimals.cs b/CheatMod.Core/Patches/EasyAnimals.cs new file mode 100644 index 0000000..8f76dbb --- /dev/null +++ b/CheatMod.Core/Patches/EasyAnimals.cs @@ -0,0 +1,43 @@ +using System.Reflection; +using System.Threading; +using Cysharp.Threading.Tasks; +using HarmonyLib; +using SodaDen.Pacha; + +namespace CheatMod.Core.Patches; + +public partial class CheatModPatches +{ + [HarmonyPatch(typeof(AnimalAttuneMinigame), "StartMinigame", typeof(Animal), typeof(AnimalVariant), typeof(bool), typeof(CancellationToken))] + [HarmonyPrefix] + private static bool SkipAttuneMinigamePatch(ref UniTask __result) + { + if (!CheatOptions.IsEasyAnimalsEnabled) + return true; + + __result = UniTask.FromResult(4); + return false; + } + + [HarmonyPatch(typeof(AnimalEntity), "OnNextDayLocal")] + [HarmonyPostfix] + private static void AnimalEntityAutoFeed(AnimalEntity __instance) + { + if (!CheatOptions.IsEasyAnimalsEnabled) return; + + if (__instance.IsTamed || __instance.IsPet) + { + var feedMethodInfo = __instance.GetType().GetMethod("Feed", BindingFlags.Instance | BindingFlags.NonPublic); + feedMethodInfo?.Invoke(__instance, new object[] { __instance.CurrentDay }); + + if (__instance.Hunger != AnimalHunger.WellFed) + { + feedMethodInfo?.Invoke(__instance, new object[] { __instance.CurrentDay - 1 }); + feedMethodInfo?.Invoke(__instance, new object[] { __instance.CurrentDay - 2 }); + feedMethodInfo?.Invoke(__instance, new object[] { __instance.CurrentDay - 3 }); + } + + __instance.CureAllSickness(); + } + } +} \ No newline at end of file diff --git a/CheatMod.Core/Patches/InfiniteFlute.cs b/CheatMod.Core/Patches/InfiniteFlute.cs index 6faccc3..85712bc 100644 --- a/CheatMod.Core/Patches/InfiniteFlute.cs +++ b/CheatMod.Core/Patches/InfiniteFlute.cs @@ -1,6 +1,4 @@ -using System.Threading; -using Cysharp.Threading.Tasks; -using HarmonyLib; +using HarmonyLib; using SodaDen.Pacha; namespace CheatMod.Core.Patches; @@ -17,15 +15,4 @@ private static bool InfiniteFlutePatch(FluteToolItem __instance, PlayerEntity pl return true; } - - [HarmonyPatch(typeof(AnimalAttuneMinigame), "StartMinigame", typeof(Animal), typeof(AnimalVariant), typeof(bool), typeof(CancellationToken))] - [HarmonyPrefix] - private static bool SkipAttuneMinigamePatch(ref UniTask __result) - { - if (!CheatOptions.IsSkipAttuneMinigameEnabled) - return true; - - __result = UniTask.FromResult(4); - return false; - } } \ No newline at end of file diff --git a/CheatMod.Core/UI/Windows/MainWindow.cs b/CheatMod.Core/UI/Windows/MainWindow.cs index 148aea2..c651601 100644 --- a/CheatMod.Core/UI/Windows/MainWindow.cs +++ b/CheatMod.Core/UI/Windows/MainWindow.cs @@ -89,8 +89,8 @@ protected override void DrawInternal(int windowId) GUILayout.Toggle(CheatOptions.IsEasyFishingEnabled, "Easy fishing", CheatUIStyles.Toggle); CheatOptions.IsInfiniteFluteEnabled = GUILayout.Toggle(CheatOptions.IsInfiniteFluteEnabled, "Infinite flute", CheatUIStyles.Toggle); - CheatOptions.IsSkipAttuneMinigameEnabled = - GUILayout.Toggle(CheatOptions.IsSkipAttuneMinigameEnabled, "Skip attune game", CheatUIStyles.Toggle); + CheatOptions.IsEasyAnimalsEnabled = + GUILayout.Toggle(CheatOptions.IsEasyAnimalsEnabled, "Easy animals", CheatUIStyles.Toggle); CheatOptions.IsInfiniteSeedsEnabled = GUILayout.Toggle(CheatOptions.IsInfiniteSeedsEnabled, "Infinite seeds", CheatUIStyles.Toggle); CheatOptions.IsInfiniteStaminaEnabled =