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 Shack Dig Deeper v1.0.0
ShackDigDeeper.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ShackDigDeeper")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ShackDigDeeper")] [assembly: AssemblyTitle("ShackDigDeeper")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace TheShack.DigDeeper { [BepInPlugin("theshack.digdeeper", "Shack Dig Deeper", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] [SynchronizationMode(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "theshack.digdeeper"; public const string PluginName = "Shack Dig Deeper"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; private void Awake() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Settings.Bind(((BaseUnityPlugin)this).Config); Harmony val = new Harmony("theshack.digdeeper"); try { val.PatchAll(Assembly.GetExecutingAssembly()); } catch (Exception arg) { val.UnpatchSelf(); Log.LogError((object)string.Format("{0} could not hook into this game version; the ground keeps the game's 8 m limit. {1}", "Shack Dig Deeper", arg)); return; } Log.LogInfo((object)("Shack Dig Deeper 1.0.0 ready (dig " + Describe(Limits.Down()) + ", raise " + Describe(Limits.Up()) + ").")); } private static string Describe(float limit) { if (!(limit >= 100000f)) { return $"{limit:0.#} m"; } return "no limit"; } } internal static class Settings { public static ConfigEntry<bool> Enabled; public static ConfigEntry<float> DigLimit; public static ConfigEntry<float> RaiseLimit; public static void Bind(ConfigFile config) { int order = 100; Enabled = Bind<bool>("1 - General", "Enabled", value: true, "The limits below replace the game's 8 m. Off: the game's own limit (8 m down, 8 m up)."); DigLimit = Bind<float>("1 - General", "Dig depth limit", 0f, "How far below the original ground you can dig or level, in meters. 0 = no limit. The game's own is 8.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10000f)); RaiseLimit = Bind<float>("1 - General", "Raise height limit", 0f, "How far above the original ground you can raise it, in meters. 0 = no limit. The game's own is 8.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10000f)); ConfigEntry<T> Bind<T>(string section, string key, T value, string description, AcceptableValueBase range = null) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown return config.Bind<T>(section, key, value, new ConfigDescription(description, range, new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true, Order = order-- } })); } } } internal static class Limits { public const float Vanilla = 8f; public const float NoLimit = 100000f; public static float Down() { return Limit(Settings.DigLimit.Value); } public static float Up() { return Limit(Settings.RaiseLimit.Value); } public static float NegDown() { return 0f - Down(); } private static float Limit(float setting) { if (Settings.Enabled.Value) { if (!(setting <= 0f)) { return setting; } return 100000f; } return 8f; } } [HarmonyPatch] internal static class TerrainComp_Limits { private static readonly MethodInfo Clamp = AccessTools.Method(typeof(Mathf), "Clamp", new Type[3] { typeof(float), typeof(float), typeof(float) }, (Type[])null); private static readonly MethodInfo Down = AccessTools.Method(typeof(Limits), "Down", (Type[])null, (Type[])null); private static readonly MethodInfo Up = AccessTools.Method(typeof(Limits), "Up", (Type[])null, (Type[])null); private static readonly MethodInfo NegDown = AccessTools.Method(typeof(Limits), "NegDown", (Type[])null, (Type[])null); private static IEnumerable<MethodBase> TargetMethods() { string[] array = new string[3] { "ApplyToHeightmap", "LevelTerrain", "RaiseTerrain" }; foreach (string text in array) { MethodInfo methodInfo = AccessTools.Method(typeof(TerrainComp), text, (Type[])null, (Type[])null); if (methodInfo == null) { throw new MissingMethodException("TerrainComp", text); } yield return methodInfo; } } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase original) { List<CodeInstruction> list = new List<CodeInstruction>(instructions); List<CodeInstruction> list2 = new List<CodeInstruction>(list); int num = 0; for (int i = 0; i < list2.Count; i++) { if (!(list2[i].opcode != OpCodes.Ldc_R4) && list2[i].operand is float num2 && Mathf.Abs(num2) == 8f && FeedsClamp(list2, i)) { OpCode opCode = ((i + 1 < list2.Count) ? list2[i + 1].opcode : OpCodes.Nop); MethodInfo operand = ((num2 < 0f) ? NegDown : ((opCode == OpCodes.Sub) ? Down : Up)); CodeInstruction val = list2[i].Clone(); val.opcode = OpCodes.Call; val.operand = operand; list2[i] = val; num++; } } if (num != 2) { Plugin.Log.LogWarning((object)($"TerrainComp.{original.Name} has {num} terrain limits instead of 2 (the game changed); " + "it keeps the game's 8 m there.")); return list; } return list2; } private static bool FeedsClamp(List<CodeInstruction> code, int index) { for (int i = index + 1; i < code.Count && i <= index + 6; i++) { if ((code[i].opcode == OpCodes.Call || code[i].opcode == OpCodes.Callvirt) && code[i].operand as MethodInfo == Clamp) { return true; } } return false; } } }