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 MyDirtyHoe v2.0.8
plugins/MyDirtyHoe.dll
Decompiled 7 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Extensions; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using MyDirtyHoe.ConsoleCommands; using Splatform; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("MyDirtyHoe")] [assembly: AssemblyDescription("https://www.nexusmods.com/profile/MagicMikeMods/mods")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("MagicMike")] [assembly: AssemblyProduct("MyDirtyHoe")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("2.0.8")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.8.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 MyDirtyHoe { internal class Heightmap_Patches { [HarmonyPatch(typeof(TerrainComp))] private static class Heightmap_Patch { [HarmonyPriority(400)] [HarmonyTranspiler] [HarmonyPatch(typeof(TerrainComp), "LevelTerrain")] public static IEnumerable<CodeInstruction> TerrainCompLevelTerrainTranspiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)(-8f))) { yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null)); } else if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)8f)) { yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null)); } else { yield return instruction; } } } [HarmonyPriority(400)] [HarmonyTranspiler] [HarmonyPatch(typeof(TerrainComp), "RaiseTerrain")] public static IEnumerable<CodeInstruction> TerrainCompRaiseTerrainTranspiler(IEnumerable<CodeInstruction> instructions) { foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)(-8f))) { yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null)); } else if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)8f)) { yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null)); } else { yield return instruction; } } } [HarmonyPriority(400)] [HarmonyTranspiler] [HarmonyPatch(typeof(TerrainComp), "ApplyToHeightmap")] public static IEnumerable<CodeInstruction> TerrainCompApplyToHeightmapTranspiler(IEnumerable<CodeInstruction> instructions) { int i = 0; foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)(-8f))) { yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null)); } else if (CodeInstructionExtensions.Is(instruction, OpCodes.Ldc_R4, (object)8f)) { if (i == 0) { yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "MinAbs", (Type[])null, (Type[])null)); } else { yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null)); } i++; } else { yield return instruction; } } } } } internal static class Radius_Patches { [HarmonyPatch(typeof(Settings), "Serialize")] private static class Serialize_Patch { private static void Postfix(ZPackage pkg, Object prefab) { try { if (MainConfig.modEnabled.Value && pkg != null) { float num = DeltaOf(AsTerrainOp(prefab)); if (num != 0f && !float.IsNaN(num) && !float.IsInfinity(num)) { pkg.Write(1213154628); pkg.Write(num); } } } catch (Exception e) { WarnOnce("serialize", e); } } } [HarmonyPatch(typeof(Settings), "Deserialize")] private static class Deserialize_Patch { private static void Postfix(ZPackage pkg, ref Settings __result) { try { if (__result == null || pkg == null || pkg.Size() - pkg.GetPos() < 8) { return; } int pos = pkg.GetPos(); if (pkg.ReadInt() != 1213154628) { pkg.SetPos(pos); return; } float num = pkg.ReadSingle(); if (num != 0f && !float.IsNaN(num) && !float.IsInfinity(num)) { __result = WithDelta(__result, num); } } catch (Exception e) { WarnOnce("deserialize", e); } } } internal const int Magic = 1213154628; private static readonly MethodInfo _clone = typeof(object).GetMethod("MemberwiseClone", BindingFlags.Instance | BindingFlags.NonPublic); private static bool _warned; private static void WarnOnce(string what, Exception e) { if (!_warned) { _warned = true; Logger.LogWarning((object)("[MyDirtyHoe] radius-over-the-wire " + what + " failed; " + $"operations continue at default size: {e}")); } } private static TerrainOp AsTerrainOp(Object o) { TerrainOp val = (TerrainOp)(object)((o is TerrainOp) ? o : null); if (val != null) { return val; } GameObject val2 = (GameObject)(object)((o is GameObject) ? o : null); if (val2 != null) { return val2.GetComponent<TerrainOp>(); } Component val3 = (Component)(object)((o is Component) ? o : null); if (val3 != null) { return val3.GetComponent<TerrainOp>(); } return null; } internal static float DeltaOf(TerrainOp placed) { if ((Object)(object)placed == (Object)null || placed.m_settings == null || (Object)(object)ObjectDB.instance == (Object)null) { return 0f; } int stableHashCode = StringExtensionMethods.GetStableHashCode(Utils.GetPrefabName(((Object)((Component)placed).gameObject).name)); TerrainOp val = default(TerrainOp); if (!ObjectDB.instance.TryGetTerrainOp(stableHashCode, ref val) || (Object)(object)val == (Object)null || val.m_settings == null) { return 0f; } Settings settings = placed.m_settings; Settings settings2 = val.m_settings; if (settings.m_level) { return settings.m_levelRadius - settings2.m_levelRadius; } if (settings.m_raise) { return settings.m_raiseRadius - settings2.m_raiseRadius; } if (settings.m_smooth) { return settings.m_smoothRadius - settings2.m_smoothRadius; } if (settings.m_paintCleared) { return settings.m_paintRadius - settings2.m_paintRadius; } return 0f; } internal static Settings WithDelta(Settings src, float delta) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown Settings val = (Settings)_clone.Invoke(src, null); if (val.m_level) { val.m_levelRadius = Math.Max(val.m_levelRadius + delta, 0f); } if (val.m_raise) { val.m_raiseRadius = Math.Max(val.m_raiseRadius + delta, 0f); } if (val.m_smooth) { val.m_smoothRadius = Math.Max(val.m_smoothRadius + delta, 0f); } if (val.m_paintCleared) { val.m_paintRadius = Math.Max(val.m_paintRadius + delta, 0f); } return val; } } [HarmonyPatch(typeof(ObjectDB), "UpdateRegisters")] internal static class TerrainOP_Registry_Patches { private static List<TerrainOp> _ours; private static List<TerrainOp> Ours() { if (_ours != null) { return _ours; } _ours = new List<TerrainOp>(); AssetBundle dirtyhoe = MyDirtyHoeMod.dirtyhoe; if ((Object)(object)dirtyhoe == (Object)null) { return _ours; } GameObject[] array = dirtyhoe.LoadAllAssets<GameObject>(); foreach (GameObject val in array) { if (!((Object)(object)val == (Object)null)) { TerrainOp component = val.GetComponent<TerrainOp>(); if ((Object)(object)component != (Object)null) { _ours.Add(component); } } } Logger.LogInfo((object)$"[MyDirtyHoe] {_ours.Count} terrain op prefab(s) to register with ObjectDB"); return _ours; } private static void Prefix(ObjectDB __instance) { if ((Object)(object)__instance == (Object)null || __instance.m_terrainOps == null) { return; } int num = 0; foreach (TerrainOp item in Ours()) { if ((Object)(object)item != (Object)null && !__instance.m_terrainOps.Contains(item)) { __instance.m_terrainOps.Add(item); num++; } } if (num > 0) { Logger.LogInfo((object)($"[MyDirtyHoe] registered {num} terrain op(s) with ObjectDB " + $"(total {__instance.m_terrainOps.Count})")); } } } internal class TerrainReset_Patches { [HarmonyPatch(typeof(TerrainOp), "Awake")] private static class TerrainOp_Patch { private static void Prefix(TerrainOp __instance) { if (__instance.m_settings.m_level) { Settings settings = __instance.m_settings; settings.m_levelRadius += MyDirtyHoeMod.lastTotalDelta; if (MainConfig.toolShape.Value == MainConfig.Shape.Circle) { __instance.m_settings.m_square = false; } else { __instance.m_settings.m_square = true; } } if (__instance.m_settings.m_raise) { Settings settings2 = __instance.m_settings; settings2.m_raiseRadius += MyDirtyHoeMod.lastTotalDelta; } if (__instance.m_settings.m_smooth) { Settings settings3 = __instance.m_settings; settings3.m_smoothRadius += MyDirtyHoeMod.lastTotalDelta; } if (__instance.m_settings.m_paintCleared) { Settings settings4 = __instance.m_settings; settings4.m_paintRadius += MyDirtyHoeMod.lastTotalDelta; } } } [HarmonyPatch(typeof(TerrainComp), "ApplyOperation")] private static class Patch_TerrainComp_ApplyOperation { private static bool Prefix(TerrainOp modifier) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (MainConfig.modEnabled.Value && CheckKeyHeld(MyDirtyHoeMod.GetToolModKey())) { ResetTerrain(((Component)modifier).transform.position, (MyDirtyHoeMod.GetToolRadius() > 0f) ? MyDirtyHoeMod.GetToolRadius() : modifier.GetRadius()); return false; } return true; } } [HarmonyPatch(typeof(TerrainOp), "OnPlaced")] private static class Patch_TerrainOp_OnPlaced { private static bool Prefix() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) if (!MainConfig.modEnabled.Value) { return !CheckKeyHeld(MyDirtyHoeMod.GetToolModKey()); } return true; } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] private static class Patch_Terminal_InitTerminal { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__1_0; internal void <Postfix>b__1_0(ConsoleEventArgs args) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) float result; if (args.Length < 2) { args.Context.AddString("Syntax: resetterrain [radius]"); } else if (float.TryParse(args[1], out result)) { int num = ResetTerrain(((Component)Player.m_localPlayer).transform.position, result); args.Context.AddString($"{num} edits reset."); } else { args.Context.AddString("Invalid command, syntax: resetterrain [radius as a float]"); } } } [HarmonyPriority(800)] private static void Prefix(out bool __state) { __state = (bool)AccessTools.Field(typeof(Terminal), "m_terminalInitialized").GetValue(null); } private static void Postfix(bool __state) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown if (__state || !MainConfig.modEnabled.Value) { return; } Logger.LogInfo((object)"Adding Terminal Command \"resetterrain\"."); try { object obj = <>c.<>9__1_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) float result; if (args.Length < 2) { args.Context.AddString("Syntax: resetterrain [radius]"); } else if (float.TryParse(args[1], out result)) { int num = ResetTerrain(((Component)Player.m_localPlayer).transform.position, result); args.Context.AddString($"{num} edits reset."); } else { args.Context.AddString("Invalid command, syntax: resetterrain [radius as a float]"); } }; <>c.<>9__1_0 = val; obj = (object)val; } new ConsoleCommand("resetterrain", "[name] [radius]", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } catch (Exception ex) { Logger.LogWarning((object)"Error, could not add terminal command. This can happen when two mods add the same command. The rest of this mod should work as expected."); Logger.LogWarning((object)ex); } } } private static readonly TerrainReset_Patches _instance = new TerrainReset_Patches(); public static TerrainReset_Patches Instance => _instance; private TerrainReset_Patches() { } public static bool IgnoreKeyPresses() { if (!((Object)(object)ZNetScene.instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !Minimap.IsOpen() && !Console.IsVisible() && !TextInput.IsVisible() && !ZNet.instance.InPasswordDialog() && (!((Object)(object)Chat.instance != (Object)null) || !Chat.instance.HasFocus()) && !StoreGui.IsVisible() && !InventoryGui.IsVisible() && !Menu.IsVisible()) { if ((Object)(object)TextViewer.instance != (Object)null) { return TextViewer.instance.IsVisible(); } return false; } return true; } public static bool CheckKeyDown(KeyCode value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ZInput.GetKeyDown(value, true); } public static bool CheckKeyHeld(KeyCode value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ZInput.GetKey(value, true); } public static int ResetTerrain(Vector3 center, float radius) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) int num = 0; List<Heightmap> list = new List<Heightmap>(); Heightmap.FindHeightmap(center, radius + 100f, list); foreach (TerrainModifier allInstance in TerrainModifier.GetAllInstances()) { Vector3 position = ((Component)allInstance).transform.position; ZNetView component = ((Component)allInstance).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid() || !(Utils.DistanceXZ(position, center) <= radius)) { continue; } if (!component.IsOwner()) { component.ClaimOwnership(); } num++; foreach (Heightmap item in list) { if (item.TerrainVSModifier(allInstance)) { item.Poke(1, false); } } component.Destroy(); } using (List<Heightmap>.Enumerator enumerator3 = list.GetEnumerator()) { int num2 = default(int); int num3 = default(int); int num4 = default(int); int num5 = default(int); while (enumerator3.MoveNext()) { TerrainComp val = TerrainComp.FindTerrainCompiler(((Component)enumerator3.Current).transform.position); if (!Object.op_Implicit((Object)(object)val)) { continue; } if (!Terrain_Comp.NView.Invoke(val).IsOwner()) { Terrain_Comp.NView.Invoke(val).ClaimOwnership(); } if (!Terrain_Comp.Initialized.Invoke(val)) { continue; } enumerator3.Current.WorldToVertex(center, ref num2, ref num3); enumerator3.Current.WorldToVertexMask(center, ref num4, ref num5); bool flag = false; int num6 = Terrain_Comp.Width.Invoke(val) + 1; for (int i = 0; i < num6; i++) { for (int j = 0; j < num6; j++) { int num7 = i * num6 + j; if (CoordDistance(num2, num3, j, i) <= radius && Terrain_Comp.ModifiedHeight.Invoke(val)[num7]) { num++; flag = true; Terrain_Comp.ModifiedHeight.Invoke(val)[num7] = false; Terrain_Comp.LevelDelta.Invoke(val)[num7] = 0f; Terrain_Comp.SmoothDelta.Invoke(val)[num7] = 0f; } if (CoordDistance(num4, num5, j, i) <= radius && Terrain_Comp.ModifiedPaint.Invoke(val)[num7]) { flag = true; Terrain_Comp.ModifiedPaint.Invoke(val)[num7] = false; Terrain_Comp.PaintMask.Invoke(val)[num7] = Color.clear; } } } if (flag) { Terrain_Comp.Save(val); enumerator3.Current.Poke(1, false); } } } if ((Object)(object)ClutterSystem.instance != (Object)null) { ClutterSystem.instance.ResetGrass(center, radius); } return num; } private static float CoordDistance(float x, float y, float rx, float ry) { float num = x - rx; float num2 = y - ry; return Mathf.Sqrt(num * num + num2 * num2); } } internal class FileWatcher { public static void WatchFileChanges(string path, Action onChanged) { FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(); string directoryName = Path.GetDirectoryName(path); string fileName = Path.GetFileName(path); fileSystemWatcher.Path = directoryName; fileSystemWatcher.Filter = fileName; fileSystemWatcher.NotifyFilter = NotifyFilters.FileName | NotifyFilters.LastWrite; fileSystemWatcher.Changed += delegate { onChanged?.Invoke(); }; fileSystemWatcher.Deleted += delegate { onChanged?.Invoke(); }; fileSystemWatcher.Created += delegate { onChanged?.Invoke(); }; fileSystemWatcher.Renamed += delegate { onChanged?.Invoke(); }; fileSystemWatcher.EnableRaisingEvents = true; } public static void WatchTranslationChanges(string path, Action onChanged) { if (!Directory.Exists(MyDirtyHoeMod.TranslationFilePath)) { return; } try { WatchFileChanges(Path.Combine(path, "*.*"), onChanged); } catch { Logger.LogError((object)"There was an issue loading Translation files!"); } } } internal class KeyUtils { public static bool IgnoreKeyPresses(bool extra = false) { if (!extra) { 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; if ((Object)(object)instance == (Object)null || !instance.HasFocus()) { return Menu.IsVisible(); } } return true; } 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 (((Object)(object)instance2 == (Object)null || !instance2.HasFocus()) && !StoreGui.IsVisible() && !InventoryGui.IsVisible() && !Menu.IsVisible()) { TextViewer instance3 = TextViewer.instance; if ((Object)(object)instance3 != (Object)null) { return instance3.IsVisible(); } return false; } } return true; } public static bool CheckKeyDown(string value) { try { return Input.GetKeyDown(value.ToLower()); } catch { return false; } } public static bool CheckKeyHeld(string value, bool req = true) { try { return Input.GetKey(value.ToLower()); } catch { return !req; } } } internal class LocalisedText { public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization(); public static void AddLocalisations() { CustomLocalization localization = Localization; string text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string> { { "item_dirty_hoe", "Dirty Hoe" }, { "item_dirty_hoe_desc", "A much better Hoe!" }, { "piece_hoe_smooth", "Smooth Terrain" }, { "piece_hoe_flatten", "Flatten Terrain" }, { "piece_hoe_lower", "Lower Terrain" }, { "piece_hoe_raise", "Raise Terrain" }, { "piece_hoe_cultivate_smooth", "Cultivate Smooth" }, { "piece_hoe_cultivate_flatten", "Cultivate Flatten" }, { "piece_hoe_paved_smooth", "Stone Paving Smooth" }, { "piece_hoe_paved_flatten", "Stone Paving Flatten" }, { "piece_hoe_path", "Dirt Path" }, { "piece_hoe_paint_dirt", "Paint Dirt" }, { "piece_hoe_paint_cultivate", "Paint Cultivate" }, { "piece_hoe_paint_paved", "Paint Paved" }, { "piece_hoe_paint_grass", "Paint Grass" }, { "mm_hoe_boost", "Hoe Boost" }, { "mm_hoe_boost_started", "Hoe Boost Started!" }, { "mm_hoe_boost_stopped", "Hoe Boost Stopped!" } }); } } internal static class Terrain_Comp { internal static readonly FieldRef<TerrainComp, bool> Initialized = AccessTools.FieldRefAccess<TerrainComp, bool>("m_initialized"); internal static readonly FieldRef<TerrainComp, int> Width = AccessTools.FieldRefAccess<TerrainComp, int>("m_width"); internal static readonly FieldRef<TerrainComp, bool[]> ModifiedHeight = AccessTools.FieldRefAccess<TerrainComp, bool[]>("m_modifiedHeight"); internal static readonly FieldRef<TerrainComp, float[]> LevelDelta = AccessTools.FieldRefAccess<TerrainComp, float[]>("m_levelDelta"); internal static readonly FieldRef<TerrainComp, float[]> SmoothDelta = AccessTools.FieldRefAccess<TerrainComp, float[]>("m_smoothDelta"); internal static readonly FieldRef<TerrainComp, bool[]> ModifiedPaint = AccessTools.FieldRefAccess<TerrainComp, bool[]>("m_modifiedPaint"); internal static readonly FieldRef<TerrainComp, Color[]> PaintMask = AccessTools.FieldRefAccess<TerrainComp, Color[]>("m_paintMask"); internal static readonly FieldRef<TerrainComp, ZNetView> NView = AccessTools.FieldRefAccess<TerrainComp, ZNetView>("m_nview"); private static readonly MethodInfo _save = AccessTools.Method(typeof(TerrainComp), "Save", new Type[1] { typeof(bool) }, (Type[])null); internal static void Save(TerrainComp comp, bool paintOnly = false) { _save.Invoke(comp, new object[1] { paintOnly }); } } internal class AddPrefabs { public static EffectList buildHoe; public static EffectList buildCultivater; public static EffectList buildStone; public static EffectList pickablePick; public static EffectList pickablePlace; public static EffectList pickableHit; public static EffectList pickableDestroy; public static CustomPiece _customPiece; public static void LoadPrefabs() { AddFX(); AddSmooth(); AddFlatten(); AddLower(); AddRaise(); AddCultivateSmooth(); AddCultivateFlatten(); AddHoePavedSmooth(); AddHoePavedFlatten(); AddHoeDirtPath(); AddPlaceableStone(); AddPlaceableRock01(); AddPlaceableRock02(); AddPaintDirt(); AddPaintCultivate(); AddPaintPaved(); AddPaintGrass(); } public static void AddFX() { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Expected O, but got Unknown //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Expected O, but got Unknown GameObject prefab = Cache.GetPrefab<GameObject>("sfx_build_hoe"); GameObject prefab2 = Cache.GetPrefab<GameObject>("sfx_build_cultivator"); GameObject prefab3 = Cache.GetPrefab<GameObject>("sfx_build_hammer_stone"); GameObject prefab4 = Cache.GetPrefab<GameObject>("sfx_pickable_pick"); GameObject prefab5 = Cache.GetPrefab<GameObject>("vfx_pickable_pick"); Cache.GetPrefab<GameObject>("vfx_Place_wood_pole"); GameObject prefab6 = Cache.GetPrefab<GameObject>("sfx_build_hammer_stone"); GameObject prefab7 = Cache.GetPrefab<GameObject>("sfx_rock_hit"); GameObject prefab8 = Cache.GetPrefab<GameObject>("sfx_rock_destroyed"); EffectList val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = prefab } }; buildHoe = val; val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = prefab2 } }; buildCultivater = val; val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = prefab3 } }; buildStone = val; val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[2] { new EffectData { m_prefab = prefab4 }, new EffectData { m_prefab = prefab5 } }; pickablePick = val; val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = prefab6 } }; pickablePlace = val; val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = prefab7 } }; pickableHit = val; val = new EffectList(); val.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { new EffectData { m_prefab = prefab8 } }; pickableDestroy = val; } public static void AddSmooth() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_smooth"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); obj.GetComponent<Piece>().m_placeEffect = buildHoe; PieceManager.Instance.AddPiece(_customPiece); } public static void AddFlatten() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown GameObject val = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_flatten"); _customPiece = new CustomPiece(val, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); val.GetComponent<Piece>().m_placeEffect = buildHoe; if (MainConfig.toolShape.Value == MainConfig.Shape.Circle) { val.GetComponent<TerrainOp>().m_settings.m_square = false; } else { val.GetComponent<TerrainOp>().m_settings.m_square = true; } PieceManager.Instance.AddPiece(_customPiece); } public static void AddLower() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_lower"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); obj.GetComponent<Piece>().m_placeEffect = buildStone; PieceManager.Instance.AddPiece(_customPiece); } public static void AddRaise() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown GameObject val = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_raise"); if (MainConfig.resourceCosts.Value) { PieceConfig val2 = new PieceConfig(); val2.PieceTable = "_DirtyHoePieceTable"; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "Stone", Amount = 2 } }; _customPiece = new CustomPiece(val, true, val2); } else { _customPiece = new CustomPiece(val, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); } val.GetComponent<Piece>().m_placeEffect = buildHoe; PieceManager.Instance.AddPiece(_customPiece); } public static void AddCultivateSmooth() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_cultivate_smooth"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); obj.GetComponent<Piece>().m_placeEffect = buildCultivater; PieceManager.Instance.AddPiece(_customPiece); } public static void AddCultivateFlatten() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown GameObject val = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_cultivate_flatten"); _customPiece = new CustomPiece(val, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); val.GetComponent<Piece>().m_placeEffect = buildCultivater; if (MainConfig.toolShape.Value == MainConfig.Shape.Circle) { val.GetComponent<TerrainOp>().m_settings.m_square = false; } else { val.GetComponent<TerrainOp>().m_settings.m_square = true; } PieceManager.Instance.AddPiece(_customPiece); } public static void AddHoePavedSmooth() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown GameObject val = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_paved_smooth"); if (MainConfig.resourceCosts.Value) { PieceConfig val2 = new PieceConfig(); val2.PieceTable = "_DirtyHoePieceTable"; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "Stone", Amount = 1 } }; _customPiece = new CustomPiece(val, true, val2); } else { _customPiece = new CustomPiece(val, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); } val.GetComponent<Piece>().m_placeEffect = buildHoe; PieceManager.Instance.AddPiece(_customPiece); } public static void AddHoePavedFlatten() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown GameObject val = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_paved_flatten"); if (MainConfig.resourceCosts.Value) { PieceConfig val2 = new PieceConfig(); val2.PieceTable = "_DirtyHoePieceTable"; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "Stone", Amount = 1 } }; _customPiece = new CustomPiece(val, true, val2); } else { _customPiece = new CustomPiece(val, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); } val.GetComponent<Piece>().m_placeEffect = buildHoe; if (MainConfig.toolShape.Value == MainConfig.Shape.Circle) { val.GetComponent<TerrainOp>().m_settings.m_square = false; } else { val.GetComponent<TerrainOp>().m_settings.m_square = true; } PieceManager.Instance.AddPiece(_customPiece); } public static void AddHoeDirtPath() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_dirt_path"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); obj.GetComponent<Piece>().m_placeEffect = buildHoe; PieceManager.Instance.AddPiece(_customPiece); } public static void AddPlaceableStone() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown GameObject val = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_place_stone"); if (MainConfig.resourceCosts.Value) { PieceConfig val2 = new PieceConfig(); val2.PieceTable = "_DirtyHoePieceTable"; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "Stone", Amount = 1 } }; _customPiece = new CustomPiece(val, true, val2); } else { _customPiece = new CustomPiece(val, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); } val.GetComponent<Pickable>().m_pickEffector = pickablePick; WearNTear component = val.GetComponent<WearNTear>(); component.m_destroyedEffect = pickableDestroy; component.m_hitEffect = pickableHit; val.GetComponent<Piece>().m_placeEffect = pickablePlace; PieceManager.Instance.AddPiece(_customPiece); } public static void AddPlaceableRock01() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown GameObject val = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_place_rock_01"); if (MainConfig.resourceCosts.Value) { PieceConfig val2 = new PieceConfig(); val2.PieceTable = "_DirtyHoePieceTable"; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "Stone", Amount = 10 } }; _customPiece = new CustomPiece(val, true, val2); } else { _customPiece = new CustomPiece(val, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); } Destructible component = val.GetComponent<Destructible>(); component.m_destroyedEffect = pickableDestroy; component.m_hitEffect = pickableHit; val.GetComponent<Piece>().m_placeEffect = pickablePlace; PieceManager.Instance.AddPiece(_customPiece); } public static void AddPlaceableRock02() { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown GameObject prefab = Cache.GetPrefab<GameObject>("Rock_3_frac"); GameObject val = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_place_rock_02"); if (MainConfig.resourceCosts.Value) { PieceConfig val2 = new PieceConfig(); val2.PieceTable = "_DirtyHoePieceTable"; val2.Category = "Rocks"; val2.Usage = new string[1] { PieceUsages.Misc }; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "Stone", Amount = 25 } }; _customPiece = new CustomPiece(val, true, val2); } else { PieceConfig val2 = new PieceConfig(); val2.PieceTable = "_DirtyHoePieceTable"; val2.Category = "Rocks"; val2.Usage = new string[1] { PieceUsages.Misc }; _customPiece = new CustomPiece(val, true, val2); } val.GetComponent<Destructible>().m_spawnWhenDestroyed = prefab; val.GetComponent<Piece>().m_placeEffect = pickablePlace; PieceManager.Instance.AddPiece(_customPiece); } public static void AddPaintDirt() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_paint_dirt"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); obj.GetComponent<Piece>().m_placeEffect = buildCultivater; PieceManager.Instance.AddPiece(_customPiece); } public static void AddPaintCultivate() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_paint_cultivate"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); obj.GetComponent<Piece>().m_placeEffect = buildCultivater; PieceManager.Instance.AddPiece(_customPiece); } public static void AddPaintPaved() { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown GameObject val = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_paint_paved"); if (MainConfig.resourceCosts.Value) { PieceConfig val2 = new PieceConfig(); val2.PieceTable = "_DirtyHoePieceTable"; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig { Item = "Stone", Amount = 1 } }; _customPiece = new CustomPiece(val, true, val2); } else { _customPiece = new CustomPiece(val, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); } val.GetComponent<Piece>().m_placeEffect = buildCultivater; PieceManager.Instance.AddPiece(_customPiece); } public static void AddPaintGrass() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_paint_grass"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable" }); obj.GetComponent<Piece>().m_placeEffect = buildCultivater; PieceManager.Instance.AddPiece(_customPiece); } } internal class MainConfig { internal enum Shape { Circle, Square } internal const string GeneralSection = "General Settings"; internal static ConfigEntry<bool> modEnabled; internal static ConfigEntry<bool> enableSE; internal const string RadiusSection = "Hoe Radius Settings"; internal static ConfigEntry<bool> useScrollWheel; internal static ConfigEntry<float> scrollWheelScale; internal static ConfigEntry<KeyCode> scrollModKey; internal static ConfigEntry<KeyCode> increaseHotKey; internal static ConfigEntry<KeyCode> decreaseHotKey; internal static ConfigEntry<float> hotkeyScale; internal const string ResetSection = "Terrain Reset Settings"; internal static ConfigEntry<float> hotKeyRadius; internal static ConfigEntry<float> toolRadius; internal static ConfigEntry<KeyCode> hotKey; internal static ConfigEntry<KeyCode> modKey; internal const string HeightmapSection = "Heightmap Settings"; internal static ConfigEntry<bool> enableHeightmap; internal static ConfigEntry<float> MaxHeight; internal static ConfigEntry<float> MinHeight; internal const string CommandsSection = "Command Settings"; internal static ConfigEntry<bool> enableCommands; internal static ConfigEntry<float> forestRadius; internal static ConfigEntry<float> pieceRadius; internal const string MiscSection = "Misc Settings"; internal static ConfigEntry<bool> durabilityDrain; internal static ConfigEntry<bool> staminaUsage; internal static ConfigEntry<bool> resourceCosts; internal static ConfigEntry<bool> needWorkbench; internal static ConfigEntry<Shape> toolShape; public static void InitConfigs(ConfigFile config) { modEnabled = ConfigFileExtensions.BindConfigInOrder<bool>(config, "General Settings", "Enable Plugin", true, "Enable this plugin.\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); enableSE = ConfigFileExtensions.BindConfigInOrder<bool>(config, "General Settings", "Enable Status Effect", true, "Enable the status effect while using the hoe.\n(Restart required).\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); enableSE.SettingChanged += MyDirtyHoeMod.OnMainConfigChanged; useScrollWheel = ConfigFileExtensions.BindConfigInOrder<bool>(config, "Hoe Radius Settings", "Use Scroll Wheel", true, "Use scroll wheel to modify radius.\n", false, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); scrollWheelScale = ConfigFileExtensions.BindConfigInOrder<float>(config, "Hoe Radius Settings", "Scroll Wheel Scale", 0.3f, "Scroll wheel change scale.\n", true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); scrollModKey = ConfigFileExtensions.BindConfigInOrder<KeyCode>(config, "Hoe Radius Settings", "Scroll ModKey", (KeyCode)308, "Modifer key to allow scroll wheel change.\n", false, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); increaseHotKey = ConfigFileExtensions.BindConfigInOrder<KeyCode>(config, "Hoe Radius Settings", "Increase HotKey", (KeyCode)61, "Hotkey to increase radius.\n", false, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); decreaseHotKey = ConfigFileExtensions.BindConfigInOrder<KeyCode>(config, "Hoe Radius Settings", "Decrease HotKey", (KeyCode)45, "Hotkey to decrease radius.\n", false, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); hotkeyScale = ConfigFileExtensions.BindConfigInOrder<float>(config, "Hoe Radius Settings", "Hotkey Scale", 0.3f, "Hotkey change scale.\n", true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); hotKeyRadius = ConfigFileExtensions.BindConfigInOrder<float>(config, "Terrain Reset Settings", "Reset Radius", 10f, "Reset radius for hotkey command.\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); toolRadius = ConfigFileExtensions.BindConfigInOrder<float>(config, "Terrain Reset Settings", "Tool Reset Radius", 0f, "Reset radius for tool. Set to 0 to use the tool's actual radius.\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); hotKey = ConfigFileExtensions.BindConfigInOrder<KeyCode>(config, "Terrain Reset Settings", "Reset Hotkey", (KeyCode)0, "Hotkey to reset terrain.\nPlease be very careful with this!\n", false, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); modKey = ConfigFileExtensions.BindConfigInOrder<KeyCode>(config, "Terrain Reset Settings", "Reset ModKey", (KeyCode)306, "Modifier key to reset terrain when using tools.\n", false, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); enableHeightmap = ConfigFileExtensions.BindConfigInOrder<bool>(config, "Heightmap Settings", "Enable Heightmap Settings", false, "Enable the heightmap settings.\nPlease be very careful with this!\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); enableHeightmap.SettingChanged += MyDirtyHoeMod.OnMainConfigChanged; MaxHeight = ConfigFileExtensions.BindConfigInOrder<float>(config, "Heightmap Settings", "Max Height", 200f, "How high you can stack up relative to the heightmap's original position.\nPlease be very careful with this!\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); MaxHeight.SettingChanged += MyDirtyHoeMod.OnMainConfigChanged; MinHeight = ConfigFileExtensions.BindConfigInOrder<float>(config, "Heightmap Settings", "Min Height", -200f, "How far you can dig down relative to the heightmap's original position.\nPlease be very careful with this!\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); MinHeight.SettingChanged += MyDirtyHoeMod.OnMainConfigChanged; enableCommands = ConfigFileExtensions.BindConfigInOrder<bool>(config, "Command Settings", "Enable Console Commands", false, "Enable the console commands.\n(Restart required).\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); forestRadius = ConfigFileExtensions.BindConfigInOrder<float>(config, "Command Settings", "Forest Remove Radius", 20f, "Radius to set when using the remove_forestry console command.\nPlease be very careful with this!\n", true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); pieceRadius = ConfigFileExtensions.BindConfigInOrder<float>(config, "Command Settings", "Piece Remove Radius", 20f, "Radius to set when using the remove_pieces console command.\nPlease be very careful with this!\n", true, true, true, (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 50f), (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); durabilityDrain = ConfigFileExtensions.BindConfigInOrder<bool>(config, "Misc Settings", "Enable Durability Drain", true, "Enable durability drain for the hoe.\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); durabilityDrain.SettingChanged += MyDirtyHoeMod.OnMainConfigChanged; staminaUsage = ConfigFileExtensions.BindConfigInOrder<bool>(config, "Misc Settings", "Enable Stamina Usage", true, "Enable stamina usage for the hoe.\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); staminaUsage.SettingChanged += MyDirtyHoeMod.OnMainConfigChanged; resourceCosts = ConfigFileExtensions.BindConfigInOrder<bool>(config, "Misc Settings", "Enable Resource Costs", true, "Enable resource costs for the hoe.\nOnly applies to raising terrain and paving terrain.\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); needWorkbench = ConfigFileExtensions.BindConfigInOrder<bool>(config, "Misc Settings", "Workbench Requirement", true, "Enable requirement of stone-cutter workbench for paving terrain.\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); needWorkbench.SettingChanged += MyDirtyHoeMod.OnMainConfigChanged; toolShape = ConfigFileExtensions.BindConfigInOrder<Shape>(config, "Misc Settings", "Flatten Tool Shape", Shape.Square, "Use the Circle or Square shape when flattening terrain.\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); toolShape.SettingChanged += MyDirtyHoeMod.OnMainConfigChanged; } } [BepInPlugin("MagicMike.MyDirtyHoe", "MyDirtyHoe", "2.0.8")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] internal class MyDirtyHoeMod : BaseUnityPlugin { internal const string PluginName = "MyDirtyHoe"; internal const string PluginVersion = "2.0.8"; internal const string PluginAuthor = "MagicMike"; internal const string PluginGUID = "MagicMike.MyDirtyHoe"; internal const string PluginLink = "https://www.nexusmods.com/profile/MagicMikeMods/mods"; private static char pds = Path.DirectorySeparatorChar; internal static readonly string _basePath = Paths.ConfigPath + pds + "MyDirtyHoe"; internal static readonly string TranslationFilePath = _basePath + pds + "Translations"; private CustomLocalization Localization = LocalizationManager.Instance.GetLocalization(); internal static ConfigFile ConfigFile; internal static ConfigFileWatcher ConfigFileWatcher; public static MyDirtyHoeMod plugininstance; public static AssetBundle dirtyhoe; public static string dirtyhoeBundle = "mydirtyhoe"; public static bool MainConfigChanged = false; private Harmony harmony = new Harmony("MagicMike.MyDirtyHoe"); public static CustomStatusEffect _hoeStamina; public static float lastOriginalRadius; public static float lastModdedRadius; public static float lastTotalDelta; internal static bool Square = true; public static KeyCode GetHotKey() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return MainConfig.hotKey.Value; } public static float GetHotKeyRadius() { return MainConfig.hotKeyRadius.Value; } public static KeyCode GetToolModKey() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) return MainConfig.modKey.Value; } public static float GetToolRadius() { return MainConfig.toolRadius.Value; } public static float Min() { return MainConfig.MinHeight.Value; } public static float Max() { return MainConfig.MaxHeight.Value; } public static float MinAbs() { return Math.Abs(MainConfig.MinHeight.Value); } public void Awake() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown plugininstance = this; ConfigFile = ((BaseUnityPlugin)this).Config; ConfigFileWatcher = new ConfigFileWatcher(((BaseUnityPlugin)this).Config, 1000L); ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; MainConfig.InitConfigs(((BaseUnityPlugin)this).Config); if (!MainConfig.enableHeightmap.Value) { MainConfig.MaxHeight.Value = 8f; MainConfig.MinHeight.Value = -8f; } UpdatePlugin(saveConfig: true, initialUpdate: true); if (MainConfig.modEnabled.Value) { LoadAssetBundle(); LoadAssets(); if (MainConfig.enableSE.Value) { LoadStatusEffect(); } if (MainConfig.enableCommands.Value) { AddCommands(); } LoadHoeTable(); PrefabManager.OnVanillaPrefabsAvailable += LoadTablePrefabs; CheckForFolders(); LocalisedText.AddLocalisations(); LoadLocalisationData(TranslationFilePath); FileWatcher.WatchTranslationChanges(TranslationFilePath, delegate { LoadLocalisationData(TranslationFilePath); }); harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "MagicMike.MyDirtyHoe"); ConfigFileWatcher.OnConfigFileReloaded += delegate { UpdatePlugin(saveConfig: false); }; SynchronizationManager.OnConfigurationWindowClosed += delegate { UpdatePlugin(); }; SynchronizationManager.OnConfigurationSynchronized += delegate { UpdatePlugin(); }; Game.isModded = true; } } public void OnDestroy() { } public void Update() { //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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) if (!MainConfig.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 (MainConfig.useScrollWheel.Value && ((int)MainConfig.scrollModKey.Value == 0 || Input.GetKey(MainConfig.scrollModKey.Value)) && Input.mouseScrollDelta.y != 0f) { SetRadius(Input.mouseScrollDelta.y * MainConfig.scrollWheelScale.Value); } else if (Input.GetKey(MainConfig.increaseHotKey.Value)) { SetRadius(MainConfig.hotkeyScale.Value); } else if (Input.GetKey(MainConfig.decreaseHotKey.Value)) { SetRadius(0f - MainConfig.hotkeyScale.Value); } } public static void LoadAssetBundle() { dirtyhoe = AssetUtils.LoadAssetBundleFromResources(dirtyhoeBundle, Assembly.GetExecutingAssembly()); if ((Object)(object)dirtyhoe == (Object)null) { Logger.LogError((object)("Failed to load asset bundle with name: " + dirtyhoeBundle)); } } public static void LoadAssets() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown GameObject val = dirtyhoe.LoadAsset<GameObject>("mm_stone"); ItemManager.Instance.AddItem(new CustomItem(val, true)); } public static void LoadStatusEffect() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown _hoeStamina = new CustomStatusEffect((StatusEffect)(object)dirtyhoe.LoadAsset<SE_Stats>("SE_Hoe_Stamina"), false); ItemManager.Instance.AddStatusEffect(_hoeStamina); } private void AddCommands() { CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RemoveForestry()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new RemovePieces()); } private void LoadHoeTable() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown PieceTableConfig val = new PieceTableConfig(); val.CanRemovePieces = false; PieceManager.Instance.AddPieceTable(new CustomPieceTable(dirtyhoe, "_DirtyHoePieceTable", val)); LoadHoeTool(); } private void LoadHoeTool() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown GameObject val = dirtyhoe.LoadAsset<GameObject>("DirtyHoe"); ItemConfig val2 = new ItemConfig(); val2.Amount = 1; val2.CraftingStation = "piece_workbench"; val2.RepairStation = "piece_workbench"; val2.MinStationLevel = 1; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[2] { new RequirementConfig { Item = "Wood", Amount = 1, AmountPerLevel = 1 }, new RequirementConfig { Item = "Stone", Amount = 1, AmountPerLevel = 1 } }; CustomItem val3 = new CustomItem(val, true, val2); if (MainConfig.durabilityDrain.Value) { val.GetComponent<ItemDrop>().m_itemData.m_shared.m_useDurabilityDrain = 1f; } if (MainConfig.staminaUsage.Value) { val.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_attackStamina = 5f; } if (MainConfig.enableSE.Value) { val.GetComponent<ItemDrop>().m_itemData.m_shared.m_equipStatusEffect = _hoeStamina.StatusEffect; } ItemManager.Instance.AddItem(val3); } private void LoadTablePrefabs() { try { AddPrefabs.LoadPrefabs(); } catch (Exception ex) { Logger.LogError((object)("Exception caught while loading Hoe Table Prefabs: " + ex.Message)); } finally { PrefabManager.OnVanillaPrefabsAvailable -= LoadTablePrefabs; } } public static void CheckForFolders() { if (!Directory.Exists(_basePath)) { Logger.LogInfo((object)"Creating MyDirtyHoe Directory"); Directory.CreateDirectory(_basePath); } if (!Directory.Exists(TranslationFilePath)) { Logger.LogInfo((object)"Creating Translations folder"); Directory.CreateDirectory(TranslationFilePath); } } public void LoadLocalisationData(string directory) { string[] fileSystemEntries = Directory.GetFileSystemEntries(directory, "*.json", SearchOption.AllDirectories); foreach (string path in fileSystemEntries) { string name = new DirectoryInfo(Path.GetDirectoryName(path)).Name; Path.GetFileNameWithoutExtension(path); Localization.AddJsonFile(name, File.ReadAllText(path)); } } public static bool IsHeadless() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 return (int)SystemInfo.graphicsDeviceType == 4; } public void SetRadius(float delta) { //IL_01fe: 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); } } } public static void OnMainConfigChanged(object obj, EventArgs args) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!MainConfigChanged) { MainConfigChanged = true; } Scene activeScene = SceneManager.GetActiveScene(); if ("main".Equals(((Scene)(ref activeScene)).name)) { UpdateHoeSettings(); } } private void UpdatePlugin(bool saveConfig = true, bool initialUpdate = false) { if (MainConfigChanged || initialUpdate) { MainConfigChanged = false; } if (saveConfig) { ((BaseUnityPlugin)this).Config.Save(); } } private static void UpdateHoeSettings() { if (!MainConfig.enableHeightmap.Value) { MainConfig.MaxHeight.Value = 8f; MainConfig.MinHeight.Value = -8f; } Square = MainConfig.toolShape.Value != MainConfig.Shape.Circle; string[] array = new string[3] { "mm_flatten", "mm_cultivate_flatten", "mm_paved_flatten" }; foreach (string text in array) { GameObject prefab = PrefabManager.Instance.GetPrefab(text); TerrainOp val = ((prefab != null) ? prefab.GetComponent<TerrainOp>() : null); if ((Object)(object)val != (Object)null) { val.m_settings.m_square = Square; } } GameObject prefab2 = PrefabManager.Instance.GetPrefab("DirtyHoe"); if ((Object)(object)prefab2 != (Object)null) { if (MainConfig.durabilityDrain.Value) { prefab2.GetComponent<ItemDrop>().m_itemData.m_shared.m_useDurabilityDrain = 1f; } else { prefab2.GetComponent<ItemDrop>().m_itemData.m_shared.m_useDurabilityDrain = 0f; } if (MainConfig.staminaUsage.Value) { prefab2.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_attackStamina = 5f; } else { prefab2.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_attackStamina = 0f; } GameObject prefab3 = PrefabManager.Instance.GetPrefab("mm_paved_smooth"); GameObject prefab4 = PrefabManager.Instance.GetPrefab("mm_paved_flatten"); GameObject prefab5 = PrefabManager.Instance.GetPrefab("mm_paint_paved"); CraftingStation prefab6 = Cache.GetPrefab<CraftingStation>("piece_stonecutter"); if (MainConfig.needWorkbench.Value) { prefab3.GetComponent<Piece>().m_craftingStation = prefab6; prefab4.GetComponent<Piece>().m_craftingStation = prefab6; prefab5.GetComponent<Piece>().m_craftingStation = prefab6; } else { prefab3.GetComponent<Piece>().m_craftingStation = null; prefab4.GetComponent<Piece>().m_craftingStation = null; prefab5.GetComponent<Piece>().m_craftingStation = null; } } } } } namespace MyDirtyHoe.Patches { internal class Game_Patches { [HarmonyPatch(typeof(ZInput), "GetMouseScrollWheel")] public static class ZInput_GetMouseScrollWheel_Patch { public static bool Prefix(ref float __result) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) if (!MainConfig.modEnabled.Value || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || !((Character)Player.m_localPlayer).InPlaceMode() || Hud.IsPieceSelectionVisible() || !MainConfig.useScrollWheel.Value || ((int)MainConfig.scrollModKey.Value != 0 && !Input.GetKey(MainConfig.scrollModKey.Value))) { return true; } __result = 0f; return false; } } [HarmonyPatch(typeof(TerrainComp), "LevelTerrain")] public static class TerrainComp_LevelTerrain_Patch { public static void Prefix(ref float radius) { if (MainConfig.modEnabled.Value) { radius += MyDirtyHoeMod.lastTotalDelta; } } } [HarmonyPatch(typeof(TerrainComp), "RaiseTerrain")] public static class TerrainComp_RaiseTerrain_Patch { public static void Prefix(ref float radius) { if (MainConfig.modEnabled.Value) { radius += MyDirtyHoeMod.lastTotalDelta; } } } [HarmonyPatch(typeof(TerrainComp), "SmoothTerrain")] public static class TerrainComp_SmoothTerrain_Patch { public static void Prefix(ref float radius) { if (MainConfig.modEnabled.Value) { radius += MyDirtyHoeMod.lastTotalDelta; } } } } } namespace MyDirtyHoe.ConsoleCommands { public class RemoveForestry : ConsoleCommand { public override string Name => "remove_forestry"; public override string Help => "removes trees, shrubs, rocks etc in a " + MainConfig.forestRadius.Value + "m radius"; public override void Run(string[] args) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Invalid comparison between Unknown and I4 //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) Game.instance.GetPlayerProfile().GetPlayerID(); Player localPlayer = Player.m_localPlayer; TreeBase[] array = Object.FindObjectsByType<TreeBase>((FindObjectsSortMode)0); Destructible[] array2 = Object.FindObjectsByType<Destructible>((FindObjectsSortMode)0); Pickable[] array3 = Object.FindObjectsByType<Pickable>((FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { if (Vector3.Distance(((Component)array[i]).transform.position, ((Component)localPlayer).transform.position) < MainConfig.forestRadius.Value) { ((Component)array[i]).GetComponent<ZNetView>().Destroy(); } } for (int j = 0; j < array2.Length; j++) { if (((int)array2[j].m_destructibleType == 2 || (int)array2[j].m_destructibleType == 1) && Vector3.Distance(((Component)array2[j]).transform.position, ((Component)localPlayer).transform.position) < MainConfig.forestRadius.Value) { ((Component)array2[j]).GetComponent<ZNetView>().Destroy(); } } for (int k = 0; k < array3.Length; k++) { if (Vector3.Distance(((Component)array3[k]).transform.position, ((Component)localPlayer).transform.position) < MainConfig.forestRadius.Value) { ((Component)array3[k]).GetComponent<ZNetView>().Destroy(); } } } } public class RemovePieces : ConsoleCommand { public static List<Vector3> treeRadiuses = new List<Vector3>(); public static List<Piece> sPieces = new List<Piece>(); public override string Name => "remove_pieces"; public override string Help => "removes all structures around the player in a " + MainConfig.pieceRadius.Value + "m radius"; public override void Run(string[] args) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) Piece[] array = Object.FindObjectsByType<Piece>((FindObjectsSortMode)0); Game.instance.GetPlayerProfile().GetPlayerID(); Player localPlayer = Player.m_localPlayer; GetNearbySPieces(); for (int i = 0; i < array.Length; i++) { if (array[i].IsCreator() && Vector3.Distance(((Component)array[i]).transform.position, ((Component)localPlayer).transform.position) < MainConfig.pieceRadius.Value) { ((Component)array[i]).GetComponent<ZNetView>().Destroy(); } } } private static void GetNearbySPieces() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; sPieces.Clear(); Piece.GetAllPiecesInRadius(((Component)localPlayer).transform.position, MainConfig.pieceRadius.Value, sPieces); sPieces = sPieces.Where((Piece p) => (int)p.m_category > 0).ToList(); foreach (Piece sPiece in sPieces) { sPiece.SetCreator(Game.instance.GetPlayerProfile().GetPlayerID(), ((IUser)PlatformManager.DistributionPlatform.LocalUser).PlatformUserID); } } } }