using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("LumberCamp")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+41a28710e50ebc4b01e3eb323e64ae679234eb71")] [assembly: AssemblyProduct("LumberCamp")] [assembly: AssemblyTitle("LumberCamp")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace LumberCampMod { internal static class CampPanel { private class Control { public Toggle Widget; public Text Label; public void SetEnabled(bool enabled) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Widget != (Object)null) { ((Selectable)Widget).interactable = enabled; } if ((Object)(object)Label != (Object)null) { ((Graphic)Label).color = (enabled ? GUIManager.Instance.ValheimOrange : Greyed); } } } private class PanelBehaviour : MonoBehaviour { private void Update() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Current == (Object)null) { return; } if (!Current.IsValid || Input.GetKeyDown((KeyCode)27)) { Hide(); return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || Vector3.Distance(((Component)localPlayer).transform.position, ((Component)Current).transform.position) > 12f) { Hide(); } else if (Time.time >= s_refreshAt) { Refresh(); } } private void OnDestroy() { if ((Object)(object)Current != (Object)null) { GUIManager.BlockInput(false); } Current = null; s_root = null; s_families.Clear(); } } [CompilerGenerated] private static class <>O { public static UnityAction <0>__Hide; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__22_0; public static UnityAction <>9__22_1; public static UnityAction <>9__22_2; public static UnityAction <>9__22_3; public static UnityAction <>9__22_4; public static UnityAction <>9__22_5; public static UnityAction <>9__22_6; public static UnityAction <>9__22_7; public static UnityAction <>9__22_8; internal void b__22_0() { Current?.RequestSetPaused(!Current.Paused); } internal void b__22_1() { Current?.RequestAddWorker(); } internal void b__22_2() { Current?.RequestRemoveWorker(); } internal void b__22_3() { Current?.RequestDepositNow(); } internal void b__22_4() { Current?.RequestAddChest(); } internal void b__22_5() { Current?.RequestClearChests(); } internal void b__22_6() { Adjust(-10f); } internal void b__22_7() { Adjust(10f); } internal void b__22_8(bool on) { if (!s_syncing) { Current?.RequestSetReplant(on); } } } private const float Width = 480f; private const float RowStep = 36f; private static readonly Color Greyed = new Color(0.55f, 0.52f, 0.47f, 0.7f); private static GameObject s_root; private static Text s_status; private static Text s_gateNote; private static Text s_pauseLabel; private static Text s_radiusLabel; private static Control s_replant; private static readonly Dictionary s_families = new Dictionary(); private static bool s_syncing; private static float s_refreshAt; public static LumberCamp Current { get; private set; } public static void Show(LumberCamp camp) { if (!((Object)(object)camp == (Object)null) && !GUIManager.IsHeadless()) { EnsureBuilt(); if ((Object)(object)s_root == (Object)null) { LumberCampPlugin.Log.LogWarning((object)"Camp panel could not be built; Jotunn's GUI is not ready."); return; } Current = camp; s_root.SetActive(true); GUIManager.BlockInput(true); Refresh(); } } public static void Hide() { if ((Object)(object)s_root != (Object)null) { s_root.SetActive(false); } if ((Object)(object)Current != (Object)null) { Current = null; GUIManager.BlockInput(false); } } private static void Refresh() { if ((Object)(object)Current == (Object)null || (Object)(object)s_root == (Object)null) { return; } s_refreshAt = Time.time + 0.5f; s_status.text = Current.StatusSummary(); s_pauseLabel.text = (Current.Paused ? "Resume work" : "Pause work"); s_radiusLabel.text = $"Radius: {Current.Radius:0} m"; s_syncing = true; s_replant.Widget.isOn = Current.Replant; List> list = new List>(); foreach (KeyValuePair s_family in s_families) { bool flag = LumberCampConfig.BossDefeated(s_family.Key); s_family.Value.Widget.isOn = flag && Current.IsFamilyChecked(s_family.Key); s_family.Value.SetEnabled(flag); if (!flag) { list.Add(new KeyValuePair(TreeFamilies.DisplayName(s_family.Key), LumberCampConfig.BossName(LumberCampConfig.BossFor(s_family.Key)))); } } s_syncing = false; s_gateNote.text = GateNote(list); } private static string GateNote(List> locked) { if (locked.Count == 0) { return string.Empty; } List list = new List(); Dictionary> dictionary = new Dictionary>(); foreach (KeyValuePair item in locked) { if (!dictionary.TryGetValue(item.Value, out var value)) { value = new List(); dictionary[item.Value] = value; list.Add(item.Value); } value.Add(item.Key); } StringBuilder stringBuilder = new StringBuilder(); foreach (string item2 in list) { if (stringBuilder.Length > 0) { stringBuilder.Append(" "); } List list2 = dictionary[item2]; stringBuilder.Append(string.Join(", ", list2.ToArray()) + " " + ((list2.Count == 1) ? "waits" : "wait") + " on " + item2 + "."); } return stringBuilder.ToString(); } private static void EnsureBuilt() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_012a: 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_0135: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_01e7: 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_01f2: Expected O, but got Unknown //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_0242: Expected O, but got Unknown //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Expected O, but got Unknown //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Expected O, but got Unknown //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Expected O, but got Unknown //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Expected O, but got Unknown if ((Object)(object)s_root != (Object)null || GUIManager.Instance == null || (Object)(object)GUIManager.CustomGUIFront == (Object)null) { return; } s_root = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, 480f, 100f, true); s_root.SetActive(false); s_root.AddComponent(); Transform transform = s_root.transform; s_families.Clear(); float num = -34f; AddText(transform, "Lumber Camp", 0f, num, 440f, 30f, 22, (TextAnchor)4); num -= 40f; s_status = AddText(transform, string.Empty, 0f, num - 44f, 430f, 110f, 14, (TextAnchor)0); num -= 118f; Section(transform, "Lumberjacks", ref num); float y = num; object obj = <>c.<>9__22_0; if (obj == null) { UnityAction val = delegate { Current?.RequestSetPaused(!Current.Paused); }; <>c.<>9__22_0 = val; obj = (object)val; } s_pauseLabel = AddButton(transform, "Pause work", -110f, y, 205f, 30f, (UnityAction)obj); float y2 = num; object obj2 = <>c.<>9__22_1; if (obj2 == null) { UnityAction val2 = delegate { Current?.RequestAddWorker(); }; <>c.<>9__22_1 = val2; obj2 = (object)val2; } AddButton(transform, "Hire a lumberjack", 110f, y2, 205f, 30f, (UnityAction)obj2); num -= 36f; float y3 = num; object obj3 = <>c.<>9__22_2; if (obj3 == null) { UnityAction val3 = delegate { Current?.RequestRemoveWorker(); }; <>c.<>9__22_2 = val3; obj3 = (object)val3; } AddButton(transform, "Send one home", -110f, y3, 205f, 30f, (UnityAction)obj3); float y4 = num; object obj4 = <>c.<>9__22_3; if (obj4 == null) { UnityAction val4 = delegate { Current?.RequestDepositNow(); }; <>c.<>9__22_3 = val4; obj4 = (object)val4; } AddButton(transform, "Store wood now", 110f, y4, 205f, 30f, (UnityAction)obj4); num -= 36f; Section(transform, "Storage", ref num); float y5 = num; object obj5 = <>c.<>9__22_4; if (obj5 == null) { UnityAction val5 = delegate { Current?.RequestAddChest(); }; <>c.<>9__22_4 = val5; obj5 = (object)val5; } AddButton(transform, "Add nearest chest", -110f, y5, 205f, 30f, (UnityAction)obj5); float y6 = num; object obj6 = <>c.<>9__22_5; if (obj6 == null) { UnityAction val6 = delegate { Current?.RequestClearChests(); }; <>c.<>9__22_5 = val6; obj6 = (object)val6; } AddButton(transform, "Clear chests", 110f, y6, 205f, 30f, (UnityAction)obj6); num -= 36f; Section(transform, "Work area", ref num); float y7 = num; object obj7 = <>c.<>9__22_6; if (obj7 == null) { UnityAction val7 = delegate { Adjust(-10f); }; <>c.<>9__22_6 = val7; obj7 = (object)val7; } AddButton(transform, "-", -150f, y7, 44f, 30f, (UnityAction)obj7); s_radiusLabel = AddText(transform, string.Empty, 0f, num, 200f, 30f, 15, (TextAnchor)4); float y8 = num; object obj8 = <>c.<>9__22_7; if (obj8 == null) { UnityAction val8 = delegate { Adjust(10f); }; <>c.<>9__22_7 = val8; obj8 = (object)val8; } AddButton(transform, "+", 150f, y8, 44f, 30f, (UnityAction)obj8); num -= 36f; s_replant = AddToggle(transform, "Replant a sapling after clearing a stump", -206f, num, delegate(bool on) { if (!s_syncing) { Current?.RequestSetReplant(on); } }); num -= 36f; Section(transform, "Trees to cut", ref num); int num2 = 0; for (int num3 = 0; num3 < TreeFamilies.All.Length; num3++) { string family = TreeFamilies.All[num3]; int num4 = num3 % 3; int num5 = num3 / 3; num2 = Mathf.Max(num2, num5 + 1); float x = -206f + (float)num4 * 150f; float y9 = num - (float)num5 * 30f; s_families[family] = AddToggle(transform, TreeFamilies.DisplayName(family), x, y9, delegate(bool on) { if (!s_syncing) { Current?.RequestSetFamily(family, on); } }); } num -= (float)num2 * 30f + 4f; s_gateNote = AddText(transform, string.Empty, 0f, num - 14f, 430f, 54f, 13, (TextAnchor)0); ((Graphic)s_gateNote).color = Greyed; num -= 64f; float y10 = num; object obj9 = <>O.<0>__Hide; if (obj9 == null) { UnityAction val9 = Hide; <>O.<0>__Hide = val9; obj9 = (object)val9; } AddButton(transform, "Close", 0f, y10, 205f, 30f, (UnityAction)obj9); num -= 42f; s_root.GetComponent().sizeDelta = new Vector2(480f, 0f - num); } private static void Adjust(float delta) { if ((Object)(object)Current != (Object)null) { Current.RequestSetRadius(Current.Radius + delta); } } private static void Section(Transform parent, string title, ref float y) { y -= 4f; AddText(parent, title, 0f, y, 440f, 24f, 16, (TextAnchor)4); y -= 30f; } private static void Place(GameObject go, float x, float y, float width, float height, Vector2 pivot) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) RectTransform component = go.GetComponent(); if (!((Object)(object)component == (Object)null)) { component.anchorMin = new Vector2(0.5f, 1f); component.anchorMax = new Vector2(0.5f, 1f); component.pivot = pivot; component.anchoredPosition = new Vector2(x, y); component.sizeDelta = new Vector2(width, height); } } private static Text AddText(Transform parent, string text, float x, float y, float width, float height, int size, TextAnchor alignment) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GUIManager.Instance.CreateText(text, parent, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(x, y), GUIManager.Instance.AveriaSerifBold, size, GUIManager.Instance.ValheimOrange, true, Color.black, width, height, false); Text componentInChildren = obj.GetComponentInChildren(true); if ((Object)(object)componentInChildren != (Object)null) { componentInChildren.alignment = alignment; componentInChildren.horizontalOverflow = (HorizontalWrapMode)0; componentInChildren.verticalOverflow = (VerticalWrapMode)1; } Place(obj, x, y, width, height, new Vector2(0.5f, 0.5f)); return componentInChildren; } private static Text AddButton(Transform parent, string label, float x, float y, float width, float height, UnityAction action) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GUIManager.Instance.CreateButton(label, parent, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(x, y), width, height); Place(obj, x, y, width, height, new Vector2(0.5f, 0.5f)); Button componentInChildren = obj.GetComponentInChildren