diff --git a/Hacks/Misc.cs b/Hacks/Misc.cs index fdb0e0c..6bc206e 100644 --- a/Hacks/Misc.cs +++ b/Hacks/Misc.cs @@ -26,14 +26,15 @@ namespace SlimeRanger.Hacks { pos += -tpp.transform.right * speed * Time.deltaTime; } - if (Input.GetKey(KeyCode.Keypad8)) + if (Input.GetKey(KeyCode.Space)) { pos += tpp.transform.up * speed * Time.deltaTime; } - if (Input.GetKey(KeyCode.Keypad2)) + if (Input.GetKey(KeyCode.LeftShift)) { pos += -tpp.transform.up * speed * Time.deltaTime; } + Misc.SetPlayerPosition(pos); } @@ -42,7 +43,7 @@ namespace SlimeRanger.Hacks StateHelpers.GetPlayerState().AddCurrency(amount, type); } - public static void AddKey() + public static void AddKey() { StateHelpers.GetPlayerState().AddKey(); } @@ -62,5 +63,6 @@ namespace SlimeRanger.Hacks TeleportablePlayer tpp = UnityEngine.Object.FindObjectOfType(); tpp.playerEventHandler.Position.Set(position); } - } + + } } diff --git a/Hacks/Unlocks.cs b/Hacks/Unlocks.cs index 43e05bd..2eb479e 100644 --- a/Hacks/Unlocks.cs +++ b/Hacks/Unlocks.cs @@ -12,6 +12,30 @@ namespace SlimeRanger.Hacks { StateHelpers.GetPlayerState().AddUpgrade(up); } + + ProgressDirector progressDirector = UnityEngine.Object.FindObjectOfType(); + foreach (ProgressDirector.ProgressType pt in Enum.GetValues(typeof(ProgressDirector.ProgressType))) + { + progressDirector.AddProgress(pt); + } + + foreach (Gadget.Id id in Enum.GetValues(typeof(Gadget.Id))) + { + SRSingleton.Instance.GadgetDirector.AddBlueprint(id); + } + + progressDirector.AddProgress(ProgressDirector.ProgressType.CORPORATE_PARTNER); + CorporatePartnerUI corporatePartnerUI = UnityEngine.Object.FindObjectOfType(); + corporatePartnerUI.RebuildUI(); + corporatePartnerUI.PlayPurchaseFX(); + SRSingleton.Instance.PediaDirector.UnlockWithoutPopup(PediaDirector.Id.CHROMA); + SRSingleton.Instance.PediaDirector.UnlockWithoutPopup(PediaDirector.Id.SLIME_TOYS); + + PediaDirector pediaDirector = UnityEngine.Object.FindObjectOfType(); + foreach (PediaDirector.Id id in Enum.GetValues(typeof(PediaDirector.Id))) + { + pediaDirector.Unlock(id); + } } } } diff --git a/Hooks/Hooks.cs b/Hooks/Hooks.cs index ab61a69..2ce3627 100644 --- a/Hooks/Hooks.cs +++ b/Hooks/Hooks.cs @@ -3,6 +3,8 @@ using HarmonyLib; using SlimeRanger.Settings; using SlimeRanger.Helpers; using System.Runtime; +using System.Linq; +using System.Reflection; using System; namespace SlimeRanger.Hooks @@ -26,6 +28,21 @@ namespace SlimeRanger.Hooks } } + [HarmonyPatch(typeof(GordoDisplayOnMap))] + [HarmonyPatch(nameof(GordoDisplayOnMap.ShowOnMap))] //annotation boiler plate to tell Harmony what to patch. Refer to docs. + static class GordoDisplayOnMap_ShowOnMap + { + static void Postfix(ref bool __result) + { + if (Settings.Settings.map_reveal) + { + __result = true; + } + + return; + } + } + // Used to delete the fog [HarmonyPatch(typeof(PlayerState))] [HarmonyPatch(nameof(PlayerState.HasUnlockedMap))] //annotation boiler plate to tell Harmony what to patch. Refer to docs. @@ -85,7 +102,7 @@ namespace SlimeRanger.Hooks [HarmonyPatch(typeof(EnergyJetpack))] [HarmonyPatch("CanStart_Jetpack")] //annotation boiler plate to tell Harmony what to patch. Refer to docs. - static class PlayerState_CanStart_Jetpack + static class EnergyJetpack_CanStart_Jetpack { static void Postfix(ref bool __result) { @@ -96,5 +113,75 @@ namespace SlimeRanger.Hooks return; } } + + [HarmonyPatch(typeof(EnergyJetpack))] + [HarmonyPatch("DownwardExtraGravity")] //annotation boiler plate to tell Harmony what to patch. Refer to docs. + static class EnergyJetpack_DownwardExtraGravity + { + static void Prefix(ref float y, ref float yVel) + { + if (Settings.Settings.infinite_jetpack) + { + yVel = 0f; + y = 0f; + } + + return; + } + } + + [HarmonyPatch(typeof(LandPlotUI))] + [HarmonyPatch("BuyPlot")] //annotation boiler plate to tell Harmony what to patch. Refer to docs. + static class LandPlotUI_BuyPlot + { + static void Prefix(ref LandPlotUI.PlotPurchaseItem plot) + { + if (Settings.Settings.max_plot) + { + Settings.Settings.plot = plot; + } + return; + } + } + + [HarmonyPatch(typeof(LandPlotUI))] + [HarmonyPatch("BuyPlot")] //annotation boiler plate to tell Harmony what to patch. Refer to docs. + static class LandPlotUI_BuyPlot_post + { + static void Postfix(ref bool __result) + { + if (__result == true && Settings.Settings.plot != null && Settings.Settings.max_plot) + { + Settings.Settings.plot.plotPrefab.gameObject.SetActive(true); + + LandPlot landPlot = UnityEngine.Object.FindObjectOfType(); + + foreach (LandPlot.Upgrade upgrade in Enum.GetValues(typeof(LandPlot.Upgrade))) + { + if (upgrade == LandPlot.Upgrade.SOLAR_SHIELD) //yeah nah we don't want solar shield, most of the slimes don't need that + { + continue; + } + landPlot.AddUpgrade(upgrade); + } + } + return; + } + } + + [HarmonyPatch(typeof(AmmoModel))] + [HarmonyPatch(nameof(AmmoModel.GetSlotMaxCount))] //annotation boiler plate to tell Harmony what to patch. Refer to docs. + static class AmmoModel_GetSlotMaxCount + { + static void Postfix(ref int __result) + { + if (Settings.Settings.max_slot_override) + { + __result = (int)Settings.Settings.max_slot; + } + + return; + } + } } } diff --git a/Plugin.cs b/Plugin.cs index 65ee7d3..d5c4a35 100644 --- a/Plugin.cs +++ b/Plugin.cs @@ -31,8 +31,19 @@ namespace SlimeRanger if (Settings.Settings.fly) { + Settings.Settings.need_to_restore_gravity = true; + + Physics.set_gravity_Injected(ref Settings.Settings.zero_gravity); Hacks.Misc.Fly(Settings.Settings.fly_speed); } + + if (!Settings.Settings.fly && Settings.Settings.need_to_restore_gravity) + { + Settings.Settings.need_to_restore_gravity = false; + Physics.set_gravity_Injected(ref Settings.Settings.original_gravity); + } + + Time.timeScale = (float)Settings.Settings.time_multiplier; } private void OnGUI() @@ -56,6 +67,13 @@ namespace SlimeRanger fontStyle = FontStyle.Bold }; + GUIStyle Statestoggle_smol; + Statestoggle_smol = new GUIStyle(GUI.skin.toggle) + { + fontSize = 10, + fontStyle = FontStyle.Bold + }; + GUI.contentColor = Color.cyan; GUI.Label(new Rect(200, Settings.Settings.y, 200, 50), "SlimeRanger", StatesLabel); //Titre du menu @@ -124,6 +142,18 @@ namespace SlimeRanger Logger.LogInfo("Teleported to position : " + Settings.Settings.savedposition.ToString()); } } + + Settings.Settings.infinite_jetpack = GUI.Toggle(new Rect(350, Settings.Settings.y + 235, 130, 25), Settings.Settings.infinite_jetpack, "∞ jetpack", Statestoggle); + Settings.Settings.max_plot = GUI.Toggle(new Rect(350, Settings.Settings.y + 265, 130, 25), Settings.Settings.max_plot, "Upgrade plot on buy", Statestoggle_smol); + + Settings.Settings.max_slot_override = GUI.Toggle(new Rect(350, Settings.Settings.y + 290, 130, 25), Settings.Settings.max_slot_override, "Override max slot", Statestoggle_smol); + GUI.Label(new Rect(350, Settings.Settings.y + 310, 200, 30), "Max : "); + Settings.Settings.max_slot = GUI.HorizontalSlider(new Rect(350, Settings.Settings.y + 330, 100, 10), Settings.Settings.max_slot, 0f, 1000f); + GUI.Label(new Rect(455, Settings.Settings.y + 325, 100, 30), ((int)Settings.Settings.max_slot).ToString()); + + GUI.Label(new Rect(500, Settings.Settings.y + 50, 200, 30), "Time multiplier :"); + Settings.Settings.time_multiplier = GUI.HorizontalSlider(new Rect(500, Settings.Settings.y + 70, 100, 10), Settings.Settings.time_multiplier, 1f, 100f); + GUI.Label(new Rect(605, Settings.Settings.y + 65, 100, 30), ((int)Settings.Settings.time_multiplier).ToString()); } } } diff --git a/Settings/Settings.cs b/Settings/Settings.cs index 14be644..74a00f6 100644 --- a/Settings/Settings.cs +++ b/Settings/Settings.cs @@ -11,15 +11,26 @@ namespace SlimeRanger.Settings public static float y = 0; public static Vector3 savedposition; + public static Vector3 original_gravity = new Vector3(0.0f, -9.8f, 0.0f); + public static Vector3 zero_gravity = new Vector3(0f, 0f, 0f); + public static LandPlotUI.PlotPurchaseItem plot; + + public static bool need_to_restore_gravity = false; + + public static bool max_plot = false; public static bool map_reveal = false; + public static bool max_slot_override = false; public static bool godmode = false; public static bool no_rad = false; public static bool infinite_energy = false; + public static bool infinite_jetpack = false; public static bool fly = false; public static float fly_speed = 50f; public static float energy_to_set = 0f; public static float health_to_set = 0f; public static float money_to_add = 0f; + public static float max_slot = 0f; + public static float time_multiplier = 1f; } } diff --git a/SlimeRanger.csproj b/SlimeRanger.csproj index 26ff00f..9f89ad0 100644 --- a/SlimeRanger.csproj +++ b/SlimeRanger.csproj @@ -9,6 +9,14 @@ latest + + 1701;1702;AD0001 + + + + 1701;1702;AD0001 + +