Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Hoe Radius by Aedonthorn v0.4.2
HoeRadius.dll
Decompiled a year agousing System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using TMPro; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+2da1c09c11a0e71dba555b0f5cf24df78b00482b")] [assembly: AssemblyVersion("1.0.0.0")] public class AedenthornUtils { public static bool IgnoreKeyPresses(bool extra = false) { if (!extra) { int result; if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog()) { Chat instance = Chat.instance; result = ((instance != null && instance.HasFocus()) ? 1 : 0); } else { result = 1; } return (byte)result != 0; } int result2; if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog()) { Chat instance2 = Chat.instance; if ((instance2 == null || !instance2.HasFocus()) && !StoreGui.IsVisible() && !InventoryGui.IsVisible() && !Menu.IsVisible()) { TextViewer instance3 = TextViewer.instance; result2 = ((instance3 != null && instance3.IsVisible()) ? 1 : 0); goto IL_00d2; } } result2 = 1; goto IL_00d2; IL_00d2: return (byte)result2 != 0; } public static bool CheckKeyDown(string value) { try { string[] array = value.Split(new char[1] { ',' }); foreach (string text in array) { if (Input.GetKeyDown(text.ToLower())) { return true; } } } catch { } return false; } public static bool CheckKeyUp(string value) { try { string[] array = value.Split(new char[1] { ',' }); foreach (string text in array) { if (Input.GetKeyUp(text.ToLower())) { return true; } } } catch { } return false; } public static bool CheckKeyHeld(string value, bool req = true) { try { string[] array = value.Split(new char[1] { ',' }); foreach (string text in array) { if (Input.GetKey(text.ToLower())) { return true; } } } catch { } return !req; } public static void ShuffleList<T>(List<T> list) { int num = list.Count; while (num > 1) { num--; int index = Random.Range(0, num); T value = list[index]; list[index] = list[num]; list[num] = value; } } public static string GetAssetPath(object obj, bool create = false) { return GetAssetPath(obj.GetType().Namespace, create); } public static string GetAssetPath(string name, bool create = false) { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name); if (create && !Directory.Exists(text)) { Directory.CreateDirectory(text); } return text; } public static string GetTransformPath(Transform t) { if (!Object.op_Implicit((Object)(object)t.parent)) { return ((Object)t).name; } return GetTransformPath(t.parent) + "/" + ((Object)t).name; } public static byte[] EncodeToPNG(Texture2D texture) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown RenderTexture temporary = RenderTexture.GetTemporary(((Texture)texture).width, ((Texture)texture).height, 0, (RenderTextureFormat)7, (RenderTextureReadWrite)0); Graphics.Blit((Texture)(object)texture, temporary); RenderTexture active = RenderTexture.active; RenderTexture.active = temporary; Texture2D val = new Texture2D(((Texture)texture).width, ((Texture)texture).height, (TextureFormat)4, true, false); val.ReadPixels(new Rect(0f, 0f, (float)((Texture)temporary).width, (float)((Texture)temporary).height), 0, 0); val.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Texture2D val2 = new Texture2D(((Texture)texture).width, ((Texture)texture).height); val2.SetPixels(val.GetPixels()); val2.Apply(); return ImageConversion.EncodeToPNG(val2); } } namespace HoeRadius; [BepInPlugin("aedenthorn.HoeRadius", "Hoe Radius", "0.4.0")] public class BepInExPlugin : BaseUnityPlugin { [HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")] public static class ZInput_GetMouseScrollWheel_Patch { public static bool Prefix(ref float __result) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (!modEnabled.Value || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || !((Character)Player.m_localPlayer).InPlaceMode() || Hud.IsPieceSelectionVisible() || !useScrollWheel.Value || ((int)scrollModKey.Value != 0 && !Input.GetKey(scrollModKey.Value))) { return true; } __result = 0f; return false; } } [HarmonyPatch(typeof(TerrainOp), "Awake")] private static class TerrainOp_Patch { private static void Prefix(TerrainOp __instance) { if (modEnabled.Value) { if (__instance.m_settings.m_level) { Settings settings = __instance.m_settings; settings.m_levelRadius += lastTotalDelta; Dbgl($"Applying level radius {__instance.m_settings.m_levelRadius}"); } if (__instance.m_settings.m_raise) { Settings settings2 = __instance.m_settings; settings2.m_raiseRadius += lastTotalDelta; Dbgl($"Applying raise radius {__instance.m_settings.m_raiseRadius}"); } if (__instance.m_settings.m_smooth) { Settings settings3 = __instance.m_settings; settings3.m_smoothRadius += lastTotalDelta; Dbgl($"Applying smooth radius {__instance.m_settings.m_smoothRadius}"); } if (__instance.m_settings.m_paintCleared) { Settings settings4 = __instance.m_settings; settings4.m_paintRadius += lastTotalDelta; Dbgl($"Applying paint radius {__instance.m_settings.m_paintRadius}"); } } } } [HarmonyPatch(typeof(Terminal), "InputText")] private static class InputText_Patch { private static bool Prefix(Terminal __instance) { if (!modEnabled.Value) { return true; } string text = ((TMP_InputField)__instance.m_input).text; if (text.ToLower().Equals(typeof(BepInExPlugin).Namespace.ToLower() + " reset")) { ((BaseUnityPlugin)context).Config.Reload(); ((BaseUnityPlugin)context).Config.Save(); Traverse.Create((object)__instance).Method("AddString", new object[1] { text }).GetValue(); Traverse.Create((object)__instance).Method("AddString", new object[1] { ((BaseUnityPlugin)context).Info.Metadata.Name + " config reloaded" }).GetValue(); return false; } return true; } } public static ConfigEntry<bool> modEnabled; public static ConfigEntry<bool> isDebug; public static ConfigEntry<int> nexusID; public static ConfigEntry<bool> useScrollWheel; public static ConfigEntry<KeyCode> scrollModKey; public static ConfigEntry<KeyCode> increaseHotKey; public static ConfigEntry<KeyCode> decreaseHotKey; public static ConfigEntry<float> scrollWheelScale; public static ConfigEntry<float> hotkeyScale; public static BepInExPlugin context; public static float lastOriginalRadius; public static float lastModdedRadius; public static float lastTotalDelta; public static void Dbgl(string str = "", bool pref = true) { if (isDebug.Value) { Debug.Log((object)((pref ? (typeof(BepInExPlugin).Namespace + " ") : "") + str)); } } public void Awake() { context = this; modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable this mod"); isDebug = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "IsDebug", true, "Enable debug logs"); nexusID = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NexusID", 1199, "Nexus mod ID for updates"); useScrollWheel = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "UseScrollWheel", true, "Use scroll wheel to modify radius"); scrollWheelScale = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "ScrollWheelScale", 0.3f, "Scroll wheel change scale"); scrollModKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Settings", "ScrollModKey", (KeyCode)308, "Modifer key to allow scroll wheel change."); decreaseHotKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Settings", "DecreaseHotKey", (KeyCode)61, "Hotkey to decrease radius."); increaseHotKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Settings", "IncreaseHotKey", (KeyCode)45, "Hotkey to increase radius."); hotkeyScale = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "HotkeyScale", 0.03f, "Hotkey change scale"); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); } public void Update() { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) if (!modEnabled.Value || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || !((Character)Player.m_localPlayer).InPlaceMode() || Hud.IsPieceSelectionVisible()) { if (lastOriginalRadius != 0f) { lastOriginalRadius = 0f; lastModdedRadius = 0f; lastTotalDelta = 0f; SetRadius(0f); } } else if (useScrollWheel.Value && ((int)scrollModKey.Value == 0 || Input.GetKey(scrollModKey.Value)) && Input.mouseScrollDelta.y != 0f) { SetRadius(Input.mouseScrollDelta.y * scrollWheelScale.Value); } else if (Input.GetKey(increaseHotKey.Value)) { SetRadius(hotkeyScale.Value); } else if (Input.GetKey(decreaseHotKey.Value)) { SetRadius(0f - hotkeyScale.Value); } } public void SetRadius(float delta) { //IL_0255: Unknown result type (might be due to invalid IL or missing references) Traverse obj = Traverse.Create((object)Player.m_localPlayer).Field("m_buildPieces"); object obj2; if (obj == null) { obj2 = null; } else { PieceTable value = obj.GetValue<PieceTable>(); obj2 = ((value != null) ? value.GetSelectedPiece() : null); } Piece val = (Piece)obj2; if (val == null) { return; } TerrainOp val2 = ((val != null) ? ((Component)val).gameObject.GetComponent<TerrainOp>() : null); if ((Object)(object)val2 == (Object)null) { return; } float num = 0f; float num2 = Mathf.Max(lastModdedRadius + delta, 0f); lastTotalDelta += delta; if (lastOriginalRadius == 0f) { if (val2.m_settings.m_level && num < val2.m_settings.m_levelRadius) { num = val2.m_settings.m_levelRadius; num2 = Mathf.Max(val2.m_settings.m_levelRadius + delta, 0f); } if (val2.m_settings.m_raise && num < val2.m_settings.m_raiseRadius) { num = val2.m_settings.m_raiseRadius; num2 = Mathf.Max(val2.m_settings.m_raiseRadius + delta, 0f); } if (val2.m_settings.m_smooth && num < val2.m_settings.m_smoothRadius) { num = val2.m_settings.m_smoothRadius; num2 = Mathf.Max(val2.m_settings.m_smoothRadius + delta, 0f); } if (val2.m_settings.m_paintCleared && num < val2.m_settings.m_paintRadius) { num = val2.m_settings.m_paintRadius; num2 = Mathf.Max(val2.m_settings.m_paintRadius + delta, 0f); } lastOriginalRadius = num; } lastModdedRadius = num2; if (lastOriginalRadius > 0f && lastModdedRadius > 0f) { GameObject value2 = Traverse.Create((object)Player.m_localPlayer).Field("m_placementGhost").GetValue<GameObject>(); Transform val3 = ((value2 != null) ? value2.transform.Find("_GhostOnly") : null); if ((Object)(object)val3 != (Object)null) { val3.localScale = new Vector3(lastModdedRadius / lastOriginalRadius, lastModdedRadius / lastOriginalRadius, lastModdedRadius / lastOriginalRadius); } } } }