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 DigDug v1.0.3
DigDug.dll
Decompiled a week agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = "")] [assembly: AssemblyVersion("0.0.0.0")] namespace DigDug; [BepInPlugin("com.antigravity.valheim.digdug", "DigDug", "1.0.3")] public class DigDugPlugin : BaseUnityPlugin { public const string PluginGUID = "com.antigravity.valheim.digdug"; public const string PluginName = "DigDug"; public const string PluginVersion = "1.0.3"; public static ManualLogSource Log; private Harmony harmony; private GameObject uiObject; private void Awake() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; DigDugConfig.Init(((BaseUnityPlugin)this).Config); DigDugReflection.Init(); harmony = new Harmony("com.antigravity.valheim.digdug"); harmony.PatchAll(); uiObject = new GameObject("DigDugUI"); uiObject.AddComponent<DigDugUI>(); Object.DontDestroyOnLoad((Object)(object)uiObject); ((BaseUnityPlugin)this).Logger.LogInfo((object)"DigDug mod initialized successfully!"); } private void OnDestroy() { if ((Object)(object)uiObject != (Object)null) { Object.Destroy((Object)(object)uiObject); } if (harmony != null) { harmony.UnpatchSelf(); } } } public static class DigDugConfig { public static ConfigEntry<bool> EnableStaminaDrain; public static ConfigEntry<bool> IgnoreDurabilityLoss; public static ConfigEntry<bool> IgnoreStoneRequirement; public static ConfigEntry<float> StoneCostMultiplier; public static ConfigEntry<float> MaxTerrainOffset; public static ConfigEntry<KeyboardShortcut> RotateLeftKey; public static ConfigEntry<KeyboardShortcut> RotateRightKey; public static ConfigEntry<KeyboardShortcut> MenuHotkey; public static void Init(ConfigFile config) { //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) EnableStaminaDrain = config.Bind<bool>("General", "EnableStaminaDrain", true, "If true, performing a batch dig/build will consume player stamina."); IgnoreDurabilityLoss = config.Bind<bool>("General", "IgnoreDurabilityLoss", false, "If true, pickaxes will not lose durability when batch digging."); IgnoreStoneRequirement = config.Bind<bool>("General", "IgnoreStoneRequirement", false, "If true, raising terrain will not consume stones from your inventory."); StoneCostMultiplier = config.Bind<float>("General", "StoneCostMultiplier", 1f, "Multiplier for the amount of stones required to raise terrain."); MaxTerrainOffset = config.Bind<float>("General", "MaxTerrainOffset", 8f, "The maximum height/depth change limit in meters from the original base height. Vanilla Valheim is 8.0m. Increase this if you use mods that extend terrain height limits."); RotateLeftKey = config.Bind<KeyboardShortcut>("Keybinds", "RotateLeftKey", new KeyboardShortcut((KeyCode)276, (KeyCode[])(object)new KeyCode[0]), "Key to rotate player/preview counter-clockwise."); RotateRightKey = config.Bind<KeyboardShortcut>("Keybinds", "RotateRightKey", new KeyboardShortcut((KeyCode)275, (KeyCode[])(object)new KeyCode[0]), "Key to rotate player/preview clockwise."); MenuHotkey = config.Bind<KeyboardShortcut>("Keybinds", "MenuHotkey", new KeyboardShortcut((KeyCode)0, (KeyCode[])(object)new KeyCode[0]), "Optional hotkey to toggle the DigDug menu while holding a pickaxe (in addition to right-click)."); } } public static class DigDugPreview { private static List<GameObject> previewObjs = new List<GameObject>(); private static Material previewMat; private static GameObject GetOrCreatePreviewObject(int index) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_0079: Unknown result type (might be due to invalid IL or missing references) while (previewObjs.Count <= index) { GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); BoxCollider component = val.GetComponent<BoxCollider>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Renderer component2 = val.GetComponent<Renderer>(); if ((Object)(object)previewMat == (Object)null) { Shader val2 = Shader.Find("Sprites/Default"); if ((Object)(object)val2 == (Object)null) { val2 = Shader.Find("Standard"); } previewMat = new Material(val2); previewMat.color = new Color(0f, 0.45f, 1f, 0.35f); } component2.material = previewMat; val.SetActive(false); previewObjs.Add(val); } return previewObjs[index]; } public static void UpdatePreview(Vector3 playerPos, Vector3 forward, Vector3 right, float depth, float length, float width, int mode, int direction) { //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: 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_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_021f: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03b2: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03c8: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03e9: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0439: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) float num = depth; if (mode != 2) { GameObject orCreatePreviewObject = GetOrCreatePreviewObject(0); orCreatePreviewObject.SetActive(true); for (int i = 1; i < previewObjs.Count; i++) { if ((Object)(object)previewObjs[i] != (Object)null) { previewObjs[i].SetActive(false); } } float num2 = width; switch (mode) { case 0: num2 = 1f; break; case 3: if (num > 0f) { num = 0f - num; } break; } float num3 = 0f; Vector3 val = playerPos + forward * direction switch { 0 => length / 2f, 1 => (0f - length) / 2f, _ => 0f, }; float num4 = playerPos.y - num / 2f; orCreatePreviewObject.transform.position = new Vector3(val.x, num4, val.z); orCreatePreviewObject.transform.rotation = Quaternion.LookRotation(forward, Vector3.up); orCreatePreviewObject.transform.localScale = new Vector3(num2, Mathf.Abs(num), length); return; } float num5 = 2f; if (length <= 2f * num5 || width <= 2f * num5) { GameObject orCreatePreviewObject2 = GetOrCreatePreviewObject(0); orCreatePreviewObject2.SetActive(true); for (int j = 1; j < previewObjs.Count; j++) { if ((Object)(object)previewObjs[j] != (Object)null) { previewObjs[j].SetActive(false); } } float num6 = 0f; Vector3 val2 = playerPos + forward * direction switch { 0 => length / 2f, 1 => (0f - length) / 2f, _ => 0f, }; float num7 = playerPos.y - num / 2f; orCreatePreviewObject2.transform.position = new Vector3(val2.x, num7, val2.z); orCreatePreviewObject2.transform.rotation = Quaternion.LookRotation(forward, Vector3.up); orCreatePreviewObject2.transform.localScale = new Vector3(width, Mathf.Abs(num), length); return; } for (int k = 0; k < 4; k++) { GetOrCreatePreviewObject(k).SetActive(true); } for (int l = 4; l < previewObjs.Count; l++) { if ((Object)(object)previewObjs[l] != (Object)null) { previewObjs[l].SetActive(false); } } float num8 = 0f; num8 = direction switch { 0 => length / 2f, 1 => (0f - length) / 2f, _ => 0f, }; float num9 = playerPos.y - num / 2f; Quaternion rotation = Quaternion.LookRotation(forward, Vector3.up); GameObject orCreatePreviewObject3 = GetOrCreatePreviewObject(0); Vector3 val3 = playerPos + forward * (num8 + length / 2f - num5 / 2f); orCreatePreviewObject3.transform.position = new Vector3(val3.x, num9, val3.z); orCreatePreviewObject3.transform.rotation = rotation; orCreatePreviewObject3.transform.localScale = new Vector3(width, Mathf.Abs(num), num5); GameObject orCreatePreviewObject4 = GetOrCreatePreviewObject(1); Vector3 val4 = playerPos + forward * (num8 - length / 2f + num5 / 2f); orCreatePreviewObject4.transform.position = new Vector3(val4.x, num9, val4.z); orCreatePreviewObject4.transform.rotation = rotation; orCreatePreviewObject4.transform.localScale = new Vector3(width, Mathf.Abs(num), num5); GameObject orCreatePreviewObject5 = GetOrCreatePreviewObject(2); Vector3 val5 = playerPos + forward * num8 - right * (width / 2f - num5 / 2f); orCreatePreviewObject5.transform.position = new Vector3(val5.x, num9, val5.z); orCreatePreviewObject5.transform.rotation = rotation; orCreatePreviewObject5.transform.localScale = new Vector3(num5, Mathf.Abs(num), length - 2f * num5); GameObject orCreatePreviewObject6 = GetOrCreatePreviewObject(3); Vector3 val6 = playerPos + forward * num8 + right * (width / 2f - num5 / 2f); orCreatePreviewObject6.transform.position = new Vector3(val6.x, num9, val6.z); orCreatePreviewObject6.transform.rotation = rotation; orCreatePreviewObject6.transform.localScale = new Vector3(num5, Mathf.Abs(num), length - 2f * num5); } public static void Hide() { foreach (GameObject previewObj in previewObjs) { if ((Object)(object)previewObj != (Object)null) { previewObj.SetActive(false); } } } public static void Destroy() { foreach (GameObject previewObj in previewObjs) { if ((Object)(object)previewObj != (Object)null) { Object.Destroy((Object)(object)previewObj); } } previewObjs.Clear(); if ((Object)(object)previewMat != (Object)null) { Object.Destroy((Object)(object)previewMat); previewMat = null; } } } public class DigDugUI : MonoBehaviour { private static Rect windowRect = new Rect(100f, 100f, 750f, 680f); private static GUIStyle windowStyle; private static GUIStyle buttonStyle; private static GUIStyle textFieldStyle; private static GUIStyle labelStyle; private static GUIStyle headerStyle; private static GUIStyle costLabelStyle; private string depthStr = "4.0"; private string lengthStr = "4.0"; private string widthStr = "4.0"; private int selectedMode = 1; private readonly string[] modeLabels = new string[4] { "Line", "Rectangle", "Trench", "Wall" }; private int selectedDirection; private readonly string[] directionLabels = new string[3] { "Forward", "Backward", "Center" }; private int selectedPaint; private readonly string[] paintLabels = new string[4] { "Dirt", "Paved", "Grass", "No Change" }; private static Font nativeFont; private float leftArrowDownTime; private float rightArrowDownTime; public static DigDugUI Instance { get; private set; } public static bool IsVisible { get; private set; } private void Awake() { Instance = this; IsVisible = false; } private void OnDestroy() { DigDugPreview.Destroy(); } public static void Show() { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { IsVisible = true; ToggleCursor(visible: true); } } public static void Hide() { IsVisible = false; ToggleCursor(visible: false); DigDugPreview.Hide(); } private static void ToggleCursor(bool visible) { if (visible) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } else { Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; } } private void HandleArrowKeyRotation(Player player) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) float num = 0f; KeyboardShortcut value = DigDugConfig.RotateLeftKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { num -= 1f; leftArrowDownTime = Time.time; } else { KeyboardShortcut value2 = DigDugConfig.RotateLeftKey.Value; if (((KeyboardShortcut)(ref value2)).IsPressed() && Time.time - leftArrowDownTime > 0.3f) { num -= 30f * Time.deltaTime; } } KeyboardShortcut value3 = DigDugConfig.RotateRightKey.Value; if (((KeyboardShortcut)(ref value3)).IsDown()) { num += 1f; rightArrowDownTime = Time.time; } else { KeyboardShortcut value4 = DigDugConfig.RotateRightKey.Value; if (((KeyboardShortcut)(ref value4)).IsPressed() && Time.time - rightArrowDownTime > 0.3f) { num += 30f * Time.deltaTime; } } if (Mathf.Abs(num) > 0.0001f) { Quaternion lookYaw = ((Character)player).GetLookYaw(); Quaternion val = lookYaw * Quaternion.Euler(0f, num, 0f); ((Character)player).SetLookDir(val * Vector3.forward, 0f); player.FaceLookDirection(); } } private void Update() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_003d: 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) //IL_0045: 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_0056: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon(); if (currentWeapon != null && (int)currentWeapon.m_shared.m_skillType == 12) { HandleArrowKeyRotation(localPlayer); KeyboardShortcut value = DigDugConfig.MenuHotkey.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey != 0) { KeyboardShortcut value2 = DigDugConfig.MenuHotkey.Value; if (((KeyboardShortcut)(ref value2)).IsDown()) { if (IsVisible) { Hide(); return; } if (!InventoryGui.IsVisible() && !Minimap.IsOpen() && !Menu.IsVisible() && !Console.IsVisible() && !StoreGui.IsVisible() && !TextInput.IsVisible() && !Hud.InRadial() && !Hud.IsPieceSelectionVisible()) { DigDugPlugin.Log.LogInfo((object)"DigDug: Menu hotkey detected! Triggering UI."); Show(); } } } } } if (IsVisible) { if (Input.GetKeyDown((KeyCode)27)) { Hide(); return; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; UpdatePreviewObject(); } } private void LateUpdate() { if (IsVisible) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } } private void UpdatePreviewObject() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { ParseInputs(out var depth, out var length, out var width); Vector3 forward = ((Component)localPlayer).transform.forward; forward.y = 0f; ((Vector3)(ref forward)).Normalize(); Vector3 right = ((Component)localPlayer).transform.right; right.y = 0f; ((Vector3)(ref right)).Normalize(); DigDugPreview.UpdatePreview(((Component)localPlayer).transform.position, forward, right, depth, length, width, selectedMode, selectedDirection); } } private void ParseInputs(out float depth, out float length, out float width) { if (!float.TryParse(depthStr, out depth)) { depth = 4f; } if (!float.TryParse(lengthStr, out length)) { length = 4f; } if (!float.TryParse(widthStr, out width)) { width = 4f; } float value = DigDugConfig.MaxTerrainOffset.Value; depth = Mathf.Clamp(depth, 0f - value, value); length = Mathf.Clamp(length, 0.1f, 100f); width = Mathf.Clamp(width, 0.1f, 100f); } private void OnGUI() { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) DrawHUDOverlay(); if (!IsVisible) { return; } if (Event.current != null && (int)Event.current.type == 4) { KeyCode keyCode = Event.current.keyCode; KeyboardShortcut value = DigDugConfig.RotateLeftKey.Value; if (keyCode != ((KeyboardShortcut)(ref value)).MainKey) { KeyCode keyCode2 = Event.current.keyCode; KeyboardShortcut value2 = DigDugConfig.RotateRightKey.Value; if (keyCode2 != ((KeyboardShortcut)(ref value2)).MainKey) { goto IL_0064; } } GUI.FocusControl((string)null); } goto IL_0064; IL_0064: Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; VerifyStyles(); ((Rect)(ref windowRect)).x = ((float)Screen.width - ((Rect)(ref windowRect)).width) / 2f; ((Rect)(ref windowRect)).y = ((float)Screen.height - ((Rect)(ref windowRect)).height) / 2f; windowRect = GUI.Window(9923, windowRect, new WindowFunction(DrawWindow), "DIGDUG EXCAVATION", windowStyle); } private void DrawWindow(int windowID) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_05e3: Unknown result type (might be due to invalid IL or missing references) //IL_05ea: Expected O, but got Unknown //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Unknown result type (might be due to invalid IL or missing references) //IL_061e: Unknown result type (might be due to invalid IL or missing references) //IL_0634: Unknown result type (might be due to invalid IL or missing references) //IL_0639: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Space(25f); GUIStyle val = new GUIStyle(labelStyle); val.normal.textColor = new Color(0.92f, 0.73f, 0.16f, 1f); val.alignment = (TextAnchor)4; val.fontSize = 24; GUILayout.Label(GetFacingString(), val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(35f) }); GUILayout.Space(5f); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Mode:", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(130f), GUILayout.Height(36f) }); int num = selectedMode; selectedMode = GUILayout.SelectionGrid(selectedMode, modeLabels, 4, buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }); GUILayout.EndHorizontal(); if (selectedMode != num) { if (selectedMode == 0) { depthStr = "2.0"; lengthStr = "10.0"; widthStr = "1.0"; } else if (selectedMode == 1) { depthStr = "4.0"; lengthStr = "4.0"; widthStr = "4.0"; } else if (selectedMode == 2) { depthStr = "4.0"; lengthStr = "4.0"; widthStr = "4.0"; } else if (selectedMode == 3) { depthStr = "2.0"; lengthStr = "4.0"; widthStr = "4.0"; } } GUILayout.Space(6f); ParseInputs(out var depth, out var length, out var width); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); string text = ((selectedMode == 3) ? "Height:" : "Depth:"); GUILayout.Label(text, labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(130f), GUILayout.Height(36f) }); depthStr = GUILayout.TextField(depthStr, textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Length:", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(130f), GUILayout.Height(36f) }); lengthStr = GUILayout.TextField(lengthStr, textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }); GUILayout.EndHorizontal(); GUILayout.Space(6f); if (selectedMode != 0) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Width:", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(130f), GUILayout.Height(36f) }); widthStr = GUILayout.TextField(widthStr, textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }); GUILayout.EndHorizontal(); GUILayout.Space(6f); } if (selectedMode != 2) { GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Direction:", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(130f), GUILayout.Height(36f) }); selectedDirection = GUILayout.SelectionGrid(selectedDirection, directionLabels, 3, buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }); GUILayout.EndHorizontal(); GUILayout.Space(6f); } GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label("Paint:", labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(130f), GUILayout.Height(36f) }); selectedPaint = GUILayout.SelectionGrid(selectedPaint, paintLabels, 4, buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }); GUILayout.EndHorizontal(); GUILayout.Space(6f); GUILayout.Space(10f); CalculateCosts(depth, length, width, out var area, out var swingCount, out var staminaCost, out var durabilityCost, out var stoneCost); GUILayout.BeginVertical(GUI.skin.box, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label($"Area: {area:F1} m² | Swings: {swingCount}", costLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]); if (selectedMode == 3 || depth < 0f) { int stoneCount = GetStoneCount(); bool flag = DigDugConfig.IgnoreStoneRequirement.Value || ((Object)(object)Player.m_localPlayer != (Object)null && Player.m_localPlayer.NoCostCheat()); string arg = ((stoneCount >= stoneCost || flag) ? "lime" : "red"); GUILayout.Label($"Stone Cost: <color={arg}>{stoneCost}</color> / {stoneCount} available", costLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]); } string arg2 = "lime"; float totalPickaxeDurability = GetTotalPickaxeDurability(); if (totalPickaxeDurability < durabilityCost && !DigDugConfig.IgnoreDurabilityLoss.Value) { arg2 = "red"; } GUILayout.Label($"Durability Cost: <color={arg2}>{durabilityCost:F0}</color> / {totalPickaxeDurability:F0} available", costLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Label($"Stamina Cost: {staminaCost:F0}", costLabelStyle, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.EndVertical(); GUILayout.Space(10f); GUIStyle val2 = new GUIStyle(labelStyle); val2.normal.textColor = Color.white; val2.alignment = (TextAnchor)4; val2.fontSize = 28; val2.wordWrap = true; string text2 = ((object)DigDugConfig.RotateLeftKey.Value/*cast due to .constrained prefix*/).ToString(); string text3 = ((object)DigDugConfig.RotateRightKey.Value/*cast due to .constrained prefix*/).ToString(); string text4 = "Tip: Use " + text2 + "/" + text3 + " to rotate 1° (hold to rotate continuously)"; GUILayout.Label(text4, val2, (GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.Space(10f); GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]); GUILayout.FlexibleSpace(); if (GUILayout.Button("Cancel", buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(140f), GUILayout.Height(38f) })) { Hide(); } GUILayout.Space(15f); string text5 = ((selectedMode == 3 || depth < 0f) ? "Build!" : "Dig!"); if (GUILayout.Button(text5, buttonStyle, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(140f), GUILayout.Height(38f) })) { ExecuteDig(depth, length, width, area, swingCount, staminaCost, durabilityCost, stoneCost); } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } private void CalculateCosts(float depth, float length, float width, out float area, out int swingCount, out float staminaCost, out float durabilityCost, out int stoneCost) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Invalid comparison between Unknown and I4 float num = width; float num2 = Mathf.Abs(depth); if (selectedMode == 0) { num = 1f; } area = length * num; if (selectedMode == 2) { float num3 = 2f; if (length > 2f * num3 && num > 2f * num3) { float num4 = (length - 2f * num3) * (num - 2f * num3); area -= num4; } } swingCount = Mathf.Max(1, Mathf.RoundToInt(area / 12.5f * Mathf.Max(1f, num2))); staminaCost = 0f; durabilityCost = 0f; stoneCost = 0; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon(); if (currentWeapon != null && (int)currentWeapon.m_shared.m_skillType == 12) { staminaCost = currentWeapon.m_shared.m_attack.m_attackStamina * (float)swingCount; durabilityCost = currentWeapon.m_shared.m_useDurabilityDrain * (float)swingCount; } } if (selectedMode == 3 || depth < 0f) { stoneCost = Mathf.Max(1, Mathf.RoundToInt(area / 12.5f * Mathf.Max(1f, num2) * 2f * DigDugConfig.StoneCostMultiplier.Value)); } } private int GetStoneCount() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return 0; } return ((Humanoid)localPlayer).GetInventory().CountItems("$item_stone", -1, false); } private float GetTotalPickaxeDurability() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Invalid comparison between Unknown and I4 Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return 0f; } float num = 0f; foreach (ItemData allItem in ((Humanoid)localPlayer).GetInventory().GetAllItems()) { if ((int)allItem.m_shared.m_skillType == 12) { num += allItem.m_durability; } } return num; } private TerrainComp GetOrCreateCompiler(Vector3 point) { //IL_0000: 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) TerrainComp val = TerrainComp.FindTerrainCompiler(point); if ((Object)(object)val != (Object)null) { return val; } Heightmap val2 = Heightmap.FindHeightmap(point); if ((Object)(object)val2 != (Object)null) { return val2.GetAndCreateTerrainCompiler(); } return null; } public static bool CheckAccessAtPoint(Vector3 point, out string blockMessage) { //IL_0022: 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_004a: 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_0088: Unknown result type (might be due to invalid IL or missing references) blockMessage = null; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return true; } if (point.y > 2000f || (Object)(object)Heightmap.FindHeightmap(point) == (Object)null) { blockMessage = "$msg_nobuildzone"; return false; } if (Location.IsInsideNoBuildLocation(point)) { blockMessage = "$msg_nobuildzone"; return false; } if (!PrivateArea.CheckAccess(point, 0f, false, true)) { blockMessage = "$msg_nobuildzone"; foreach (PrivateArea allArea in DigDugReflection.GetAllAreas()) { if (DigDugReflection.IsAreaEnabled(allArea) && Vector3.Distance(((Component)allArea).transform.position, point) < allArea.m_radius && allArea.m_name == "$piece_guardstone") { blockMessage = "$msg_privatezone"; break; } } return false; } return true; } private void ExecuteDig(float depth, float length, float width, float area, int swingCount, float staminaCost, float durabilityCost, int stoneCost) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0228: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) //IL_035f: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_0600: Expected O, but got Unknown //IL_0803: Unknown result type (might be due to invalid IL or missing references) //IL_0808: Unknown result type (might be due to invalid IL or missing references) //IL_0810: Unknown result type (might be due to invalid IL or missing references) //IL_0815: Unknown result type (might be due to invalid IL or missing references) //IL_0830: Unknown result type (might be due to invalid IL or missing references) //IL_0835: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Expected O, but got Unknown //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0907: Unknown result type (might be due to invalid IL or missing references) //IL_0909: Unknown result type (might be due to invalid IL or missing references) //IL_090d: Unknown result type (might be due to invalid IL or missing references) //IL_0912: Unknown result type (might be due to invalid IL or missing references) //IL_0917: Unknown result type (might be due to invalid IL or missing references) //IL_091b: Unknown result type (might be due to invalid IL or missing references) //IL_0920: Unknown result type (might be due to invalid IL or missing references) //IL_0925: Unknown result type (might be due to invalid IL or missing references) //IL_0928: Unknown result type (might be due to invalid IL or missing references) //IL_0733: Unknown result type (might be due to invalid IL or missing references) //IL_0a51: Unknown result type (might be due to invalid IL or missing references) //IL_0a56: Unknown result type (might be due to invalid IL or missing references) //IL_0ad3: Unknown result type (might be due to invalid IL or missing references) //IL_0ad5: Unknown result type (might be due to invalid IL or missing references) //IL_0ad7: Unknown result type (might be due to invalid IL or missing references) //IL_0adc: Unknown result type (might be due to invalid IL or missing references) //IL_0ade: Unknown result type (might be due to invalid IL or missing references) //IL_0ae0: Unknown result type (might be due to invalid IL or missing references) //IL_0ae9: Unknown result type (might be due to invalid IL or missing references) //IL_0aeb: Unknown result type (might be due to invalid IL or missing references) //IL_0e47: Unknown result type (might be due to invalid IL or missing references) //IL_0fbe: Unknown result type (might be due to invalid IL or missing references) //IL_0f9f: Unknown result type (might be due to invalid IL or missing references) //IL_0fa1: Unknown result type (might be due to invalid IL or missing references) //IL_0fd2: Unknown result type (might be due to invalid IL or missing references) //IL_0ff1: Unknown result type (might be due to invalid IL or missing references) //IL_0ff6: Unknown result type (might be due to invalid IL or missing references) //IL_1002: Unknown result type (might be due to invalid IL or missing references) //IL_100a: Unknown result type (might be due to invalid IL or missing references) //IL_0f30: Unknown result type (might be due to invalid IL or missing references) //IL_0f37: Invalid comparison between Unknown and I4 //IL_0c97: Unknown result type (might be due to invalid IL or missing references) //IL_0c9c: Unknown result type (might be due to invalid IL or missing references) //IL_0cb3: Unknown result type (might be due to invalid IL or missing references) //IL_0cb5: Unknown result type (might be due to invalid IL or missing references) //IL_0ccb: Unknown result type (might be due to invalid IL or missing references) //IL_0cd0: Unknown result type (might be due to invalid IL or missing references) //IL_0ce7: Unknown result type (might be due to invalid IL or missing references) //IL_0ce9: Unknown result type (might be due to invalid IL or missing references) //IL_0cff: Unknown result type (might be due to invalid IL or missing references) //IL_0d04: Unknown result type (might be due to invalid IL or missing references) //IL_0d1b: Unknown result type (might be due to invalid IL or missing references) //IL_0d1d: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon(); if (currentWeapon == null || (int)currentWeapon.m_shared.m_skillType != 12) { ((Character)localPlayer).Message((MessageType)1, "You must equip a pickaxe to execute this operation!", 0, (Sprite)null); return; } float value = DigDugConfig.MaxTerrainOffset.Value; float num = 0f; int num2 = 0; Vector3 position = ((Component)localPlayer).transform.position; Vector3 forward = ((Component)localPlayer).transform.forward; forward.y = 0f; ((Vector3)(ref forward)).Normalize(); Vector3 right = ((Component)localPlayer).transform.right; right.y = 0f; ((Vector3)(ref right)).Normalize(); float num3 = width; float num4 = depth; if (selectedMode == 0) { num3 = 1f; } else if (selectedMode == 3) { num4 = 0f - depth; } float num5 = 0f; float num6 = 0f; float num7 = (0f - num3) / 2f; float num8 = num3 / 2f; if (selectedDirection == 0) { num5 = 0.5f; num6 = length + 0.5f; } else if (selectedDirection == 1) { num5 = 0f - length - 0.5f; num6 = -0.5f; } else { num5 = (0f - length) / 2f; num6 = length / 2f; } Vector3 val = position + forward * ((num5 + num6) / 2f); Vector3 val2 = position + forward * num5 + right * num7; Vector3 val3 = position + forward * num5 + right * num8; Vector3 val4 = position + forward * num6 + right * num7; Vector3 val5 = position + forward * num6 + right * num8; Vector3[] array = (Vector3[])(object)new Vector3[6] { position, val, val2, val3, val4, val5 }; Vector3[] array2 = array; foreach (Vector3 point in array2) { if (!CheckAccessAtPoint(point, out var blockMessage)) { Hide(); ((Character)localPlayer).Message((MessageType)2, blockMessage, 0, (Sprite)null); return; } } float num9 = position.y - num4; HashSet<TerrainComp> hashSet = new HashSet<TerrainComp>(); for (float num10 = num5 - 4f; num10 <= num6 + 4f; num10 += 8f) { for (float num11 = num7 - 4f; num11 <= num8 + 4f; num11 += 8f) { Vector3 point2 = position + forward * num10 + right * num11; TerrainComp orCreateCompiler = GetOrCreateCompiler(point2); if ((Object)(object)orCreateCompiler != (Object)null) { hashSet.Add(orCreateCompiler); } } } HashSet<string> hashSet2 = new HashSet<string>(); Vector3 val6 = default(Vector3); foreach (TerrainComp item3 in hashSet) { Heightmap hmap = DigDugReflection.GetHmap(item3); if ((Object)(object)hmap == (Object)null) { continue; } int width2 = hmap.m_width; float scale = hmap.m_scale; Vector3 position2 = ((Component)hmap).transform.position; int num12 = width2 / 2; for (int j = 0; j <= width2; j++) { for (int k = 0; k <= width2; k++) { float num13 = position2.x + (float)(k - num12) * scale; float num14 = position2.z + (float)(j - num12) * scale; ((Vector3)(ref val6))..ctor(num13, position.y, num14); Vector3 val7 = val6 - position; float num15 = Vector3.Dot(val7, forward); float num16 = Vector3.Dot(val7, right); float num17 = num5 - scale / 2f; float num18 = num6 + scale / 2f; float num19 = num7 - scale / 2f; float num20 = num8 + scale / 2f; if (!(num15 >= num17 - 0.1f) || !(num15 <= num18 + 0.1f) || !(num16 >= num19 - 0.1f) || !(num16 <= num20 + 0.1f)) { continue; } if (selectedMode == 2) { float num21 = 2f; if (length > 2f * num21 && num3 > 2f * num21 && num15 >= num17 + num21 - 0.01f && num15 <= num18 - num21 + 0.01f && num16 >= num19 + num21 - 0.01f && num16 <= num20 - num21 + 0.01f) { continue; } } string item = ((Object)((Component)item3).gameObject).name + "_" + k + "_" + j; if (!hashSet2.Contains(item)) { hashSet2.Add(item); num2++; float height = hmap.GetHeight(k, j); DigDugReflection.GetWorldBaseHeight(hmap, new Vector3(num13, position.y, num14), out var baseHeight); float num22 = Mathf.Clamp(num9, baseHeight - value, baseHeight + value); num += Mathf.Abs(num22 - height); } } } } if (num2 > 0 && num < 0.01f && (!(Mathf.Abs(depth) < 0.001f) || selectedPaint == 3)) { ((Character)localPlayer).Message((MessageType)1, "Cannot execute! The target height is already reached or exceeds the maximum terrain modification limit (" + value + "m from original base ground).", 0, (Sprite)null); return; } bool flag = selectedMode == 3 || depth < 0f; GameObject val8 = null; Piece val9 = null; if (flag) { val8 = new GameObject("DigDug_DummyPiece"); val8.SetActive(false); val9 = val8.AddComponent<Piece>(); GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Stone"); ItemDrop resItem = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponent<ItemDrop>() : null); val9.m_resources = (Requirement[])(object)new Requirement[1]; val9.m_resources[0] = new Requirement(); val9.m_resources[0].m_resItem = resItem; val9.m_resources[0].m_amount = stoneCost; val9.m_resources[0].m_amountPerLevel = 0; val9.m_resources[0].m_recover = true; if (selectedMode == 3) { GameObject prefab = ZNetScene.instance.GetPrefab("piece_stonecutter"); val9.m_craftingStation = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<CraftingStation>() : null); } else { GameObject prefab2 = ZNetScene.instance.GetPrefab("piece_workbench"); val9.m_craftingStation = (((Object)(object)prefab2 != (Object)null) ? prefab2.GetComponent<CraftingStation>() : null); } if (!localPlayer.NoCostCheat() && !DigDugConfig.IgnoreStoneRequirement.Value) { if ((Object)(object)val9.m_craftingStation != (Object)null) { string name = val9.m_craftingStation.m_name; if (!Object.op_Implicit((Object)(object)CraftingStation.HaveBuildStationInRange(name, ((Component)localPlayer).transform.position))) { string text = Localization.instance.Localize(name); ((Character)localPlayer).Message((MessageType)1, "Missing station: " + text + " in range!", 0, (Sprite)null); Object.Destroy((Object)(object)val8); return; } } if (!localPlayer.HaveRequirements(val9, (RequirementMode)0)) { int stoneCount = GetStoneCount(); ((Character)localPlayer).Message((MessageType)1, $"Not enough stone! Required: {stoneCost}, you have: {stoneCount}", 0, (Sprite)null); Object.Destroy((Object)(object)val8); return; } } } if (!DigDugConfig.IgnoreDurabilityLoss.Value) { float totalPickaxeDurability = GetTotalPickaxeDurability(); if (totalPickaxeDurability < durabilityCost) { ((Character)localPlayer).Message((MessageType)1, $"Your pickaxes are too damaged! Required durability: {durabilityCost:F0}, you have: {totalPickaxeDurability:F0}", 0, (Sprite)null); if ((Object)(object)val8 != (Object)null) { Object.Destroy((Object)(object)val8); } return; } } Vector3 position3 = ((Component)localPlayer).transform.position; Vector3 forward2 = ((Component)localPlayer).transform.forward; forward2.y = 0f; ((Vector3)(ref forward2)).Normalize(); Vector3 right2 = ((Component)localPlayer).transform.right; right2.y = 0f; ((Vector3)(ref right2)).Normalize(); float num23 = width; float num24 = depth; if (selectedMode == 0) { num23 = 1f; } else if (selectedMode == 3) { num24 = 0f - depth; } float num25 = 0f; float num26 = 0f; float num27 = (0f - num23) / 2f; float num28 = num23 / 2f; if (selectedDirection == 0) { num25 = 0f; num26 = length; } else if (selectedDirection == 1) { num25 = 0f - length; num26 = 0f; } else { num25 = (0f - length) / 2f; num26 = length / 2f; } float num29 = position3.y - num24; HashSet<TerrainComp> hashSet3 = new HashSet<TerrainComp>(); float num30 = 8f; for (float num31 = num25 - 4f; num31 <= num26 + 4f; num31 += num30) { for (float num32 = num27 - 4f; num32 <= num28 + 4f; num32 += num30) { Vector3 point3 = position3 + forward2 * num31 + right2 * num32; TerrainComp orCreateCompiler2 = GetOrCreateCompiler(point3); if ((Object)(object)orCreateCompiler2 != (Object)null) { hashSet3.Add(orCreateCompiler2); } } } HashSet<string> hashSet4 = new HashSet<string>(); HashSet<TerrainComp> hashSet5 = new HashSet<TerrainComp>(); Vector3 val10 = default(Vector3); foreach (TerrainComp item4 in hashSet3) { ZNetView nView = DigDugReflection.GetNView(item4); if ((Object)(object)nView != (Object)null && nView.IsValid()) { long owner = nView.GetZDO().GetOwner(); long uID = ZNet.GetUID(); DigDugPlugin.Log.LogInfo((object)("DigDug: Modifying TerrainComp. ZDO Owner: " + owner + ", Local UID: " + uID + ", IsOwner: " + nView.IsOwner())); nView.ClaimOwnership(); } Heightmap hmap2 = DigDugReflection.GetHmap(item4); if ((Object)(object)hmap2 == (Object)null) { continue; } int width3 = hmap2.m_width; float scale2 = hmap2.m_scale; Vector3 position4 = ((Component)hmap2).transform.position; int num33 = width3 / 2; float[] levelDelta = DigDugReflection.GetLevelDelta(item4); float[] smoothDelta = DigDugReflection.GetSmoothDelta(item4); bool[] modifiedHeight = DigDugReflection.GetModifiedHeight(item4); Color[] paintMask = DigDugReflection.GetPaintMask(item4); bool[] modifiedPaint = DigDugReflection.GetModifiedPaint(item4); for (int l = 0; l <= width3; l++) { for (int m = 0; m <= width3; m++) { float num34 = position4.x + (float)(m - num33) * scale2; float num35 = position4.z + (float)(l - num33) * scale2; ((Vector3)(ref val10))..ctor(num34, position3.y, num35); Vector3 val11 = val10 - position3; float num36 = Vector3.Dot(val11, forward2); float num37 = Vector3.Dot(val11, right2); float num38 = num25 - scale2 / 2f; float num39 = num26 + scale2 / 2f; float num40 = num27 - scale2 / 2f; float num41 = num28 + scale2 / 2f; if (!(num36 >= num38 - 0.1f) || !(num36 <= num39 + 0.1f) || !(num37 >= num40 - 0.1f) || !(num37 <= num41 + 0.1f)) { continue; } if (selectedMode == 2) { float num42 = 2f; if (length > 2f * num42 && num23 > 2f * num42 && num36 >= num38 + num42 - 0.01f && num36 <= num39 - num42 + 0.01f && num37 >= num40 + num42 - 0.01f && num37 <= num41 - num42 + 0.01f) { continue; } } string item2 = ((Object)((Component)item4).gameObject).name + "_" + m + "_" + l; if (!hashSet4.Contains(item2)) { hashSet4.Add(item2); int num43 = l * (width3 + 1) + m; float height2 = hmap2.GetHeight(m, l); float num44 = num29 - height2; num44 += smoothDelta[num43]; smoothDelta[num43] = 0f; levelDelta[num43] += num44; levelDelta[num43] = Mathf.Clamp(levelDelta[num43], 0f - value, value); modifiedHeight[num43] = true; if (selectedPaint == 0) { Color paintMaskDirt = Heightmap.m_paintMaskDirt; paintMaskDirt.a = 0f; paintMask[num43] = paintMaskDirt; modifiedPaint[num43] = true; } else if (selectedPaint == 1) { Color paintMaskPaved = Heightmap.m_paintMaskPaved; paintMaskPaved.a = 0f; paintMask[num43] = paintMaskPaved; modifiedPaint[num43] = true; } else if (selectedPaint == 2) { Color paintMaskNothing = Heightmap.m_paintMaskNothing; paintMaskNothing.a = 1f; paintMask[num43] = paintMaskNothing; modifiedPaint[num43] = true; } hashSet5.Add(item4); } } } } foreach (TerrainComp item5 in hashSet5) { ZNetView nView2 = DigDugReflection.GetNView(item5); if ((Object)(object)nView2 != (Object)null && nView2.IsValid()) { long owner2 = nView2.GetZDO().GetOwner(); long uID2 = ZNet.GetUID(); DigDugPlugin.Log.LogInfo((object)("DigDug: Saving TerrainComp. ZDO Owner: " + owner2 + ", Local UID: " + uID2 + ", IsOwner: " + nView2.IsOwner())); nView2.ClaimOwnership(); } DigDugReflection.Save(item5); DigDugReflection.GetHmap(item5).Poke(false); if ((Object)(object)ClutterSystem.instance != (Object)null) { ClutterSystem.instance.ResetGrass(((Component)item5).transform.position, DigDugReflection.GetSize(item5)); } } if (DigDugConfig.EnableStaminaDrain.Value) { ((Character)localPlayer).UseStamina(staminaCost); } if (flag) { if (!localPlayer.NoCostCheat() && !DigDugConfig.IgnoreStoneRequirement.Value && (Object)(object)val9 != (Object)null) { localPlayer.ConsumeResources(val9.m_resources, 0, 1, 1); } if ((Object)(object)val8 != (Object)null) { Object.Destroy((Object)(object)val8); } } if (!DigDugConfig.IgnoreDurabilityLoss.Value) { float num45 = durabilityCost; float num46 = Mathf.Min(currentWeapon.m_durability, num45); currentWeapon.m_durability -= num46; num45 -= num46; if (num45 > 0f) { foreach (ItemData allItem in ((Humanoid)localPlayer).GetInventory().GetAllItems()) { if ((int)allItem.m_shared.m_skillType == 12 && allItem != currentWeapon) { float num47 = Mathf.Min(allItem.m_durability, num45); allItem.m_durability -= num47; num45 -= num47; if (num45 <= 0f) { break; } } } } } if (currentWeapon.m_shared.m_hitTerrainEffect != null) { currentWeapon.m_shared.m_hitTerrainEffect.Create(position3, Quaternion.identity, (Transform)null, 1f, -1); } float num48 = default(float); if (ZoneSystem.instance.GetGroundHeight(((Component)localPlayer).transform.position, ref num48) && Mathf.Abs(((Component)localPlayer).transform.position.y - num48) > 0.05f) { Vector3 position5 = ((Component)localPlayer).transform.position; position5.y = num48; ((Character)localPlayer).TeleportTo(position5, ((Component)localPlayer).transform.rotation, false); } Hide(); } private string GetFacingString() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return "Facing: Unknown"; } Vector3 forward = ((Component)localPlayer).transform.forward; forward.y = 0f; ((Vector3)(ref forward)).Normalize(); float num = Mathf.Atan2(forward.x, forward.z) * 57.29578f; if (num < 0f) { num += 360f; } string text = ""; text = ((num >= 337.5f || num < 22.5f) ? "North (N)" : ((num >= 22.5f && num < 67.5f) ? "North-East (NE)" : ((num >= 67.5f && num < 112.5f) ? "East (E)" : ((num >= 112.5f && num < 157.5f) ? "South-East (SE)" : ((num >= 157.5f && num < 202.5f) ? "South (S)" : ((num >= 202.5f && num < 247.5f) ? "South-West (SW)" : ((!(num >= 247.5f) || !(num < 292.5f)) ? "North-West (NW)" : "West (W)"))))))); return $"Facing: {text} ({num:F0}°)"; } private void DrawHUDOverlay() { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon(); if (currentWeapon != null && (int)currentWeapon.m_shared.m_skillType == 12) { string facingString = GetFacingString(); GUIStyle val = new GUIStyle(); val.fontSize = 36; val.fontStyle = (FontStyle)1; val.normal.textColor = new Color(0.92f, 0.73f, 0.16f, 1f); val.alignment = (TextAnchor)4; Font val2 = GetNativeFont(); if ((Object)(object)val2 != (Object)null) { val.font = val2; } GUIStyle val3 = new GUIStyle(val); val3.normal.textColor = Color.black; float num = 800f; float num2 = 60f; float num3 = ((float)Screen.width - num) / 2f; float num4 = 90f; GUI.Label(new Rect(num3 + 2f, num4 + 2f, num, num2), facingString, val3); GUI.Label(new Rect(num3, num4, num, num2), facingString, val); } } private static Font GetNativeFont() { if ((Object)(object)nativeFont == (Object)null) { Font[] array = Resources.FindObjectsOfTypeAll<Font>(); foreach (Font val in array) { if (((Object)val).name == "AveriaSansLibre-Bold" || ((Object)val).name == "AveriaSerifLibre-Regular" || ((Object)val).name.Contains("Averia")) { nativeFont = val; break; } } } return nativeFont; } private static void VerifyStyles() { if (windowStyle == null || !((Object)(object)windowStyle.normal.background != (Object)null)) { InitStyles(); } } private static void InitStyles() { //IL_002f: 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_0060: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Expected O, but got Unknown //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Expected O, but got Unknown //IL_0228: 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_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_036e: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Expected O, but got Unknown //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Expected O, but got Unknown //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Expected O, but got Unknown //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Expected O, but got Unknown //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04bb: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04e4: Unknown result type (might be due to invalid IL or missing references) //IL_04ee: Expected O, but got Unknown //IL_04f7: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Expected O, but got Unknown //IL_0516: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Expected O, but got Unknown Color textColor = default(Color); ((Color)(ref textColor))..ctor(0.92f, 0.73f, 0.16f, 1f); new Color(0.85f, 0.7f, 0.2f, 1f); Color val = default(Color); ((Color)(ref val))..ctor(0.88f, 0.63f, 0.28f, 1f); Font val2 = GetNativeFont(); windowStyle = new GUIStyle(); windowStyle.normal.background = CreateWoodPanelTexture(128, 128); windowStyle.normal.textColor = textColor; windowStyle.padding = new RectOffset(20, 20, 60, 20); windowStyle.alignment = (TextAnchor)1; windowStyle.fontSize = 26; windowStyle.fontStyle = (FontStyle)1; windowStyle.border = new RectOffset(6, 6, 6, 6); if ((Object)(object)val2 != (Object)null) { windowStyle.font = val2; } labelStyle = new GUIStyle(); labelStyle.normal.textColor = val; labelStyle.fontSize = 18; labelStyle.fontStyle = (FontStyle)1; labelStyle.alignment = (TextAnchor)3; labelStyle.margin = new RectOffset(0, 5, 5, 5); if ((Object)(object)val2 != (Object)null) { labelStyle.font = val2; } headerStyle = new GUIStyle(labelStyle); headerStyle.fontSize = 24; headerStyle.alignment = (TextAnchor)4; headerStyle.normal.textColor = textColor; costLabelStyle = new GUIStyle(labelStyle); costLabelStyle.fontSize = 16; costLabelStyle.normal.textColor = new Color(0.7f, 0.7f, 0.7f, 1f); costLabelStyle.richText = true; costLabelStyle.margin = new RectOffset(5, 5, 2, 2); if ((Object)(object)val2 != (Object)null) { costLabelStyle.font = val2; } buttonStyle = new GUIStyle(); buttonStyle.normal.background = CreateButtonTexture(64, 24, new Color(0.08f, 0.08f, 0.08f, 0.9f), new Color(0.27f, 0.23f, 0.2f, 1f)); buttonStyle.hover.background = CreateButtonTexture(64, 24, new Color(0.12f, 0.12f, 0.12f, 0.9f), val); buttonStyle.active.background = CreateButtonTexture(64, 24, new Color(0.05f, 0.05f, 0.05f, 0.9f), val); buttonStyle.normal.textColor = val; buttonStyle.hover.textColor = Color.white; buttonStyle.active.textColor = val; buttonStyle.onNormal.background = CreateButtonTexture(64, 24, new Color(0.22f, 0.18f, 0.15f, 0.95f), val); buttonStyle.onHover.background = CreateButtonTexture(64, 24, new Color(0.26f, 0.22f, 0.19f, 0.95f), val); buttonStyle.onActive.background = CreateButtonTexture(64, 24, new Color(0.18f, 0.15f, 0.12f, 0.95f), val); buttonStyle.onNormal.textColor = Color.white; buttonStyle.onHover.textColor = Color.white; buttonStyle.onActive.textColor = Color.white; buttonStyle.alignment = (TextAnchor)4; buttonStyle.fontSize = 18; buttonStyle.fontStyle = (FontStyle)1; buttonStyle.margin = new RectOffset(4, 4, 4, 4); buttonStyle.padding = new RectOffset(12, 12, 8, 8); buttonStyle.border = new RectOffset(2, 2, 2, 2); if ((Object)(object)val2 != (Object)null) { buttonStyle.font = val2; } textFieldStyle = new GUIStyle(); textFieldStyle.normal.background = CreateButtonTexture(64, 24, new Color(0.05f, 0.05f, 0.05f, 0.95f), new Color(0.2f, 0.18f, 0.15f, 1f)); textFieldStyle.focused.background = CreateButtonTexture(64, 24, new Color(0.05f, 0.05f, 0.05f, 0.95f), val); textFieldStyle.normal.textColor = Color.white; textFieldStyle.focused.textColor = Color.white; textFieldStyle.padding = new RectOffset(12, 12, 8, 8); textFieldStyle.margin = new RectOffset(0, 0, 4, 4); textFieldStyle.fontSize = 18; textFieldStyle.border = new RectOffset(2, 2, 2, 2); if ((Object)(object)val2 != (Object)null) { textFieldStyle.font = val2; } } private static Texture2D CreateWoodPanelTexture(int width, int height) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.12f, 0.08f, 0.06f, 1f); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.38f, 0.25f, 0.18f, 0.98f); Color val4 = default(Color); ((Color)(ref val4))..ctor(0.22f, 0.15f, 0.11f, 1f); Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { bool flag = j == 0 || j == width - 1 || i == 0 || i == height - 1; bool flag2 = (j > 0 && j < 4) || (j >= width - 4 && j < width - 1) || (i > 0 && i < 4) || (i >= height - 4 && i < height - 1); if (flag) { array[i * width + j] = val2; continue; } if (flag2) { array[i * width + j] = val4; continue; } float num = Mathf.PerlinNoise((float)j * 0.15f, (float)i * 0.03f) * 0.06f - 0.03f; float num2 = Mathf.Sin((float)i * 1.5f + Mathf.PerlinNoise((float)j * 0.05f, (float)i * 0.05f) * 6f) * 0.02f; float num3 = Mathf.Clamp01(val3.r + num + num2); float num4 = Mathf.Clamp01(val3.g + num + num2); float num5 = Mathf.Clamp01(val3.b + num + num2); ref Color reference = ref array[i * width + j]; reference = new Color(num3, num4, num5, val3.a); } } val.SetPixels(array); val.Apply(); return val; } private static Texture2D CreateButtonTexture(int width, int height, Color bgColor, Color borderColor) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(width, height); Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { bool flag = j == 0 || j == width - 1 || i == 0 || i == height - 1; array[i * width + j] = (flag ? borderColor : bgColor); } } val.SetPixels(array); val.Apply(); return val; } } [HarmonyPatch] public static class DigDugPatches { private static float lastLogTime; [HarmonyPrefix] [HarmonyPatch(typeof(Player), "SetControls")] public static void Player_SetControls_Prefix(Player __instance, ref bool block, ref bool blockHold) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Invalid comparison between Unknown and I4 //IL_0077: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || InventoryGui.IsVisible() || Minimap.IsOpen() || Menu.IsVisible() || Console.IsVisible() || StoreGui.IsVisible() || TextInput.IsVisible() || Hud.InRadial() || Hud.IsPieceSelectionVisible()) { return; } ItemData currentWeapon = ((Humanoid)__instance).GetCurrentWeapon(); if (currentWeapon == null || (int)currentWeapon.m_shared.m_skillType != 12 || !block) { return; } block = false; blockHold = false; if (!DigDugUI.IsVisible) { if (!DigDugUI.CheckAccessAtPoint(((Component)__instance).transform.position, out var blockMessage)) { ((Character)__instance).Message((MessageType)2, blockMessage, 0, (Sprite)null); return; } DigDugPlugin.Log.LogInfo((object)"DigDug: Pickaxe block (Right-click) detected! Triggering UI."); DigDugUI.Show(); } } [HarmonyPrefix] [HarmonyPatch(typeof(Player), "TakeInput")] public static bool Player_TakeInput_Prefix(ref bool __result) { if (DigDugUI.IsVisible) { __result = false; return false; } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(PlayerController), "TakeInput")] public static bool PlayerController_TakeInput_Prefix(ref bool __result, bool look) { if (DigDugUI.IsVisible) { __result = false; return false; } return true; } [HarmonyPrefix] [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] public static bool GameCamera_UpdateMouseCapture_Prefix() { if (DigDugUI.IsVisible) { if (Time.time - lastLogTime > 2f) { DigDugPlugin.Log.LogInfo((object)"DigDug: Bypassing UpdateMouseCapture and forcing cursor unlock."); lastLogTime = Time.time; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; return false; } return true; } } public static class DigDugReflection { public delegate void LevelTerrainDelegate(TerrainComp instance, Vector3 worldPos, float radius, bool square); public delegate void SaveDelegate(TerrainComp instance); public delegate bool GetWorldBaseHeightDelegate(Heightmap instance, Vector3 worldPos, out float baseHeight); public static LevelTerrainDelegate LevelTerrain; public static SaveDelegate Save; public static GetWorldBaseHeightDelegate GetWorldBaseHeight; private static FieldInfo f_hmap; private static FieldInfo f_size; private static FieldInfo f_levelDelta; private static FieldInfo f_smoothDelta; private static FieldInfo f_modifiedHeight; private static FieldInfo f_paintMask; private static FieldInfo f_modifiedPaint; private static FieldInfo f_nview; private static FieldInfo f_raiseSkillAmount; private static FieldInfo f_allAreas; private static FieldInfo f_enabled; public static void Init() { MethodInfo method = AccessTools.Method(typeof(TerrainComp), "LevelTerrain", new Type[3] { typeof(Vector3), typeof(float), typeof(bool) }, (Type[])null); LevelTerrain = (LevelTerrainDelegate)Delegate.CreateDelegate(typeof(LevelTerrainDelegate), method); MethodInfo method2 = AccessTools.Method(typeof(TerrainComp), "Save", (Type[])null, (Type[])null); Save = (SaveDelegate)Delegate.CreateDelegate(typeof(SaveDelegate), method2); MethodInfo method3 = AccessTools.Method(typeof(Heightmap), "GetWorldBaseHeight", new Type[2] { typeof(Vector3), typeof(float).MakeByRefType() }, (Type[])null); GetWorldBaseHeight = (GetWorldBaseHeightDelegate)Delegate.CreateDelegate(typeof(GetWorldBaseHeightDelegate), method3); f_hmap = AccessTools.Field(typeof(TerrainComp), "m_hmap"); f_size = AccessTools.Field(typeof(TerrainComp), "m_size"); f_levelDelta = AccessTools.Field(typeof(TerrainComp), "m_levelDelta"); f_smoothDelta = AccessTools.Field(typeof(TerrainComp), "m_smoothDelta"); f_modifiedHeight = AccessTools.Field(typeof(TerrainComp), "m_modifiedHeight"); f_paintMask = AccessTools.Field(typeof(TerrainComp), "m_paintMask"); f_modifiedPaint = AccessTools.Field(typeof(TerrainComp), "m_modifiedPaint"); f_nview = AccessTools.Field(typeof(TerrainComp), "m_nview"); f_raiseSkillAmount = AccessTools.Field(typeof(Attack), "m_raiseSkillAmount"); f_allAreas = AccessTools.Field(typeof(PrivateArea), "m_allAreas"); f_enabled = AccessTools.Field(typeof(PrivateArea), "m_enabled"); } public static Heightmap GetHmap(TerrainComp instance) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown return (Heightmap)f_hmap.GetValue(instance); } public static float GetSize(TerrainComp instance) { return (float)f_size.GetValue(instance); } public static float[] GetLevelDelta(TerrainComp instance) { return (float[])f_levelDelta.GetValue(instance); } public static float[] GetSmoothDelta(TerrainComp instance) { return (float[])f_smoothDelta.GetValue(instance); } public static bool[] GetModifiedHeight(TerrainComp instance) { return (bool[])f_modifiedHeight.GetValue(instance); } public static Color[] GetPaintMask(TerrainComp instance) { return (Color[])f_paintMask.GetValue(instance); } public static bool[] GetModifiedPaint(TerrainComp instance) { return (bool[])f_modifiedPaint.GetValue(instance); } public static float GetRaiseSkillAmount(Attack attack) { return (float)f_raiseSkillAmount.GetValue(attack); } public static ZNetView GetNView(TerrainComp instance) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown return (ZNetView)f_nview.GetValue(instance); } public static List<PrivateArea> GetAllAreas() { return (List<PrivateArea>)f_allAreas.GetValue(null); } public static bool IsAreaEnabled(PrivateArea instance) { return (bool)f_enabled.GetValue(instance); } }