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.2
plugins/MyDirtyHoe.dll
Decompiled a year agousing System; using System.Collections; 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 UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("MyDirtyHoe")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("MagicMike")] [assembly: AssemblyProduct("MyDirtyHoe")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("2.0.2")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.2.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 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(ZNetScene), "Awake")] private static class SFXFix { private static void Postfix() { GameObject prefab = ZNetScene.instance.GetPrefab("sfx_Potion_stamina_Start"); try { prefab.GetComponentInChildren<AudioSource>().outputAudioMixerGroup = AudioMan.instance.m_ambientMixer; } catch { Logger.LogError((object)"AudioMan.instance.m_ambientMixer could not be assigned on outputAudioMixerGroup"); } } } } internal class AddPrefabs { public static EffectList buildHoe; public static EffectList buildCultivater; public static EffectList buildStone; public static CustomPiece _customPiece; public static void LoadPrefabs() { AddFX(); AddSmooth(); AddFlatten(); AddLower(); AddRaise(); AddCultivateSmooth(); AddCultivateFlatten(); AddHoePavedSmooth(); AddHoePavedFlatten(); AddHoeDirtPath(); AddPaintDirt(); AddPaintCultivate(); AddPaintPaved(); AddPaintGrass(); } public static void AddFX() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_0057: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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"); 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; } 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_smooth"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable", Category = "Misc" }); obj.GetComponent<Piece>().m_placeEffect = buildHoe; PieceManager.Instance.AddPiece(_customPiece); } public static void AddFlatten() { //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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_flatten"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable", Category = "Misc" }); obj.GetComponent<Piece>().m_placeEffect = buildHoe; 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_lower"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable", Category = "Misc" }); obj.GetComponent<Piece>().m_placeEffect = buildStone; PieceManager.Instance.AddPiece(_customPiece); } public static void AddRaise() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_0043: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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.Category = "Misc"; 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", Category = "Misc" }); } 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_cultivate_smooth"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable", Category = "Misc" }); obj.GetComponent<Piece>().m_placeEffect = buildCultivater; PieceManager.Instance.AddPiece(_customPiece); } public static void AddCultivateFlatten() { //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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_cultivate_flatten"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable", Category = "Misc" }); obj.GetComponent<Piece>().m_placeEffect = buildCultivater; PieceManager.Instance.AddPiece(_customPiece); } public static void AddHoePavedSmooth() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_0043: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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.Category = "Misc"; 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", Category = "Misc" }); } val.GetComponent<Piece>().m_placeEffect = buildHoe; PieceManager.Instance.AddPiece(_customPiece); } public static void AddHoePavedFlatten() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_0043: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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.Category = "Misc"; 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", Category = "Misc" }); } val.GetComponent<Piece>().m_placeEffect = buildHoe; 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_dirt_path"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable", Category = "Misc" }); obj.GetComponent<Piece>().m_placeEffect = buildHoe; 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_paint_dirt"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable", Category = "Paint" }); 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_paint_cultivate"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable", Category = "Paint" }); obj.GetComponent<Piece>().m_placeEffect = buildCultivater; PieceManager.Instance.AddPiece(_customPiece); } public static void AddPaintPaved() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_0043: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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.Category = "Paint"; 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", Category = "Paint" }); } 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown GameObject obj = MyDirtyHoeMod.dirtyhoe.LoadAsset<GameObject>("mm_paint_grass"); _customPiece = new CustomPiece(obj, true, new PieceConfig { PieceTable = "_DirtyHoePieceTable", Category = "Paint" }); obj.GetComponent<Piece>().m_placeEffect = buildCultivater; PieceManager.Instance.AddPiece(_customPiece); } } internal class Heightmap_Patches { [HarmonyPatch(typeof(TerrainComp))] private static class Heightmap_Patch { [CompilerGenerated] private sealed class <TerrainCompApplyToHeightmapTranspiler>d__2 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable<CodeInstruction> instructions; public IEnumerable<CodeInstruction> <>3__instructions; private int <i>5__2; private IEnumerator<CodeInstruction> <>7__wrap2; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <TerrainCompApplyToHeightmapTranspiler>d__2(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 3u) { try { } finally { <>m__Finally1(); } } <>7__wrap2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <i>5__2 = 0; <>7__wrap2 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; case 2: <>1__state = -3; goto IL_0151; case 3: <>1__state = -3; goto IL_0151; case 4: { <>1__state = -3; break; } IL_0151: <i>5__2++; break; } if (<>7__wrap2.MoveNext()) { CodeInstruction current = <>7__wrap2.Current; if (CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)(-8f))) { <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null)); <>1__state = 1; return true; } if (CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)8f)) { if (<i>5__2 == 0) { <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "MinAbs", (Type[])null, (Type[])null)); <>1__state = 2; return true; } <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null)); <>1__state = 3; return true; } <>2__current = current; <>1__state = 4; return true; } <>m__Finally1(); <>7__wrap2 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap2 != null) { <>7__wrap2.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { <TerrainCompApplyToHeightmapTranspiler>d__2 <TerrainCompApplyToHeightmapTranspiler>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <TerrainCompApplyToHeightmapTranspiler>d__ = this; } else { <TerrainCompApplyToHeightmapTranspiler>d__ = new <TerrainCompApplyToHeightmapTranspiler>d__2(0); } <TerrainCompApplyToHeightmapTranspiler>d__.instructions = <>3__instructions; return <TerrainCompApplyToHeightmapTranspiler>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } [CompilerGenerated] private sealed class <TerrainCompLevelTerrainTranspiler>d__0 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable<CodeInstruction> instructions; public IEnumerable<CodeInstruction> <>3__instructions; private IEnumerator<CodeInstruction> <>7__wrap1; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <TerrainCompLevelTerrainTranspiler>d__0(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 2u) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; case 2: <>1__state = -3; break; case 3: <>1__state = -3; break; } if (<>7__wrap1.MoveNext()) { CodeInstruction current = <>7__wrap1.Current; if (CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)(-8f))) { <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null)); <>1__state = 1; return true; } if (CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)8f)) { <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null)); <>1__state = 2; return true; } <>2__current = current; <>1__state = 3; return true; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { <TerrainCompLevelTerrainTranspiler>d__0 <TerrainCompLevelTerrainTranspiler>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <TerrainCompLevelTerrainTranspiler>d__ = this; } else { <TerrainCompLevelTerrainTranspiler>d__ = new <TerrainCompLevelTerrainTranspiler>d__0(0); } <TerrainCompLevelTerrainTranspiler>d__.instructions = <>3__instructions; return <TerrainCompLevelTerrainTranspiler>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } [CompilerGenerated] private sealed class <TerrainCompRaiseTerrainTranspiler>d__1 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable<CodeInstruction> instructions; public IEnumerable<CodeInstruction> <>3__instructions; private IEnumerator<CodeInstruction> <>7__wrap1; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <TerrainCompRaiseTerrainTranspiler>d__1(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 2u) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; case 2: <>1__state = -3; break; case 3: <>1__state = -3; break; } if (<>7__wrap1.MoveNext()) { CodeInstruction current = <>7__wrap1.Current; if (CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)(-8f))) { <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null)); <>1__state = 1; return true; } if (CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)8f)) { <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null)); <>1__state = 2; return true; } <>2__current = current; <>1__state = 3; return true; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { <TerrainCompRaiseTerrainTranspiler>d__1 <TerrainCompRaiseTerrainTranspiler>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <TerrainCompRaiseTerrainTranspiler>d__ = this; } else { <TerrainCompRaiseTerrainTranspiler>d__ = new <TerrainCompRaiseTerrainTranspiler>d__1(0); } <TerrainCompRaiseTerrainTranspiler>d__.instructions = <>3__instructions; return <TerrainCompRaiseTerrainTranspiler>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } [IteratorStateMachine(typeof(<TerrainCompLevelTerrainTranspiler>d__0))] [HarmonyTranspiler] [HarmonyPatch("LevelTerrain")] public static IEnumerable<CodeInstruction> TerrainCompLevelTerrainTranspiler(IEnumerable<CodeInstruction> instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <TerrainCompLevelTerrainTranspiler>d__0(-2) { <>3__instructions = instructions }; } [IteratorStateMachine(typeof(<TerrainCompRaiseTerrainTranspiler>d__1))] [HarmonyTranspiler] [HarmonyPatch("RaiseTerrain")] public static IEnumerable<CodeInstruction> TerrainCompRaiseTerrainTranspiler(IEnumerable<CodeInstruction> instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <TerrainCompRaiseTerrainTranspiler>d__1(-2) { <>3__instructions = instructions }; } [IteratorStateMachine(typeof(<TerrainCompApplyToHeightmapTranspiler>d__2))] [HarmonyTranspiler] [HarmonyPatch("ApplyToHeightmap")] public static IEnumerable<CodeInstruction> TerrainCompApplyToHeightmapTranspiler(IEnumerable<CodeInstruction> instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <TerrainCompApplyToHeightmapTranspiler>d__2(-2) { <>3__instructions = instructions }; } } } 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 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!" } }); } } [BepInPlugin("MagicMike.MyDirtyHoe", "MyDirtyHoe", "2.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class MyDirtyHoeMod : BaseUnityPlugin { internal const string PluginName = "MyDirtyHoe"; internal const string PluginVersion = "2.0.2"; internal const string Author = "MagicMike"; internal const string PluginGUID = "MagicMike.MyDirtyHoe"; private static char pds = Path.DirectorySeparatorChar; public static readonly string _basePath = Paths.ConfigPath + pds + "MyDirtyHoe"; public 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; 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 MinAbs() { return Math.Abs(MainConfig.MinHeight.Value); } public static float Max() { return MainConfig.MaxHeight.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); 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() { ((BaseUnityPlugin)this).Config.Save(); } public void Update() { //IL_00bc: 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_00de: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown CustomPrefab val = new CustomPrefab(dirtyhoe.LoadAsset<GameObject>("sfx_Potion_stamina_Start"), false); PrefabManager.Instance.AddPrefab(val); } 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_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown GameObject obj = dirtyhoe.LoadAsset<GameObject>("_DirtyHoePieceTable"); PieceTableConfig val = new PieceTableConfig(); val.CanRemovePieces = false; val.UseCategories = false; val.UseCustomCategories = true; val.CustomCategories = new string[1] { "Paint" }; CustomPieceTable val2 = new CustomPieceTable(obj, val); PieceManager.Instance.AddPieceTable(val2); 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (!MainConfigChanged) { MainConfigChanged = true; } Scene activeScene = SceneManager.GetActiveScene(); if (((Scene)(ref activeScene)).name.Equals("main")) { 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() { GameObject prefab = PrefabManager.Instance.GetPrefab("DirtyHoe"); if ((Object)(object)prefab != (Object)null) { if (MainConfig.durabilityDrain.Value) { prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_useDurabilityDrain = 1f; } else { prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_useDurabilityDrain = 0f; } if (MainConfig.staminaUsage.Value) { prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_attackStamina = 5f; } else { prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_attack.m_attackStamina = 0f; } GameObject prefab2 = PrefabManager.Instance.GetPrefab("mm_paved_smooth"); GameObject prefab3 = PrefabManager.Instance.GetPrefab("mm_paved_flatten"); GameObject prefab4 = PrefabManager.Instance.GetPrefab("mm_paint_paved"); CraftingStation prefab5 = Cache.GetPrefab<CraftingStation>("piece_stonecutter"); if (MainConfig.needWorkbench.Value) { prefab2.GetComponent<Piece>().m_craftingStation = prefab5; prefab3.GetComponent<Piece>().m_craftingStation = prefab5; prefab4.GetComponent<Piece>().m_craftingStation = prefab5; } else { prefab2.GetComponent<Piece>().m_craftingStation = null; prefab3.GetComponent<Piece>().m_craftingStation = null; prefab4.GetComponent<Piece>().m_craftingStation = null; } } } } 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 MainConfig { 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; 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)306, "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", 150f, "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(Restart required).\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); 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(Restart required).\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); 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(Restart required).\n", true, true, true, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null); 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; } } 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 (__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 = Terminal.m_terminalInitialized; } private static void Postfix(bool __state) { //IL_004c: 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, (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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: 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(true); } } 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 (!val.m_nview.IsOwner()) { val.m_nview.ClaimOwnership(); } if (!val.m_initialized) { continue; } enumerator3.Current.WorldToVertex(center, ref num2, ref num3); enumerator3.Current.WorldToVertexMask(center, ref num4, ref num5); bool flag = false; int num6 = val.m_width + 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 && val.m_modifiedHeight[num7]) { num++; flag = true; val.m_modifiedHeight[num7] = false; val.m_levelDelta[num7] = 0f; val.m_smoothDelta[num7] = 0f; } if (CoordDistance(num4, num5, j, i) <= radius && val.m_modifiedPaint[num7]) { flag = true; val.m_modifiedPaint[num7] = false; val.m_paintMask[num7] = Color.clear; } } } if (flag) { val.Save(); enumerator3.Current.Poke(true); } } } 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); } } } 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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Invalid comparison between Unknown and I4 //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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: Invalid comparison between Unknown and I4 //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) Game.instance.GetPlayerProfile().GetPlayerID(); Player localPlayer = Player.m_localPlayer; TreeBase[] array = Object.FindObjectsOfType<TreeBase>(); Destructible[] array2 = Object.FindObjectsOfType<Destructible>(); Pickable[] array3 = Object.FindObjectsOfType<Pickable>(); 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) Piece[] array = Object.FindObjectsOfType<Piece>(); 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) 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()); } } } }