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 BlueCollarTrolls v0.3.29
BlueCollarTrolls.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; 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.Configuration; using HarmonyLib; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using MyMods; using MyMods.Web; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Pebble; using UnityEngine; using UnityEngine.Networking; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("BlueCollarTrolls")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.3.29.0")] [assembly: AssemblyInformationalVersion("0.3.29+0bd1a83dbfd4c46c0de3fdcfa7893c366ec1a377")] [assembly: AssemblyProduct("BlueCollarTrolls")] [assembly: AssemblyTitle("BlueCollarTrolls")] [assembly: AssemblyVersion("0.3.29.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 Pebble { public class ClipLibrary { private readonly Dictionary<string, AudioClip> m_clips = new Dictionary<string, AudioClip>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary<string, string> m_errors = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); private readonly List<UnityWebRequest> m_mp3Requests = new List<UnityWebRequest>(); public bool Loading { get; private set; } public int Loaded { get; private set; } public int Failed { get; private set; } public string CurrentFile { get; private set; } public string LastError { get; private set; } public int Pending { get; private set; } public AudioClip Get(string fileName) { if (string.IsNullOrEmpty(fileName)) { return null; } if (!m_clips.TryGetValue(fileName, out var value)) { return null; } return value; } public AudioClip AddWav(string fileName, string path) { if (string.IsNullOrEmpty(fileName) || string.IsNullOrEmpty(path)) { return null; } if (m_clips.TryGetValue(fileName, out var value) && (Object)(object)value != (Object)null) { return value; } AudioClip val; try { val = LoadWav(fileName, path); } catch (Exception ex) { LastError = fileName + ": " + ex.Message; return null; } if ((Object)(object)val == (Object)null) { return null; } Object.DontDestroyOnLoad((Object)(object)val); m_clips[fileName] = val; Loaded++; return val; } public bool HasClip(string fileName) { if (!string.IsNullOrEmpty(fileName)) { return m_clips.ContainsKey(fileName); } return false; } public string ErrorFor(string fileName) { if (!m_errors.TryGetValue(fileName ?? "", out var value)) { return null; } return value; } public void Reset() { foreach (AudioClip value in m_clips.Values) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)value); } } m_clips.Clear(); m_errors.Clear(); Loaded = 0; Failed = 0; Pending = 0; CurrentFile = null; LastError = null; } public IEnumerator LoadAll(IEnumerable<string> fileNames, string tracksDir, Action onComplete) { Reset(); Loading = true; List<string> queue = new List<string>(); foreach (string fileName in fileNames) { if (!string.IsNullOrWhiteSpace(fileName)) { queue.Add(fileName.Trim()); } } Pending = queue.Count; try { for (int i = 0; i < queue.Count; i++) { string name = (CurrentFile = queue[i]); if (m_clips.ContainsKey(name)) { Loaded++; continue; } AudioClip val = null; string error = null; string path = Path.Combine(tracksDir, name); if (!File.Exists(path)) { error = "File not found in tracks folder"; } else { string text2 = Path.GetExtension(name).ToLowerInvariant(); if (text2 == ".wav") { try { val = LoadWav(name, path); if ((Object)(object)val == (Object)null) { error = "Unsupported WAV format"; } } catch (Exception ex) { error = ex.Message; } } else if (text2 == ".mp3") { AudioClip decoded = null; yield return LoadMp3(name, path, delegate(AudioClip result) { decoded = result; }); val = decoded; if ((Object)(object)val == (Object)null) { error = "MP3 decode failed"; } } else { error = "Unsupported audio type " + text2; } } if ((Object)(object)val != (Object)null) { Object.DontDestroyOnLoad((Object)(object)val); m_clips[name] = val; Loaded++; } else { m_errors[name] = error ?? "unknown error"; LastError = name + ": " + m_errors[name]; Failed++; Logger.LogWarning((object)("[Pebble] Failed to load track '" + name + "': " + m_errors[name])); } } } finally { ClipLibrary clipLibrary = this; clipLibrary.Loading = false; clipLibrary.CurrentFile = null; clipLibrary.Pending = 0; } onComplete?.Invoke(); } private static AudioClip LoadWav(string name, string path) { byte[] array = File.ReadAllBytes(path); if (array.Length < 44 || !Tag(array, 0, "RIFF") || !Tag(array, 8, "WAVE")) { return null; } int num = 0; int num2 = 0; int num3 = 0; int num4 = 0; byte[] array2 = null; int num5 = 12; while (num5 + 8 <= array.Length) { string text = Encoding.ASCII.GetString(array, num5, 4); int num6 = BitConverter.ToInt32(array, num5 + 4); int num7 = num5 + 8; if (num6 < 0 || num7 > array.Length) { break; } if (num7 + num6 > array.Length) { num6 = array.Length - num7; } if (text == "fmt " && num7 + 16 <= array.Length) { num = BitConverter.ToUInt16(array, num7); num2 = BitConverter.ToUInt16(array, num7 + 2); num3 = BitConverter.ToInt32(array, num7 + 4); num4 = BitConverter.ToUInt16(array, num7 + 14); if (num == 65534 && num7 + 26 <= array.Length) { num = BitConverter.ToUInt16(array, num7 + 24); } } else if (text == "data") { array2 = new byte[num6]; Array.Copy(array, num7, array2, 0, num6); } num5 = num7 + num6 + (num6 & 1); } if (array2 == null || num2 < 1 || num2 > 8 || num3 < 1) { return null; } int num8 = num4 / 8; if (num8 < 1) { return null; } int num9 = num8 * num2; int num10 = array2.Length / num9; if (num10 < 1) { return null; } float[] array3 = new float[num10 * num2]; for (int i = 0; i < array3.Length; i++) { int num11 = i * num8; if (num11 + num8 > array2.Length) { break; } array3[i] = DecodeSample(array2, num11, num, num4); } AudioClip obj = AudioClip.Create(name, num10, num2, num3, false); obj.SetData(array3, 0); return obj; } private static float DecodeSample(byte[] data, int offset, int format, int bits) { if (format == 3) { return BitConverter.ToSingle(data, offset); } switch (bits) { case 8: return (float)(data[offset] - 128) / 128f; case 16: return (float)BitConverter.ToInt16(data, offset) / 32768f; case 24: { int num = data[offset] | (data[offset + 1] << 8) | (data[offset + 2] << 16); if ((num & 0x800000) != 0) { num |= -16777216; } return (float)num / 8388608f; } case 32: return (float)BitConverter.ToInt32(data, offset) / 2.1474836E+09f; default: throw new NotSupportedException(bits + "-bit WAV"); } } private static bool Tag(byte[] bytes, int offset, string tag) { if (offset + 4 > bytes.Length) { return false; } if (bytes[offset] == tag[0] && bytes[offset + 1] == tag[1] && bytes[offset + 2] == tag[2]) { return bytes[offset + 3] == tag[3]; } return false; } private IEnumerator LoadMp3(string name, string path, Action<AudioClip> done) { string text = "file:///" + path.Replace('\\', '/').TrimStart('/'); UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(text, (AudioType)13); yield return request.SendWebRequest(); if ((int)request.result != 1) { Logger.LogWarning((object)("[Pebble] MP3 '" + name + "' failed: " + request.error)); request.Dispose(); yield break; } AudioClip content = DownloadHandlerAudioClip.GetContent(request); if ((Object)(object)content == (Object)null) { request.Dispose(); yield break; } ((Object)content).name = name; m_mp3Requests.Add(request); done(content); } public void DisposeRequests() { foreach (UnityWebRequest mp3Request in m_mp3Requests) { if (mp3Request != null) { mp3Request.Dispose(); } } m_mp3Requests.Clear(); } } } namespace MyMods { public static class HallClient { private struct Pending { public string Id; public string Title; public int Order; public Action<Rect> Draw; } private static readonly List<Pending> s_pending = new List<Pending>(); private static Type s_type; private static bool s_miss; private static MethodInfo s_register; private static MethodInfo s_open; private static MethodInfo s_close; private static MethodInfo s_hosting; private static MethodInfo s_yield; private static MethodInfo s_hold; private static PropertyInfo s_ready; private static PropertyInfo s_openProp; private static Type HallType { get { if (s_type != null || s_miss) { return s_type; } s_type = Type.GetType("DFGHub.HallBoard, DFGHub"); s_miss = s_type == null; return s_type; } } public static bool Ready { get { if (s_ready == null && HallType != null) { s_ready = HallType.GetProperty("Ready", BindingFlags.Static | BindingFlags.Public); } if (s_ready == null) { return false; } object value = s_ready.GetValue(null, null); bool flag = default(bool); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } } public static bool IsOpen { get { if (s_openProp == null && HallType != null) { s_openProp = HallType.GetProperty("IsOpen", BindingFlags.Static | BindingFlags.Public); } if (s_openProp == null) { return false; } object value = s_openProp.GetValue(null, null); bool flag = default(bool); int num; if (value is bool) { flag = (bool)value; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } } public static void Bind(string id, string title, int order, Action<Rect> draw) { if (string.IsNullOrEmpty(id) || draw == null) { return; } for (int num = s_pending.Count - 1; num >= 0; num--) { if (string.Equals(s_pending[num].Id, id, StringComparison.OrdinalIgnoreCase)) { s_pending.RemoveAt(num); } } s_pending.Add(new Pending { Id = id, Title = title, Order = order, Draw = draw }); Flush(); } public static void Flush() { if (s_pending.Count != 0 && Ready) { for (int i = 0; i < s_pending.Count; i++) { Pending pending = s_pending[i]; TryRegister(pending.Id, pending.Title, pending.Order, pending.Draw); } s_pending.Clear(); } } public static bool TryOpen(string tabId) { if (!Ready) { return false; } if (s_open == null) { s_open = HallType.GetMethod("Open", BindingFlags.Static | BindingFlags.Public); } if (s_open == null) { return false; } try { object obj = s_open.Invoke(null, new object[1] { tabId }); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch (Exception) { return false; } } public static void Close() { if (HallType == null) { return; } if (s_close == null) { s_close = HallType.GetMethod("Close", BindingFlags.Static | BindingFlags.Public); } try { s_close?.Invoke(null, null); } catch (Exception) { } } public static bool IsHosting(string id) { if (HallType == null || string.IsNullOrEmpty(id)) { return false; } if (s_hosting == null) { s_hosting = HallType.GetMethod("IsHosting", BindingFlags.Static | BindingFlags.Public); } if (s_hosting == null) { return false; } try { object obj = s_hosting.Invoke(null, new object[1] { id }); bool flag = default(bool); int num; if (obj is bool) { flag = (bool)obj; num = 1; } else { num = 0; } return (byte)((uint)num & (flag ? 1u : 0u)) != 0; } catch (Exception) { return false; } } public static void SetYield(bool yieldScreen) { if (HallType == null) { return; } if (s_yield == null) { s_yield = HallType.GetMethod("SetYield", BindingFlags.Static | BindingFlags.Public); } try { s_yield?.Invoke(null, new object[1] { yieldScreen }); } catch (Exception) { } } public static void HoldEscape() { if (HallType == null) { return; } if (s_hold == null) { s_hold = HallType.GetMethod("HoldEscape", BindingFlags.Static | BindingFlags.Public); } try { s_hold?.Invoke(null, null); } catch (Exception) { } } private static void TryRegister(string id, string title, int order, Action<Rect> draw) { if (s_register == null) { s_register = HallType.GetMethod("Register", BindingFlags.Static | BindingFlags.Public); } s_register?.Invoke(null, new object[4] { id, title, order, draw }); } } } 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[14] { 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) }; public const string Style = "nav.top{position:sticky;top:0;z-index:20;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:#7f8fa0;font-size:11px;text-transform:uppercase;letter-spacing:.6px;margin-right:8px}\nnav.top a{color:#9fc3dd;text-decoration:none;font-size:13px;padding:4px 9px;border-radius:5px}\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'>MyMods</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 BlueCollarTrolls { public static class BeeTrollModel { private static UnionRepModel.Clip s_walk; private static UnionRepModel.Clip s_collect; private static bool s_failed; private static Material s_material; private static float s_fitHeight; public static bool TryAttach(GameObject troll) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)troll == (Object)null) { return false; } if ((Object)(object)troll.GetComponentInChildren<BeeTrollPlayer>(true) != (Object)null) { return true; } UnionRepModel.Clip clip; UnionRepModel.Clip clip2; try { float height = MeasureLocalHeight(troll); clip = GetClip(ref s_walk, "walk", height); clip2 = GetClip(ref s_collect, "collect", height); if (clip2 != null && clip != null) { clip2.CopyFitFrom(clip); } } catch (Exception ex) { if (!s_failed) { s_failed = true; Logger.LogWarning((object)("[Blue Collar Trolls] bee troll model failed to load: " + ex.Message)); } return false; } if (clip == null) { return false; } GameObject val = new GameObject("BeeTrollModel"); val.transform.SetParent(troll.transform, false); val.transform.localPosition = Vector3.zero; val.transform.localRotation = Quaternion.identity; val.transform.localScale = Vector3.one; val.layer = troll.layer; Mesh val2 = new Mesh(); ((Object)val2).name = "beetroll"; val2.MarkDynamic(); val2.indexFormat = (IndexFormat)(clip.VertCount > 65535); Vector3[] array = (Vector3[])(object)new Vector3[clip.VertCount]; Vector3[] array2 = (Vector3[])(object)new Vector3[clip.VertCount]; clip.Skin(0f, array, array2, applyFit: true); val2.vertices = array; val2.normals = array2; val2.uv = clip.Uvs; val2.triangles = FrontFaces(clip.Triangles); Color[] array3 = (Color[])(object)new Color[clip.VertCount]; for (int i = 0; i < array3.Length; i++) { array3[i] = Color.white; } val2.colors = array3; val2.RecalculateTangents(); float num = Mathf.Max(1f, s_fitHeight); val2.bounds = new Bounds(new Vector3(0f, num * 0.5f, 0f), new Vector3(num, num + 0.4f, num)); val.AddComponent<MeshFilter>().sharedMesh = val2; MeshRenderer val3 = val.AddComponent<MeshRenderer>(); ((Renderer)val3).sharedMaterial = GetMaterial(clip); ((Renderer)val3).shadowCastingMode = (ShadowCastingMode)1; val.AddComponent<BeeTrollPlayer>().Init(clip, (clip2 != null) ? clip2 : clip, val2, array, array2); UnionRepHider unionRepHider = troll.GetComponent<UnionRepHider>(); if ((Object)(object)unionRepHider == (Object)null) { unionRepHider = troll.AddComponent<UnionRepHider>(); } unionRepHider.Keep = (Renderer)(object)val3; unionRepHider.HideVanilla(); Logger.LogInfo((object)$"[Blue Collar Trolls] apiary troll is using beetroll.glb (fitted to {s_fitHeight:0.00}m)."); return true; } private static Material GetMaterial(UnionRepModel.Clip clip) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_material != (Object)null) { return s_material; } Shader val = FarmPlotModel.FindPlotShader(); if ((Object)(object)val == (Object)null || ((Object)val).name == "Hidden/InternalErrorShader") { val = Shader.Find("Custom/Creature") ?? Shader.Find("Standard"); } s_material = new Material(val); ((Object)s_material).name = "beetroll_Mat"; s_material.color = Color.white; if (s_material.HasProperty("_Color")) { s_material.SetColor("_Color", Color.white); } if ((Object)(object)clip.Diffuse != (Object)null) { s_material.mainTexture = (Texture)(object)clip.Diffuse; } if ((Object)(object)clip.Normal != (Object)null && s_material.HasProperty("_BumpMap")) { s_material.SetTexture("_BumpMap", (Texture)(object)clip.Normal); s_material.EnableKeyword("_NORMALMAP"); } if (s_material.HasProperty("_Cull")) { s_material.SetInt("_Cull", 0); } s_material.doubleSidedGI = true; if (s_material.HasProperty("_Mode")) { s_material.SetFloat("_Mode", 0f); } if (s_material.HasProperty("_Cutoff")) { s_material.SetFloat("_Cutoff", 0f); } s_material.DisableKeyword("_ALPHATEST_ON"); s_material.DisableKeyword("_ALPHABLEND_ON"); s_material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); s_material.renderQueue = 2000; return s_material; } private static int[] FrontFaces(int[] triangles) { int[] array = (int[])triangles.Clone(); for (int i = 0; i < array.Length; i += 3) { int num = array[i + 1]; array[i + 1] = array[i + 2]; array[i + 2] = num; } return array; } private static UnionRepModel.Clip GetClip(ref UnionRepModel.Clip slot, string which, float height) { if (slot != null) { return slot; } if (s_failed) { return null; } string text = FindGlb(); if (string.IsNullOrEmpty(text)) { return null; } byte[] file = File.ReadAllBytes(text); int num = ((which == "walk") ? FindAnim(file, "walk") : FindAnim(file, "collect")); if (num < 0) { num = ((!(which == "walk")) ? 1 : 0); } s_fitHeight = height; Logger.LogInfo((object)("[Blue Collar Trolls] loading beekeeper " + which + " from " + text)); slot = UnionRepModel.Clip.Load(file, num, height, lockHipsXZ: true); return slot; } private static int FindAnim(byte[] file, string namePart) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) int num = 12; while (num + 8 <= file.Length) { int num2 = BitConverter.ToInt32(file, num); int num3 = BitConverter.ToInt32(file, num + 4); num += 8; if (num3 == 1313821514) { JArray val = (JArray)JObject.Parse(Encoding.UTF8.GetString(file, num, num2))["animations"]; if (val == null) { return -1; } int result = -1; for (int i = 0; i < ((JContainer)val).Count; i++) { string text = ((((JObject)val[i])["name"] != null) ? Extensions.Value<string>((IEnumerable<JToken>)((JObject)val[i])["name"]) : ""); if (text.IndexOf(namePart, StringComparison.OrdinalIgnoreCase) >= 0) { return i; } if (namePart == "collect" && (text.IndexOf("harvest", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("work", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("attack", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("plant", StringComparison.OrdinalIgnoreCase) >= 0)) { result = i; } } return result; } num += num2; } return -1; } private static string FindGlb() { string[] array = new string[4] { "beetroll.glb", "BeeTroll.glb", "bee_troll.glb", "troll_beekeeper.glb" }; string[] searchDirectories = FarmPlotModel.GetSearchDirectories(); foreach (string text in searchDirectories) { if (string.IsNullOrEmpty(text) || !Directory.Exists(text)) { continue; } for (int j = 0; j < array.Length; j++) { string text2 = Path.Combine(text, array[j]); if (File.Exists(text2)) { return text2; } } } return null; } private static float MeasureLocalHeight(GameObject troll) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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) float num = Mathf.Abs(troll.transform.lossyScale.y); if (num < 0.001f) { num = 1f; } float num2 = 0f; Renderer[] componentsInChildren = troll.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!((Object)(object)val == (Object)null)) { Bounds bounds = val.bounds; float num3 = ((Bounds)(ref bounds)).size.y / num; if (num3 > num2 && num3 < 40f) { num2 = num3; } } } if (!(num2 > 0.5f)) { return 6f; } return num2; } } public class BeeTrollPlayer : MonoBehaviour { private UnionRepModel.Clip m_walk; private UnionRepModel.Clip m_collect; private Mesh m_mesh; private Vector3[] m_verts; private Vector3[] m_norms; private float m_time; private bool m_wasCollecting; private Vector3 m_lastPos; private bool m_haveLast; public bool Collecting; internal void Init(UnionRepModel.Clip walk, UnionRepModel.Clip collect, Mesh mesh, Vector3[] verts, Vector3[] norms) { m_walk = walk; m_collect = collect; m_mesh = mesh; m_verts = verts; m_norms = norms; } private void Update() { //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_0052: 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_002d: 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) if (m_walk != null && !((Object)(object)m_mesh == (Object)null)) { bool flag = false; Vector3 position = ((Component)this).transform.position; if (m_haveLast) { flag = Vector3.Distance(position, m_lastPos) / Mathf.Max(0.0001f, Time.deltaTime) > 0.35f; } m_lastPos = position; m_haveLast = true; UnionRepModel.Clip clip = (Collecting ? m_collect : m_walk); if (Collecting != m_wasCollecting) { m_time = 0f; m_wasCollecting = Collecting; } if (!Collecting && !flag) { clip.Skin(0f, m_verts, m_norms, applyFit: true); } else { m_time += Time.deltaTime; clip.Skin(m_time, m_verts, m_norms, applyFit: true); } m_mesh.vertices = m_verts; m_mesh.normals = m_norms; m_mesh.RecalculateTangents(); } } } public static class BlueCollarHud { private static bool s_isDragging; private static Vector2 s_dragOffset; private static Texture2D s_whiteTex; private static readonly List<Trolward> s_renderWards = new List<Trolward>(); private static readonly Color ColHeaderBg = new Color(0.12f, 0.16f, 0.22f, 1f); private static readonly Color ColBorder = new Color(0.74f, 0.58f, 0.28f, 1f); private static readonly Color ColCardBg = new Color(0.08f, 0.1f, 0.14f, 0.96f); private static readonly Color ColCardBorder = new Color(0.2f, 0.26f, 0.36f, 0.85f); private static readonly Color ColProgressBarBg = new Color(0.04f, 0.06f, 0.08f, 0.9f); private static readonly Color ColProgressFill = new Color(0.24f, 0.7f, 0.44f, 0.9f); private static readonly Color ColProgressLow = new Color(0.88f, 0.32f, 0.28f, 0.9f); 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 ColDim = new Color(0.65f, 0.72f, 0.82f, 1f); private static readonly Color ColGreen = new Color(0.4f, 0.92f, 0.5f, 1f); private static readonly Color ColRed = new Color(0.98f, 0.4f, 0.4f, 1f); private static readonly Color ColYellow = new Color(1f, 0.82f, 0.32f, 1f); private static readonly Color ColCyan = new Color(0.4f, 0.82f, 1f, 1f); private static GUIStyle s_headerTitleStyle; private static GUIStyle s_cardTitleStyle; private static GUIStyle s_badgeStyle; private static GUIStyle s_textStyle; private static GUIStyle s_dimStyle; private static GUIStyle s_buttonStyle; private static GUIStyle s_nameStyle; private static Texture2D WhiteTex { get { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)s_whiteTex == (Object)null) { s_whiteTex = new Texture2D(1, 1); s_whiteTex.SetPixel(0, 0, Color.white); s_whiteTex.Apply(); } return s_whiteTex; } } private static void InitStyles() { //IL_0012: 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_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: 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_0042: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_007c: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0093: 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_00a6: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00e3: 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_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown if (s_headerTitleStyle == null) { GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 13, fontStyle = (FontStyle)1 }; val.normal.textColor = ColGold; val.alignment = (TextAnchor)3; s_headerTitleStyle = val; GUIStyle val2 = new GUIStyle(GUI.skin.label) { fontSize = 12, fontStyle = (FontStyle)1 }; val2.normal.textColor = ColWhite; val2.alignment = (TextAnchor)3; s_cardTitleStyle = val2; s_badgeStyle = new GUIStyle(GUI.skin.label) { fontSize = 11, fontStyle = (FontStyle)1, alignment = (TextAnchor)5 }; GUIStyle val3 = new GUIStyle(GUI.skin.label) { fontSize = 11 }; val3.normal.textColor = ColWhite; val3.alignment = (TextAnchor)3; s_textStyle = val3; GUIStyle val4 = new GUIStyle(GUI.skin.label) { fontSize = 10 }; val4.normal.textColor = ColDim; val4.alignment = (TextAnchor)3; s_dimStyle = val4; GUIStyle val5 = new GUIStyle(GUI.skin.button) { fontSize = 10, fontStyle = (FontStyle)1 }; val5.normal.textColor = ColGold; s_buttonStyle = val5; } } public static void Render() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_0309: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Invalid comparison between Unknown and I4 //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Invalid comparison between Unknown and I4 //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Invalid comparison between Unknown and I4 //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) if (!BlueCollarTrollsPlugin.Enabled.Value || !BlueCollarTrollsPlugin.HudVisible.Value) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead()) { return; } InitStyles(); Vector3 position = ((Component)localPlayer).transform.position; s_renderWards.Clear(); bool value = BlueCollarTrollsPlugin.HudShowAllGlobal.Value; float num = HudRangeSq(); for (int i = 0; i < Trolward.Instances.Count; i++) { Trolward trolward = Trolward.Instances[i]; if ((Object)(object)trolward == (Object)null) { continue; } if (!value) { Vector3 val = ((Component)trolward).transform.position - position; if (((Vector3)(ref val)).sqrMagnitude > num) { continue; } } if (BlueCollarTrollsPlugin.HudShowIdle.Value || trolward.HudStatus != 0) { s_renderWards.Add(trolward); } } if (s_renderWards.Count == 0) { return; } float num2 = Mathf.Clamp(BlueCollarTrollsPlugin.HudScale.Value, 0.6f, 1.8f); bool value2 = BlueCollarTrollsPlugin.HudDetailedContracts.Value; float num3 = (value2 ? 420f : 320f); float num4 = (value2 ? 108f : 62f); float num5 = num3 * num2; float num6 = (32f + (float)s_renderWards.Count * (num4 + 6f) + 8f) * num2; float num7 = Mathf.Clamp(BlueCollarTrollsPlugin.HudScreenX.Value, 0f, 1f); float num8 = Mathf.Clamp(BlueCollarTrollsPlugin.HudScreenY.Value, 0f, 1f); float num9 = num7 * ((float)Screen.width - num5); float num10 = num8 * ((float)Screen.height - num6); Rect rect = new Rect(num9, num10, num5, num6); Event current = Event.current; Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(num9, num10, num5, 28f * num2); if (current != null && (UnionGui.IsOpen || Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307) || (int)current.type == 3)) { if ((int)current.type == 0 && ((Rect)(ref val2)).Contains(current.mousePosition)) { s_isDragging = true; s_dragOffset = current.mousePosition - new Vector2(num9, num10); current.Use(); } else if ((int)current.type == 1) { s_isDragging = false; } else if ((int)current.type == 3 && s_isDragging) { Vector2 val3 = current.mousePosition - s_dragOffset; float value3 = Mathf.Clamp01(val3.x / Mathf.Max(1f, (float)Screen.width - num5)); float value4 = Mathf.Clamp01(val3.y / Mathf.Max(1f, (float)Screen.height - num6)); BlueCollarTrollsPlugin.HudScreenX.Value = value3; BlueCollarTrollsPlugin.HudScreenY.Value = value4; current.Use(); } } float num11 = Mathf.Clamp(BlueCollarTrollsPlugin.HudBgOpacity.Value, 0.1f, 1f); Color col = default(Color); ((Color)(ref col))..ctor(0.06f, 0.08f, 0.11f, num11); DrawSolidRect(rect, col); DrawBorderRect(rect, ColBorder, 1.5f); DrawSolidRect(new Rect(num9, num10, num5, 28f * num2), ColHeaderBg); string text = (value ? "⚔\ufe0f TROLL LABOR CONTRACTS (ALL)" : "⚔\ufe0f TROLL LABOR CONTRACTS"); GUI.Label(new Rect(num9 + 8f * num2, num10 + 2f * num2, num5 - 140f * num2, 24f * num2), text, s_headerTitleStyle); float num12 = 54f * num2; float num13 = 20f * num2; float num14 = num10 + 4f * num2; if (GUI.Button(new Rect(num9 + num5 - (num12 * 2f + 8f * num2), num14, num12, num13), value2 ? "Compact" : "Details", s_buttonStyle)) { BlueCollarTrollsPlugin.HudDetailedContracts.Value = !value2; } if (GUI.Button(new Rect(num9 + num5 - (num12 + 4f * num2), num14, num12, num13), value ? "Nearby" : "Global", s_buttonStyle)) { BlueCollarTrollsPlugin.HudShowAllGlobal.Value = !value; } float num15 = num10 + 34f * num2; for (int j = 0; j < s_renderWards.Count; j++) { Trolward ward = s_renderWards[j]; DrawContractCard(num9 + 6f * num2, num15, num5 - 12f * num2, num4 * num2, ward, position, num2, value2); num15 += (num4 + 6f) * num2; } } public static void RenderNames() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) if (!BlueCollarTrollsPlugin.Enabled.Value) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || UnionGui.IsOpen) { return; } Camera main = Camera.main; if ((Object)(object)main == (Object)null || Minimap.IsOpen()) { return; } if (s_nameStyle == null) { GUIStyle val = new GUIStyle(GUI.skin.label) { fontSize = 14, fontStyle = (FontStyle)1, alignment = (TextAnchor)4 }; val.normal.textColor = ColGold; s_nameStyle = val; } float num = ((BlueCollarTrollsPlugin.HudRange != null) ? Mathf.Max(8f, BlueCollarTrollsPlugin.HudRange.Value) : 40f); float num2 = num * num; Vector3 position = ((Component)localPlayer).transform.position; Vector3 val2; Rect val4 = default(Rect); for (int i = 0; i < Trolward.Instances.Count; i++) { Trolward trolward = Trolward.Instances[i]; if ((Object)(object)trolward == (Object)null || !trolward.TryWorkerHead(out var world)) { continue; } val2 = world - position; if (((Vector3)(ref val2)).sqrMagnitude > num2) { continue; } Vector3 val3 = main.WorldToScreenPoint(world); if (val3.z <= 0.1f) { continue; } float num3 = (float)Screen.height - val3.y; string workerName = trolward.WorkerName; if (!string.IsNullOrEmpty(workerName)) { ((Rect)(ref val4))..ctor(val3.x - 150f, num3 - 18f, 300f, 22f); if (!(((Rect)(ref val4)).xMax < 0f) && !(((Rect)(ref val4)).x > (float)Screen.width) && !(((Rect)(ref val4)).yMax < 0f) && !(((Rect)(ref val4)).y > (float)Screen.height)) { Color color = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.9f); GUI.Label(new Rect(((Rect)(ref val4)).x + 1f, ((Rect)(ref val4)).y + 1f, ((Rect)(ref val4)).width, ((Rect)(ref val4)).height), workerName, s_nameStyle); GUI.color = Color.white; GUI.Label(val4, workerName, s_nameStyle); GUI.color = color; } } } Rect val6 = default(Rect); for (int j = 0; j < CollectorStake.Instances.Count; j++) { CollectorStake collectorStake = CollectorStake.Instances[j]; if ((Object)(object)collectorStake == (Object)null || !collectorStake.TryNamePoint(out var point)) { continue; } val2 = point - position; if (((Vector3)(ref val2)).sqrMagnitude > num2) { continue; } Vector3 val5 = main.WorldToScreenPoint(point); if (val5.z <= 0.1f) { continue; } float num4 = (float)Screen.height - val5.y; string displayName = collectorStake.DisplayName; if (!string.IsNullOrEmpty(displayName)) { ((Rect)(ref val6))..ctor(val5.x - 150f, num4 - 18f, 300f, 22f); if (!(((Rect)(ref val6)).xMax < 0f) && !(((Rect)(ref val6)).x > (float)Screen.width) && !(((Rect)(ref val6)).yMax < 0f) && !(((Rect)(ref val6)).y > (float)Screen.height)) { Color color2 = GUI.color; GUI.color = new Color(0f, 0f, 0f, 0.9f); GUI.Label(new Rect(((Rect)(ref val6)).x + 1f, ((Rect)(ref val6)).y + 1f, ((Rect)(ref val6)).width, ((Rect)(ref val6)).height), displayName, s_nameStyle); GUI.color = Color.white; GUI.Label(val6, displayName, s_nameStyle); GUI.color = color2; } } } } private static void DrawContractCard(float x, float y, float w, float h, Trolward ward, Vector3 playerPos, float scale, bool detailed) { //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) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: 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_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_05e7: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) //IL_04ea: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_05a2: Unknown result type (might be due to invalid IL or missing references) Rect rect = new Rect(x, y, w, h); DrawSolidRect(rect, ColCardBg); DrawBorderRect(rect, ColCardBorder, 1f); TrollContractData contractData = ward.GetContractData(playerPos); string arg = "\ud83d\udc77"; switch ((TrolwardKind)contractData.Kind) { case TrolwardKind.Lumber: arg = "\ud83c\udf32"; break; case TrolwardKind.Mining: arg = "⛏\ufe0f"; break; case TrolwardKind.Farming: arg = "\ud83c\udf3e"; break; case TrolwardKind.Apiary: arg = "\ud83c\udf6f"; break; case TrolwardKind.Sorting: arg = "\ud83d\udce6"; break; case TrolwardKind.Defense: arg = "\ud83d\udee1\ufe0f"; break; case TrolwardKind.Gradener: arg = "\ud83c\udf3f"; break; } string text = $"{arg} {((!string.IsNullOrEmpty(contractData.WorkerName)) ? contractData.WorkerName : contractData.KindName)} (Lv.{contractData.Level})"; GUI.Label(new Rect(x + 6f * scale, y + 2f * scale, w * 0.58f, 18f * scale), text, s_cardTitleStyle); Color textColor = ColDim; switch (contractData.Status) { case 1: textColor = ColGreen; break; case 2: textColor = ColRed; break; case 3: textColor = ColYellow; break; case 4: textColor = ColYellow; break; } s_badgeStyle.normal.textColor = textColor; GUI.Label(new Rect(x + w * 0.56f, y + 2f * scale, w * 0.4f, 18f * scale), "● " + contractData.StatusText, s_badgeStyle); float num = x + 6f * scale; float num2 = y + 22f * scale; float num3 = w - 12f * scale; float num4 = 12f * scale; float num5 = Mathf.Max(3600f, BlueCollarTrollsPlugin.FuelCapSeconds.Value); float num6 = Mathf.Clamp01(contractData.FuelSeconds / num5); DrawSolidRect(new Rect(num, num2, num3, num4), ColProgressBarBg); if (num6 > 0f) { Color col = ((contractData.FuelSeconds < 600f) ? ColProgressLow : ColProgressFill); DrawSolidRect(new Rect(num, num2, num3 * num6, num4), col); } DrawBorderRect(new Rect(num, num2, num3, num4), ColCardBorder, 1f); string text2 = ((contractData.FuelSeconds > 0f) ? $"⏱\ufe0f {contractData.TimeRemaining} ({contractData.StockCount} provisions stored)" : "⚠\ufe0f No Fuel (Starving)"); s_dimStyle.normal.textColor = ((contractData.FuelSeconds > 0f) ? ColWhite : ColRed); GUI.Label(new Rect(num + 4f * scale, num2 - 1f * scale, num3 - 8f * scale, num4 + 2f * scale), text2, s_dimStyle); if (detailed) { float num7 = y + 37f * scale; string text3 = "⚡ Task: " + contractData.CurrentTask; s_textStyle.normal.textColor = ColWhite; GUI.Label(new Rect(x + 6f * scale, num7, w - 12f * scale, 17f * scale), text3, s_textStyle); float num8 = num7 + 17f * scale; string text4; if (contractData.EquippedToolName != null && contractData.EquippedToolName != "None") { text4 = "\ud83e\ude93 Tool: " + contractData.EquippedToolName + " (" + contractData.EquippedToolStats + ")"; s_textStyle.normal.textColor = ColGold; } else if (contractData.RequiredTool != null) { text4 = "⚠\ufe0f Needs: " + contractData.RequiredTool + " (Equip in Union Menu)"; s_textStyle.normal.textColor = ColYellow; } else { text4 = "ℹ\ufe0f Tool: Hands-on / Unarmed"; s_textStyle.normal.textColor = ColDim; } GUI.Label(new Rect(x + 6f * scale, num8, w - 12f * scale, 17f * scale), text4, s_textStyle); float num9 = num8 + 17f * scale; string text5 = ""; text5 = ((contractData.Kind == 2 || contractData.Kind == 5) ? ("\ud83c\udf31 Seeds: " + contractData.SeedsInfo) : ((contractData.Kind == 6) ? ("\ud83c\udf6f Apiary: " + contractData.HoneyInfo) : ((contractData.Kind != 3) ? $"\ud83c\udfdb\ufe0f Dues Chest: {contractData.StockCount} items in stock" : "\ud83d\udce6 Hauling & Sorting Active"))); s_textStyle.normal.textColor = (text5.Contains("Needs") ? ColYellow : ColWhite); GUI.Label(new Rect(x + 6f * scale, num9, w - 12f * scale, 17f * scale), text5, s_textStyle); float num10 = num9 + 17f * scale; string arg2 = (contractData.VaultConnected ? (" · \ud83c\udfdb\ufe0f Vault: " + contractData.VaultName) : ""); string text6 = $"\ud83d\udccd {contractData.Biome} · {contractData.Distance:0}m away{arg2}"; s_dimStyle.normal.textColor = ColDim; GUI.Label(new Rect(x + 6f * scale, num10, w - 12f * scale, 16f * scale), text6, s_dimStyle); } else { float num11 = y + 38f * scale; string text7 = $"\ud83d\udccd {contractData.Biome} · {contractData.Distance:0}m"; s_dimStyle.normal.textColor = ColDim; GUI.Label(new Rect(x + 6f * scale, num11, w - 12f * scale, 16f * scale), text7, s_dimStyle); } } private static float HudRangeSq() { float num = Mathf.Max(1f, BlueCollarTrollsPlugin.HudRange.Value); return num * num; } private static void DrawSolidRect(Rect rect, Color col) { //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 color = GUI.color; GUI.color = col; GUI.DrawTexture(rect, (Texture)(object)WhiteTex); GUI.color = color; } private static void DrawBorderRect(Rect rect, Color col, float thickness) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) DrawSolidRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, thickness), col); DrawSolidRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + ((Rect)(ref rect)).height - thickness, ((Rect)(ref rect)).width, thickness), col); DrawSolidRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, thickness, ((Rect)(ref rect)).height), col); DrawSolidRect(new Rect(((Rect)(ref rect)).x + ((Rect)(ref rect)).width - thickness, ((Rect)(ref rect)).y, thickness, ((Rect)(ref rect)).height), col); } } public enum TrolwardKind { Lumber, Mining, Farming, Sorting, Defense, Gradener, Apiary } [BepInPlugin("com.bluecollartrolls.bluecollartrolls", "Blue Collar Trolls", "0.3.29")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class BlueCollarTrollsPlugin : BaseUnityPlugin { private class MainThreadSlot<T> { public T Value; public Exception Error; } public const string PluginGUID = "com.bluecollartrolls.bluecollartrolls"; public const string PluginName = "Blue Collar Trolls"; public const string PluginVersion = "0.3.29"; private const string BaseWardName = "piece_ward"; private const string LarderModelName = "piece_chest_wood"; internal static readonly string[] PrefabNames = new string[8] { "TrolwardLumberV3", "TrolwardMiningV3", "TrolwardFarmingV3", "TrolwardSortingV3", "TrolwardDefenseV3", "TrolwardGradenerV3", "TrolwardApiaryV3", "BCT_UnionHall" }; internal static readonly string[] PieceNames = new string[8] { "Lumber Trolward", "Mining Trolward", "Farming Trolward", "Sorting Trolward", "Defense Trolward", "Gradener Trolward", "Apiary Trolward", "Union Hall" }; internal static readonly string[] PieceDescriptions = new string[8] { "Hires a blue-collar troll to fell trees and chop logs inside the ward. Feed it to keep it working.", "Hires a blue-collar troll to mine rock and ore inside the ward. Feed it to keep it working.", "Hires a blue-collar troll to harvest your cultivated crops inside the ward. Feed it to keep it working.", "Hires a blue-collar troll to haul loose goods into chests and merge stacks chest-to-chest. Feed it to keep it working.", "Hires a blue-collar troll to thrash hostiles that enter the ward. Feed it to keep it working.", "Hires a blue-collar troll to tend garden beds and tree plots inside the ward. Feed it to keep it working.", "Hires a blue-collar troll to harvest honey from beehives inside the ward. Feed it to keep it working.", "The central Union Hall. Hires a versatile blue-collar troll. You can change its profession and upgrade its skills." }; internal static readonly string[] LarderNames = new string[8] { "Lumber Trolward Larder", "Mining Trolward Larder", "Farming Trolward Larder", "Sorting Trolward Larder", "Defense Trolward Larder", "Gradener Trolward Larder", "Apiary Trolward Larder", "Union Hall Chest" }; internal const string ClaimPrefabName = "BCT_ClaimStake"; internal const string CollectorPrefabName = "BCT_CollectorStake"; private static bool s_claimRegistered; private static bool s_collectorRegistered; private static bool s_loggedMissingSign; internal static readonly string[] PlotPrefabNames = new string[4] { "BCT_FarmPlot4x4", "BCT_FarmPlot8x8", "BCT_GardenBed", "BCT_TreeBed" }; internal static readonly string[] PlotPieceNames = new string[4] { "Farm Plot (4x4)", "Farm Plot (8x8)", "Garden Bed", "Tree Plot" }; internal static readonly string[] PlotPieceDescriptions = new string[4] { "A 4x4 raised soil bed (9 crop slots) managed by the Troll Farmers' Union. Assign a crop to automate planting and harvesting.", "An 8x8 large raised soil bed (36 crop slots) managed by the Troll Farmers' Union. Assign a crop to automate planting and harvesting.", "A 4x4 raised garden bed (9 crop slots) for the Gradener. Assign a crop to automate planting and harvesting.", "A 4x4 raised tree plot with one planting spot in the center. The Gradener plants and harvests it." }; internal static readonly bool[] PlotPrefabRegistered = new bool[4]; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<bool> AddBuildPieces; internal static ConfigEntry<bool> DebugLogging; internal static ConfigEntry<float> TrollScale; internal static ConfigEntry<bool> CleanupStrayHires; internal static ConfigEntry<float> CleanupRadius; internal static ConfigEntry<float> CleanupSpeedFactor; internal static ConfigEntry<float> RepScale; internal static ConfigEntry<float> FoodSecondsPerPoint; internal static ConfigEntry<float> FuelCapSeconds; internal static ConfigEntry<float> FuelBurnPerSecond; internal static ConfigEntry<string> AttackAnimation; internal static ConfigEntry<float> HudRange; internal static ConfigEntry<float> DepositInterval; internal static ConfigEntry<bool> HudShowIdle; internal static ConfigEntry<bool> FarmingOnlyPlantedCrops; internal static ConfigEntry<float> AxeScale; internal static ConfigEntry<bool> AllowAllBiomes; internal static ConfigEntry<bool> AllowGreenhouses; internal static ConfigEntry<bool> AutoDepositToVault; internal static ConfigEntry<float> VaultSearchRange; internal static ConfigEntry<float> ClaimRadius; internal static ConfigEntry<float> ClaimAssignRange; internal static ConfigEntry<float> CollectorRadius; internal static ConfigEntry<int> CollectorCargo; internal static ConfigEntry<float> CollectorSpeed; internal static ConfigEntry<bool> EnableWebGui; internal static ConfigEntry<int> WebPort; internal static ConfigEntry<bool> HudVisible; internal static ConfigEntry<float> HudScreenX; internal static ConfigEntry<float> HudScreenY; internal static ConfigEntry<float> HudScale; internal static ConfigEntry<float> HudBgOpacity; internal static ConfigEntry<bool> HudShowAllGlobal; internal static ConfigEntry<bool> HudDetailedContracts; internal static ConfigEntry<KeyCode> HudToggleKey; private BlueCollarWebGui m_webGui; private readonly ConcurrentQueue<Action> m_mainThread = new ConcurrentQueue<Action>(); private int m_mainThreadId; internal static readonly TrolwardSettings[] Settings = new TrolwardSettings[7]; internal static readonly bool[] PrefabRegistered = new bool[8]; internal static BlueCollarTrollsPlugin Instance; internal static string PluginDirectory; private static bool s_cleanupDone; private static float s_nextCleanupAttempt; private const float CleanupInterval = 10f; private float m_retryTimer; private bool m_registrationDone; private bool m_piecesAdded; private bool m_claimMenuAdded; private bool m_collectorMenuAdded; private bool m_loggedFindFailure; private bool m_sawZNetScene; private bool m_piecesKnown; private float m_knownCheckTimer; private static MethodInfo s_addKnownPieceMethod; private static MethodInfo s_updateAvailablePiecesListMethod; private static MethodInfo s_refreshCategoriesMethod; private static readonly FieldInfo s_namedPrefabsField = typeof(ZNetScene).GetField("m_namedPrefabs", BindingFlags.Instance | BindingFlags.NonPublic); private static ItemDrop s_stoneItem; private static ItemDrop s_woodItem; private static string s_wardFindDiagnostic = "no scan run yet"; private static bool s_loggedStorageScan; private static readonly HashSet<string> s_chestLikeNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private static Sprite[] s_icons; private static readonly Dictionary<string, Sprite> s_fileIcons = new Dictionary<string, Sprite>(); internal void Ask(Action action) { if (action != null) { m_mainThread.Enqueue(action); } } internal T Ask<T>(Func<T> work, T fallback) { if (work == null) { return fallback; } if (Thread.CurrentThread.ManagedThreadId == m_mainThreadId) { try { return work(); } catch (Exception ex) { Logger.LogWarning((object)("Blue Collar Trolls: " + ex.Message)); return fallback; } } ManualResetEventSlim done = new ManualResetEventSlim(initialState: false); MainThreadSlot<T> slot = new MainThreadSlot<T>(); m_mainThread.Enqueue(delegate { try { slot.Value = work(); } catch (Exception error) { slot.Error = error; } finally { done.Set(); } }); if (!done.Wait(TimeSpan.FromSeconds(3.0))) { Logger.LogWarning((object)"Blue Collar Trolls: the labor dashboard gave up waiting on the game thread."); return fallback; } if (slot.Error != null) { Logger.LogWarning((object)("Blue Collar Trolls: labor dashboard request failed: " + slot.Error.Message)); return fallback; } return slot.Value; } private void Awake() { //IL_07aa: Unknown result type (might be due to invalid IL or missing references) m_mainThreadId = Thread.CurrentThread.ManagedThreadId; Instance = this; PluginDirectory = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Master toggle. When false the trolwards do nothing."); AddBuildPieces = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AddBuildPieces", true, "Add the five trolward pieces to the Hammer build menu. Requires a game restart."); DebugLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DebugLogging", true, "Log target acquisition, swings and fuel events to the BepInEx log. Turn off once the trolls behave."); TrollScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TrollScale", 0.25f, "Scale of the hired troll (0.25 = a quarter of the normal size)."); TrollScale.Value = Mathf.Clamp(TrollScale.Value, 0.25f, 1f); CleanupSpeedFactor = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CleanupSpeedFactor", 3f, "Movement speed multiplier for the Sorting ward cleanup boy."); CleanupSpeedFactor.Value = Mathf.Clamp(CleanupSpeedFactor.Value, 1f, 6f); RepScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RepScale", 0.4f, "Scale of the mini union rep (a small Haldor) who collects the dues."); RepScale.Value = Mathf.Clamp(RepScale.Value, 0.2f, 1f); FoodSecondsPerPoint = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FoodSecondsPerPoint", 60f, "Working seconds a troll gets from one point of nourishment (m_food + m_foodStamina + m_foodEitr)."); FuelCapSeconds = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FuelCapSeconds", 86400f, "Maximum stored working time a troll can hold (seconds). Excess food is left in the larder."); FuelBurnPerSecond = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FuelBurnPerSecond", 1f, "Working seconds drained from the fuel pool per real second of work."); AttackAnimation = ((BaseUnityPlugin)this).Config.Bind<string>("General", "AttackAnimation", "attack", "Animator trigger the troll plays when it swings (trolls use 'attack')."); HudRange = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "HudRange", 40f, "Distance (m) a player must be from a trolward before its status panel is shown."); DepositInterval = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DepositInterval", 1f, "Seconds between deposit/sorting sweeps that haul drops into chests."); HudShowIdle = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "HudShowIdle", true, "Show wards that are idle (no fuel or nothing to do) in the panel."); AxeScale = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AxeScale", 1f, "Scale of the tool visual the troll grips, relative to the troll's own scaled hand (1 = proportionate)."); FarmingOnlyPlantedCrops = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "FarmingOnlyPlantedCrops", true, "If true, farming trolls only harvest crops that are player-planted."); AllowAllBiomes = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowAllBiomes", false, "If true, crops can be planted in any biome."); AllowGreenhouses = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AllowGreenhouses", false, "If true, crops ignore the needs-sunlight requirement."); AutoDepositToVault = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "AutoDepositToVault", false, "If true, sorting/harvesting trolls try to deposit to VikingVault first."); VaultSearchRange = ((BaseUnityPlugin)this).Config.Bind<float>("General", "VaultSearchRange", 100f, "Range in meters to search for a VikingVault to deposit into."); ClaimRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Claims", "ClaimRadius", 30f, "Default work radius (m) of a newly placed Claim Stake. Each stake can be resized from the union rep."); ClaimRadius.Value = Mathf.Clamp(ClaimRadius.Value, 10f, 80f); ClaimAssignRange = ((BaseUnityPlugin)this).Config.Bind<float>("Claims", "ClaimAssignRange", 120f, "How far (m) from the union hall a Claim Stake can be and still be assigned to a troll."); ClaimAssignRange.Value = Mathf.Clamp(ClaimAssignRange.Value, 20f, 300f); CollectorRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Collectors", "CollectorRadius", 40f, "Default gather radius (m) of a newly placed Collector Stake. Each stake can be resized from the union rep."); CollectorRadius.Value = Mathf.Clamp(CollectorRadius.Value, 10f, 80f); CollectorCargo = ((BaseUnityPlugin)this).Config.Bind<int>("Collectors", "CollectorCargo", 8, "How many ground drops a collector blimp picks up before it flies home. Stacks that still have room count as one drop."); CollectorCargo.Value = Mathf.Clamp(CollectorCargo.Value, 1, 40); CollectorSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Collectors", "CollectorSpeed", 8f, "How fast the collector blimp flies, in metres per second."); CollectorSpeed.Value = Mathf.Clamp(CollectorSpeed.Value, 2f, 20f); EnableWebGui = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableWebGui", true, "Open the troll line editor at http://127.0.0.1:8790/ while the game is running."); WebPort = ((BaseUnityPlugin)this).Config.Bind<int>("General", "WebPort", 8790, "Localhost port for the troll line editor."); HudVisible = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "HudVisible", true, "Show the troll labor contracts and timers HUD overlay on screen."); HudScreenX = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "HudScreenX", 0.78f, "Normalized screen X position (0.0 = left, 1.0 = right)."); HudScreenY = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "HudScreenY", 0.22f, "Normalized screen Y position (0.0 = top, 1.0 = bottom)."); HudScale = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "HudScale", 1f, "Scale of the HUD overlay (0.6 to 1.8)."); HudBgOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "HudBgOpacity", 0.85f, "Background opacity for the HUD overlay (0.0 to 1.0)."); HudShowAllGlobal = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "HudShowAllGlobal", false, "Show all troll labor contracts across the world, not just nearby."); HudDetailedContracts = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "HudDetailedContracts", true, "Show detailed labor contract info (seeds, honey, tools, beds, exp)."); HudToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("HUD", "HudToggleKey", (KeyCode)288, "Hotkey to toggle the Troll Labor HUD on/off."); CleanupStrayHires = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "CleanupStrayHires", true, "On load, delete Troll/Haldor objects that older builds saved near a ward. Those are full sized creatures that this mod put in your world save by accident. Set false to leave anything Troll-shaped alone."); CleanupRadius = ((BaseUnityPlugin)this).Config.Bind<float>("General", "CleanupRadius", 4f, "How close a stray must be to a loaded ward to count as one of ours, in metres."); Settings[0] = new TrolwardSettings(((BaseUnityPlugin)this).Config, "Lumber", 30f, 60f, 2, 1.2f, depositToChests: true); Settings[1] = new TrolwardSettings(((BaseUnityPlugin)this).Config, "Mining", 30f, 60f, 2, 1.2f, depositToChests: true); Settings[2] = new TrolwardSettings(((BaseUnityPlugin)this).Config, "Farming", 25f, 0f, 0, 0.5f, depositToChests: true); Settings[3] = new TrolwardSettings(((BaseUnityPlugin)this).Config, "Sorting", 60f, 0f, 0, 1f, depositToChests: true); Settings[4] = new TrolwardSettings(((BaseUnityPlugin)this).Config, "Defense", 35f, 50f, 3, 1.2f, depositToChests: false); Settings[5] = new TrolwardSettings(((BaseUnityPlugin)this).Config, "Gradener", 25f, 0f, 0, 0.5f, depositToChests: true); Settings[6] = new TrolwardSettings(((BaseUnityPlugin)this).Config, "Apiary", 30f, 0f, 0, 2f, depositToChests: true); if (Settings[3].Range.Value <= 30f) { Settings[3].Range.Value = 60f; ((BaseUnityPlugin)this).Config.Save(); Logger.LogInfo((object)"Blue Collar Trolls: bumped Sorting (cleanup boy) range to 60m"); } if (AxeScale.Value <= 0.3f) { AxeScale.Value = 1f; ((BaseUnityPlugin)this).Config.Save(); Logger.LogInfo((object)"Blue Collar Trolls: bumped AxeScale to 1 (tool model now shares the troll's own scale)"); } try { new Harmony("com.bluecollartrolls.bluecollartrolls").PatchAll(); Logger.LogInfo((object)"Blue Collar Trolls: Harmony patches applied successfully."); } catch (Exception arg) { Logger.LogError((object)string.Format("{0}: Harmony patching failed: {1}", "Blue Collar Trolls", arg)); } if ((Object)(object)((Component)this).GetComponent<UnionGui>() == (Object)null) { ((Component)this).gameObject.AddComponent<UnionGui>(); } HallClient.Bind("bluecollar", "Blue Collar", 10, delegate(Rect rect) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) UnionGui.Instance?.DrawHosted(rect); }); HallClient.Bind("earl", "Earl", 12, EarlQuests.Draw); EarlQuests.Initialize(); TrollLines.Initialize(); if (EnableWebGui.Value) { int port = ((WebPort.Value > 0) ? WebPort.Value : 8790); m_webGui = new BlueCollarWebGui(this, port); m_webGui.Start(); } Logger.LogInfo((object)"Blue Collar Trolls 0.3.29 loading..."); PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable; PieceManager.OnPiecesRegistered += OnPiecesRegistered; if (IsVanillaPrefabReady()) { OnVanillaPrefabsAvailable(); } } private void OnGUI() { if (Enabled.Value) { BlueCollarHud.RenderNames(); BlueCollarHud.Render(); } } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable; PieceManager.OnPiecesRegistered -= OnPiecesRegistered; if (m_webGui != null) { m_webGui.Stop(); m_webGui = null; } TrollLines.Clips.DisposeRequests(); } private void RunStrayHireCleanup() { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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) if (s_cleanupDone || !CleanupStrayHires.Value || (Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || (Object)(object)ZNetScene.instance == (Object)null || ZDOMan.instance == null) { return; } Trolward[] array = Object.FindObjectsOfType<Trolward>(); if (array == null || array.Length == 0) { return; } float num = Mathf.Max(0.5f, CleanupRadius.Value); float num2 = num * num; int num3 = 0; string[] array2 = new string[3] { "Troll", "Haldor", "Dvergr" }; foreach (string text in array2) { List<ZDO> list = new List<ZDO>(); int num4 = 0; while (!ZDOMan.instance.GetAllZDOsWithPrefabIterative(text, list, ref num4)) { } foreach (ZDO item in list) { if (item == null || !item.IsOwner()) { continue; } Vector3 position = item.GetPosition(); Trolward[] array3 = array; foreach (Trolward trolward in array3) { if (!((Object)(object)trolward == (Object)null)) { Vector3 val = ((Component)trolward).transform.position - position; val.y = 0f; if (!(((Vector3)(ref val)).sqrMagnitude > num2)) { ZDOMan.instance.DestroyZDO(item); num3++; Logger.LogWarning((object)$"[Blue Collar Trolls] removed a stray {text} at {position} ({((Vector3)(ref val)).magnitude:0.0} m from a ward) that an older build had saved into this world."); break; } } } } } s_cleanupDone = true; if (num3 > 0) { Logger.LogWarning((object)$"[Blue Collar Trolls] removed {num3} stray hire(s). Any left elsewhere are next to a ward that is not currently loaded, and will be cleaned when you load that area."); } } private IEnumerator RunStrayHireCleanupRoutine() { while (!s_cleanupDone && CleanupStrayHires.Value) { RunStrayHireCleanup(); if (s_cleanupDone) { break; } yield return (object)new WaitForSeconds(10f); } } private void OnVanillaPrefabsAvailable() { TryRegisterAll(); } private void Start() { ((MonoBehaviour)this).StartCoroutine(RunStrayHireCleanupRoutine()); ((MonoBehaviour)this).StartCoroutine(CleanupStrayCropsRoutine()); } private IEnumerator CleanupStrayCropsRoutine() { if (!CleanupStrayHires.Value) { yield break; } while ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || (Object)(object)ZNetScene.instance == (Object)null || ZDOMan.instance == null) { yield return (object)new WaitForSeconds(5f); } yield return (object)new WaitForSeconds(2f); string[] cropPrefabs = new string[13] { "sapling_seedcarrot", "sapling_carrot", "sapling_seedturnip", "sapling_turnip", "sapling_seedonion", "sapling_onion", "sapling_seedkale", "sapling_Kale", "sapling_barley", "sapling_flax", "sapling_jotunpuffs", "sapling_magecap", "sapling_poteitr" }; while (true) { int removed = 0; string[] array = cropPrefabs; foreach (string prefab in array) { List<ZDO> found = new List<ZDO>(); int index = 0; while (!ZDOMan.instance.GetAllZDOsWithPrefabIterative(prefab, found, ref index)) { yield return null; } int destroyedThisFrame = 0; foreach (ZDO item in found) { if (item != null && item.IsOwner() && item.Persistent && item.GetLong(ZDOVars.s_creator, 0L) == 0L) { ZDOMan.instance.DestroyZDO(item); removed++; destroyedThisFrame++; if (destroyedThisFrame >= 20) { destroyedThisFrame = 0; yield return null; } } } } if (removed > 0) { Logger.LogWarning((object)$"[Blue Collar Trolls] Cleared {removed} phantom crop ZDOs that lacked a creator ID!"); } yield return (object)new WaitForSeconds(10f); } } private void Update() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) HallClient.Flush(); Action result; while (m_mainThread.TryDequeue(out result)) { try { result(); } catch (Exception ex) { Logger.LogWarning((object)("Blue Collar Trolls: " + ex.Message)); } } if (Input.GetKeyDown(HudToggleKey.Value)) { HudVisible.Value = !HudVisible.Value; } ObjLoader.RepairPendingMaterials(); CharacterInteractionPatch.TickChestAllow(); if (m_registrationDone) { if (!m_piecesAdded || !m_claimMenuAdded || !m_collectorMenuAdded) { AddPiecesToMenu(); } EnsureLocalPlayerKnownPieces(); return; } if ((Object)(object)ZNetScene.instance != (Object)null && !m_sawZNetScene) { m_sawZNetScene = true; m_loggedFindFailure = false; } m_retryTimer -= Time.deltaTime; if (m_retryTimer <= 0f) { m_retryTimer = 1f; TryRegisterAll(); } } private void EnsureLocalPlayerKnownPieces() { if (m_piecesKnown || (Object)(object)Player.m_localPlayer == (Object)null) { return; } m_knownCheckTimer -= Time.deltaTime; if (m_knownCheckTimer > 0f) { return; } m_knownCheckTimer = 1.5f; bool flag = true; for (int i = 0; i < PrefabNames.Length; i++) { GameObject prefab = PrefabManager.Instance.GetPrefab(PrefabNames[i]); if ((Object)(object)prefab != (Object)null && !UnlockPiece(prefab)) { flag = false; } } for (int j = 0; j < PlotPrefabNames.Length; j++) { GameObject prefab2 = PrefabManager.Instance.GetPrefab(PlotPrefabNames[j]); if ((Object)(object)prefab2 != (Object)null && !UnlockPiece(prefab2)) { flag = false; } } GameObject prefab3 = PrefabManager.Instance.GetPrefab("BCT_ClaimStake"); if ((Object)(object)prefab3 == (Object)null || !UnlockPiece(prefab3)) { flag = false; } if (flag) { m_piecesKnown = true; RefreshHammerCategories(); Logger.LogInfo((object)"Blue Collar Trolls: all build pieces unlocked and known in Hammer menu."); } } private static bool UnlockPiece(GameObject prefab) { Piece component = prefab.GetComponent<Piece>(); if ((Object)(object)component == (Object)null) { return true; } if (!Player.m_localPlayer.IsRecipeKnown(component.m_name)) { if (s_addKnownPieceMethod == null) { s_addKnownPieceMethod = typeof(Player).GetMethod("AddKnownPiece", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } if (s_updateAvailablePiecesListMethod == null) { s_updateAvailablePiecesListMethod = typeof(Player).GetMethod("UpdateAvailablePiecesList", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } try { s_addKnownPieceMethod?.Invoke(Player.m_localPlayer, new object[1] { component }); s_updateAvailablePiecesListMethod?.Invoke(Player.m_localPlayer, null); } catch { } } return Player.m_localPlayer.IsRecipeKnown(component.m_name); } private static void RefreshHammerCategories() { try { if (s_refreshCategoriesMethod == null) { s_refreshCategoriesMethod = typeof(PieceManager).GetMethod("RefreshCategories", BindingFlags.Instance | BindingFlags.NonPublic); } s_refreshCategoriesMethod?.Invoke(PieceManager.Instance, null); } catch { } } private void TryRegisterAll() { if (!Enabled.Value || !AddBuildPieces.Value || m_registrationDone) { return; } GameObject val = FindPieceBasePrefab(); if ((Object)(object)val == (Object)null) { if (!m_loggedFindFailure) { m_loggedFindFailure = true; Logger.LogWarning((object)("Blue Collar Trolls: base piece not found yet (" + s_wardFindDiagnostic + "). Retrying.")); } return; } for (int i = 0; i < PrefabNames.Length; i++) { if (!PrefabRegistered[i]) { try { RegisterPrefab(i, val); } catch (Exception arg) { Logger.LogError((object)$"Blue Collar Trolls: failed to register '{PieceNames[i]}': {arg}"); } } } RegisterPlotPrefabs(); RegisterBedPrefabs(); RegisterClaimStake(); RegisterCollectorStake(); AddPiecesToMenu(); m_registrationDone = s_claimRegistered && s_collectorRegistered; } internal static void AddLarder(GameObject prefab, string name, int width = 4, int height = 6) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) Container component = prefab.GetComponent<Container>(); if ((Object)(object)component != (Object)null) { Object.DestroyImmediate((Object)(object)component); } component = prefab.AddComponent<Container>(); component.m_name = name; component.m_width = width; component.m_height = height; component.m_privacy = (PrivacySetting)0; component.m_checkGuardStone = false; component.m_autoDestroyEmpty = false; component.m_defaultItems = null; } private static void EnsureBuildableComponents(GameObject prefab, int kind) { //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) Piece val = prefab.GetComponent<Piece>(); GameObject val2 = FindBuildableTemplate(); Piece val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<Piece>() : null); if ((Object)(object)val == (Object)null) { val = prefab.AddComponent<Piece>(); if ((Object)(object)val3 != (Object)null) { val.m_icon = val3.m_icon; val.m_category = val3.m_category; val.m_enabled = val3.m_enabled; val.m_groundPiece = val3.m_groundPiece; val.m_groundOnly = val3.m_groundOnly; val.m_allowAltGroundPlacement = val3.m_allowAltGroundPlacement; val.m_clipGround = val3.m_clipGround; val.m_noInWater = val3.m_noInWater; val.m_notOnWood = val3.m_notOnWood; val.m_notOnTiltingSurface = val3.m_notOnTiltingSurface; val.m_noClipping = val3.m_noClipping; val.m_onlyInTeleportArea = val3.m_onlyInTeleportArea; val.m_allowedInDungeons = val3.m_allowedInDungeons; val.m_spaceRequirement = val3.m_spaceRequirement; val.m_repairPiece = val3.m_repairPiece; val.m_removePiece = val3.m_removePiece; val.m_canBeRemoved = val3.m_canBeRemoved; val.m_canRotate = val3.m_canRotate; val.m_comfort = val3.m_comfort; val.m_comfortGroup = val3.m_comfortGroup; val.m_placeEffect = val3.m_placeEffect; val.m_destroyedLootPrefab = val3.m_destroyedLootPrefab; val.m_dlc = val3.m_dlc; val.m_usage = val3.m_usage; } else { val.m_enabled = true; val.m_category = (PieceCategory)0; val.m_groundPiece = true; val.m_groundOnly = false; val.m_clipGround = false; val.m_noClipping = true; val.m_allowedInDungeons = false; val.m_spaceRequirement = 0f; val.m_repairPiece = false; val.m_removePiece = false; val.m_canBeRemoved = true; val.m_canRotate = true; } } val.m_repairPiece = false; val.m_removePiece = false; val.m_groundPiece = true; val.m_groundOnly = false; val.m_clipGround = true; val.m_noClipping = false; val.m_canRotate = true; val.m_canBeRemoved = true; val.m_enabled = true; val.m_name = PieceNames[kind]; val.m_description = PieceDescriptions[kind]; val.m_craftingStation = null; val.m_resources = (Requirement[])(object)new Requirement[0]; WearNTear val4 = prefab.GetComponent<WearNTear>(); if ((Object)(object)val4 == (Object)null) { val4 = prefab.AddComponent<WearNTear>(); WearNTear val5 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<WearNTear>() : null); if ((Object)(object)val5 != (Object)null) { val4.m_damages = val5.m_damages; val4.m_materialType = val5.m_materialType; val4.m_minToolTier = val5.m_minToolTier; val4.m_hitEffect = val5.m_hitEffect; val4.m_destroyedEffect = val5.m_destroyedEffect; val4.m_hitNoise = val5.m_hitNoise; val4.m_destroyNoise = val5.m_destroyNoise; val4.m_burnable = val5.m_burnable; } else { val4.m_materialType = (MaterialType)0; val4.m_minToolTier = 0; } } Destructible[] componentsInChildren = prefab.GetComponentsInChildren<Destructible>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentsInChildren[i] != (Object)null) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } } val4.m_health = 1000f; val4.m_supports = false; val4.m_noSupportWear = false; val4.m_noRoofWear = false; val4.m_snowDamageImmune = true; val4.m_ashDamageImmune = true; val4.m_new = null; val4.m_worn = null; val4.m_broken = null; val4.m_wet = null; val4.m_fragmentRoots = (GameObject[])(object)new GameObject[0]; val4.m_autoCreateFragments = false; ZNetView val6 = prefab.GetComponent<ZNetView>(); if ((Object)(object)val6 == (Object)null) { val6 = prefab.AddComponent<ZNetView>(); } val6.m_persistent = true; } private static GameObject FindBuildableTemplate() { GameObject val = FindPrefab("piece_workbench", "piece_wood_floor1x1", "piece_wood_wall1x1", "piece_stone_floor1x1"); if ((Object)(object)val != (Object)null && (Object)(object)val.GetComponent<Piece>() != (Object)null) { return val; } if ((Object)(object)ZNetScene.instance != (Object)null && ZNetScene.instance.m_prefabs != null) { foreach (GameObject prefab in ZNetScene.instance.m_prefabs) { if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent<Piece>() != (Object)null && (Object)(object)prefab.GetComponent<WearNTear>() != (Object)null) { return prefab; } } } return null; } private void RegisterPrefab(int kind, GameObject baseWard) { GameObject val = PrefabManager.Instance.CreateClonedPrefab(PrefabNames[kind], baseWard); if ((Object)(object)val == (Object)null) { Logger.LogWarning((object)("Blue Collar Trolls: failed to clone the base piece for '" + PieceNames[kind] + "'.")); return; } if (kind == 7) { AddLarder(val, LarderNames[kind], 8, 8); UnionHallModel.TryAttach(val); } else { AddLarder(val, LarderNames[kind]); } EnsureBuildableComponents(val, kind); Trolward trolward = val.AddComponent<Trolward>(); trolward.KindIndex = 0; trolward.m_initialKindIndex = 0; trolward.m_initialIsUnionHall = kind == 7; PrefabManager.Instance.AddPrefab(val); PrefabRegistered[kind] = true; ForceRegisterInZNetScene(val); Logger.LogInfo((object)$"Blue Collar Trolls: registered '{PrefabNames[kind]}' ({PieceNames[kind]}) cloned from '{((Object)baseWard).name}' buildable={(Object)(object)val.GetComponent<Piece>() != (Object)null}/{(Object)(object)val.GetComponent<WearNTear>() != (Object)null}/{(Object)(object)val.GetComponent<Container>() != (Object)null}."); } private static void ForceRegisterInZNetScene(GameObject prefab) { if ((Object)(object)prefab == (Object)null) { return; } ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null || instance.m_prefabs == null) { return; } if (!instance.m_prefabs.Contains(prefab)) { instance.m_prefabs.Add(prefab); } int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)prefab).name); try { IDictionary dictionary = (IDictionary)s_namedPrefabsField.GetValue(instance); if (dictionary != null) { dictionary[stableHashCode] = prefab; } } catch (Exception arg) { Logger.LogWarning((object)$"Blue Collar Trolls: could not force-register '{((Object)prefab).name}' in ZNetScene name table: {arg}"); } } private void OnPiecesRegistered() { AddPiecesToMenu(); } private void AddPiecesToMenu() { if (!Enabled.Value || !AddBuildPieces.Value || (m_piecesAdded && m_claimMenuAdded && m_collectorMenuAdded) || PieceManager.Instance == null || (Object)(object)PieceManager.Instance.GetPieceTable("Hammer") == (Object)null) { return; } bool piecesAdded = m_piecesAdded; if (!m_piecesAdded) { for (int i = 0; i < PrefabNames.Length; i++) { if (PrefabRegistered[i]) { try { AddPiece(i); piecesAdded = true; } catch (Exception arg) { Logger.LogError((object)$"Blue Collar Trolls: failed to add '{PieceNames[i]}' to the Hammer menu: {arg}"); } } } } if (!m_piecesAdded) { for (int j = 0; j < PlotPrefabNames.Length; j++) { if (PlotPrefabRegistered[j]) { try { AddPlotPiece(j); piecesAdded = true; } catch (Exception arg2) { Logger.LogError((object)$"Blue Collar Trolls: failed to add '{PlotPieceNames[j]}' to the Hammer menu: {arg2}"); } } } } if (!m_piecesAdded) { m_piecesAdded = piecesAdded; } if (s_claimRegistered && !m_claimMenuAdded) { try { AddClaimPiece(); m_claimMenuAdded = true; } catch (Exception ex) { Logger.LogError((object)("Blue Collar Trolls: failed to add 'Claim Stake' to the Hammer menu: " + ex)); } } if (!s_collectorRegistered || m_collectorMenuAdded) { return; } try { AddCollectorPiece(); m_collectorMenuAdded = true; } catch (Exception ex2) { Logger.LogError((object)("Blue Collar Trolls: failed to add 'Collector Stake' to the Hammer menu: " + ex2)); } } private void AddPiece(int kind) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown GameObject prefab = PrefabManager.Instance.GetPrefab(PrefabNames[kind]); if (!((Object)(object)prefab == (Object)null) && kind == 7) { PieceConfig val = new PieceConfig { Name = PieceNames[kind], Description = PieceDescriptions[kind], PieceTable = "Hammer", Category = "DFG", Enabled = true, Icon = LoadIconForKind(kind) }; PieceManager.Instance.AddPiece(new CustomPiece(prefab, false, val)); try { PieceManager.Instance.RegisterPieceInPieceTable(prefab, "Hammer", "DFG"); Logger.LogInfo((object)("Blue Collar Trolls: registered '" + PieceNames[kind] + "' in the Hammer PieceTable under 'DFG'.")); } catch (Exception arg) { Logger.LogError((object)$"Blue Collar Trolls: could not register '{PieceNames[kind]}' in the Hammer PieceTable: {arg}"); } FinalizeBuildablePiece(prefab, kind); Logger.LogInfo((object)("Blue Collar Trolls: added '" + PieceNames[kind] + "' build piece to the Hammer menu.")); } } private static ItemDrop ResolveStoneItem() { if ((Object)(object)s_stoneItem != (Object)null) { return s_stoneItem; } Piece[] array = Resources.FindObjectsOfTypeAll<Piece>(); foreach (Piece val in array) { if ((Object)(object)val == (Object)null || val.m_resources == null) { continue; } for (int j = 0; j < val.m_resources.Length; j++) { Requirement val2 = val.m_resources[j]; if (val2 != null && !((Object)(object)val2.m_resItem == (Object)null) && !(((Object)val2.m_resItem).name != "Stone") && val2.m_resItem.m_itemData != null && val2.m_resItem.m_itemData.m_shared != null) { s_stoneItem = val2.m_resItem; return s_stoneItem; } } } return null; } private static void FinalizeBuildablePiece(GameObject prefab, int kind) { //IL_0040: 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_0055: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) Piece val = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<Piece>() : null); if (!((Object)(object)val == (Object)null)) { val.m_name = PieceNames[kind]; val.m_description = PieceDescriptions[kind]; val.m_craftingStation = null; val.m_usage = (UsageTagFlags)0; val.m_category = PieceManager.Instance.AddPieceCategory("DFG"); Sprite val2 = LoadIconForKind(kind); if ((Object)(object)val2 != (Object)null) { val.m_icon = val2; } ItemDrop val3 = ResolveStoneItem(); if ((Object)(object)val3 == (Object)null) { val.m_resources = (Requirement[])(object)new Requirement[0]; Logger.LogWarning((object)("Blue Collar Trolls: '" + PieceNames[kind] + "' has no build cost - a usable Stone item was not found.")); } else { val.m_resources = (Requirement[])(object)new Requirement[1] { new Requirement { m_resItem = val3, m_amount = 10, m_recover = true } }; } Logger.LogInfo((object)string.Format("Blue Collar Trolls: '{0}' build cost = {1}, category={2}, usage={3}.", PieceNames[kind], ((Object)(object)val3 != (Object)null) ? "10 Stone (real item)" : "none", val.m_category, val.m_usage)); } } private void RegisterPlotPrefabs() { int[] array = new int[2] { 4, 8 }; for (int i = 0; i < array.Length; i++) { if (!PlotPrefabRegistered[i]) { try { int size = array[i]; GameObject val = FarmPlotModel.CreatePlotPrefab(size); EnsurePlotBuildableComponents(val, i, size); PrefabManager.Instance.AddPrefab(val); val.SetActive(true); PlotPrefabRegistered[i] = true; ForceRegisterInZNetScene(val); Logger.LogInfo((object)("Blue Collar Trolls: registered '" + PlotPrefabNames[i] + "' (" + PlotPieceNames[i] + ").")); } catch (Exception arg) { Logger.LogError((object)$"Blue Collar Trolls: failed to register plot '{PlotPieceNames[i]}': {arg}"); } } } } private void RegisterBedPrefabs() { string[] array = new string[2] { "garden", "tree" }; int[] array2 = new int[2] { 2, 3 }; for (int i = 0; i < array.Length; i++) { int num = array2[i]; if (!PlotPrefabRegistered[num]) { try { GameObject val = FarmPlotModel.CreateBedPrefab(array[i], PlotPrefabNames[num]); EnsurePlotBuildableComponents(val, num, 4); PrefabManager.Instance.AddPrefab(val); val.SetActive(true); PlotPrefabRegistered[num] = true; ForceRegisterInZNetScene(val); Logger.LogInfo((object)("Blue Collar Trolls: registered '" + PlotPrefabNames[num] + "' (" + PlotPieceNames[num] + ").")); } catch (Exception arg) { Logger.LogError((object)$"Blue Collar Trolls: failed to register plot '{PlotPieceNames[num]}': {arg}"); } } } } private void RegisterClaimStake() { if (s_claimRegistered) { return; } GameObject val = FindSignPrefab(); if ((Object)(object)val == (Object)null) { if (!s_loggedMissingSi