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.8
DigDug.dll
Decompiled 11 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; using ValheimShared.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace ValheimShared.UI { public static class ValheimUiBuilder { public static readonly Color ColorNorseGold = new Color(1f, 0.73f, 0.25f, 1f); public static readonly Color ColorParchment = new Color(0.88f, 0.82f, 0.72f, 1f); public static readonly Color ColorMutedText = new Color(0.7f, 0.65f, 0.55f, 1f); public static readonly Color ColorSunkenDark = new Color(0.08f, 0.07f, 0.06f, 0.9f); public static readonly Color ColorSunkenBg = new Color(0.06f, 0.05f, 0.04f, 0.65f); public static readonly Color ColorDividerGold = new Color(0.75f, 0.58f, 0.22f, 0.4f); private static TMP_FontAsset s_valheimFont; private static Material s_valheimFontMaterial; private static Dictionary<string, Sprite> s_spriteCache = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase); private static GameObject s_woodPanelTemplate; private static TMP_Text s_cleanTextTemplate; private static Button s_buttonTemplate; public static TMP_Text GetOrCreateTextTemplate() { //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_cleanTextTemplate != (Object)null) { return s_cleanTextTemplate; } TMP_Text val = null; if ((Object)(object)PlayerCustomizaton.m_barberInstance != (Object)null && (Object)(object)PlayerCustomizaton.m_barberInstance.m_selectedHair != (Object)null) { val = PlayerCustomizaton.m_barberInstance.m_selectedHair; } else if ((Object)(object)PlayerCustomizaton.m_barberInstance != (Object)null && (Object)(object)PlayerCustomizaton.m_barberInstance.m_rootPanel != (Object)null) { TMP_Text[] componentsInChildren = PlayerCustomizaton.m_barberInstance.m_rootPanel.GetComponentsInChildren<TMP_Text>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null && (Object)(object)componentsInChildren[i].font != (Object)null) { val = componentsInChildren[i]; break; } } } if ((Object)(object)val == (Object)null) { TMP_Text[] array = Resources.FindObjectsOfTypeAll<TMP_Text>(); if (array != null) { for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null && (Object)(object)array[i].font != (Object)null) { val = array[i]; break; } } } } if ((Object)(object)val != (Object)null) { s_valheimFont = val.font; s_valheimFontMaterial = val.fontSharedMaterial; try { GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject); ((Object)val2).name = "ValheimUi_CleanTextTemplate"; val2.SetActive(false); Object.DontDestroyOnLoad((Object)(object)val2); StripLocalize(val2); for (int i = val2.transform.childCount - 1; i >= 0; i--) { Object.DestroyImmediate((Object)(object)((Component)val2.transform.GetChild(i)).gameObject); } Component[] components = val2.GetComponents<Component>(); foreach (Component val3 in components) { if (!((Object)(object)val3 == (Object)null) && !(val3 is Transform) && !(val3 is RectTransform) && !(val3 is TMP_Text) && !(val3 is CanvasRenderer)) { Object.DestroyImmediate((Object)(object)val3); } } s_cleanTextTemplate = val2.GetComponent<TMP_Text>(); if ((Object)(object)s_cleanTextTemplate != (Object)null) { s_cleanTextTemplate.enableAutoSizing = false; s_cleanTextTemplate.margin = Vector4.zero; s_cleanTextTemplate.textWrappingMode = (TextWrappingModes)0; s_cleanTextTemplate.overflowMode = (TextOverflowModes)1; s_cleanTextTemplate.rectTransform.anchoredPosition = Vector2.zero; s_cleanTextTemplate.rectTransform.offsetMin = Vector2.zero; s_cleanTextTemplate.rectTransform.offsetMax = Vector2.zero; } return s_cleanTextTemplate; } catch { return val; } } return null; } public static TMP_FontAsset GetValheimFont() { if ((Object)(object)s_valheimFont != (Object)null) { return s_valheimFont; } GetOrCreateTextTemplate(); return s_valheimFont; } public static Material GetValheimFontMaterial() { if ((Object)(object)s_valheimFontMaterial != (Object)null) { return s_valheimFontMaterial; } GetOrCreateTextTemplate(); return s_valheimFontMaterial; } public static Sprite GetValheimSprite(string spriteName) { if (string.IsNullOrEmpty(spriteName)) { return null; } if (s_spriteCache.TryGetValue(spriteName, out var value) && (Object)(object)value != (Object)null) { return value; } Sprite[] array = Resources.FindObjectsOfTypeAll<Sprite>(); if (array != null) { for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null && string.Equals(((Object)array[i]).name, spriteName, StringComparison.OrdinalIgnoreCase)) { s_spriteCache[spriteName] = array[i]; return array[i]; } } } return null; } public static GameObject GetOrCreateWoodPanelTemplate() { //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) if ((Object)(object)s_woodPanelTemplate != (Object)null) { return s_woodPanelTemplate; } if ((Object)(object)PlayerCustomizaton.m_barberInstance != (Object)null && (Object)(object)PlayerCustomizaton.m_barberInstance.m_rootPanel != (Object)null) { s_woodPanelTemplate = PlayerCustomizaton.m_barberInstance.m_rootPanel; return s_woodPanelTemplate; } if ((Object)(object)InventoryGui.instance != (Object)null && (Object)(object)InventoryGui.instance.m_trophiesPanel != (Object)null) { s_woodPanelTemplate = InventoryGui.instance.m_trophiesPanel; return s_woodPanelTemplate; } Scene activeScene = SceneManager.GetActiveScene(); GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects(); if (rootGameObjects != null) { for (int i = 0; i < rootGameObjects.Length; i++) { PlayerCustomizaton componentInChildren = rootGameObjects[i].GetComponentInChildren<PlayerCustomizaton>(true); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.m_rootPanel != (Object)null) { s_woodPanelTemplate = componentInChildren.m_rootPanel; return s_woodPanelTemplate; } } } return null; } public static void PlayButtonClickAudio() { try { } catch { } } public static bool IsAnyInputFocused() { if ((Object)(object)EventSystem.current != (Object)null) { GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject; if ((Object)(object)currentSelectedGameObject != (Object)null && ((Object)(object)currentSelectedGameObject.GetComponentInParent<TMP_InputField>() != (Object)null || (Object)(object)currentSelectedGameObject.GetComponentInParent<InputField>() != (Object)null)) { return true; } } return false; } public static ValheimUiPanel CreatePanel(string name, string title, Vector2 size, Transform parent = null, Action onClose = null, bool draggable = true) { //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Expected O, but got Unknown //IL_0403: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_046c: 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_0486: Unknown result type (might be due to invalid IL or missing references) //IL_049d: Unknown result type (might be due to invalid IL or missing references) //IL_0281: 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_02bb: 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_02d5: 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_0353: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)parent == (Object)null) { if ((Object)(object)Hud.instance != (Object)null && (Object)(object)Hud.instance.m_rootObject != (Object)null) { parent = Hud.instance.m_rootObject.transform; } else { Canvas val = Object.FindObjectOfType<Canvas>(); if ((Object)(object)val != (Object)null) { parent = ((Component)val).transform; } } } GameObject orCreateWoodPanelTemplate = GetOrCreateWoodPanelTemplate(); GameObject val2; if ((Object)(object)orCreateWoodPanelTemplate != (Object)null) { val2 = Object.Instantiate<GameObject>(orCreateWoodPanelTemplate, parent, false); ((Object)val2).name = name; MonoBehaviour[] components = val2.GetComponents<MonoBehaviour>(); for (int i = 0; i < components.Length; i++) { if ((Object)(object)components[i] != (Object)null && ((object)components[i]).GetType().Name != "RectTransform" && ((object)components[i]).GetType().Name != "Image" && ((object)components[i]).GetType().Name != "CanvasRenderer") { Object.DestroyImmediate((Object)(object)components[i]); } } VerticalLayoutGroup component = val2.GetComponent<VerticalLayoutGroup>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } HorizontalLayoutGroup component2 = val2.GetComponent<HorizontalLayoutGroup>(); if ((Object)(object)component2 != (Object)null) { Object.DestroyImmediate((Object)(object)component2); } ContentSizeFitter component3 = val2.GetComponent<ContentSizeFitter>(); if ((Object)(object)component3 != (Object)null) { Object.DestroyImmediate((Object)(object)component3); } CanvasGroup component4 = val2.GetComponent<CanvasGroup>(); if ((Object)(object)component4 != (Object)null) { Object.DestroyImmediate((Object)(object)component4); } Component component5 = val2.GetComponent("Animator"); if ((Object)(object)component5 != (Object)null) { Object.DestroyImmediate((Object)(object)component5); } Image val3 = val2.GetComponent<Image>(); if ((Object)(object)val3 == (Object)null) { val3 = val2.GetComponentInChildren<Image>(true); } for (int i = val2.transform.childCount - 1; i >= 0; i--) { Transform child = val2.transform.GetChild(i); if (!((Object)(object)val3 != (Object)null) || !((Object)(object)((Component)child).gameObject == (Object)(object)((Component)val3).gameObject)) { Object.DestroyImmediate((Object)(object)((Component)child).gameObject); } } if ((Object)(object)val3 != (Object)null) { ((Graphic)val3).color = Color.white; if ((Object)(object)((Component)val3).gameObject != (Object)(object)val2) { RectTransform rectTransform = ((Graphic)val3).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; ((Transform)rectTransform).localScale = Vector3.one; } } else { val3 = val2.AddComponent<Image>(); Sprite val4 = GetValheimSprite("woodpanel_settings") ?? GetValheimSprite("box_sunken"); if ((Object)(object)val4 != (Object)null) { val3.sprite = val4; val3.type = (Type)1; } else { ((Graphic)val3).color = new Color(0.13f, 0.1f, 0.08f, 0.95f); } } } else { val2 = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Image) }); val2.transform.SetParent(parent, false); Image component6 = val2.GetComponent<Image>(); Sprite val4 = GetValheimSprite("woodpanel_settings") ?? GetValheimSprite("box_sunken"); if ((Object)(object)val4 != (Object)null) { component6.sprite = val4; component6.type = (Type)1; } else { ((Graphic)component6).color = new Color(0.13f, 0.1f, 0.08f, 0.95f); } } RectTransform component7 = val2.GetComponent<RectTransform>(); component7.anchorMin = new Vector2(0.5f, 0.5f); component7.anchorMax = new Vector2(0.5f, 0.5f); component7.pivot = new Vector2(0.5f, 0.5f); component7.anchoredPosition = Vector2.zero; component7.sizeDelta = size; ((Transform)component7).localScale = Vector3.one; val2.transform.localScale = Vector3.one; ValheimUiPanel valheimUiPanel = val2.AddComponent<ValheimUiPanel>(); valheimUiPanel.Initialize(name, title, size, onClose, draggable); return valheimUiPanel; } public static TMP_Text CreateLabel(Transform parent, string text, float fontSize = 14f, Color? color = null, TextAlignmentOptions align = (TextAlignmentOptions)513, float width = 0f, float height = 0f, FontStyles fontStyle = (FontStyles)0) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) TMP_Text orCreateTextTemplate = GetOrCreateTextTemplate(); GameObject val; TMP_Text component; if ((Object)(object)orCreateTextTemplate != (Object)null) { val = Object.Instantiate<GameObject>(((Component)orCreateTextTemplate).gameObject, parent, false); ((Object)val).name = "Label_" + text; val.transform.localScale = Vector3.one; val.SetActive(true); component = val.GetComponent<TMP_Text>(); } else { val = new GameObject("Label_" + text, new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); if ((Object)(object)parent != (Object)null) { val.transform.SetParent(parent, false); } val.transform.localScale = Vector3.one; component = (TMP_Text)(object)val.GetComponent<TextMeshProUGUI>(); TMP_FontAsset valheimFont = GetValheimFont(); if ((Object)(object)valheimFont != (Object)null) { component.font = valheimFont; Material valheimFontMaterial = GetValheimFontMaterial(); if ((Object)(object)valheimFontMaterial != (Object)null) { component.fontSharedMaterial = valheimFontMaterial; } } } component.text = text; component.enableAutoSizing = false; component.fontSize = fontSize; component.fontStyle = fontStyle; component.margin = Vector4.zero; ((Graphic)component).color = (color.HasValue ? color.Value : ColorParchment); component.alignment = align; component.textWrappingMode = (TextWrappingModes)0; ((Graphic)component).raycastTarget = false; RectTransform rectTransform = component.rectTransform; float num = ((width > 0f) ? width : ((rectTransform.sizeDelta.x > 0f) ? rectTransform.sizeDelta.x : 160f)); float num2 = ((height > 0f) ? height : ((rectTransform.sizeDelta.y > 0f) ? rectTransform.sizeDelta.y : 24f)); rectTransform.sizeDelta = new Vector2(num, num2); rectTransform.anchoredPosition = Vector2.zero; if (width > 0f || height > 0f) { LayoutElement val2 = val.GetComponent<LayoutElement>(); if ((Object)(object)val2 == (Object)null) { val2 = val.AddComponent<LayoutElement>(); } if (width > 0f) { val2.minWidth = width; val2.preferredWidth = width; } if (height > 0f) { val2.minHeight = height; val2.preferredHeight = height; } } return component; } public static Button GetOrCreateButtonTemplate() { if ((Object)(object)s_buttonTemplate != (Object)null) { return s_buttonTemplate; } if ((Object)(object)PlayerCustomizaton.m_barberInstance != (Object)null && (Object)(object)PlayerCustomizaton.m_barberInstance.m_apply != (Object)null) { s_buttonTemplate = PlayerCustomizaton.m_barberInstance.m_apply; return s_buttonTemplate; } Button[] array = Resources.FindObjectsOfTypeAll<Button>(); if (array != null) { for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null && (Object)(object)((Component)array[i]).GetComponentInChildren<TMP_Text>() != (Object)null) { s_buttonTemplate = array[i]; return s_buttonTemplate; } } } return null; } public static void StripLocalize(GameObject go) { if ((Object)(object)go == (Object)null) { return; } Component[] componentsInChildren = go.GetComponentsInChildren(typeof(Component), true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null && ((object)componentsInChildren[i]).GetType().Name == "Localize") { Component obj = componentsInChildren[i]; Behaviour val = (Behaviour)(object)((obj is Behaviour) ? obj : null); if ((Object)(object)val != (Object)null) { val.enabled = false; } Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } } } public static void SetButtonTextColor(Button btn, Color col) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)btn == (Object)null)) { TMP_Text componentInChildren = ((Component)btn).GetComponentInChildren<TMP_Text>(); if ((Object)(object)componentInChildren != (Object)null) { ((Graphic)componentInChildren).color = col; } } } public static Button CreateButton(Transform parent, string label, Action onClick, Vector2? size = null) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: 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_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02f8: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0265: 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_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Expected O, but got Unknown UnityAction val = null; Vector2 sizeDelta = (Vector2)(size.HasValue ? size.Value : new Vector2(120f, 32f)); Button orCreateButtonTemplate = GetOrCreateButtonTemplate(); Button val2 = null; if ((Object)(object)orCreateButtonTemplate != (Object)null) { val2 = Object.Instantiate<Button>(orCreateButtonTemplate, parent, false); ((Object)val2).name = "Btn_" + label; StripLocalize(((Component)val2).gameObject); val2.onClick = new ButtonClickedEvent(); } else { GameObject val3 = new GameObject("Btn_" + label, new Type[4] { typeof(RectTransform), typeof(Image), typeof(Button), typeof(LayoutElement) }); val3.transform.SetParent(parent, false); val2 = val3.GetComponent<Button>(); val2.onClick = new ButtonClickedEvent(); Image component = val3.GetComponent<Image>(); Sprite val4 = GetValheimSprite("button_normal") ?? GetValheimSprite("box_sunken"); if ((Object)(object)val4 != (Object)null) { component.sprite = val4; component.type = (Type)1; } else { ((Graphic)component).color = new Color(0.25f, 0.2f, 0.16f, 1f); } } RectTransform component2 = ((Component)val2).GetComponent<RectTransform>(); component2.sizeDelta = sizeDelta; LayoutElement val5 = ((Component)val2).GetComponent<LayoutElement>(); if ((Object)(object)val5 == (Object)null) { val5 = ((Component)val2).gameObject.AddComponent<LayoutElement>(); } val5.minWidth = sizeDelta.x; val5.preferredWidth = sizeDelta.x; val5.minHeight = sizeDelta.y; val5.preferredHeight = sizeDelta.y; if (onClick != null) { ButtonClickedEvent onClick2 = val2.onClick; if (val == null) { val = (UnityAction)delegate { PlayButtonClickAudio(); onClick(); }; } ((UnityEvent)onClick2).AddListener(val); } TMP_Text componentInChildren = ((Component)val2).GetComponentInChildren<TMP_Text>(); if ((Object)(object)componentInChildren == (Object)null) { componentInChildren = CreateLabel(((Component)val2).transform, label, 14.5f, ColorNorseGold, (TextAlignmentOptions)514, 0f, 0f, (FontStyles)1); RectTransform rectTransform = componentInChildren.rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.sizeDelta = Vector2.zero; } else { componentInChildren.text = label; componentInChildren.enableAutoSizing = false; componentInChildren.fontSize = 14.5f; componentInChildren.fontStyle = (FontStyles)1; componentInChildren.margin = Vector4.zero; ((Graphic)componentInChildren).color = ColorNorseGold; componentInChildren.alignment = (TextAlignmentOptions)514; RectTransform rectTransform = componentInChildren.rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; } ((Component)val2).gameObject.SetActive(true); return val2; } public static Button CreateSmallButton(Transform parent, string label, Action onClick, float width = 24f, float height = 22f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Button val = CreateButton(parent, label, onClick, (Vector2?)new Vector2(width, height)); ((Object)val).name = "SmallBtn_" + label; TMP_Text componentInChildren = ((Component)val).GetComponentInChildren<TMP_Text>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.fontSize = 14f; componentInChildren.fontStyle = (FontStyles)1; } return val; } public static Button CreateArrowButton(Transform parent, string label, Action onClick, float width = 36f, float height = 30f) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Button val = CreateButton(parent, label, onClick, (Vector2?)new Vector2(width, height)); ((Object)val).name = "Arrow_" + label; TMP_Text componentInChildren = ((Component)val).GetComponentInChildren<TMP_Text>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.fontSize = 16f; componentInChildren.fontStyle = (FontStyles)1; } return val; } public static Button CreateTabButton(Transform parent, string label, int tabIndex, Action<int> onTabSelected, float width = 96f, float height = 32f) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) Button val = CreateButton(parent, label, (Action)delegate { if (onTabSelected != null) { onTabSelected(tabIndex); } }, (Vector2?)new Vector2(width, height)); ((Object)val).name = "TabBtn_" + label; TMP_Text componentInChildren = ((Component)val).GetComponentInChildren<TMP_Text>(); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.fontSize = 13.5f; componentInChildren.fontStyle = (FontStyles)1; componentInChildren.margin = Vector4.zero; componentInChildren.rectTransform.offsetMin = Vector2.zero; componentInChildren.rectTransform.offsetMax = Vector2.zero; componentInChildren.textWrappingMode = (TextWrappingModes)0; componentInChildren.overflowMode = (TextOverflowModes)0; } return val; } public static GameObject CreateTabBar(Transform parent, string[] tabs, Action<int> onTabSelected, out List<Button> buttonsOut, float width = 395f, float height = 32f) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("TabBar", new Type[2] { typeof(RectTransform), typeof(HorizontalLayoutGroup) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(width, height); HorizontalLayoutGroup component2 = val.GetComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)component2).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)component2).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)component2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)component2).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)component2).spacing = 5f; ((LayoutGroup)component2).childAlignment = (TextAnchor)4; buttonsOut = new List<Button>(); if (tabs != null) { float width2 = Mathf.Max(60f, (width - (float)(tabs.Length - 1) * 5f) / (float)tabs.Length); for (int i = 0; i < tabs.Length; i++) { int tabIndex = i; Button item = CreateTabButton(val.transform, tabs[i], tabIndex, onTabSelected, width2, height); buttonsOut.Add(item); } } return val; } public static GameObject CreateSliderRow(Transform parent, string label, float min, float max, float initialValue, Action<float> onValueChanged, out Slider sliderOut, out TMP_Text valueTextOut) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Expected O, but got Unknown //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02fa: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Expected O, but got Unknown //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03a9: Expected O, but got Unknown //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SliderRow_" + label, new Type[2] { typeof(RectTransform), typeof(HorizontalLayoutGroup) }); val.transform.SetParent(parent, false); val.GetComponent<RectTransform>().sizeDelta = new Vector2(370f, 28f); HorizontalLayoutGroup component = val.GetComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)component).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)component).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)component).spacing = 8f; ((LayoutGroup)component).childAlignment = (TextAnchor)4; TMP_Text val2 = CreateLabel(val.transform, label, 13f, ColorParchment, (TextAlignmentOptions)513, 0f, 0f, (FontStyles)0); val2.rectTransform.sizeDelta = new Vector2(110f, 26f); GameObject val3 = new GameObject("Slider", new Type[2] { typeof(RectTransform), typeof(Slider) }); val3.transform.SetParent(val.transform, false); val3.GetComponent<RectTransform>().sizeDelta = new Vector2(170f, 18f); GameObject val4 = new GameObject("Background", new Type[2] { typeof(RectTransform), typeof(Image) }); val4.transform.SetParent(val3.transform, false); RectTransform component2 = val4.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.sizeDelta = Vector2.zero; Image component3 = val4.GetComponent<Image>(); Sprite valheimSprite = GetValheimSprite("box_sunken"); if ((Object)(object)valheimSprite != (Object)null) { component3.sprite = valheimSprite; component3.type = (Type)1; } else { ((Graphic)component3).color = ColorSunkenDark; } GameObject val5 = new GameObject("Fill Area", new Type[1] { typeof(RectTransform) }); val5.transform.SetParent(val3.transform, false); RectTransform component4 = val5.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(0f, 0.25f); component4.anchorMax = new Vector2(1f, 0.75f); component4.sizeDelta = new Vector2(-10f, 0f); GameObject val6 = new GameObject("Fill", new Type[2] { typeof(RectTransform), typeof(Image) }); val6.transform.SetParent(val5.transform, false); RectTransform component5 = val6.GetComponent<RectTransform>(); component5.sizeDelta = Vector2.zero; Image component6 = val6.GetComponent<Image>(); ((Graphic)component6).color = ColorNorseGold; GameObject val7 = new GameObject("Handle Slide Area", new Type[1] { typeof(RectTransform) }); val7.transform.SetParent(val3.transform, false); RectTransform component7 = val7.GetComponent<RectTransform>(); component7.anchorMin = Vector2.zero; component7.anchorMax = Vector2.one; component7.sizeDelta = new Vector2(-10f, 0f); GameObject val8 = new GameObject("Handle", new Type[2] { typeof(RectTransform), typeof(Image) }); val8.transform.SetParent(val7.transform, false); RectTransform component8 = val8.GetComponent<RectTransform>(); component8.sizeDelta = new Vector2(14f, 0f); Image component9 = val8.GetComponent<Image>(); ((Graphic)component9).color = new Color(0.95f, 0.85f, 0.65f, 1f); Slider component10 = val3.GetComponent<Slider>(); component10.fillRect = component5; component10.handleRect = component8; ((Selectable)component10).targetGraphic = (Graphic)(object)component9; component10.direction = (Direction)0; component10.minValue = min; component10.maxValue = max; component10.value = initialValue; TMP_Text valTxt = CreateLabel(val.transform, $"{initialValue:0.0}", 13f, ColorNorseGold, (TextAlignmentOptions)516, 0f, 0f, (FontStyles)0); valTxt.rectTransform.sizeDelta = new Vector2(50f, 26f); ((UnityEvent<float>)(object)component10.onValueChanged).AddListener((UnityAction<float>)delegate(float v) { valTxt.text = $"{v:0.0}"; if (onValueChanged != null) { onValueChanged(v); } }); sliderOut = component10; valueTextOut = valTxt; return val; } public static TMP_InputField CreateInputField(Transform parent, string placeholder, string initialText, Action<string> onValueChanged, Vector2? size = null) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0014: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_00a5: 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_013a: 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_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Expected O, but got Unknown //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_0392: 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_0308: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) Vector2 sizeDelta = (Vector2)(size.HasValue ? size.Value : new Vector2(180f, 26f)); GameObject val = new GameObject("InputField", new Type[5] { typeof(RectTransform), typeof(Image), typeof(Outline), typeof(TMP_InputField), typeof(LayoutElement) }); if ((Object)(object)parent != (Object)null) { val.transform.SetParent(parent, false); } RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = sizeDelta; LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minWidth = sizeDelta.x; component2.preferredWidth = sizeDelta.x; component2.minHeight = sizeDelta.y; component2.preferredHeight = sizeDelta.y; Image component3 = val.GetComponent<Image>(); Sprite valheimSprite = GetValheimSprite("box_sunken"); if ((Object)(object)valheimSprite != (Object)null) { component3.sprite = valheimSprite; component3.type = (Type)1; ((Graphic)component3).color = new Color(0.12f, 0.1f, 0.08f, 0.95f); } else { ((Graphic)component3).color = new Color(0.05f, 0.04f, 0.035f, 0.95f); } Outline component4 = val.GetComponent<Outline>(); ((Shadow)component4).effectColor = new Color(0.45f, 0.35f, 0.2f, 0.85f); ((Shadow)component4).effectDistance = new Vector2(1f, -1f); GameObject val2 = new GameObject("TextArea", new Type[2] { typeof(RectTransform), typeof(RectMask2D) }); val2.transform.SetParent(val.transform, false); RectTransform component5 = val2.GetComponent<RectTransform>(); component5.anchorMin = Vector2.zero; component5.anchorMax = Vector2.one; component5.offsetMin = new Vector2(6f, 2f); component5.offsetMax = new Vector2(-6f, -2f); TMP_Text val3 = CreateLabel(val2.transform, (initialText != null) ? initialText : "", 14f, ColorNorseGold, (TextAlignmentOptions)4097, 0f, 0f, (FontStyles)1); ((Object)val3).name = "Text"; RectTransform rectTransform = val3.rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; TMP_InputField component6 = val.GetComponent<TMP_InputField>(); ((Selectable)component6).targetGraphic = (Graphic)(object)component3; component6.textViewport = component5; component6.textComponent = val3; if (!string.IsNullOrEmpty(placeholder)) { TMP_Text val4 = CreateLabel(val2.transform, placeholder, 14f, ColorMutedText, (TextAlignmentOptions)4097, 0f, 0f, (FontStyles)2); ((Object)val4).name = "Placeholder"; val4.fontStyle = (FontStyles)2; RectTransform rectTransform2 = val4.rectTransform; rectTransform2.anchorMin = Vector2.zero; rectTransform2.anchorMax = Vector2.one; rectTransform2.offsetMin = Vector2.zero; rectTransform2.offsetMax = Vector2.zero; component6.placeholder = (Graphic)(object)val4; } component6.customCaretColor = true; component6.caretColor = ColorNorseGold; component6.caretWidth = 2; component6.selectionColor = new Color(1f, 0.73f, 0.25f, 0.35f); component6.text = ((initialText != null) ? initialText : ""); if (onValueChanged != null) { ((UnityEvent<string>)(object)component6.onValueChanged).AddListener((UnityAction<string>)onValueChanged.Invoke); } return component6; } public static Toggle CreateToggle(Transform parent, string label, bool initialValue, Action<bool> onValueChanged) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_0192: 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_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Toggle_" + label, new Type[3] { typeof(RectTransform), typeof(Toggle), typeof(HorizontalLayoutGroup) }); val.transform.SetParent(parent, false); HorizontalLayoutGroup component = val.GetComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)component).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)component).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)component).spacing = 8f; ((LayoutGroup)component).childAlignment = (TextAnchor)3; GameObject val2 = new GameObject("Background", new Type[2] { typeof(RectTransform), typeof(Image) }); val2.transform.SetParent(val.transform, false); val2.GetComponent<RectTransform>().sizeDelta = new Vector2(22f, 22f); Image component2 = val2.GetComponent<Image>(); Sprite valheimSprite = GetValheimSprite("box_sunken"); if ((Object)(object)valheimSprite != (Object)null) { component2.sprite = valheimSprite; component2.type = (Type)1; } else { ((Graphic)component2).color = ColorSunkenDark; } GameObject val3 = new GameObject("Checkmark", new Type[2] { typeof(RectTransform), typeof(Image) }); val3.transform.SetParent(val2.transform, false); RectTransform component3 = val3.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0.15f, 0.15f); component3.anchorMax = new Vector2(0.85f, 0.85f); component3.sizeDelta = Vector2.zero; Image component4 = val3.GetComponent<Image>(); ((Graphic)component4).color = ColorNorseGold; CreateLabel(val.transform, label, 13f, ColorParchment, (TextAlignmentOptions)513, 0f, 0f, (FontStyles)0); Toggle component5 = val.GetComponent<Toggle>(); component5.graphic = (Graphic)(object)component4; ((Selectable)component5).targetGraphic = (Graphic)(object)component2; component5.isOn = initialValue; if (onValueChanged != null) { ((UnityEvent<bool>)(object)component5.onValueChanged).AddListener((UnityAction<bool>)delegate(bool state) { PlayButtonClickAudio(); onValueChanged(state); }); } return component5; } public static GameObject CreateDivider(Transform parent, float width = 370f) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Divider", new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(parent, false); val.GetComponent<RectTransform>().sizeDelta = new Vector2(width, 2f); Image component = val.GetComponent<Image>(); ((Graphic)component).color = ColorDividerGold; ((Graphic)component).raycastTarget = false; return val; } public static GameObject CreateScrollView(Transform parent, Vector2 size, out RectTransform contentOut) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_0194: Expected O, but got Unknown //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: 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_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Expected O, but got Unknown GameObject val = new GameObject("ScrollView", new Type[3] { typeof(RectTransform), typeof(ScrollRect), typeof(Image) }); val.transform.SetParent(parent, false); val.GetComponent<RectTransform>().sizeDelta = size; Image component = val.GetComponent<Image>(); Sprite valheimSprite = GetValheimSprite("box_sunken"); if ((Object)(object)valheimSprite != (Object)null) { component.sprite = valheimSprite; component.type = (Type)1; } else { ((Graphic)component).color = ColorSunkenBg; } ScrollRect component2 = val.GetComponent<ScrollRect>(); component2.horizontal = false; component2.vertical = true; component2.scrollSensitivity = 25f; GameObject val2 = new GameObject("Viewport", new Type[3] { typeof(RectTransform), typeof(Mask), typeof(Image) }); val2.transform.SetParent(val.transform, false); RectTransform component3 = val2.GetComponent<RectTransform>(); component3.anchorMin = Vector2.zero; component3.anchorMax = Vector2.one; component3.sizeDelta = Vector2.zero; val2.GetComponent<Mask>().showMaskGraphic = false; GameObject val3 = new GameObject("Content", new Type[3] { typeof(RectTransform), typeof(VerticalLayoutGroup), typeof(ContentSizeFitter) }); val3.transform.SetParent(val2.transform, false); RectTransform component4 = val3.GetComponent<RectTransform>(); component4.anchorMin = new Vector2(0f, 1f); component4.anchorMax = new Vector2(1f, 1f); component4.pivot = new Vector2(0.5f, 1f); component4.sizeDelta = Vector2.zero; VerticalLayoutGroup component5 = val3.GetComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)component5).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)component5).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)component5).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)component5).spacing = 6f; ((LayoutGroup)component5).padding = new RectOffset(6, 6, 6, 6); ContentSizeFitter component6 = val3.GetComponent<ContentSizeFitter>(); component6.verticalFit = (FitMode)2; component2.viewport = component3; component2.content = component4; contentOut = component4; return val; } } public class ValheimUiPanel : MonoBehaviour { public Action OnCloseCallback; private TMP_Text _titleLabel; private bool _draggable; private bool _isDragging; private Vector2 _lastMousePos; private RectTransform _panelRt; public bool IsOpen { get; private set; } public GameObject ContentArea { get; private set; } public void Initialize(string name, string title, Vector2 size, Action onClose, bool draggable) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0065: 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_0091: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: 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_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Expected O, but got Unknown _panelRt = ((Component)this).GetComponent<RectTransform>(); _draggable = draggable; OnCloseCallback = onClose; GameObject val = new GameObject("PanelHeader", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(((Component)this).transform, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0.5f, 1f); component.anchoredPosition = new Vector2(0f, -8f); component.sizeDelta = new Vector2(-28f, 32f); _titleLabel = ValheimUiBuilder.CreateLabel(val.transform, title, 18f, ValheimUiBuilder.ColorNorseGold, (TextAlignmentOptions)514, 0f, 0f, (FontStyles)0); RectTransform rectTransform = _titleLabel.rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.offsetMin = Vector2.zero; rectTransform.offsetMax = Vector2.zero; rectTransform.anchoredPosition = Vector2.zero; rectTransform.sizeDelta = Vector2.zero; Button val2 = ValheimUiBuilder.CreateButton(val.transform, "X", (Action)delegate { Hide(); }, (Vector2?)new Vector2(28f, 26f)); RectTransform component2 = ((Component)val2).GetComponent<RectTransform>(); component2.anchorMin = new Vector2(1f, 0.5f); component2.anchorMax = new Vector2(1f, 0.5f); component2.pivot = new Vector2(1f, 0.5f); component2.anchoredPosition = Vector2.zero; ContentArea = new GameObject("PanelContent", new Type[2] { typeof(RectTransform), typeof(VerticalLayoutGroup) }); ContentArea.transform.SetParent(((Component)this).transform, false); RectTransform component3 = ContentArea.GetComponent<RectTransform>(); component3.anchorMin = new Vector2(0f, 0f); component3.anchorMax = new Vector2(1f, 1f); component3.pivot = new Vector2(0.5f, 0.5f); component3.offsetMin = new Vector2(16f, 12f); component3.offsetMax = new Vector2(-16f, -44f); ((Transform)component3).localScale = Vector3.one; VerticalLayoutGroup component4 = ContentArea.GetComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)component4).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)component4).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)component4).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)component4).childForceExpandHeight = false; ((LayoutGroup)component4).childAlignment = (TextAnchor)1; ((HorizontalOrVerticalLayoutGroup)component4).spacing = 6f; ((LayoutGroup)component4).padding = new RectOffset(4, 4, 4, 4); ((Component)this).gameObject.SetActive(false); } public void SetTitle(string newTitle) { if ((Object)(object)_titleLabel != (Object)null) { _titleLabel.text = newTitle; } } public void Show() { IsOpen = true; ((Component)this).gameObject.SetActive(true); Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } public void Hide() { IsOpen = false; ((Component)this).gameObject.SetActive(false); Cursor.lockState = (CursorLockMode)1; Cursor.visible = false; if (OnCloseCallback != null) { OnCloseCallback(); } } public void Toggle() { if (IsOpen) { Hide(); } else { Show(); } } private void Update() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: 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_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_0188: 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) if (!IsOpen) { return; } Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if (Input.GetKeyDown((KeyCode)27)) { Hide(); } if (!_draggable || !((Object)(object)_panelRt != (Object)null)) { return; } Canvas componentInParent = ((Component)this).GetComponentInParent<Canvas>(); Camera val = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null); if (Input.GetMouseButtonDown(0)) { Vector2 val2 = Vector2.op_Implicit(Input.mousePosition); Vector2 val3 = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(_panelRt, val2, val, ref val3)) { float y = val3.y; Rect rect = _panelRt.rect; if (y > ((Rect)(ref rect)).height / 2f - 50f) { _isDragging = true; _lastMousePos = val2; } } } else if (Input.GetMouseButtonUp(0)) { _isDragging = false; } if (_isDragging && Input.GetMouseButton(0)) { Vector2 val4 = Vector2.op_Implicit(Input.mousePosition); Vector2 val5 = val4 - _lastMousePos; _lastMousePos = val4; float num = (((Object)(object)componentInParent != (Object)null && componentInParent.scaleFactor > 0f) ? componentInParent.scaleFactor : 1f); RectTransform panelRt = _panelRt; panelRt.anchoredPosition += val5 / num; } else if (_isDragging && !Input.GetMouseButton(0)) { _isDragging = false; } } public TMP_Text AddLabel(string text, float fontSize = 14f, Color? color = null) { return ValheimUiBuilder.CreateLabel(ContentArea.transform, text, fontSize, color, (TextAlignmentOptions)513, 0f, 0f, (FontStyles)0); } public Button AddButton(string label, Action onClick, Vector2? size = null) { return ValheimUiBuilder.CreateButton(ContentArea.transform, label, onClick, size); } public GameObject AddSlider(string label, float min, float max, float current, Action<float> onChanged, out Slider slider, out TMP_Text valText) { return ValheimUiBuilder.CreateSliderRow(ContentArea.transform, label, min, max, current, onChanged, out slider, out valText); } public TMP_InputField AddInputField(string placeholder, string initialText, Action<string> onChanged, Vector2? size = null) { return ValheimUiBuilder.CreateInputField(ContentArea.transform, placeholder, initialText, onChanged, size); } public Toggle AddToggle(string label, bool initial, Action<bool> onChanged) { return ValheimUiBuilder.CreateToggle(ContentArea.transform, label, initial, onChanged); } public GameObject AddDivider(float width = 370f) { return ValheimUiBuilder.CreateDivider(ContentArea.transform, width); } } } namespace DigDug { 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<float> WindowPositionX; public static ConfigEntry<float> WindowPositionY; public static ConfigEntry<float> WindowOffsetX; public static ConfigEntry<float> WindowOffsetY; public static ConfigEntry<KeyboardShortcut> RotateLeftKey; public static ConfigEntry<KeyboardShortcut> RotateRightKey; public static ConfigEntry<KeyboardShortcut> MenuHotkey; public static void Init(ConfigFile config) { //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_014c: 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) 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."); WindowPositionX = config.Bind<float>("UI", "WindowPositionX", -1f, "Legacy screen X coordinate for the DigDug window."); WindowPositionY = config.Bind<float>("UI", "WindowPositionY", -1f, "Legacy screen Y coordinate for the DigDug window."); WindowOffsetX = config.Bind<float>("UI", "WindowOffsetX", 0f, "Horizontal pixel offset from screen center for the DigDug window."); WindowOffsetY = config.Bind<float>("UI", "WindowOffsetY", 0f, "Vertical pixel offset from screen center for the DigDug window."); 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)324, (KeyCode[])(object)new KeyCode[0]), "Key or mouse button to open the DigDug menu while holding a pickaxe. Defaults to Right Mouse Button (Mouse1). If reassigned to another key (e.g. G), Right Mouse Button will retain its native pickaxe blocking and dodge roll actions."); } } [HarmonyPatch] public static class DigDugPatches { private static float lastLogTime = 0f; [HarmonyPatch(typeof(Player), "SetControls")] [HarmonyPrefix] public static void Player_SetControls_Prefix(Player __instance, ref bool block, ref bool blockHold) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between Unknown and I4 //IL_0088: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Invalid comparison between Unknown and I4 //IL_00c4: 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) { return; } KeyboardShortcut value = DigDugConfig.MenuHotkey.Value; if ((int)((KeyboardShortcut)(ref value)).MainKey != 324 || !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, false); return; } DigDugPlugin.Log.LogInfo((object)"DigDug: Pickaxe block (Right-click) detected! Triggering UI."); DigDugUI.Show(); } } [HarmonyPatch(typeof(Player), "TakeInput")] [HarmonyPrefix] public static bool Player_TakeInput_Prefix(ref bool __result) { if (DigDugUI.IsVisible || ValheimUiBuilder.IsAnyInputFocused()) { __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 || ValheimUiBuilder.IsAnyInputFocused()) { __result = false; return false; } return true; } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] [HarmonyPrefix] 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; } } [BepInPlugin("com.antigravity.valheim.digdug", "DigDug", "1.0.8")] public class DigDugPlugin : BaseUnityPlugin { public const string PluginGUID = "com.antigravity.valheim.digdug"; public const string PluginName = "DigDug"; public const string PluginVersion = "1.0.8"; public static ManualLogSource Log; private Harmony harmony; private GameObject uiObject; private void Awake() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown 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 DigDugPreview { private static List<GameObject> previewObjs = new List<GameObject>(); private static Material previewMat; private static GameObject GetOrCreatePreviewObject(int index) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0096: 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_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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: 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_026a: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0382: Unknown result type (might be due to invalid IL or missing references) //IL_0397: 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_03a1: 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_03cc: 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_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Unknown result type (might be due to invalid IL or missing references) //IL_0413: 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_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_046f: 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_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_04c4: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Unknown result type (might be due to invalid IL or missing references) //IL_04fa: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_053c: Unknown result type (might be due to invalid IL or missing references) //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0570: Unknown result type (might be due to invalid IL or missing references) float num = depth; float num3; float num4; 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; } num3 = 0f; Vector3 val = playerPos + forward * direction switch { 0 => length / 2f, 1 => (0f - length) / 2f, _ => 0f, }; 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 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); } } num3 = 0f; Vector3 val = playerPos + forward * direction switch { 0 => length / 2f, 1 => (0f - length) / 2f, _ => 0f, }; 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(width, Mathf.Abs(num), length); return; } for (int i = 0; i < 4; i++) { GetOrCreatePreviewObject(i).SetActive(true); } for (int i = 4; i < previewObjs.Count; i++) { if ((Object)(object)previewObjs[i] != (Object)null) { previewObjs[i].SetActive(false); } } num3 = 0f; num3 = direction switch { 0 => length / 2f, 1 => (0f - length) / 2f, _ => 0f, }; num4 = playerPos.y - num / 2f; Quaternion rotation = Quaternion.LookRotation(forward, Vector3.up); GameObject orCreatePreviewObject2 = GetOrCreatePreviewObject(0); Vector3 val2 = playerPos + forward * (num3 + length / 2f - num5 / 2f); orCreatePreviewObject2.transform.position = new Vector3(val2.x, num4, val2.z); orCreatePreviewObject2.transform.rotation = rotation; orCreatePreviewObject2.transform.localScale = new Vector3(width, Mathf.Abs(num), num5); GameObject orCreatePreviewObject3 = GetOrCreatePreviewObject(1); Vector3 val3 = playerPos + forward * (num3 - length / 2f + num5 / 2f); orCreatePreviewObject3.transform.position = new Vector3(val3.x, num4, val3.z); orCreatePreviewObject3.transform.rotation = rotation; orCreatePreviewObject3.transform.localScale = new Vector3(width, Mathf.Abs(num), num5); GameObject orCreatePreviewObject4 = GetOrCreatePreviewObject(2); Vector3 val4 = playerPos + forward * num3 - right * (width / 2f - num5 / 2f); orCreatePreviewObject4.transform.position = new Vector3(val4.x, num4, val4.z); orCreatePreviewObject4.transform.rotation = rotation; orCreatePreviewObject4.transform.localScale = new Vector3(num5, Mathf.Abs(num), length - 2f * num5); GameObject orCreatePreviewObject5 = GetOrCreatePreviewObject(3); Vector3 val5 = playerPos + forward * num3 + right * (width / 2f - num5 / 2f); orCreatePreviewObject5.transform.position = new Vector3(val5.x, num4, val5.z); orCreatePreviewObject5.transform.rotation = rotation; orCreatePreviewObject5.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 static class DigDugReflection { public delegate void LevelTerrainDelegate(TerrainComp instance, Vector3 worldPos, float radius, bool square); public delegate void SaveInternalDelegate(TerrainComp instance, bool paintOnly); public delegate bool GetWorldBaseHeightDelegate(Heightmap instance, Vector3 worldPos, out float baseHeight); public delegate bool IsAreaEnabledDelegate(PrivateArea instance); public static LevelTerrainDelegate LevelTerrain; public static GetWorldBaseHeightDelegate GetWorldBaseHeight; private static SaveInternalDelegate s_saveInternal; private static IsAreaEnabledDelegate s_isAreaEnabled; 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; public static void Init() { try { MethodInfo methodInfo = AccessTools.Method(typeof(TerrainComp), "LevelTerrain", new Type[3] { typeof(Vector3), typeof(float), typeof(bool) }, (Type[])null); if (methodInfo != null) { LevelTerrain = (LevelTerrainDelegate)Delegate.CreateDelegate(typeof(LevelTerrainDelegate), methodInfo); } else { LogError("DigDugReflection: TerrainComp.LevelTerrain(Vector3, float, bool) not found!"); } } catch (Exception ex) { LogError("DigDugReflection: Failed to bind LevelTerrain delegate: " + ex.Message); } try { MethodInfo methodInfo2 = AccessTools.Method(typeof(TerrainComp), "Save", new Type[1] { typeof(bool) }, (Type[])null); if (methodInfo2 != null) { s_saveInternal = (SaveInternalDelegate)Delegate.CreateDelegate(typeof(SaveInternalDelegate), methodInfo2); } else { LogError("DigDugReflection: TerrainComp.Save(bool) not found!"); } } catch (Exception ex) { LogError("DigDugReflection: Failed to bind Save delegate: " + ex.Message); } try { MethodInfo methodInfo3 = AccessTools.Method(typeof(Heightmap), "GetWorldBaseHeight", new Type[2] { typeof(Vector3), typeof(float).MakeByRefType() }, (Type[])null); if (methodInfo3 != null) { GetWorldBaseHeight = (GetWorldBaseHeightDelegate)Delegate.CreateDelegate(typeof(GetWorldBaseHeightDelegate), methodInfo3); } else { LogError("DigDugReflection: Heightmap.GetWorldBaseHeight(Vector3, out float) not found!"); } } catch (Exception ex) { LogError("DigDugReflection: Failed to bind GetWorldBaseHeight delegate: " + ex.Message); } try { MethodInfo methodInfo4 = AccessTools.Method(typeof(PrivateArea), "IsEnabled", Type.EmptyTypes, (Type[])null); if (methodInfo4 != null) { s_isAreaEnabled = (IsAreaEnabledDelegate)Delegate.CreateDelegate(typeof(IsAreaEnabledDelegate), methodInfo4); } else { LogError("DigDugReflection: PrivateArea.IsEnabled() not found!"); } } catch (Exception ex) { LogError("DigDugReflection: Failed to bind IsAreaEnabled delegate: " + ex.Message); } f_hmap = CacheField(typeof(TerrainComp), "m_hmap"); f_size = CacheField(typeof(TerrainComp), "m_size"); f_levelDelta = CacheField(typeof(TerrainComp), "m_levelDelta"); f_smoothDelta = CacheField(typeof(TerrainComp), "m_smoothDelta"); f_modifiedHeight = CacheField(typeof(TerrainComp), "m_modifiedHeight"); f_paintMask = CacheField(typeof(TerrainComp), "m_paintMask"); f_modifiedPaint = CacheField(typeof(TerrainComp), "m_modifiedPaint"); f_nview = CacheField(typeof(TerrainComp), "m_nview"); f_raiseSkillAmount = CacheField(typeof(Attack), "m_raiseSkillAmount"); f_allAreas = CacheField(typeof(PrivateArea), "m_allAreas"); } private static void LogError(string message) { if (DigDugPlugin.Log != null) { DigDugPlugin.Log.LogError((object)message); } } private static void LogWarning(string message) { if (DigDugPlugin.Log != null) { DigDugPlugin.Log.LogWarning((object)message); } } private static FieldInfo CacheField(Type type, string fieldName) { FieldInfo fieldInfo = AccessTools.Field(type, fieldName); if (fieldInfo == null) { LogError("DigDugReflection: Field '" + fieldName + "' on " + type.FullName + " not found!"); } return fieldInfo; } public static void Save(TerrainComp instance) { if (!((Object)(object)instance == (Object)null)) { if (s_saveInternal != null) { s_saveInternal(instance, paintOnly: false); } else { LogError("DigDugReflection: Save called but TerrainComp.Save delegate is not initialized!"); } } } public static Heightmap GetHmap(TerrainComp instance) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if ((Object)(object)instance == (Object)null || f_hmap == null) { return null; } return (Heightmap)f_hmap.GetValue(instance); } public static float GetSize(TerrainComp instance) { if ((Object)(object)instance == (Object)null || f_size == null) { return 0f; } return (float)f_size.GetValue(instance); } public static float[] GetLevelDelta(TerrainComp instance) { if ((Object)(object)instance == (Object)null || f_levelDelta == null) { return null; } return (float[])f_levelDelta.GetValue(instance); } public static float[] GetSmoothDelta(TerrainComp instance) { if ((Object)(object)instance == (Object)null || f_smoothDelta == null) { return null; } return (float[])f_smoothDelta.GetValue(instance); } public static bool[] GetModifiedHeight(TerrainComp instance) { if ((Object)(object)instance == (Object)null || f_modifiedHeight == null) { return null; } return (bool[])f_modifiedHeight.GetValue(instance); } public static Color[] GetPaintMask(TerrainComp instance) { if ((Object)(object)instance == (Object)null || f_paintMask == null) { return null; } return (Color[])f_paintMask.GetValue(instance); } public static bool[] GetModifiedPaint(TerrainComp instance) { if ((Object)(object)instance == (Object)null || f_modifiedPaint == null) { return null; } return (bool[])f_modifiedPaint.GetValue(instance); } public static float GetRaiseSkillAmount(Attack attack) { if (attack == null || f_raiseSkillAmount == null) { return 0f; } return (float)f_raiseSkillAmount.GetValue(attack); } public static ZNetView GetNView(TerrainComp instance) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown if ((Object)(object)instance == (Object)null || f_nview == null) { return null; } return (ZNetView)f_nview.GetValue(instance); } public static List<PrivateArea> GetAllAreas() { if (f_allAreas == null) { return new List<PrivateArea>(); } return (List<PrivateArea>)f_allAreas.GetValue(null); } public static bool IsAreaEnabled(PrivateArea instance) { if ((Object)(object)instance == (Object)null) { return false; } if (s_isAreaEnabled != null) { try { return s_isAreaEnabled(instance); } catch (Exception ex) { LogWarning("DigDugReflection: Error checking IsAreaEnabled: " + ex.Message); } } return true; } } public class DigDugUI : MonoBehaviour { private ValheimUiPanel _panel; private TMP_Text _facingLabel; private Button[] _modeButtons; private Button[] _dirButtons; private Button[] _paintButtons; private TMP_InputField _lengthInput; private TMP_InputField _depthInput; private TMP_InputField _widthInput; private TMP_Text _depthLabel; private GameObject _widthContainer; private GameObject _dirContainer; private TMP_Text _costAreaSwingsText; private TMP_Text _costStoneText; private TMP_Text _costDurabilityStaminaText; private TMP_Text _tipLabel; private Button _actionBtn; private Button _cancelBtn; 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 = 0; private readonly string[] directionLabels = new string[3] { "Forward", "Backward", "Center" }; private int selectedPaint = 0; private readonly string[] paintLabels = new string[4] { "Dirt", "Paved", "Grass", "No Change" }; private static Font nativeFont; private float leftArrowDownTime = 0f; private float rightArrowDownTime = 0f; private float continuousRotationAccumulator = 0f; public static DigDugUI Instance { get; private set; } public static bool IsVisible => (Object)(object)Instance != (Object)null && (Object)(object)Instance._panel != (Object)null && Instance._panel.IsOpen; private void Awake() { Instance = this; } private void OnDestroy() { DigDugPreview.Destroy(); if ((Object)(object)_panel != (Object)null) { Object.Destroy((Object)(object)((Component)_panel).gameObject); _panel = null; } } public static void Show() { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { if ((Object)(object)Instance != (Object)null) { Instance.EnsurePanelCreated(); Instance._panel.Show(); ((Component)Instance._panel).transform.SetAsLastSibling(); Instance.UpdateInputValuesFromFields(); Instance.UpdateUIElements(); Instance.RefreshCosts(); } SnapToNearestDegree(); } } public static void Hide() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance._panel != (Object)null && Instance._panel.IsOpen) { Instance._panel.Hide(); } DigDugPreview.Hide(); } private void OnPanelClosed() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_panel != (Object)null) { RectTransform component = ((Component)_panel).GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { DigDugConfig.WindowOffsetX.Value = component.anchoredPosition.x; DigDugConfig.WindowOffsetY.Value = component.anchoredPosition.y; } } DigDugPreview.Hide(); } private void EnsurePanelCreated() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_panel != (Object)null)) { _panel = ValheimUiBuilder.CreatePanel("DigDug_ExcavationPanel", "DIGDUG EXCAVATION", new Vector2(510f, 430f), null, OnPanelClosed); RectTransform component = ((Component)_panel).GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null) { ((Transform)component).localScale = Vector3.one; float num = Mathf.Max(0f, ((float)Screen.width - 510f) / 2f); float num2 = Mathf.Max(0f, ((float)Screen.height - 430f) / 2f); float num3 = Mathf.Clamp(DigDugConfig.WindowOffsetX.Value, 0f - num, num); float num4 = Mathf.Clamp(DigDugConfig.WindowOffsetY.Value, 0f - num2, num2); component.anchoredPosition = new Vector2(num3, num4); } BuildPanelContent(); } } private void BuildPanelContent() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_0303: 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_03af: Unknown result type (might be due to invalid IL or missing references) //IL_04a7: 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_0523: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Expected O, but got Unknown //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_05fd: Unknown result type (might be due to invalid IL or missing references) //IL_063f: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Expected O, but got Unknown //IL_065c: Unknown result type (might be due to invalid IL or missing references) //IL_0692: Unknown result type (might be due to invalid IL or missing references) //IL_06c8: Unknown result type (might be due to invalid IL or missing references) //IL_06f1: Unknown result type (might be due to invalid IL or missing references) //IL_06f6: Unknown result type (might be due to invalid IL or missing references) //IL_070c: Unknown result type (might be due to invalid IL or missing references) //IL_0711: Unknown result type (might be due to invalid IL or missing references) //IL_0763: Unknown result type (might be due to invalid IL or missing references) //IL_07d6: Unknown result type (might be due to invalid IL or missing references) //IL_080d: Unknown result type (might be due to invalid IL or missing references) Transform transform = _panel.ContentArea.transform; _facingLabel = ValheimUiBuilder.CreateLabel(transform, GetFacingString(), 16f, ValheimUiBuilder.ColorNorseGold, (TextAlignmentOptions)514, 0f, 22f, (FontStyles)1); GameObject val = CreateHorizontalRow(transform, 480f, 26f, 10f, (TextAnchor)4); ValheimUiBuilder.CreateButton(val.transform, "Snap to Cardinal (N/E/S/W)", (Action)SnapToCardinal, (Vector2?)new Vector2(210f, 26f)); ValheimUiBuilder.CreateButton(val.transform, "Snap to 45°", (Action)delegate { SnapToAngle(45f); }, (Vector2?)new Vector2(110f, 26f)); ValheimUiBuilder.CreateDivider(transform, 470f); GameObject val2 = CreateHorizontalRow(transform, 480f, 28f, 5f, (TextAnchor)3); ValheimUiBuilder.CreateLabel(val2.transform, "Mode:", 13.5f, ValheimUiBuilder.ColorParchment, (TextAlignmentOptions)513, 50f, 26f, (FontStyles)1); _modeButtons = (Button[])(object)new Button[modeLabels.Length]; for (int num = 0; num < modeLabels.Length; num++) { int modeIdx = num; _modeButtons[num] = ValheimUiBuilder.CreateButton(val2.transform, modeLabels[num], (Action)delegate { OnModeSelected(modeIdx); }, (Vector2?)new Vector2(95f, 26f)); } GameObject val3 = CreateHorizontalRow(transform, 480f, 28f, 6f, (TextAnchor)3); ValheimUiBuilder.CreateLabel(val3.transform, "Length:", 13.5f, ValheimUiBuilder.ColorParchment, (TextAlignmentOptions)513, 55f, 26f, (FontStyles)1); _lengthInput = ValheimUiBuilder.CreateInputField(val3.transform, "4.0", lengthStr, (Action<string>)delegate(string text4) { lengthStr = text4; RefreshCosts(); }, (Vector2?)new Vector2(75f, 26f)); CreateSpacer(val3.transform, 20f); _depthLabel = ValheimUiBuilder.CreateLabel(val3.transform, "Depth:", 13.5f, ValheimUiBuilder.ColorParchment, (TextAlignmentOptions)513, 55f, 26f, (FontStyles)1); _depthInput = ValheimUiBuilder.CreateInputField(val3.transform, "4.0", depthStr, (Action<string>)delegate(string text4) { depthStr = text4; RefreshCosts(); }, (Vector2?)new Vector2(75f, 26f)); GameObject val4 = CreateHorizontalRow(transform, 480f, 28f, 6f, (TextAnchor)3); _widthContainer = CreateSubContainer(val4.transform, 136f, 28f, 6f, (TextAnchor)3); ValheimUiBuilder.CreateLabel(_widthContainer.transform, "Width:", 13.5f, ValheimUiBuilder.ColorParchment, (TextAlignmentOptions)513, 55f, 26f, (FontStyles)1); _widthInput = ValheimUiBuilder.CreateInputField(_widthContainer.transform, "4.0", widthStr, (Action<string>)delegate(string text4) { widthStr = text4; RefreshCosts(); }, (Vector2?)new Vector2(75f, 26f)); CreateSpacer(val4.transform, 20f); _dirContainer = CreateSubContainer(val4.transform, 235f, 28f, 4f, (TextAnchor)3); ValheimUiBuilder.CreateLabel(_dirContainer.transform, "Dir:", 13.5f, ValheimUiBuilder.ColorParchment, (TextAlignmentOptions)513, 35f, 26f, (FontStyles)1); float[] array = new float[3] { 60f, 68f, 58f }; _dirButtons = (Button[])(object)new Button[directionLabels.Length]; for (int num = 0; num < directionLabels.Length; num++) { int dirIdx = num; float num2 = ((num < array.Length) ? array[num] : 62f); _dirButtons[num] = ValheimUiBuilder.CreateButton(_dirContainer.transform, directionLabels[num], (Action)delegate { OnDirectionSelected(dirIdx); }, (Vector2?)new Vector2(num2, 26f)); } GameObject val5 = CreateHorizontalRow(transform, 480f, 28f, 5f, (TextAnchor)3); ValheimUiBuilder.CreateLabel(val5.transform, "Paint:", 13.5f, ValheimUiBuilder.ColorParchment, (TextAlignmentOptions)513, 50f, 26f, (FontStyles)1); _paintButtons = (Button[])(object)new Button[paintLabels.Length]; for (int num = 0; num < paintLabels.Length; num++) { int pIdx = num; _paintButtons[num] = ValheimUiBuilder.CreateButton(val5.transform, paintLabels[num], (Action)delegate { OnPaintSelected(pIdx); }, (Vector2?)new Vector2(95f, 26f)); } ValheimUiBuilder.CreateDivider(transform, 470f); GameObject val6 = new GameObject("CostSummaryBox", new Type[3] { typeof(RectTransform), typeof(Image), typeof(VerticalLayoutGroup) }); val6.transform.SetParent(transform, false); val6.GetComponent<RectTransform>().sizeDelta = new Vector2(470f, 62f); Image component = val6.GetComponent<Image>(); Sprite valheimSprite = ValheimUiBuilder.GetValheimSprite("box_sunken"); if ((Object)(object)valheimSprite != (Object)null) { component.sprite = valheimSprite; component.type = (Type)1; } ((Graphic)component).color = ValheimUiBuilder.ColorSunkenDark; VerticalLayoutGroup component2 = val6.GetComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)component2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)component2).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)component2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)component2).spacing = 2f; ((LayoutGroup)component2).padding = new RectOffset(8, 8, 4, 4); _costAreaSwingsText = ValheimUiBuilder.CreateLabel(val6.transform, "Area: 0.0 m² | Swings: 0", 12.5f, ValheimUiBuilder.ColorParchment, (TextAlignmentOptions)513, 0f, 16f, (FontStyles)0); _costStoneText = ValheimUiBuilder.CreateLabel(val6.transform, "Stone Cost: 0 / 0 available", 12.5f, ValheimUiBuilder.ColorParchment, (TextAlignmentOptions)513, 0f, 16f, (FontStyles)0); _costDurabilityStaminaText = ValheimUiBuilder.CreateLabel(val6.transform, "Durability Cost: 0 / 0 available | Stamina: 0", 12.5f, ValheimUiBuilder.ColorParchment, (TextAlignmentOptions)513, 0f, 16f, (FontStyles)0); string text = ((object)DigDugConfig.RotateLeftKey.Value/*cast due to .constrained prefix*/).ToString(); string text2 = ((object)DigDugConfig.RotateRightKey.Value/*cast due to .constrained prefix*/).ToString(); string text3 = "Tip: Use " + text + "/" + text2 + " to rotate 1° (hold to rotate continuously)"; _tipLabel = ValheimUiBuilder.CreateLabel(transform, text3, 12f, ValheimUiBuilder.ColorMutedText, (TextAlignmentOptions)514, 0f, 16f, (FontStyles)2); GameObject val7 = CreateHorizontalRow(transform, 470f, 32f, 14f, (TextAnchor)5); _cancelBtn = ValheimUiBuilder.CreateButton(val7.transform, "Cancel", (Action)delegate { Hide(); }, (Vector2?)new Vector2(105f, 30f)); _actionBtn = ValheimUiBuilder.CreateButton(val7.transform, "Dig!", (Action)delegate { OnActionClicked(); }, (Vector2?)new Vector2(105f, 30f)); UpdateUIElements(); RefreshCosts(); } private GameObject CreateHorizontalRow(Transform parent, float width, float height, float spacing, TextAnchor alignment) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Row", new Type[3] { typeof(RectTransform), typeof(HorizontalLayoutGroup), typeof(LayoutElement) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(width, height); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minWidth = width; component2.preferredWidth = width; component2.minHeight = height; component2.preferredHeight = height; HorizontalLayoutGroup component3 = val.GetComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)component3).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)component3).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)component3).spacing = spacing; ((LayoutGroup)component3).childAlignment = alignment; return val; } private GameObject CreateSubContainer(Transform parent, float width, float height, float spacing, TextAnchor alignment) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("SubContainer", new Type[3] { typeof(RectTransform), typeof(HorizontalLayoutGroup), typeof(LayoutElement) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); component.sizeDelta = new Vector2(width, height); LayoutElement component2 = val.GetComponent<LayoutElement>(); component2.minWidth = width; component2.preferredWidth = width; component2.minHeight = height; component2.preferredHeight = height; HorizontalLayoutGroup component3 = val.GetComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)component3).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)component3).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)component3).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)component3).spacing = spacing; ((LayoutGroup)component3).childA