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 DFGHub v1.5.4
DFGHub.dll
Decompiled 4 days 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.Diagnostics; using System.Globalization; using System.IO; using System.Net; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using MyMods.Web; using Newtonsoft.Json; using TMPro; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("DFGHub")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.5.4.0")] [assembly: AssemblyInformationalVersion("1.5.4+8bdaa863778638364d8f7029ad69c1d362f821eb")] [assembly: AssemblyProduct("DFGHub")] [assembly: AssemblyTitle("DFGHub")] [assembly: AssemblyVersion("1.5.4.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MyMods.Web { public static class WebNav { public sealed class Link { public readonly string Id; public readonly string Label; public readonly int Port; public string Url => "http://127.0.0.1:" + Port + "/"; public Link(string id, string label, int port) { Id = id; Label = label; Port = port; } } public static readonly Link[] Links = new Link[27] { new Link("monsters", "Monsters", 8777), new Link("searoute", "SeaRoute", 8778), new Link("longboat", "Harpoon Longboat", 8779), new Link("tradewind", "TradeWind", 8780), new Link("safeharbor", "Safe Harbor", 8781), new Link("hub", "DFG Hub", 8782), new Link("vault", "Viking Vault", 8783), new Link("qolvault", "QoL Vault Buttons", 8784), new Link("qolinventory", "QoL Inventory Buttons", 8785), new Link("cacophony", "Cacophony", 8787), new Link("ominous", "Ominous", 8788), new Link("pebble", "Pebble", 8789), new Link("trolls", "Trolls", 8790), new Link("transporter", "Transporter", 8791), new Link("skytram", "Sky-Tram", 8792), new Link("dockfortress", "Dock Fortress", 8793), new Link("odinseye", "Odin's Eye", 8794), new Link("skyherd", "Skyherd", 8795), new Link("lawspeaker", "Lawspeaker", 8796), new Link("ymirsmarrow", "Ymir's Marrow", 8797), new Link("fogwarden", "Fogwarden", 8798), new Link("raiders", "DFG Raiders", 8799), new Link("scoutcopter", "Scout Copter", 8800), new Link("sanctuary", "Sanctuary", 8801), new Link("goldbiter", "Gold-Biter", 8802), new Link("vending", "Vending Machines", 8803), new Link("odiensplosion", "Odiensplosion", 8804) }; public const string LogoSvg = "<svg width='22' height='26' viewBox='0 0 22 26' fill='none' xmlns='http://www.w3.org/2000/svg' style='vertical-align:middle;margin-right:6px'><path d='M11 0L22 5V13C22 19.0751 17.3025 24.3125 11 26C4.6975 24.3125 0 19.0751 0 13V5L11 0Z' fill='#161a20' stroke='#ffd760' stroke-width='1.2'/><path d='M11 3L19 6.5V13C19 17.5 15.5 21.5 11 23C6.5 21.5 3 17.5 3 13V6.5L11 3Z' fill='#1d222a'/><text x='11' y='17' text-anchor='middle' fill='#ffd760' font-size='10' font-weight='bold' font-family='serif'>DFG</text></svg>"; public const string Style = "nav.top{position:sticky;top:0;z-index:20;width:100%;box-sizing:border-box;flex:0 0 auto;font-family:'Segoe UI',Arial,sans-serif;background:#0d1219;border-bottom:1px solid #2b3b4c;padding:6px 14px;display:flex;align-items:center;gap:6px;flex-wrap:wrap}\nnav.top .brand{color:#ffd760;font-size:12px;text-transform:uppercase;letter-spacing:.8px;margin-right:10px;display:inline-flex;align-items:center;font-weight:600;text-shadow:0 1px 2px rgba(0,0,0,0.5)}\nnav.top a{color:#9fc3dd;text-decoration:none;font-size:13px;padding:4px 9px;border-radius:5px;transition:background .15s}\nnav.top a:hover{background:#1a2530}\nnav.top a.here{background:#3a2b4c;border:1px solid #55406b;color:#efe0ff}\n"; public static string Html(string currentId) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<nav class='top'><span class='brand'>").Append("<svg width='22' height='26' viewBox='0 0 22 26' fill='none' xmlns='http://www.w3.org/2000/svg' style='vertical-align:middle;margin-right:6px'><path d='M11 0L22 5V13C22 19.0751 17.3025 24.3125 11 26C4.6975 24.3125 0 19.0751 0 13V5L11 0Z' fill='#161a20' stroke='#ffd760' stroke-width='1.2'/><path d='M11 3L19 6.5V13C19 17.5 15.5 21.5 11 23C6.5 21.5 3 17.5 3 13V6.5L11 3Z' fill='#1d222a'/><text x='11' y='17' text-anchor='middle' fill='#ffd760' font-size='10' font-weight='bold' font-family='serif'>DFG</text></svg>").Append("DFG</span>"); Link[] links = Links; foreach (Link link in links) { stringBuilder.Append("<a class='"); if (link.Id == currentId) { stringBuilder.Append("here"); } stringBuilder.Append("' href='").Append(link.Url).Append("'>") .Append(link.Label) .Append("</a>"); } stringBuilder.Append("</nav>"); return stringBuilder.ToString(); } public static Link Find(string id) { Link[] links = Links; foreach (Link link in links) { if (link.Id == id) { return link; } } return null; } } } namespace DFGHub { internal static class DFGHammer { private sealed class Routed { public Piece Piece; public string CategoryName; public PieceCategory Category; } private struct HammerPose { public float X; public float Y; public float Z; public float RotX; public float RotY; public float RotZ; public float Scale; public HammerPose(float x, float y, float z, float rotX, float rotY, float rotZ, float scale) { X = x; Y = y; Z = z; RotX = rotX; RotY = rotY; RotZ = rotZ; Scale = scale; } } private sealed class Bucket { public string Name; public PieceCategory Category; public int Count; } internal const string PrefabName = "DFG_Hammer"; internal const string TableName = "DFGHammer"; internal const string ItemName = "DFG Hammer"; internal const string ItemDescription = "The forge's own hammer. Every Draugr Forged build piece is here, sorted by the mod that added it."; private const string VisualName = "dfg_hammer_visual"; private const float DefaultPosX = 0f; private const float DefaultPosY = 0f; private const float DefaultPosZ = 0.206f; private const float DefaultRotX = -90f; private const float DefaultRotY = 180f; private const float DefaultRotZ = 0f; private const float DefaultScale = 0.6f; private static bool s_modView; private static bool s_registered; private static GameObject s_item; private static readonly object s_poseGate = new object(); private static bool s_poseQueued; private static HammerPose s_poseQueuedValue; private static ConfigEntry<float> CfgPosX; private static ConfigEntry<float> CfgPosY; private static ConfigEntry<float> CfgPosZ; private static ConfigEntry<float> CfgRotX; private static ConfigEntry<float> CfgRotY; private static ConfigEntry<float> CfgRotZ; private static ConfigEntry<float> CfgScale; private static bool s_haveShared; private static PieceCategory s_shared; private static PieceTable s_vanilla; private static string s_lastSummary = ""; private static readonly Dictionary<int, Routed> s_pieces = new Dictionary<int, Routed>(); private static readonly Dictionary<string, PieceCategory> s_categoryByGuid = new Dictionary<string, PieceCategory>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<string, string> s_nameByGuid = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary<string, string> s_guidByName = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); internal static PieceTable Table { get; private set; } internal static bool ModView => s_modView; internal static void Register() { //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: 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_00c2: Expected O, but got Unknown //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Expected O, but got Unknown //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= Register; if (s_registered || !DFGHubPlugin.EnableDfgHammer.Value) { return; } try { GameObject prefab = PrefabManager.Instance.GetPrefab("Hammer"); if ((Object)(object)prefab == (Object)null) { Logger.LogWarning((object)"DFG Hammer: the vanilla Hammer prefab is missing."); return; } ItemDrop component = prefab.GetComponent<ItemDrop>(); PieceTable val = (((Object)(object)component != (Object)null && component.m_itemData != null && component.m_itemData.m_shared != null) ? component.m_itemData.m_shared.m_buildPieces : null); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)"DFG Hammer: the vanilla Hammer has no piece table."); return; } PieceTableConfig val2 = new PieceTableConfig { CanRemovePieces = true, GuessUsage = false }; CustomPieceTable val3 = new CustomPieceTable("DFGHammer", val2); if (!PieceManager.Instance.AddPieceTable(val3)) { Logger.LogWarning((object)"DFG Hammer: the piece table was not accepted."); return; } Table = val3.PieceTable; s_vanilla = val; Table.m_skill = val.m_skill; Table.m_canRemoveFeasts = val.m_canRemoveFeasts; Table.m_hideAdvancedMenu = val.m_hideAdvancedMenu; GameObject val4 = PrefabManager.Instance.CreateClonedPrefab("DFG_Hammer", prefab); if ((Object)(object)val4 == (Object)null) { Logger.LogWarning((object)"DFG Hammer: the hammer clone failed."); Table = null; return; } ItemDrop component2 = val4.GetComponent<ItemDrop>(); if ((Object)(object)component2 == (Object)null || component2.m_itemData == null || component2.m_itemData.m_shared == null) { Logger.LogWarning((object)"DFG Hammer: the clone has no item data."); Table = null; return; } component2.m_itemData.m_shared.m_buildPieces = Table; component2.m_itemData.m_shared.m_maxStackSize = 1; s_item = val4; AttachModel(val4); Sprite icon = LoadIcon(); ItemConfig val5 = new ItemConfig { Name = "DFG Hammer", Description = "The forge's own hammer. Every Draugr Forged build piece is here, sorted by the mod that added it.", Icon = icon, CraftingStation = CraftingStations.Workbench, MinStationLevel = 1, Amount = 1 }; val5.AddRequirement("Wood", 4, 0); val5.AddRequirement("Stone", 2, 0); if (!ItemManager.Instance.AddItem(new CustomItem(val4, true, val5))) { Logger.LogWarning((object)"DFG Hammer: the item was not accepted."); Table = null; } else { component2.m_itemData.m_shared.m_buildPieces = Table; s_registered = true; Logger.LogInfo((object)"DFG Hammer: registered. Workbench recipe is 4 Wood and 2 Stone."); } } catch (Exception ex) { Table = null; Logger.LogWarning((object)("DFG Hammer: registration failed: " + ex)); } } private static void AttachModel(GameObject item) { Transform val = FindNamed(item.transform, "attach"); if ((Object)(object)val == (Object)null) { val = item.transform; } Renderer[] componentsInChildren = ((Component)val).GetComponentsInChildren<Renderer>(true); GameObject val2 = HammerGlb.Load("hammer.glb"); if ((Object)(object)val2 == (Object)null) { Logger.LogWarning((object)"DFG Hammer: hammer.glb did not load. The vanilla hammer mesh stays."); return; } for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { componentsInChildren[i].enabled = false; } } ((Object)val2).name = "dfg_hammer_visual"; val2.transform.SetParent(val, false); ApplyLocal(val2.transform, ReadPose()); int layer = ((Component)val).gameObject.layer; Transform[] componentsInChildren2 = val2.GetComponentsInChildren<Transform>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { ((Component)componentsInChildren2[j]).gameObject.layer = layer; } } private static Transform FindNamed(Transform root, string name) { if (((Object)root).name == name) { return root; } for (int i = 0; i < root.childCount; i++) { Transform val = FindNamed(root.GetChild(i), name); if ((Object)(object)val != (Object)null) { return val; } } return null; } internal static void Bind(ConfigFile config) { CfgPosX = config.Bind<float>("Hammer", "PosX", 0f, "Metres, hand local space. Left and right in the fist."); CfgPosY = config.Bind<float>("Hammer", "PosY", 0f, "Metres, hand local space. Up and down."); CfgPosZ = config.Bind<float>("Hammer", "PosZ", 0.206f, "Metres along the arm. The hand bone points back, so a positive value brings the grip out of the fist."); CfgRotX = config.Bind<float>("Hammer", "RotX", -90f, "Pitch, degrees."); CfgRotY = config.Bind<float>("Hammer", "RotY", 180f, "Yaw, degrees. 180 turns the head out of the hand. 0 points it back up the arm."); CfgRotZ = config.Bind<float>("Hammer", "RotZ", 0f, "Roll, degrees."); CfgScale = config.Bind<float>("Hammer", "Scale", 0.6f, "Size of hammer.glb in the hand."); } internal static string PosePage() { using Stream stream = typeof(DFGHammer).GetTypeInfo().Assembly.GetManifestResourceStream("DFGHub.HammerPose.html"); if (stream == null) { return "<p>Hammer placement page is missing from the DLL.</p>"; } using StreamReader streamReader = new StreamReader(stream); return streamReader.ReadToEnd(); } internal static string PoseJson() { HammerPose hammerPose = ReadPose(); lock (s_poseGate) { if (s_poseQueued) { hammerPose = s_poseQueuedValue; } } return string.Format(CultureInfo.InvariantCulture, "{{\"x\":{0:0.###},\"y\":{1:0.###},\"z\":{2:0.###},\"rx\":{3:0.###},\"ry\":{4:0.###},\"rz\":{5:0.###},\"scale\":{6:0.###}}}", hammerPose.X, hammerPose.Y, hammerPose.Z, hammerPose.RotX, hammerPose.RotY, hammerPose.RotZ, hammerPose.Scale); } internal static void QueueQuery(string query) { Dictionary<string, string> dictionary = ParseQuery(query); HammerPose hammerPose = ReadPose(); if (dictionary.TryGetValue("preset", out var value) && value == "back") { hammerPose = new HammerPose(0f, 0f, -0.206f, -90f, 0f, 0f, 0.6f); } else if (dictionary.ContainsKey("preset")) { hammerPose = DefaultPose(); } else { hammerPose.X = Pick(dictionary, "x", hammerPose.X, -1.5f, 1.5f); hammerPose.Y = Pick(dictionary, "y", hammerPose.Y, -1.5f, 1.5f); hammerPose.Z = Pick(dictionary, "z", hammerPose.Z, -1.5f, 1.5f); hammerPose.RotX = Pick(dictionary, "rx", hammerPose.RotX, -180f, 180f); hammerPose.RotY = Pick(dictionary, "ry", hammerPose.RotY, -180f, 180f); hammerPose.RotZ = Pick(dictionary, "rz", hammerPose.RotZ, -180f, 180f); hammerPose.Scale = Pick(dictionary, "scale", hammerPose.Scale, 0.05f, 2.5f); } lock (s_poseGate) { s_poseQueued = true; s_poseQueuedValue = hammerPose; } } internal static void DrainPose() { bool flag; HammerPose pose; lock (s_poseGate) { flag = s_poseQueued; pose = s_poseQueuedValue; s_poseQueued = false; } if (flag) { WritePose(pose); ApplyEverywhere(pose); } } private static HammerPose DefaultPose() { return new HammerPose(0f, 0f, 0.206f, -90f, 180f, 0f, 0.6f); } private static HammerPose ReadPose() { if (CfgScale == null) { return DefaultPose(); } return new HammerPose(CfgPosX.Value, CfgPosY.Value, CfgPosZ.Value, CfgRotX.Value, CfgRotY.Value, CfgRotZ.Value, CfgScale.Value); } private static void WritePose(HammerPose pose) { if (CfgScale != null) { CfgPosX.Value = pose.X; CfgPosY.Value = pose.Y; CfgPosZ.Value = pose.Z; CfgRotX.Value = pose.RotX; CfgRotY.Value = pose.RotY; CfgRotZ.Value = pose.RotZ; CfgScale.Value = pose.Scale; } } private static void ApplyEverywhere(HammerPose pose) { if ((Object)(object)s_item != (Object)null) { ApplyNamed(s_item.transform, pose); } Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null)) { VisEquipment componentInChildren = ((Component)localPlayer).GetComponentInChildren<VisEquipment>(); if ((Object)(object)componentInChildren != (Object)null) { ApplyNamed(((Component)componentInChildren).transform, pose); } } } private static void ApplyNamed(Transform root, HammerPose pose) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null && ((Object)componentsInChildren[i]).name == "dfg_hammer_visual") { ApplyLocal(componentsInChildren[i], pose); } } } private static void ApplyLocal(Transform visual, HammerPose pose) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) float num = pose.Scale; if (num < 0.05f) { num = 0.05f; } visual.localPosition = new Vector3(pose.X, pose.Y, pose.Z); visual.localRotation = Quaternion.Euler(pose.RotX, pose.RotY, pose.RotZ); visual.localScale = new Vector3(num, num, num); } private static float Pick(Dictionary<string, string> map, string key, float current, float min, float max) { if (!map.TryGetValue(key, out var value)) { return current; } if (!float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return current; } if (result < min) { return min; } if (result > max) { return max; } return result; } private static Dictionary<string, string> ParseQuery(string query) { Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); if (string.IsNullOrEmpty(query)) { return dictionary; } if (query[0] == '?') { query = query.Substring(1); } string[] array = query.Split('&'); foreach (string text in array) { if (text.Length != 0) { int num = text.IndexOf('='); string stringToUnescape = ((num >= 0) ? text.Substring(0, num) : text); string text2 = ((num >= 0) ? text.Substring(num + 1) : ""); dictionary[Uri.UnescapeDataString(stringToUnescape)] = Uri.UnescapeDataString(text2.Replace('+', ' ')); } } return dictionary; } internal static void Adopt(string guid, Piece piece, GameObject prefab, PieceCategory sharedCategory) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) s_shared = sharedCategory; if ((Object)(object)piece == (Object)null || (Object)(object)Table == (Object)null || (Object)(object)prefab == (Object)null) { return; } int instanceID = ((Object)prefab).GetInstanceID(); if (!s_pieces.TryGetValue(instanceID, out var value)) { value = new Routed(); s_pieces[instanceID] = value; if (!Table.m_pieces.Contains(prefab)) { Table.m_pieces.Add(prefab); } } value.Piece = piece; value.Category = CategoryFor(guid); value.CategoryName = (s_nameByGuid.TryGetValue(guid, out var value2) ? value2 : guid); piece.m_category = (s_modView ? value.Category : sharedCategory); } internal static int CollectStrays(PieceCategory shared) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) s_shared = shared; s_haveShared = true; if ((Object)(object)Table == (Object)null) { return 0; } PieceTable val = VanillaTable(); if ((Object)(object)val == (Object)null || val.m_pieces == null) { return 0; } Dictionary<string, string> dictionary = null; int num = 0; foreach (GameObject piece in val.m_pieces) { if ((Object)(object)piece == (Object)null || s_pieces.ContainsKey(((Object)piece).GetInstanceID())) { continue; } Piece component = piece.GetComponent<Piece>(); if (!((Object)(object)component == (Object)null) && !component.m_repairPiece && !component.m_removePiece && (component.m_category == shared || OwnsCategory(component.m_category))) { if (DFGHubPlugin.UnlockByDefault != null && DFGHubPlugin.UnlockByDefault.Value) { component.m_craftingStation = null; } if (dictionary == null) { dictionary = PrefabOwners(); } if (!dictionary.TryGetValue(((Object)piece).name, out var value) || string.IsNullOrEmpty(value)) { value = "DFG"; } Adopt(value, component, piece, shared); num++; } } return num; } internal static void OnPlaceMode(PieceTable buildPieces) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) s_modView = (Object)(object)Table != (Object)null && (Object)(object)buildPieces == (Object)(object)Table; if (s_modView && s_haveShared) { CollectStrays(s_shared); } ApplyCategories(); if (s_modView) { Arrange(); } } internal static void Arrange() { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_01d8: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Table == (Object)null) { return; } List<Bucket> list = new List<Bucket>(); foreach (Routed value in s_pieces.Values) { if ((Object)(object)value.Piece == (Object)null) { continue; } Bucket bucket = null; for (int i = 0; i < list.Count; i++) { if (list[i].Category == value.Category) { bucket = list[i]; break; } } if (bucket == null) { bucket = new Bucket { Name = value.CategoryName, Category = value.Category }; list.Add(bucket); } bucket.Count++; } list.Sort((Bucket a, Bucket b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase)); Table.m_categories.Clear(); Table.m_categoryLabels.Clear(); int num = 0; StringBuilder stringBuilder = new StringBuilder(); foreach (Bucket item in list) { Table.m_categories.Add(item.Category); Table.m_categoryLabels.Add(item.Name); num += item.Count; if (stringBuilder.Length > 0) { stringBuilder.Append(", "); } stringBuilder.Append(item.Name).Append('=').Append(item.Count); } if (Table.m_categories.Count > 0 && !Table.m_categories.Contains(Table.GetSelectedCategory())) { Table.SetCategory(0); } string text = stringBuilder.ToString(); if (text != s_lastSummary) { s_lastSummary = text; Logger.LogInfo((object)("DFG Hammer: " + num + " pieces in " + Table.m_categories.Count + " categories. " + text)); } } private static void ApplyCategories() { //IL_003d: 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_0042: Unknown result type (might be due to invalid IL or missing references) foreach (Routed value in s_pieces.Values) { if (!((Object)(object)value.Piece == (Object)null)) { value.Piece.m_category = (s_modView ? value.Category : s_shared); } } } private static PieceTable VanillaTable() { if ((Object)(object)s_vanilla != (Object)null) { return s_vanilla; } GameObject val = ((PrefabManager.Instance != null) ? PrefabManager.Instance.GetPrefab("Hammer") : null); ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null); s_vanilla = (((Object)(object)val2 != (Object)null && val2.m_itemData != null && val2.m_itemData.m_shared != null) ? val2.m_itemData.m_shared.m_buildPieces : null); return s_vanilla; } private static bool OwnsCategory(PieceCategory category) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) foreach (PieceCategory value in s_categoryByGuid.Values) { if (value == category) { return true; } } return false; } private static Dictionary<string, string> PrefabOwners() { Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.Ordinal); foreach (CustomPrefab prefab in ModRegistry.GetPrefabs()) { if (prefab != null && !((Object)(object)prefab.Prefab == (Object)null) && ((CustomEntity)prefab).SourceMod != null && !string.IsNullOrEmpty(((CustomEntity)prefab).SourceMod.GUID) && !string.IsNullOrEmpty(((Object)prefab.Prefab).name)) { dictionary[((Object)prefab.Prefab).name] = ((CustomEntity)prefab).SourceMod.GUID; } } return dictionary; } private static PieceCategory CategoryFor(string guid) { //IL_000f: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (s_categoryByGuid.TryGetValue(guid, out var value)) { return value; } string text = DisplayName(guid); string b = ((DFGHubPlugin.CategoryName != null) ? DFGHubPlugin.CategoryName.Value : "DFG"); if (string.Equals(text, b, StringComparison.OrdinalIgnoreCase)) { text += " pieces"; } int num = 2; string text2 = text; string value2; while (s_guidByName.TryGetValue(text2, out value2) && !string.Equals(value2, guid, StringComparison.OrdinalIgnoreCase)) { text2 = text + " " + num; num++; } s_guidByName[text2] = guid; s_nameByGuid[guid] = text2; PieceCategory val = PieceManager.Instance.AddPieceCategory(text2); s_categoryByGuid[guid] = val; return val; } private static string DisplayName(string guid) { if (!string.IsNullOrEmpty(guid) && Chainloader.PluginInfos.TryGetValue(guid, out var value) && value.Metadata != null) { string name = value.Metadata.Name; if (!string.IsNullOrWhiteSpace(name)) { return name.Trim(); } } if (string.IsNullOrEmpty(guid)) { return "DFG"; } int num = guid.LastIndexOf('.'); if (num < 0 || num >= guid.Length - 1) { return guid; } return guid.Substring(num + 1); } private static Sprite LoadIcon() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) try { using Stream stream = typeof(DFGHammer).GetTypeInfo().Assembly.GetManifestResourceStream("DFGHub.logo.png"); if (stream == null) { return null; } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, memoryStream.ToArray())) { return null; } return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); } catch (Exception ex) { Logger.LogWarning((object)("DFG Hammer: icon failed, keeping the hammer icon. " + ex.Message)); return null; } } } [HarmonyPatch(typeof(Player), "SetPlaceMode")] internal static class DFGHammerPlacePatch { private static void Prefix(PieceTable buildPieces) { DFGHammer.OnPlaceMode(buildPieces); } [HarmonyPriority(100)] private static void Postfix(PieceTable buildPieces) { if ((Object)(object)buildPieces != (Object)null && (Object)(object)buildPieces == (Object)(object)DFGHammer.Table) { DFGHammer.Arrange(); } } } [HarmonyPatch] internal static class DFGHammerMenuPatch { private static readonly HashSet<int> s_reported = new HashSet<int>(); [HarmonyPatch(typeof(BuildUiPieceButton), "RefreshSearchTerm")] private static bool Prefix(BuildUiPieceButton __instance) { List<string> localizedSearchTerms = __instance.LocalizedSearchTerms; if (localizedSearchTerms == null) { return false; } localizedSearchTerms.Clear(); Piece piece = __instance.Piece; if ((Object)(object)piece == (Object)null) { return false; } Scrub(piece); AddTerm(localizedSearchTerms, piece.m_name); Requirement[] resources = piece.m_resources; if (resources == null) { return false; } for (int i = 0; i < resources.Length; i++) { ItemDrop val = resources[i]?.m_resItem; if (!((Object)(object)val == (Object)null) && val.m_itemData != null && val.m_itemData.m_shared != null) { AddTerm(localizedSearchTerms, val.m_itemData.m_shared.m_name); } } return false; } [HarmonyPatch(typeof(Player), "HaveRequirements", new Type[] { typeof(Piece), typeof(RequirementMode) })] private static void Prefix(Piece piece) { Scrub(piece); } private static void Scrub(Piece piece) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown if ((Object)(object)piece == (Object)null) { return; } if (string.IsNullOrEmpty(piece.m_name)) { piece.m_name = (((Object)(object)((Component)piece).gameObject != (Object)null) ? ((Object)((Component)piece).gameObject).name : "piece"); Report(piece, "has no name, so the build menu was using the prefab name"); } if (piece.m_resources == null) { piece.m_resources = (Requirement[])(object)new Requirement[0]; Report(piece, "has no cost list"); return; } Requirement[] resources = piece.m_resources; for (int i = 0; i < resources.Length; i++) { Requirement val = resources[i]; if (val == null) { resources[i] = new Requirement(); Report(piece, "has an empty cost slot"); continue; } ItemDrop resItem = val.m_resItem; if (!((Object)(object)resItem == (Object)null) && (resItem.m_itemData == null || resItem.m_itemData.m_shared == null || resItem.m_itemData.m_shared.m_name == null)) { string text = (((Object)(object)((Component)resItem).gameObject != (Object)null) ? ((Object)((Component)resItem).gameObject).name : ((Object)resItem).name); val.m_resItem = null; Report(piece, "dropped a cost whose item '" + text + "' has no item data"); } } } private static void AddTerm(List<string> terms, string token) { if (!string.IsNullOrEmpty(token)) { string text = ((Localization.instance != null) ? Localization.instance.Localize(token) : token); if (!string.IsNullOrEmpty(text)) { terms.Add(text.ToLowerInvariant().Replace(" ", "")); } } } private static void Report(Piece piece, string detail) { int instanceID = ((Object)piece).GetInstanceID(); if (s_reported.Add(instanceID)) { string text = (string.IsNullOrEmpty(piece.m_name) ? ((Object)piece).name : piece.m_name); Logger.LogWarning((object)("DFG Hammer: '" + text + "' " + detail + ". Right-click opens the build menu again.")); } } } [BepInPlugin("com.dfghub.dfghub", "DFGHub", "1.5.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class DFGHubPlugin : BaseUnityPlugin { public const string PluginGUID = "com.dfghub.dfghub"; public const string PluginName = "DFGHub"; public const string PluginVersion = "1.5.4"; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<string> CategoryName; internal static ConfigEntry<bool> UnlockByDefault; internal static ConfigEntry<bool> ExclusiveCategory; internal static ConfigEntry<bool> EnableDfgHammer; internal static ConfigEntry<bool> EnableWebHub; internal static ConfigEntry<int> WebPort; internal static ConfigEntry<bool> EnableHall; internal static ConfigEntry<KeyboardShortcut> HallKey; internal static ConfigEntry<int> HallFontPercent; internal static ConfigEntry<bool> ShowMainMenuLogo; internal static ConfigEntry<bool> ShowActiveModList; internal static ConfigEntry<bool> ShowModVersions; internal static ConfigEntry<bool> IncludeHubInList; internal static ConfigEntry<bool> ShowModListBackground; internal static ConfigEntry<int> ModListColumns; internal static ConfigEntry<int> MaxItemsPerColumn; internal static ConfigEntry<int> MainMenuLogoSize; internal static ConfigEntry<int> MainMenuLogoRightMargin; internal static ConfigEntry<int> MainMenuLogoTopMargin; internal static ConfigEntry<int> MainMenuLogoOpacity; internal static ConfigEntry<int> ModListFontSize; internal static ConfigEntry<int> ModListColumnWidth; internal static ConfigEntry<int> ModListLineSpacing; internal static ManualLogSource Log; internal static int RoutedPieceCount; internal static string ActiveCategory = "DFG"; private static readonly string[] ModGuids = new string[33] { "com.harpoonlooter.harpoonlooter", "com.harvestturrets.harvestturrets", "com.seatapult.seatapult", "com.safeharbor.safeharbor", "com.tradewind.tradewind", "com.bluecollartrolls.bluecollartrolls", "com.harpoonlongboat.harpoonlongboat", "com.storagesign.storagesign", "com.dfg.qol", "com.vikingvault.vikingvault", "com.dfg.freyjasfeeder", "com.dfg.pebble", "com.dfg.salvagestation", "com.dfg.transporter", "com.dfg.skald", "com.dfg.dvergarskytram", "com.dfg.smidrworks", "com.dfg.ransnet", "com.dfg.dockfortress", "com.dfg.odinseye", "com.dfg.skyherd", "com.dfg.ymirsmarrow", "com.dfg.chucknorse", "com.dfg.landdrakkar", "com.dfg.dropcrate", "com.dfg.raiders", "com.dfg.hoardgoblin", "com.dfg.brasseye", "com.dfg.brasseye", "com.dfg.trophyspike", "com.dfg.torgue", "com.dfg.vending", "com.dfg.underdome" }; private Harmony m_harmony; private float m_retryWindow; private float m_retryTimer; private bool m_sawSpawn; private int m_refreshCount; private float m_refreshCooldown; private int m_lastRoutedCount = -1; private void Awake() { //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Expected O, but got Unknown //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Expected O, but got Unknown //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Expected O, but got Unknown //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Expected O, but got Unknown //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Expected O, but got Unknown //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Expected O, but got Unknown //IL_037b: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Expected O, but got Unknown //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Expected O, but got Unknown //IL_03eb: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Expected O, but got Unknown //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Expected O, but got Unknown Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master switch for DFGHub."); CategoryName = ((BaseUnityPlugin)this).Config.Bind<string>("General", "CategoryName", "DFG", "Name of the shared Hammer build category."); UnlockByDefault = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "UnlockByDefault", true, "Clear any crafting-station requirement so DFG pieces are always buildable."); ExclusiveCategory = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ExclusiveCategory", false, "When true, remove pieces from their vanilla tag (Misc/Furniture) so they only appear under the DFG category."); EnableDfgHammer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableDfgHammer", true, "Add the DFG Hammer. It builds the same pieces as the DFG tab, with one category for each mod. Crafted at a workbench from 4 Wood and 2 Stone."); EnableWebHub = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableWebHub", true, "Serve the parent web hub on localhost."); WebPort = ((BaseUnityPlugin)this).Config.Bind<int>("General", "WebPort", 8782, "TCP port for the DFG hub (http://127.0.0.1:<port>/)."); EnableHall = ((BaseUnityPlugin)this).Config.Bind<bool>("Hall", "EnableHall", true, "Open Sea Route, TradeWind, Blue Collar, and Pebble bounties in one board. It covers 80% of the screen, and the header can shrink it to the left 30% or drag it."); HallKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hall", "HallKey", new KeyboardShortcut((KeyCode)116, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Opens and closes the DFG board. Sea Route and TradeWind stop using this key while the board is on."); HallFontPercent = ((BaseUnityPlugin)this).Config.Bind<int>("Hall", "FontPercent", 100, new ConfigDescription("Text size on the DFG board, as a percent of normal. The A- and A+ buttons on the board change this.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(80, 160), Array.Empty<object>())); ShowMainMenuLogo = ((BaseUnityPlugin)this).Config.Bind<bool>("MainMenu", "ShowLogo", true, "Show the DFG logo on the Valheim main menu."); ShowActiveModList = ((BaseUnityPlugin)this).Config.Bind<bool>("MainMenu", "ShowActiveModList", true, "Show the list of active DFG mods loaded on the main menu."); ShowModVersions = ((BaseUnityPlugin)this).Config.Bind<bool>("MainMenu", "ShowModVersions", true, "Show a light beside each active mod: green when this build is the latest DFG package on Thunderstore, yellow when a newer one is published, gray when it is not published there. The list carries a key for those lights."); IncludeHubInList = ((BaseUnityPlugin)this).Config.Bind<bool>("MainMenu", "IncludeHubInList", false, "Include DFGHub itself in the active DFG mods list count and items."); ShowModListBackground = ((BaseUnityPlugin)this).Config.Bind<bool>("MainMenu", "ShowModListBackground", true, "Show a subtle dark backing panel behind the active mod list for readability."); ModListColumns = ((BaseUnityPlugin)this).Config.Bind<int>("MainMenu", "ModListColumns", 2, new ConfigDescription("Number of columns for the active DFG mods list.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 4), Array.Empty<object>())); MaxItemsPerColumn = ((BaseUnityPlugin)this).Config.Bind<int>("MainMenu", "MaxItemsPerColumn", 24, new ConfigDescription("Max mods per column before wrapping when column count is automatic.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 40), Array.Empty<object>())); MainMenuLogoSize = ((BaseUnityPlugin)this).Config.Bind<int>("MainMenu", "LogoSize", 200, new ConfigDescription("Logo width and height in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(64, 512), Array.Empty<object>())); MainMenuLogoRightMargin = ((BaseUnityPlugin)this).Config.Bind<int>("MainMenu", "LogoRightMargin", 32, new ConfigDescription("Distance in pixels from the right edge.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); MainMenuLogoTopMargin = ((BaseUnityPlugin)this).Config.Bind<int>("MainMenu", "LogoTopMargin", 24, new ConfigDescription("Distance in pixels from the top edge.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000), Array.Empty<object>())); MainMenuLogoOpacity = ((BaseUnityPlugin)this).Config.Bind<int>("MainMenu", "LogoOpacity", 255, new ConfigDescription("Logo opacity from 0 to 255.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>())); ModListFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("MainMenu", "ModListFontSize", 13, new ConfigDescription("Font size for the active DFG mods list.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(8, 24), Array.Empty<object>())); ModListColumnWidth = ((BaseUnityPlugin)this).Config.Bind<int>("MainMenu", "ModListColumnWidth", 290, new ConfigDescription("Width in pixels for each column in the active DFG mods list.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(180, 500), Array.Empty<object>())); ModListLineSpacing = ((BaseUnityPlugin)this).Config.Bind<int>("MainMenu", "ModListLineSpacing", 20, new ConfigDescription("Extra line spacing percentage between items.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); DFGHammer.Bind(((BaseUnityPlugin)this).Config); Log = ((BaseUnityPlugin)this).Logger; if (Enabled.Value) { ActiveCategory = CategoryName.Value; PieceManager.OnPiecesRegistered += OnPiecesRegistered; if (EnableDfgHammer.Value) { PrefabManager.OnVanillaPrefabsAvailable += DFGHammer.Register; } if (EnableWebHub.Value) { HubWeb.Start(); } m_harmony = new Harmony("com.dfghub.dfghub"); m_harmony.PatchAll(typeof(DFGHammerPlacePatch)); m_harmony.PatchAll(typeof(DFGHammerMenuPatch)); if (EnableHall.Value && (Object)(object)((Component)this).GetComponent<HallBoard>() == (Object)null) { ((Component)this).gameObject.AddComponent<HallBoard>(); m_harmony.PatchAll(typeof(HallInput)); } } } private void OnDestroy() { PieceManager.OnPiecesRegistered -= OnPiecesRegistered; PrefabManager.OnVanillaPrefabsAvailable -= DFGHammer.Register; HubWeb.Stop(); Harmony harmony = m_harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void OnPiecesRegistered() { m_retryWindow = 60f; m_retryTimer = 0f; m_sawSpawn = false; m_refreshCount = 0; m_refreshCooldown = 0f; m_lastRoutedCount = -1; } private void Update() { DFGHammer.DrainPose(); MainMenuLogo.Tick(); if (m_retryWindow <= 0f) { return; } m_retryWindow -= Time.deltaTime; m_retryTimer -= Time.deltaTime; if (m_retryTimer <= 0f) { m_retryTimer = 1f; ReorganizePieces(); } if (!((Object)(object)Player.m_localPlayer != (Object)null)) { return; } if (!m_sawSpawn) { m_sawSpawn = true; m_refreshCount = 3; m_refreshCooldown = 0f; } if (m_refreshCount > 0) { m_refreshCooldown -= Time.deltaTime; if (m_refreshCooldown <= 0f) { m_refreshCooldown = 2f; m_refreshCount--; ReorganizePieces(); RefreshCategories(); } } } private void ReorganizePieces() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected I4, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) if (!Enabled.Value) { return; } try { string value = CategoryName.Value; PieceCategory val = PieceManager.Instance.AddPieceCategory(value); int num = 0; StringBuilder stringBuilder = new StringBuilder(); string[] modGuids = ModGuids; foreach (string text in modGuids) { int num2 = 0; foreach (CustomPiece piece in ModRegistry.GetPieces(text)) { Piece val2 = ((piece == null) ? null : piece.Piece); if (!((Object)(object)val2 == (Object)null)) { val2.m_category = val; if (ExclusiveCategory.Value) { val2.m_usage = (UsageTagFlags)0; } if (UnlockByDefault.Value) { val2.m_craftingStation = null; } GameObject prefab = (((Object)(object)piece.PiecePrefab != (Object)null) ? piece.PiecePrefab : ((Component)val2).gameObject); DFGHammer.Adopt(text, val2, prefab, val); num++; num2++; } } if (stringBuilder.Length > 0) { stringBuilder.Append(", "); } stringBuilder.Append(text).Append("=").Append(num2); } int num3 = DFGHammer.CollectStrays(val); if (num3 > 0) { num += num3; stringBuilder.Append(" | hammer-only=").Append(num3); } RoutedPieceCount = num; if (num != m_lastRoutedCount) { m_lastRoutedCount = num; Logger.LogInfo((object)("DFGHub: routed " + num + " pieces into '" + value + "' (id=" + (int)val + "). " + stringBuilder)); if (DFGHammer.ModView) { DFGHammer.Arrange(); } RefreshCategories(); } } catch (Exception ex) { Logger.LogWarning((object)("DFGHub: piece reorganization failed: " + ex)); } } private static void RefreshCategories() { try { MethodInfo method = typeof(PieceManager).GetMethod("RefreshCategories", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { method.Invoke(PieceManager.Instance, null); } } catch (Exception ex) { Logger.LogWarning((object)("DFGHub: could not refresh piece categories: " + ex.Message)); } } } public class HallBoard : MonoBehaviour { private sealed class Tab { public string Id; public string Title; public int Order; public Action<Rect> Draw; } private static readonly List<Tab> s_tabs = new List<Tab>(); private static int s_index; private static bool s_yield; private static bool s_escapeHeld; private static bool s_compact; private static bool s_placed; private static Rect s_window; private static bool s_dragging; private static Vector2 s_dragOffset; private static readonly Color ColBackdrop = new Color(0f, 0f, 0f, 0.8f); private static readonly Color ColWindow = new Color(0.08f, 0.1f, 0.14f, 0.99f); private static readonly Color ColBorder = new Color(0.74f, 0.58f, 0.28f, 1f); private static readonly Color ColInner = new Color(0.18f, 0.23f, 0.32f, 0.85f); private static readonly Color ColHeader = new Color(0.12f, 0.16f, 0.22f, 1f); private static readonly Color ColTab = new Color(0.1f, 0.13f, 0.18f, 0.95f); private static readonly Color ColTabOn = new Color(0.22f, 0.18f, 0.08f, 0.98f); private static readonly Color ColGold = new Color(1f, 0.84f, 0.38f, 1f); private static readonly Color ColWhite = new Color(0.92f, 0.95f, 0.98f, 1f); private static readonly Color ColMuted = new Color(0.6f, 0.66f, 0.75f, 1f); private static readonly Dictionary<string, GUIStyle> s_styles = new Dictionary<string, GUIStyle>(); private bool m_open; private Texture2D m_white; private bool m_hotkeyWasDown; public static HallBoard Instance { get; private set; } public static bool Ready => (Object)(object)Instance != (Object)null; public static bool IsOpen { get { if ((Object)(object)Instance != (Object)null) { return Instance.m_open; } return false; } } public static float TextScale => (float)Mathf.Clamp(DFGHubPlugin.HallFontPercent?.Value ?? 100, 80, 160) / 100f; private void Awake() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) Instance = this; m_white = new Texture2D(1, 1); m_white.SetPixel(0, 0, Color.white); m_white.Apply(); } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } public static void Register(string id, string title, int order, Action<Rect> draw) { if (string.IsNullOrEmpty(id) || draw == null) { return; } for (int i = 0; i < s_tabs.Count; i++) { if (string.Equals(s_tabs[i].Id, id, StringComparison.OrdinalIgnoreCase)) { s_tabs[i].Title = (string.IsNullOrEmpty(title) ? id : title); s_tabs[i].Order = order; s_tabs[i].Draw = draw; SortTabs(); return; } } s_tabs.Add(new Tab { Id = id, Title = (string.IsNullOrEmpty(title) ? id : title), Order = order, Draw = draw }); SortTabs(); ManualLogSource log = DFGHubPlugin.Log; if (log != null) { log.LogInfo((object)("DFG board tab '" + title + "' (" + id + ")")); } } public static bool Open(string tabId) { if ((Object)(object)Instance == (Object)null) { return false; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { return false; } if (!string.IsNullOrEmpty(tabId)) { int num = IndexOf(tabId); if (num < 0) { return false; } s_index = num; } Instance.m_open = true; Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; return true; } public static void Close() { if ((Object)(object)Instance == (Object)null || !Instance.m_open) { s_yield = false; s_escapeHeld = false; return; } Instance.m_open = false; s_yield = false; s_escapeHeld = false; s_dragging = false; if (!InventoryGui.IsVisible()) { Cursor.visible = false; Cursor.lockState = (CursorLockMode)1; } } public static bool IsHosting(string id) { if (!IsOpen || s_tabs.Count == 0 || string.IsNullOrEmpty(id)) { return false; } int index = Mathf.Clamp(s_index, 0, s_tabs.Count - 1); return string.Equals(s_tabs[index].Id, id, StringComparison.OrdinalIgnoreCase); } public static void SetYield(bool yieldScreen) { s_yield = yieldScreen; } public static void HoldEscape() { s_escapeHeld = true; } private void Update() { bool flag = HotkeyDown(); if (!m_open) { if (flag && CanOpen()) { Open(null); } return; } bool flag2 = s_escapeHeld; s_escapeHeld = false; Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || Menu.IsVisible()) { Close(); return; } PlayerController.SetTakeInputDelay(0.25f); Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; if (flag && GUIUtility.keyboardControl == 0) { Close(); } else if (Input.GetKeyDown((KeyCode)27) || ZInput.GetButtonDown("JoyButtonB")) { if (GUIUtility.keyboardControl != 0) { GUIUtility.keyboardControl = 0; } else if (!(s_yield || flag2)) { Close(); } } } private void OnGUI() { if (!m_open || (Object)(object)Player.m_localPlayer == (Object)null) { return; } ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); int depth = GUI.depth; GUI.depth = -50; try { if (s_yield) { DrawYielded(); } else { DrawFull(); } } finally { GUI.depth = depth; } } private void DrawFull() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0082: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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_010d: 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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_01e9: 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_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) DrawRect(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), ColBackdrop); PlaceWindow(); HandleDrag(); Rect rect = s_window; DrawBox(rect, ColWindow, ColBorder, 2f); DrawBorder(new Rect(((Rect)(ref rect)).x + 3f, ((Rect)(ref rect)).y + 3f, ((Rect)(ref rect)).width - 6f, ((Rect)(ref rect)).height - 6f), ColInner, 1f); Rect rect2 = default(Rect); ((Rect)(ref rect2))..ctor(((Rect)(ref rect)).x + 12f, ((Rect)(ref rect)).y + 10f, ((Rect)(ref rect)).width - 24f, 32f); DrawBox(rect2, ColHeader, ColInner, 1f); GUI.Label(new Rect(((Rect)(ref rect2)).x + 10f, ((Rect)(ref rect2)).y, 64f, ((Rect)(ref rect2)).height), "DFG", Style(16, bold: true, (TextAnchor)3, ColGold)); float right = ((Rect)(ref rect2)).xMax - 4f; float y = ((Rect)(ref rect2)).y + 4f; Rect rect3 = TakeButton(ref right, y, 24f); Rect rect4 = TakeButton(ref right, y, 36f); Rect val = TakeButton(ref right, y, 44f); Rect rect5 = TakeButton(ref right, y, 36f); Rect rect6 = TakeButton(ref right, y, 44f); if (Button(rect6, s_compact ? "80%" : "30%", ColGold)) { s_compact = !s_compact; s_placed = false; s_dragging = false; } if (NudgeButton(rect5, "A-")) { NudgeFont(-10); } GUI.Label(val, TextScale.ToString("0%"), Style(12, bold: true, (TextAnchor)4, ColGold)); if (NudgeButton(rect4, "A+")) { NudgeFont(10); } if (Button(rect3, "x", ColWhite)) { Close(); return; } Rect bar = default(Rect); ((Rect)(ref bar))..ctor(((Rect)(ref rect)).x + 12f, ((Rect)(ref rect2)).yMax + 8f, ((Rect)(ref rect)).width - 24f, 32f); DrawTabs(bar); Rect body = default(Rect); ((Rect)(ref body))..ctor(((Rect)(ref rect)).x + 12f, ((Rect)(ref bar)).yMax + 8f, ((Rect)(ref rect)).width - 24f, ((Rect)(ref rect)).yMax - ((Rect)(ref bar)).yMax - 20f); DrawScaled(body); } private static Rect TakeButton(ref float right, float y, float width) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) right -= width; Rect result = new Rect(right, y, width, 24f); right -= 4f; return result; } private static void PlaceWindow() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) bool flag = s_compact; float num = (float)Screen.width * (flag ? 0.3f : 0.8f); float num2 = (flag ? ((float)Screen.height - 32f) : ((float)Screen.height * 0.8f)); if (!s_placed) { float num3 = (flag ? 16f : (((float)Screen.width - num) * 0.5f)); float num4 = (flag ? 16f : (((float)Screen.height - num2) * 0.5f)); s_window = new Rect(num3, num4, num, num2); s_placed = true; } else { ((Rect)(ref s_window)).width = num; ((Rect)(ref s_window)).height = num2; ((Rect)(ref s_window)).x = Mathf.Clamp(((Rect)(ref s_window)).x, 0f, Mathf.Max(0f, (float)Screen.width - num)); ((Rect)(ref s_window)).y = Mathf.Clamp(((Rect)(ref s_window)).y, 0f, Mathf.Max(0f, (float)Screen.height - num2)); } } private void HandleDrag() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Invalid comparison between Unknown and I4 //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Invalid comparison between Unknown and I4 //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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) Event current = Event.current; if (current != null) { Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref s_window)).x + 12f, ((Rect)(ref s_window)).y + 10f, ((Rect)(ref s_window)).width - 24f, 32f); float num = 208f; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref val)).x, ((Rect)(ref val)).y, Mathf.Max(48f, ((Rect)(ref val)).width - num), ((Rect)(ref val)).height); if ((int)current.type == 0 && ((Rect)(ref val2)).Contains(current.mousePosition)) { s_dragging = true; s_dragOffset = current.mousePosition - new Vector2(((Rect)(ref s_window)).x, ((Rect)(ref s_window)).y); current.Use(); } else if ((int)current.type == 3 && s_dragging) { ((Rect)(ref s_window)).x = current.mousePosition.x - s_dragOffset.x; ((Rect)(ref s_window)).y = current.mousePosition.y - s_dragOffset.y; ((Rect)(ref s_window)).x = Mathf.Clamp(((Rect)(ref s_window)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref s_window)).width)); ((Rect)(ref s_window)).y = Mathf.Clamp(((Rect)(ref s_window)).y, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref s_window)).height)); current.Use(); } else if ((int)current.type == 1 && s_dragging) { s_dragging = false; current.Use(); } } } private void DrawYielded() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) float num = 520f; float num2 = Mathf.Min(760f, (float)Screen.height - 40f); Rect rect = default(Rect); ((Rect)(ref rect))..ctor((float)Screen.width - num - 20f, ((float)Screen.height - num2) * 0.5f, num, num2); DrawBox(rect, ColWindow, ColBorder, 2f); Rect body = default(Rect); ((Rect)(ref body))..ctor(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y + 8f, ((Rect)(ref rect)).width - 16f, ((Rect)(ref rect)).height - 16f); DrawScaled(body); } private void DrawScaled(Rect body) { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_002f: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) float textScale = TextScale; if (textScale < 1.05f && textScale > 0.95f) { DrawActive(body); return; } Event current = Event.current; Vector2 val = ((current != null) ? current.mousePosition : Vector2.zero); if (current != null) { Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(((Rect)(ref body)).x, ((Rect)(ref body)).y); current.mousePosition = val2 + (val - val2) / textScale; } Matrix4x4 matrix = GUI.matrix; GUIUtility.ScaleAroundPivot(new Vector2(textScale, textScale), new Vector2(((Rect)(ref body)).x, ((Rect)(ref body)).y)); try { DrawActive(new Rect(((Rect)(ref body)).x, ((Rect)(ref body)).y, ((Rect)(ref body)).width / textScale, ((Rect)(ref body)).height / textScale)); } finally { GUI.matrix = matrix; if (current != null) { current.mousePosition = val; } } } private static void NudgeFont(int delta) { ConfigEntry<int> hallFontPercent = DFGHubPlugin.HallFontPercent; if (hallFontPercent != null) { hallFontPercent.Value = Mathf.Clamp(hallFontPercent.Value + delta, 80, 160); } } private bool NudgeButton(Rect rect, string text) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return Button(rect, text, ColGold); } private void DrawTabs(Rect bar) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) if (s_tabs.Count == 0) { GUI.Label(bar, "No boards have registered yet.", Style(13, bold: false, (TextAnchor)3, ColMuted)); return; } s_index = Mathf.Clamp(s_index, 0, s_tabs.Count - 1); float num = 4f; float num2 = Mathf.Min(180f, (((Rect)(ref bar)).width - num * (float)(s_tabs.Count - 1)) / (float)s_tabs.Count); Rect rect = default(Rect); for (int i = 0; i < s_tabs.Count; i++) { ((Rect)(ref rect))..ctor(((Rect)(ref bar)).x + (float)i * (num2 + num), ((Rect)(ref bar)).y, num2, ((Rect)(ref bar)).height); bool flag = i == s_index; if (Button(rect, s_tabs[i].Title, flag ? ColGold : ColWhite, flag ? ColTabOn : ColTab, flag ? ColBorder : ColInner)) { s_index = i; s_yield = false; } } } private void DrawActive(Rect body) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) if (s_tabs.Count == 0) { GUI.Label(body, "Sea Route, TradeWind, Blue Collar, and Bounties appear here when those mods are loaded.", Style(14, bold: false, (TextAnchor)0, ColMuted)); return; } s_index = Mathf.Clamp(s_index, 0, s_tabs.Count - 1); try { s_tabs[s_index].Draw(body); } catch (Exception ex) { GUI.Label(body, "This tab hit an error. See the BepInEx log.", Style(14, bold: false, (TextAnchor)0, ColMuted)); ManualLogSource log = DFGHubPlugin.Log; if (log != null) { log.LogWarning((object)("DFG board tab '" + s_tabs[s_index].Id + "' failed: " + ex.Message)); } } } private bool CanOpen() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { return false; } if (Menu.IsVisible() || Console.IsVisible() || InventoryGui.IsVisible() || Minimap.InTextInput()) { return false; } if ((Object)(object)Chat.instance != (Object)null && Chat.instance.IsChatDialogWindowVisible()) { return false; } if (GUIUtility.keyboardControl != 0) { return false; } return true; } private bool HotkeyDown() { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (DFGHubPlugin.HallKey == null) { return false; } KeyboardShortcut value = DFGHubPlugin.HallKey.Value; bool flag = ((KeyboardShortcut)(ref value)).IsDown(); bool result = flag && !m_hotkeyWasDown; m_hotkeyWasDown = flag; return result; } private bool Button(Rect rect, string text, Color textColor) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) return Button(rect, text, textColor, ColTab, ColInner); } private bool Button(Rect rect, string text, Color textColor, Color background, Color border) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_0038: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) bool flag = ((Rect)(ref rect)).Contains((Event.current != null) ? Event.current.mousePosition : Vector2.zero); DrawBox(rect, flag ? (background * 1.25f) : background, flag ? ColGold : border, 1f); GUI.Label(rect, text, Style(13, bold: true, (TextAnchor)4, textColor)); return GUI.Button(rect, GUIContent.none, GUIStyle.none); } private void DrawRect(Rect rect, Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Color color2 = GUI.color; GUI.color = color; GUI.DrawTexture(rect, (Texture)(object)m_white); GUI.color = color2; } private void DrawBorder(Rect rect, Color color, float thickness) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) DrawRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, thickness), color); DrawRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - thickness, ((Rect)(ref rect)).width, thickness), color); DrawRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + thickness, thickness, ((Rect)(ref rect)).height - thickness * 2f), color); DrawRect(new Rect(((Rect)(ref rect)).xMax - thickness, ((Rect)(ref rect)).y + thickness, thickness, ((Rect)(ref rect)).height - thickness * 2f), color); } private void DrawBox(Rect rect, Color background, Color border, float thickness) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) DrawRect(rect, background); if (thickness > 0f) { DrawBorder(rect, border, thickness); } } private static GUIStyle Style(int size, bool bold, TextAnchor anchor, Color color) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected I4, but got Unknown //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) string key = size + ":" + (bold ? 1 : 0) + ":" + (int)anchor + ":" + color.r.ToString("F2") + color.g.ToString("F2") + color.b.ToString("F2"); if (!s_styles.TryGetValue(key, out var value)) { value = new GUIStyle(GUI.skin.label) { fontSize = size, fontStyle = (FontStyle)(bold ? 1 : 0), alignment = anchor, clipping = (TextClipping)1 }; value.normal.textColor = color; value.hover.textColor = color; value.active.textColor = color; s_styles[key] = value; } return value; } private static int IndexOf(string id) { for (int i = 0; i < s_tabs.Count; i++) { if (string.Equals(s_tabs[i].Id, id, StringComparison.OrdinalIgnoreCase)) { return i; } } return -1; } private static void SortTabs() { s_tabs.Sort((Tab a, Tab b) => (a.Order == b.Order) ? string.Compare(a.Title, b.Title, StringComparison.OrdinalIgnoreCase) : a.Order.CompareTo(b.Order)); } } internal static class HallInput { [HarmonyPatch(typeof(PlayerController), "InInventoryEtc")] [HarmonyPostfix] public static void InInventoryEtc(ref bool __result) { if (HallBoard.IsOpen) { __result = true; } } [HarmonyPatch(typeof(Player), "TakeInput")] [HarmonyPrefix] public static bool PlayerTakeInput(ref bool __result) { if (!HallBoard.IsOpen) { return true; } __result = false; return false; } [HarmonyPatch(typeof(PlayerController), "TakeInput")] [HarmonyPrefix] public static bool ControllerTakeInput(ref bool __result) { if (!HallBoard.IsOpen) { return true; } __result = false; return false; } [HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")] [HarmonyPostfix] public static void KeepCursorFree() { if (HallBoard.IsOpen) { ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); } } } internal static class HammerGlb { [Serializable] private class Gltf { public GltfScene[] scenes; public GltfNode[] nodes; public GltfMesh[] meshes; public GltfMaterial[] materials; public GltfAccessor[] accessors; public GltfBufferView[] bufferViews; public GltfTexture[] textures; public GltfImage[] images; } [Serializable] private class GltfScene { public int[] nodes; } [Serializable] private class GltfNode { public string name; public int mesh = -1; public float[] translation; public float[] rotation; public float[] scale; public int[] children; } [Serializable] private class GltfMesh { public string name; public GltfPrimitive[] primitives; } [Serializable] private class GltfPrimitive { public GltfAttributes attributes; public int indices = -1; public int material = -1; } [Serializable] private class GltfAttributes { public int POSITION = -1; public int NORMAL = -1; public int TEXCOORD_0 = -1; } [Serializable] private class GltfMaterial { public string name; public GltfPbr pbrMetallicRoughness; } [Serializable] private class GltfPbr { public float[] baseColorFactor; public GltfTextureInfo baseColorTexture; } [Serializable] private class GltfTextureInfo { public int index = -1; } [Serializable] private class GltfTexture { public int source = -1; } [Serializable] private class GltfImage { public int bufferView = -1; } [Serializable] private class GltfAccessor { public int bufferView; public int byteOffset; public int componentType; public int count; } [Serializable] private class GltfBufferView { public int byteOffset; public int byteLength; public int byteStride; } internal static GameObject Load(string fileName) { try { string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), fileName); if (!File.Exists(text)) { Logger.LogWarning((object)("DFG Hammer: GLB not found at " + text)); return null; } return Parse(File.ReadAllBytes(text), fileName); } catch (Exception ex) { Logger.LogWarning((object)("DFG Hammer: GLB load exception " + fileName + ": " + ex)); return null; } } private static GameObject Parse(byte[] data, string fileName) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03d1: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_0441: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0466: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0491: Unknown result type (might be due to invalid IL or missing references) if (data.Length < 20 || BitConverter.ToUInt32(data, 0) != 1179937895) { Logger.LogWarning((object)("DFG Hammer: " + fileName + " is not a binary glTF.")); return null; } string text = null; byte[] array = null; int num = 12; while (num + 8 <= data.Length) { uint num2 = BitConverter.ToUInt32(data, num); uint num3 = BitConverter.ToUInt32(data, num + 4); num += 8; switch (num3) { case 1313821514u: text = Encoding.UTF8.GetString(data, num, (int)num2); break; case 5130562u: array = new byte[num2]; Array.Copy(data, num, array, 0, (int)num2); break; } num += (int)num2; num = (num + 3) & -4; } if (text == null || array == null) { Logger.LogWarning((object)("DFG Hammer: " + fileName + " has no JSON or BIN chunk.")); return null; } Gltf gltf = JsonConvert.DeserializeObject<Gltf>(text); GameObject val = new GameObject(Path.GetFileNameWithoutExtension(fileName)); Shader shader = FindShader(); Material[] materials = BuildMaterials(gltf, array, shader); Mesh[] array2 = BuildMeshes(gltf, array); Material[][] array3 = new Material[array2.Length][]; for (int i = 0; i < gltf.meshes.Length; i++) { array3[i] = MaterialsForMesh(gltf.meshes[i], materials, shader); } GameObject[] array4 = (GameObject[])(object)new GameObject[gltf.nodes.Length]; for (int j = 0; j < gltf.nodes.Length; j++) { GltfNode gltfNode = gltf.nodes[j]; array4[j] = new GameObject(gltfNode.name ?? ("node" + j)); if (gltfNode.translation != null && gltfNode.translation.Length == 3) { array4[j].transform.localPosition = new Vector3(gltfNode.translation[0], gltfNode.translation[1], gltfNode.translation[2]); } if (gltfNode.rotation != null && gltfNode.rotation.Length == 4) { array4[j].transform.localRotation = new Quaternion(gltfNode.rotation[0], gltfNode.rotation[1], gltfNode.rotation[2], gltfNode.rotation[3]); } if (gltfNode.scale != null && gltfNode.scale.Length == 3) { array4[j].transform.localScale = new Vector3(gltfNode.scale[0], gltfNode.scale[1], gltfNode.scale[2]); } if (gltfNode.mesh >= 0 && gltfNode.mesh < array2.Length) { array4[j].AddComponent<MeshFilter>().sharedMesh = array2[gltfNode.mesh]; ((Renderer)array4[j].AddComponent<MeshRenderer>()).sharedMaterials = array3[gltfNode.mesh]; } } bool[] array5 = new bool[array4.Length]; for (int k = 0; k < gltf.nodes.Length; k++) { if (gltf.nodes[k].children == null) { continue; } int[] children = gltf.nodes[k].children; foreach (int num4 in children) { if (num4 >= 0 && num4 < array4.Length) { array4[num4].transform.SetParent(array4[k].transform, false); array5[num4] = true; } } } if (gltf.scenes != null && gltf.scenes.Length != 0 && gltf.scenes[0].nodes != null) { int[] children = gltf.scenes[0].nodes; foreach (int num5 in children) { if (num5 >= 0 && num5 < array4.Length) { array4[num5].transform.SetParent(val.transform, false); } } } else { for (int m = 0; m < array4.Length; m++) { if (!array5[m]) { array4[m].transform.SetParent(val.transform, false); } } } MeshRenderer[] componentsInChildren = val.GetComponentsInChildren<MeshRenderer>(true); Bounds val2 = (Bounds)((componentsInChildren.Length != 0) ? ((Renderer)componentsInChildren[0]).bounds : default(Bounds)); for (int n = 1; n < componentsInChildren.Length; n++) { ((Bounds)(ref val2)).Encapsulate(((Renderer)componentsInChildren[n]).bounds); } Logger.LogInfo((object)("DFG Hammer: " + fileName + " loaded: " + componentsInChildren.Length + " renderer(s), raw size " + ((Bounds)(ref val2)).size.x.ToString("0.00") + " x " + ((Bounds)(ref val2)).size.y.ToString("0.00") + " x " + ((Bounds)(ref val2)).size.z.ToString("0.00") + " m.")); return val; } private static Shader FindShader() { Shader val = Shader.Find("Custom/Piece") ?? Shader.Find("Custom/Creature") ?? Shader.Find("Custom/StaticObject") ?? Shader.Find("Standard"); if ((Object)(object)val != (Object)null) { return val; } Shader[] array = Resources.FindObjectsOfTypeAll<Shader>(); foreach (Shader val2 in array) { if (((Object)val2).name == "Custom/Piece" || ((Object)val2).name == "Custom/Creature" || ((Object)val2).name == "Custom/StaticObject" || ((Object)val2).name == "Standard") { return val2; } } return Shader.Find("Diffuse") ?? Shader.Find("Unlit/Texture"); } private static Material[] BuildMaterials(Gltf gltf, byte[] bin, Shader shader) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_006e: 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) Texture2D[] array = (Texture2D[])(object)new Texture2D[(gltf.images != null) ? gltf.images.Length : 0]; Material[] array2 = (Material[])(object)new Material[(gltf.materials != null) ? gltf.materials.Length : 0]; for (int i = 0; i < array2.Length; i++) { GltfMaterial gltfMaterial = gltf.materials[i]; Material val = new Material(shader); ((Object)val).name = gltfMaterial.name ?? ("glb_material_" + i); val.color = Color.white; GltfPbr pbrMetallicRoughness = gltfMaterial.pbrMetallicRoughness; if (pbrMetallicRoughness != null) { if (pbrMetallicRoughness.baseColorFactor != null && pbrMetallicRoughness.baseColorFactor.Length == 4) { val.color = new Color(pbrMetallicRoughness.baseColorFactor[0], pbrMetallicRoughness.baseColorFactor[1], pbrMetallicRoughness.baseColorFactor[2], pbrMetallicRoughness.baseColorFactor[3]); } if (pbrMetallicRoughness.baseColorTexture != null && gltf.textures != null && pbrMetallicRoughness.baseColorTexture.index >= 0 && pbrMetallicRoughness.baseColorTexture.index < gltf.textures.Length) { int source = gltf.textures[pbrMetallicRoughness.baseColorTexture.index].source; if (source >= 0 && source < array.Length) { if ((Object)(object)array[source] == (Object)null) { array[source] = LoadTexture(gltf, bin, source); } if ((Object)(object)array[source] != (Object)null) { val.mainTexture = (Texture)(object)array[source]; if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", (Texture)(object)array[source]); } } } } } array2[i] = val; } return array2; } private static Texture2D LoadTexture(Gltf gltf, byte[] bin, int image) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown GltfImage gltfImage = gltf.images[image]; if (gltfImage.bufferView < 0 || gltfImage.bufferView >= gltf.bufferViews.Length) { return null; } GltfBufferView gltfBufferView = gltf.bufferViews[gltfImage.bufferView]; byte[] array = new byte[gltfBufferView.byteLength]; Array.Copy(bin, gltfBufferView.byteOffset, array, 0, gltfBufferView.byteLength); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, true); if (!ImageConversion.LoadImage(val, array)) { Object.Destroy((Object)(object)val); return null; } ((Texture)val).wrapMode = (TextureWrapMode)0; ((Texture)val).filterMode = (FilterMode)1; return val; } private static Material[] MaterialsForMesh(GltfMesh mesh, Material[] materials, Shader shader) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown Material[] array = (Material[])(object)new Material[mesh.primitives.Length]; for (int i = 0; i < mesh.primitives.Length; i++) { int material = mesh.primitives[i].material; array[i] = (Material)((material >= 0 && material < materials.Length) ? ((object)materials[material]) : ((object)new Material(shader) { color = Color.white })); } return array; } private static Mesh[] BuildMeshes(Gltf gltf, byte[] bin) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) Mesh[] array = (Mesh[])(object)new Mesh[(gltf.meshes != null) ? gltf.meshes.Length : 0]; for (int i = 0; i < array.Length; i++) { GltfMesh gltfMesh = gltf.meshes[i]; Mesh val = new Mesh(); ((Object)val).name = gltfMesh.name ?? ("glb_mesh_" + i); List<Vector3> list = new List<Vector3>(); List<Vector3> list2 = new List<Vector3>(); List<Vector2> list3 = new List<Vector2>(); List<int[]> list4 = new List<int[]>(); bool flag = true; GltfPrimitive[] primitives = gltfMesh.primitives; foreach (GltfPrimitive gltfPrimitive in primitives) { int count = list.Count; float[] array2 = ReadFloats(gltf, bin, gltfPrimitive.attributes.POSITION, 3); float[] array3 = ((gltfPrimitive.attributes.NORMAL >= 0) ? ReadFloats(gltf, bin, gltfPrimitive.attributes.NORMAL, 3) : null); float[] array4 = ((gltfPrimitive.attributes.TEXCOORD_0 >= 0) ? ReadFloats(gltf, bin, gltfPrimitive.attributes.TEXCOORD_0, 2) : null); int num = array2.Length / 3; for (int k = 0; k < num; k++) { list.Add(new Vector3(array2[k * 3], array2[k * 3 + 1], array2[k * 3 + 2])); if (array3 != null && array3.Length == array2.Length) { list2.Add(new Vector3(array3[k * 3], array3[k * 3 + 1], array3[k * 3 + 2])); } else { flag = false; } list3.Add((Vector2)((array4 != null && array4.Length == num * 2) ? new Vector2(array4[k * 2], 1f - array4[k * 2 + 1]) : Vector2.zero)); } int[] array5; if (gltfPrimitive.indices >= 0) { array5 = ReadIndices(gltf, bin, gltfPrimitive.indices); } else { array5 = new int[num]; for (int l = 0; l < num; l++) { array5[l] = l; } } for (int m = 0; m < array5.Length; m++) { array5[m] += count; } list4.Add(array5); } if (list.Count > 65535) { val.indexFormat = (IndexFormat)1; } val.SetVertices(list); val.SetUVs(0, list3); if (flag && list2.Count == list.Count) { val.SetNormals(list2); } val.subMeshCount = list4.Count; for (int n = 0; n < list4.Count; n++) { val.SetTriangles(list4[n], n); } if (!flag) { val.RecalculateNormals(); } val.RecalculateBounds(); array[i] = val; } return array; } private static float[] ReadFloats(Gltf gltf, byte[] bin, int accessorIndex, int components) { GltfAccessor gltfAccessor = gltf.accessors[accessorIndex]; GltfBufferView gltfBufferView = gltf.bufferViews[gltfAccessor.bufferView]; int num = ((gltfBufferView.byteStride > 0) ? gltfBufferView.byteStride : (components * 4)); int num2 = gltfBufferView.byteOffset + gltfAccessor.byteOffset; float[] array = new float[gltfAccessor.count * components]; for (int i = 0; i < gltfAccessor.count; i++) { for (int j = 0; j < components; j++) { array[i * components + j] = BitConverter.ToSingle(bin, num2 + i * num + j * 4); } } return array; } private static int[] ReadIndices(Gltf gltf, byte[] bin, int accessorIndex) { GltfAccessor gltfAccessor = gltf.accessors[accessorIndex]; GltfBufferView gltfBufferView = gltf.bufferViews[gltfAccessor.bufferView]; int num = ((gltfAccessor.componentType == 5121) ? 1 : ((gltfAccessor.componentType == 5123) ? 2 : 4)); int num2 = ((gltfBufferView.byteStride > 0) ? gltfBufferView.byteStride : num); int num3 = gltfBufferView.byteOffset + gltfAccessor.byteOffset; int[] array = new int[gltfAccessor.count]; for (int i = 0; i < gltfAccessor.count; i++) { int num4 = num3 + i * num2; array[i] = num switch { 2 => BitConverter.ToUInt16(bin, num4), 1 => bin[num4], _ => BitConverter.ToInt32(bin, num4), }; } return array; } } internal static class HubWeb { private static HttpListener s_listener; private static Thread s_thread; private static volatile bool s_running; public static void Start() { if (s_running) { return; } try { s_listener = new HttpListener(); s_listener.Prefixes.Add("http://127.0.0.1:" + DFGHubPlugin.WebPort.Value + "/"); s_listener.Start(); s_running = true; s_thread = new Thread(Loop) { IsBackground = true }; s_thread.Start(); Logger.LogInfo((object)("DFGHub: hub at http://127.0.0.1:" + DFGHubPlugin.WebPort.Value + "/")); } catch (Exception ex) { s_running = false; Logger.LogWarning((object)("DFGHub: could not start web hub: " + ex.Message)); } } public static void Stop() { s_running = false; try { if (s_listener != null) { s_listener.Stop(); s_listener.Close(); } } catch { } s_listener = null; } private static void Loop() { while (s_running && s_listener != null && s_listener.IsListening) { try { Handle(s_listener.GetContext()); } catch { } } } private static void Handle(HttpListenerContext context) { try { switch (context.Request.Url.AbsolutePath) { case "/": case "/index.html": Write(context, "text/html; charset=utf-8", BuildPage()); break; case "/hammer": Write(context, "text/html; charset=utf-8", DFGHammer.PosePage()); break; case "/hammer/state": Write(context, "application/json; charset=utf-8", DFGHammer.PoseJson()); break; case "/hammer/apply": DFGHammer.QueueQuery(context.Request.Url.Query); Write(context, "application/json; charset=utf-8", DFGHammer.PoseJson()); break; case "/status": Write(context, "application/json; charset=utf-8", BuildStatus()); break; default: context.Response.StatusCode = 404; context.Response.Close(); break; } } catch { try { context.Response.StatusCode = 500; context.Response.Close(); } catch { } } } private static bool IsUp(int port) { try { HttpWebRequest obj = (HttpWebRequest)WebRequest.Create("http://127.0.0.1:" + port + "/"); obj.Timeout = 250; obj.ReadWriteTimeout = 250; obj.Method = "GET"; using ((HttpWebResponse)obj.GetResponse()) { return true; } } catch { return false; } } private static string BuildStatus() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{\"port\":").Append(DFGHubPlugin.WebPort.Value); stringBuilder.Append(",\"category\":\"").Append(Escape(DFGHubPlugin.ActiveCategory)).Append("\""); stringBuilder.Append(",\"pieces\":").Append(DFGHubPlugin.RoutedPieceCount); stringBuilder.Append(",\"mods\":["); for (int i = 0; i < WebNav.Links.Length; i++) { if (i > 0) { stringBuilder.Append(","); } WebNav.Link link = WebNav.Links[i]; stringBuilder.Append("{\"id\":\"").Append(Escape(link.Id)).Append("\""); stringBuilder.Append(",\"name\":\"").Append(Escape(link.Label)).Append("\""); stringBuilder.Append(",\"port\":").Append(link.Port); stringBuilder.Append(",\"up\":").Append(IsUp(link.Port) ? "true" : "false"); stringBuilder.Append("}"); } stringBuilder.Append("]}"); return stringBuilder.ToString(); } private static string Escape(string value) { return (value ?? "").Replace("\\", "\\\\").Replace("\"", "\\\""); } private static void Write(HttpListenerContext context, string contentType, string body) { byte[] bytes = Encoding.UTF8.GetBytes(body ?? ""); context.Response.ContentType = contentType; context.Response.ContentEncoding = Encoding.UTF8; context.Response.ContentLength64 = bytes.Length; context.Response.OutputStream.Write(bytes, 0, bytes.Length); context.Response.OutputStream.Close(); } private static string BuildPage() { return "<!DOCTYPE html>\r\n<html>\r\n<head>\r\n<meta charset='utf-8'>\r\n<title>DFG Hub</title>\r\n<style>\r\n*{box-sizing:border-box;font-family:Segoe UI,Arial,sans-serif}\r\nbody{margin:0;background:#10151c;color:#dce3ec;font-size:14px}\r\n#wrap{max-width:900px;margin:0 auto;padding:8px 16px 30px}\r\nh1{margin:10px 0;font-size:20px;color:#9fd7ff}\r\nh1 small{color:#6b7f8c;font-weight:400}\r\n.sub{color:#7f8fa0;font-size:13px;margin-bottom:16px}\r\nnav.top{position:sticky;top:0;z-index:20;width:100%;box-sizing:border-box;flex:0 0 auto;font-family:'Segoe UI',Arial,sans-serif;background:#0d1219;border-bottom:1px solid #2b3b4c;padding:6px 14px;display:flex;align-items:center;gap:6px;flex-wrap:wrap}\nnav.top .brand{color:#ffd760;font-size:12px;text-transform:uppercase;letter-spacing:.8px;margin-right:10px;display:inline-flex;align-items:center;font-weight:600;text-shadow:0 1px 2px rgba(0,0,0,0.5)}\nnav.top a{color:#9fc3dd;text-decoration:none;font-size:13px;padding:4px 9px;border-radius:5px;transition:background .15s}\nnav.top a:hover{background:#1a2530}\nnav.top a.here{background:#3a2b4c;border:1px solid #55406b;color:#efe0ff}\n\r\n.grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:12px}\r\n.card{background:#151e28;border:1px solid #28363f;border-radius:8px;padding:14px;display:flex;flex-direction:column;gap:10px}\r\n.card .name{font-size:15px;font-weight:600;color:#e6f4ff}\r\n.card .meta{color:#7f8fa0;font-size:12px}\r\n.card a{display:inline-block;background:#2e6b96;border:1px solid #3f86b8;color:#e6f4ff;text-decoration:none;border-radius:5px;padding:7px 10px;text-align:center;font-size:13px}\r\n.card a:hover{background:#3a82b8}\r\n.dot{display:inline-block;width:9px;height:9px;border-radius:50%;margin-right:6px;vertical-align:1px}\r\n.dot.up{background:#59d07e}\r\n.dot.down{background:#c05a5a}\r\n.info{background:#151e28;border:1px solid #28363f;border-radius:8px;padding:12px;margin-top:16px;color:#9fb3c4;font-size:13px;line-height:1.6}\r\n</style>\r\n</head>\r\n<body>\r\n" + WebNav.Html("hub") + "\r\n<div id='wrap'>\r\n<h1>DFG Hub <small id='ver'></small></h1>\r\n<div class='sub' id='summary'>Loading…</div>\r\n<div class='card' style='margin-bottom:12px'>\r\n<div class='name'>DFG Hammer placement</div>\r\n<div class='meta'>The hammer sits in the hand. Drag it there while it is equipped.</div>\r\n<a href='/hammer'>Adjust the hammer</a>\r\n</div>\r\n<div class='grid' id='grid'></div>\r\n<div class='info'>\r\nAll build pieces from this mod collection are routed into the in-game Hammer category <b id='cat'>DFG</b> and unlocked by default (no crafting station required). If a link below shows offline, that mod is not loaded or its web GUI is disabled.\r\n</div>\r\n</div>\r\n<script>\r\nvar $=function(s){return document.querySelector(s)};\r\nfunction mk(tag,cls,text){var e=document.createElement(tag);if(cls)e.className=cls;if(text!==undefined)e.textContent=text;return e}\r\nfunction render(s){\r\n $('#ver').textContent='v1.0.0';\r\n $('#cat').textContent=s.category||'DFG';\r\n $('#summary').textContent='Hammer category: '+s.category+' - '+s.pieces+' pieces routed.';\r\n var g=$('#grid');g.innerHTML='';\r\n (s.mods||[]).forEach(function(m){\r\n var c=mk('div','card');\r\n c.appendChild(mk('div','name',m.name));\r\n var meta=mk('div','meta');meta.textContent='127.0.0.1:'+m.port;\r\n c.appendChild(meta);\r\n var a=mk('a',null,'Open');a.href='http://127.0.0.1:'+m.port+'/';a.target='_blank';\r\n c.appendChild(a);\r\n var st=mk('div','meta');\r\n var d=mk('span','dot '+(m.up?'up':'down'));\r\n st.appendChild(d);\r\n st.appendChild(document.createTextNode(m.up?'online':'offline'));\r\n c.appendChild(st);\r\n g.appendChild(c);\r\n });\r\n}\r\nfunction poll(){\r\n fetch('/status').then(function(r){return r.json()}).then(render).catch(function(){});\r\n}\r\npoll();\r\nsetInterval(poll,2500);\r\n</scrip