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 Hoedin v1.1.2
plugins/Hoedin/Hoedin.dll
Decompiled a month 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.Versioning; 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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MyDirtyHoe { 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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 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 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 Heightmap_Patches { [HarmonyPatch(typeof(TerrainComp))] private static class Heightmap_Patch { [CompilerGenerated] private sealed class _003CTerrainCompApplyToHeightmapTranspiler_003Ed__2 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable { private int _003C_003E1__state; private CodeInstruction _003C_003E2__current; private int _003C_003El__initialThreadId; private IEnumerable<CodeInstruction> instructions; public IEnumerable<CodeInstruction> _003C_003E3__instructions; private int _003Ci_003E5__2; private IEnumerator<CodeInstruction> _003C_003E7__wrap2; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return _003C_003E2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return _003C_003E2__current; } } [DebuggerHidden] public _003CTerrainCompApplyToHeightmapTranspiler_003Ed__2(int _003C_003E1__state) { this._003C_003E1__state = _003C_003E1__state; _003C_003El__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = _003C_003E1__state; if (num == -3 || (uint)(num - 1) <= 3u) { try { } finally { _003C_003Em__Finally1(); } } _003C_003E7__wrap2 = null; _003C_003E1__state = -2; } private bool MoveNext() { //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown try { switch (_003C_003E1__state) { default: return false; case 0: _003C_003E1__state = -1; _003Ci_003E5__2 = 0; _003C_003E7__wrap2 = instructions.GetEnumerator(); _003C_003E1__state = -3; break; case 1: _003C_003E1__state = -3; break; case 2: _003C_003E1__state = -3; goto IL_0079; case 3: _003C_003E1__state = -3; goto IL_0079; case 4: { _003C_003E1__state = -3; break; } IL_0079: _003Ci_003E5__2++; break; } if (_003C_003E7__wrap2.MoveNext()) { CodeInstruction current = _003C_003E7__wrap2.Current; if (CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)(-8f))) { _003C_003E2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null)); _003C_003E1__state = 1; return true; } if (CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)8f)) { if (_003Ci_003E5__2 == 0) { _003C_003E2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "MinAbs", (Type[])null, (Type[])null)); _003C_003E1__state = 2; return true; } _003C_003E2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null)); _003C_003E1__state = 3; return true; } _003C_003E2__current = current; _003C_003E1__state = 4; return true; } _003C_003Em__Finally1(); _003C_003E7__wrap2 = null; return false; } catch { ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { return MoveNext(); } private void _003C_003Em__Finally1() { _003C_003E1__state = -1; if (_003C_003E7__wrap2 != null) { _003C_003E7__wrap2.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { _003CTerrainCompApplyToHeightmapTranspiler_003Ed__2 _003CTerrainCompApplyToHeightmapTranspiler_003Ed__; if (_003C_003E1__state == -2 && _003C_003El__initialThreadId == Environment.CurrentManagedThreadId) { _003C_003E1__state = 0; _003CTerrainCompApplyToHeightmapTranspiler_003Ed__ = this; } else { _003CTerrainCompApplyToHeightmapTranspiler_003Ed__ = new _003CTerrainCompApplyToHeightmapTranspiler_003Ed__2(0); } _003CTerrainCompApplyToHeightmapTranspiler_003Ed__.instructions = _003C_003E3__instructions; return _003CTerrainCompApplyToHeightmapTranspiler_003Ed__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } [CompilerGenerated] private sealed class _003CTerrainCompLevelTerrainTranspiler_003Ed__0 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable { private int _003C_003E1__state; private CodeInstruction _003C_003E2__current; private int _003C_003El__initialThreadId; private IEnumerable<CodeInstruction> instructions; public IEnumerable<CodeInstruction> _003C_003E3__instructions; private IEnumerator<CodeInstruction> _003C_003E7__wrap1; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return _003C_003E2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return _003C_003E2__current; } } [DebuggerHidden] public _003CTerrainCompLevelTerrainTranspiler_003Ed__0(int _003C_003E1__state) { this._003C_003E1__state = _003C_003E1__state; _003C_003El__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = _003C_003E1__state; if (num == -3 || (uint)(num - 1) <= 2u) { try { } finally { _003C_003Em__Finally1(); } } _003C_003E7__wrap1 = null; _003C_003E1__state = -2; } private bool MoveNext() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown try { switch (_003C_003E1__state) { default: return false; case 0: _003C_003E1__state = -1; _003C_003E7__wrap1 = instructions.GetEnumerator(); _003C_003E1__state = -3; break; case 1: _003C_003E1__state = -3; break; case 2: _003C_003E1__state = -3; break; case 3: _003C_003E1__state = -3; break; } if (_003C_003E7__wrap1.MoveNext()) { CodeInstruction current = _003C_003E7__wrap1.Current; if (CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)(-8f))) { _003C_003E2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null)); _003C_003E1__state = 1; return true; } if (CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)8f)) { _003C_003E2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null)); _003C_003E1__state = 2; return true; } _003C_003E2__current = current; _003C_003E1__state = 3; return true; } _003C_003Em__Finally1(); _003C_003E7__wrap1 = null; return false; } catch { ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { return MoveNext(); } private void _003C_003Em__Finally1() { _003C_003E1__state = -1; if (_003C_003E7__wrap1 != null) { _003C_003E7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { _003CTerrainCompLevelTerrainTranspiler_003Ed__0 _003CTerrainCompLevelTerrainTranspiler_003Ed__; if (_003C_003E1__state == -2 && _003C_003El__initialThreadId == Environment.CurrentManagedThreadId) { _003C_003E1__state = 0; _003CTerrainCompLevelTerrainTranspiler_003Ed__ = this; } else { _003CTerrainCompLevelTerrainTranspiler_003Ed__ = new _003CTerrainCompLevelTerrainTranspiler_003Ed__0(0); } _003CTerrainCompLevelTerrainTranspiler_003Ed__.instructions = _003C_003E3__instructions; return _003CTerrainCompLevelTerrainTranspiler_003Ed__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } [CompilerGenerated] private sealed class _003CTerrainCompRaiseTerrainTranspiler_003Ed__1 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IEnumerator, IDisposable { private int _003C_003E1__state; private CodeInstruction _003C_003E2__current; private int _003C_003El__initialThreadId; private IEnumerable<CodeInstruction> instructions; public IEnumerable<CodeInstruction> _003C_003E3__instructions; private IEnumerator<CodeInstruction> _003C_003E7__wrap1; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return _003C_003E2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return _003C_003E2__current; } } [DebuggerHidden] public _003CTerrainCompRaiseTerrainTranspiler_003Ed__1(int _003C_003E1__state) { this._003C_003E1__state = _003C_003E1__state; _003C_003El__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = _003C_003E1__state; if (num == -3 || (uint)(num - 1) <= 2u) { try { } finally { _003C_003Em__Finally1(); } } _003C_003E7__wrap1 = null; _003C_003E1__state = -2; } private bool MoveNext() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown try { switch (_003C_003E1__state) { default: return false; case 0: _003C_003E1__state = -1; _003C_003E7__wrap1 = instructions.GetEnumerator(); _003C_003E1__state = -3; break; case 1: _003C_003E1__state = -3; break; case 2: _003C_003E1__state = -3; break; case 3: _003C_003E1__state = -3; break; } if (_003C_003E7__wrap1.MoveNext()) { CodeInstruction current = _003C_003E7__wrap1.Current; if (CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)(-8f))) { _003C_003E2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null)); _003C_003E1__state = 1; return true; } if (CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)8f)) { _003C_003E2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null)); _003C_003E1__state = 2; return true; } _003C_003E2__current = current; _003C_003E1__state = 3; return true; } _003C_003Em__Finally1(); _003C_003E7__wrap1 = null; return false; } catch { ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { return MoveNext(); } private void _003C_003Em__Finally1() { _003C_003E1__state = -1; if (_003C_003E7__wrap1 != null) { _003C_003E7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { _003CTerrainCompRaiseTerrainTranspiler_003Ed__1 _003CTerrainCompRaiseTerrainTranspiler_003Ed__; if (_003C_003E1__state == -2 && _003C_003El__initialThreadId == Environment.CurrentManagedThreadId) { _003C_003E1__state = 0; _003CTerrainCompRaiseTerrainTranspiler_003Ed__ = this; } else { _003CTerrainCompRaiseTerrainTranspiler_003Ed__ = new _003CTerrainCompRaiseTerrainTranspiler_003Ed__1(0); } _003CTerrainCompRaiseTerrainTranspiler_003Ed__.instructions = _003C_003E3__instructions; return _003CTerrainCompRaiseTerrainTranspiler_003Ed__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } [HarmonyTranspiler] [HarmonyPatch("LevelTerrain")] public static IEnumerable<CodeInstruction> TerrainCompLevelTerrainTranspiler(IEnumerable<CodeInstruction> instructions) { try { int num = default(int); IEnumerator<CodeInstruction> enumerator = default(IEnumerator<CodeInstruction>); switch (num) { case 0: enumerator = instructions.GetEnumerator(); break; case 1: case 2: case 3: break; default: yield break; } if (enumerator.MoveNext()) { CodeInstruction current = enumerator.Current; if (!CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)(-8f))) { if (!CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)8f)) { /*Error near IL_013b: Unexpected return in MoveNext()*/; } new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null)); /*Error near IL_013b: Unexpected return in MoveNext()*/; } new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null)); /*Error near IL_013b: Unexpected return in MoveNext()*/; } ((_003CTerrainCompLevelTerrainTranspiler_003Ed__0)/*Error near IL_0120: stateMachine*/)._003C_003Em__Finally1(); } catch { ((IDisposable)/*Error near IL_0132: stateMachine*/).Dispose(); throw; } } [HarmonyTranspiler] [HarmonyPatch("RaiseTerrain")] public static IEnumerable<CodeInstruction> TerrainCompRaiseTerrainTranspiler(IEnumerable<CodeInstruction> instructions) { try { int num = default(int); IEnumerator<CodeInstruction> enumerator = default(IEnumerator<CodeInstruction>); switch (num) { case 0: enumerator = instructions.GetEnumerator(); break; case 1: case 2: case 3: break; default: yield break; } if (enumerator.MoveNext()) { CodeInstruction current = enumerator.Current; if (!CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)(-8f))) { if (!CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)8f)) { /*Error near IL_013b: Unexpected return in MoveNext()*/; } new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null)); /*Error near IL_013b: Unexpected return in MoveNext()*/; } new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null)); /*Error near IL_013b: Unexpected return in MoveNext()*/; } ((_003CTerrainCompRaiseTerrainTranspiler_003Ed__1)/*Error near IL_0120: stateMachine*/)._003C_003Em__Finally1(); } catch { ((IDisposable)/*Error near IL_0132: stateMachine*/).Dispose(); throw; } } [HarmonyTranspiler] [HarmonyPatch("ApplyToHeightmap")] public static IEnumerable<CodeInstruction> TerrainCompApplyToHeightmapTranspiler(IEnumerable<CodeInstruction> instructions) { try { int num = default(int); int num2 = default(int); IEnumerator<CodeInstruction> enumerator = default(IEnumerator<CodeInstruction>); switch (num) { case 0: num2 = 0; enumerator = instructions.GetEnumerator(); break; case 2: case 3: num2++; break; case 1: case 4: break; default: yield break; } if (enumerator.MoveNext()) { CodeInstruction current = enumerator.Current; if (!CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)(-8f))) { if (CodeInstructionExtensions.Is(current, OpCodes.Ldc_R4, (object)8f)) { if (num2 != 0) { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Max", (Type[])null, (Type[])null)); /*Error near IL_019c: Unexpected return in MoveNext()*/; } new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "MinAbs", (Type[])null, (Type[])null)); /*Error near IL_019c: Unexpected return in MoveNext()*/; } /*Error near IL_019c: Unexpected return in MoveNext()*/; } new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(MyDirtyHoeMod), "Min", (Type[])null, (Type[])null)); /*Error near IL_019c: Unexpected return in MoveNext()*/; } ((_003CTerrainCompApplyToHeightmapTranspiler_003Ed__2)/*Error near IL_0181: stateMachine*/)._003C_003Em__Finally1(); } catch { ((IDisposable)/*Error near IL_0193: stateMachine*/).Dispose(); throw; } } } } 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 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 static class Muffins { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__2_0; internal void <Register>b__2_0(ConsoleEventArgs args) { args.Context.AddString(Verdict()); } } private static readonly string[] Greetings = new string[5] { "Hoedin loaded. Remember: the soil gives, and the soil takes. Mostly it gives muffins.", "Hoedin loaded. Terraforming is just baking with a much larger tin.", "Hoedin loaded. Flatten the earth, raise the muffins.", "Hoedin loaded. A well-levelled plot is the first ingredient of a good muffin.", "Hoedin loaded. Odin gave an eye for wisdom. Zorus would give one for a muffin." }; internal static string Greeting() { return Greetings[DateTime.UtcNow.DayOfYear % Greetings.Length]; } internal static void Register() { //IL_0033: 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) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown try { object obj = <>c.<>9__2_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { args.Context.AddString(Verdict()); }; <>c.<>9__2_0 = val; obj = (object)val; } new ConsoleCommand("muffin", "the only unit of terraforming that matters", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } catch (Exception) { } } private static string Verdict() { if ((Object)(object)Player.m_localPlayer == (Object)null) { return "No muffins can be baked from the main menu."; } PlayerProfile val = (((Object)(object)Game.instance != (Object)null) ? Game.instance.GetPlayerProfile() : null); if (val == null) { return "The muffins are, regrettably, indeterminate."; } float stat = val.GetStat((PlayerStatType)37); float stat2 = val.GetStat((PlayerStatType)2); long num = (long)((stat + stat2) / 42f); if (num <= 0) { return "You have not yet earned a muffin. Dig something."; } return string.Format("{0} dig(s) and {1} build(s): that is {2} muffin{3} of honest labour.", (long)stat, (long)stat2, num, (num == 1) ? "" : "s"); } } [BepInPlugin("org.zrikzinc.hoedin", "Hoedin", "1.0.7.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class MyDirtyHoeMod : BaseUnityPlugin { internal const string PluginName = "Hoedin"; internal const string PluginVersion = "1.0.7.4"; internal const string Author = "MagicMike (original) / zrikz (1.0.7 port)"; internal const string PluginGUID = "org.zrikzinc.hoedin"; private static char pds = Path.DirectorySeparatorChar; public static readonly string _basePath = Paths.ConfigPath + pds + "Hoedin"; 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown Logger.LogInfo((object)Muffins.Greeting()); Muffins.Register(); 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_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_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() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown CommandManager.Instance.AddConsoleCommand((ConsoleCommand)new RemoveForestry()); CommandManager.Instance.AddConsoleCommand((ConsoleCommand)new RemovePieces()); } private void LoadHoeTable() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown GameObject val = dirtyhoe.LoadAsset<GameObject>("_DirtyHoePieceTable"); PieceTableConfig val2 = new PieceTableConfig(); val2.CanRemovePieces = false; val2.UseCategories = false; val2.UseCustomCategories = true; val2.CustomCategories = new string[1] { "Paint" }; CustomPieceTable val3 = new CustomPieceTable(val, val2); PieceManager.Instance.AddPieceTable(val3); LoadHoeTool(); } private void LoadHoeTool() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown //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_0074: 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_0083: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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 static class RadiusWire { [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)("[Hoedin] 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; } } internal static class TC { 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 }); } } [HarmonyPatch(typeof(ObjectDB), "UpdateRegisters")] internal static class TerrainOpRegistry { 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)$"[Hoedin] {_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)($"[Hoedin] 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 (__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 (!TC.NView.Invoke(val).IsOwner()) { TC.NView.Invoke(val).ClaimOwnership(); } if (!TC.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 = TC.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 && TC.ModifiedHeight.Invoke(val)[num7]) { num++; flag = true; TC.ModifiedHeight.Invoke(val)[num7] = false; TC.LevelDelta.Invoke(val)[num7] = 0f; TC.SmoothDelta.Invoke(val)[num7] = 0f; } if (CoordDistance(num4, num5, j, i) <= radius && TC.ModifiedPaint.Invoke(val)[num7]) { flag = true; TC.ModifiedPaint.Invoke(val)[num7] = false; TC.PaintMask.Invoke(val)[num7] = Color.clear; } } } if (flag) { TC.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); } } } 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) //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); } } } }