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 OdinsEye v1.1.0
OdinsEye.dll
Decompiled 5 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.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 BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Microsoft.CodeAnalysis; using MyMods.Web; using Newtonsoft.Json; using UnityEngine; using UnityEngine.Rendering; [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("OdinsEye")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+f75d827baa95f1d47870309b7aa509e2e0eaf69c")] [assembly: AssemblyProduct("OdinsEye")] [assembly: AssemblyTitle("OdinsEye")] [assembly: AssemblyVersion("1.1.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MyMods.Web { public static class WebNav { public sealed class Link { public readonly string Id; public readonly string Label; public readonly int Port; public string Url => "http://127.0.0.1:" + Port + "/"; public Link(string id, string label, int port) { Id = id; Label = label; Port = port; } } public static readonly Link[] Links = new Link[23] { new Link("monsters", "Monsters", 8777), new Link("searoute", "SeaRoute", 8778), new Link("longboat", "Harpoon Longboat", 8779), new Link("tradewind", "TradeWind", 8780), new Link("safeharbor", "Safe Harbor", 8781), new Link("hub", "DFG Hub", 8782), new Link("vault", "Viking Vault", 8783), new Link("qolvault", "QoL Vault Buttons", 8784), new Link("qolinventory", "QoL Inventory Buttons", 8785), new Link("cacophony", "Cacophony", 8787), new Link("ominous", "Ominous", 8788), new Link("pebble", "Pebble", 8789), new Link("trolls", "Trolls", 8790), new Link("transporter", "Transporter", 8791), new Link("skytram", "Sky-Tram", 8792), new Link("dockfortress", "Dock Fortress", 8793), new Link("odinseye", "Odin's Eye", 8794), new Link("skyherd", "Skyherd", 8795), new Link("lawspeaker", "Lawspeaker", 8796), new Link("ymirsmarrow", "Ymir's Marrow", 8797), new Link("fogwarden", "Fogwarden", 8798), new Link("raiders", "DFG Raiders", 8799), new Link("scoutcopter", "Scout Copter", 8800) }; 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 OdinsEye { public class OdinsEyeCamera : MonoBehaviour, Hoverable, Interactable, TextReceiver { public static readonly List<OdinsEyeCamera> AllCameras = new List<OdinsEyeCamera>(); private ZNetView m_nview; private Transform m_headPivot; private GameObject m_visualTrophy; private GameObject m_eyeGlow; private Camera m_camera; private GameObject m_camObject; private string m_cachedTrophyName = ""; private float m_currentYaw; private float m_currentPitch; private float m_currentFov = 60f; public string CameraId { get { if (!((Object)(object)m_nview != (Object)null) || !m_nview.IsValid()) { return ((Object)this).GetInstanceID().ToString(); } return ((object)Unsafe.As<ZDOID, ZDOID>(ref m_nview.GetZDO().m_uid)/*cast due to .constrained prefix*/).ToString(); } } private void Awake() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_007b: 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) m_nview = ((Component)this).GetComponent<ZNetView>(); StripResidualStationComponents(); Transform val = ((Component)this).transform.Find("OdinsEyeCameraModel/HeadPivot") ?? ((Component)this).transform.Find("HeadPivot"); if ((Object)(object)val != (Object)null) { m_headPivot = val; } else { GameObject val2 = new GameObject("HeadPivot"); val2.transform.SetParent(((Component)this).transform, false); val2.transform.localPosition = new Vector3(0f, 0.611f, 0.356f); val2.transform.localRotation = Quaternion.identity; m_headPivot = val2.transform; } SetupCameraSensor(); if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { m_nview.Register<string>("RPC_SetTrophy", (Action<long, string>)RPC_SetTrophy); } } private void OnEnable() { if (!AllCameras.Contains(this)) { AllCameras.Add(this); } } private void OnDisable() { AllCameras.Remove(this); } private void Start() { RefreshFromZDO(); } private void SetupCameraSensor() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)m_camObject != (Object)null)) { Transform val = (((Object)(object)m_headPivot != (Object)null) ? m_headPivot.Find("SurveillanceSensor") : null); if ((Object)(object)val != (Object)null) { m_camObject = ((Component)val).gameObject; m_camera = m_camObject.GetComponent<Camera>(); } else { m_camObject = new GameObject("SurveillanceSensor"); m_camObject.transform.SetParent(((Object)(object)m_headPivot != (Object)null) ? m_headPivot : ((Component)this).transform, false); m_camObject.transform.localPosition = new Vector3(0f, 0.134f, 0.325f); m_camObject.transform.localRotation = Quaternion.identity; m_camera = m_camObject.AddComponent<Camera>(); } if ((Object)(object)m_camera == (Object)null) { m_camera = m_camObject.AddComponent<Camera>(); } ((Behaviour)m_camera).enabled = false; m_camera.nearClipPlane = 0.15f; m_camera.farClipPlane = ((OdinsEyePlugin.CameraFarClip != null) ? OdinsEyePlugin.CameraFarClip.Value : 80f); m_camera.fieldOfView = 60f; m_camera.clearFlags = (CameraClearFlags)1; if ((Object)(object)Camera.main != (Object)null) { m_camera.cullingMask = Camera.main.cullingMask; } } } private void Update() { //IL_0144: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)m_nview == (Object)null) && m_nview.IsValid()) { string text = m_nview.GetZDO().GetString("OE_Trophy", ""); if (text != m_cachedTrophyName) { UpdateVisual(text); } float num = m_nview.GetZDO().GetFloat("OE_Yaw", 0f); float num2 = m_nview.GetZDO().GetFloat("OE_Pitch", 0f); float num3 = m_nview.GetZDO().GetFloat("OE_Fov", 60f); if (ScryingSession.IsActive && (Object)(object)ScryingSession.CurrentCamera == (Object)(object)this) { m_currentYaw = num; m_currentPitch = num2; m_currentFov = num3; } else { m_currentYaw = Mathf.Lerp(m_currentYaw, num, Time.deltaTime * 12f); m_currentPitch = Mathf.Lerp(m_currentPitch, num2, Time.deltaTime * 12f); m_currentFov = Mathf.Lerp(m_currentFov, num3, Time.deltaTime * 12f); } if ((Object)(object)m_headPivot != (Object)null) { m_headPivot.localRotation = Quaternion.Euler(m_currentPitch, m_currentYaw, 0f); } if ((Object)(object)m_camera != (Object)null) { m_camera.fieldOfView = m_currentFov; } } } public void RefreshFromZDO() { if (!((Object)(object)m_nview == (Object)null) && m_nview.IsValid()) { string trophyPrefabName = m_nview.GetZDO().GetString("OE_Trophy", ""); UpdateVisual(trophyPrefabName); m_currentYaw = m_nview.GetZDO().GetFloat("OE_Yaw", 0f); m_currentPitch = m_nview.GetZDO().GetFloat("OE_Pitch", 0f); m_currentFov = m_nview.GetZDO().GetFloat("OE_Fov", 60f); } } public string GetTrophyPrefab() { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { return ""; } return m_nview.GetZDO().GetString("OE_Trophy", ""); } public string GetCameraName() { if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { return "Camera"; } string text = m_nview.GetZDO().GetString("OE_Name", ""); if (!string.IsNullOrEmpty(text)) { return text; } int num = AllCameras.IndexOf(this) + 1; string trophyPrefab = GetTrophyPrefab(); if (!string.IsNullOrEmpty(trophyPrefab)) { return $"Cam {num} ({GetTrophyDisplayName(trophyPrefab)})"; } return $"Cam {num} (Empty Mount)"; } public string GetTrophyDisplayName(string prefabName = null) { if (string.IsNullOrEmpty(prefabName)) { prefabName = GetTrophyPrefab(); } if (string.IsNullOrEmpty(prefabName)) { return "None"; } GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(prefabName) : null); if ((Object)(object)val != (Object)null) { ItemDrop component = val.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null && component.m_itemData != null && component.m_itemData.m_shared != null) { return Localization.instance.Localize(component.m_itemData.m_shared.m_name); } } if (prefabName.StartsWith("Trophy")) { return prefabName.Substring(6) + " Head"; } return prefabName; } public float GetYaw() { if (!((Object)(object)m_nview != (Object)null) || !m_nview.IsValid()) { return m_currentYaw; } return m_nview.GetZDO().GetFloat("OE_Yaw", 0f); } public float GetPitch() { if (!((Object)(object)m_nview != (Object)null) || !m_nview.IsValid()) { return m_currentPitch; } return m_nview.GetZDO().GetFloat("OE_Pitch", 0f); } public float GetFOV() { if (!((Object)(object)m_nview != (Object)null) || !m_nview.IsValid()) { return m_currentFov; } return m_nview.GetZDO().GetFloat("OE_Fov", 60f); } public void SetPTZ(float yaw, float pitch, float fov) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) yaw = Mathf.Clamp(yaw, -75f, 75f); pitch = Mathf.Clamp(pitch, -50f, 40f); fov = Mathf.Clamp(fov, 25f, 75f); if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { m_nview.GetZDO().Set("OE_Yaw", yaw); m_nview.GetZDO().Set("OE_Pitch", pitch); m_nview.GetZDO().Set("OE_Fov", fov); } m_currentYaw = yaw; m_currentPitch = pitch; m_currentFov = fov; if ((Object)(object)m_headPivot != (Object)null) { m_headPivot.localRotation = Quaternion.Euler(pitch, yaw, 0f); } if ((Object)(object)m_camera != (Object)null) { m_camera.fieldOfView = fov; } } public void AdjustPTZ(float deltaYaw, float deltaPitch, float deltaFov) { SetPTZ(GetYaw() + deltaYaw, GetPitch() + deltaPitch, GetFOV() + deltaFov); } public Vector3 GetCameraEyePosition() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_headPivot != (Object)null) { return m_headPivot.position + ((Component)this).transform.TransformDirection(new Vector3(0f, 0.134f, 0.325f)); } if ((Object)(object)m_camObject != (Object)null) { return m_camObject.transform.position; } return ((Component)this).transform.position; } public Quaternion GetCameraEyeRotation() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_headPivot != (Object)null) { return m_headPivot.rotation; } if ((Object)(object)m_camObject != (Object)null) { return m_camObject.transform.rotation; } return ((Component)this).transform.rotation; } public void RenderToTexture(RenderTexture rt) { if ((Object)(object)m_camera == (Object)null) { SetupCameraSensor(); } if (!((Object)(object)m_camera == (Object)null) && !((Object)(object)rt == (Object)null)) { if ((Object)(object)Camera.main != (Object)null && m_camera.cullingMask != Camera.main.cullingMask) { m_camera.cullingMask = Camera.main.cullingMask; } m_camera.targetTexture = rt; m_camera.Render(); m_camera.targetTexture = null; } } private void RPC_SetTrophy(long sender, string trophyName) { UpdateVisual(trophyName); } private void UpdateVisual(string trophyPrefabName) { //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) m_cachedTrophyName = trophyPrefabName; if ((Object)(object)m_visualTrophy != (Object)null) { Object.Destroy((Object)(object)m_visualTrophy); m_visualTrophy = null; } if ((Object)(object)m_eyeGlow != (Object)null) { Object.Destroy((Object)(object)m_eyeGlow); m_eyeGlow = null; } if (string.IsNullOrEmpty(trophyPrefabName) || (Object)(object)ObjectDB.instance == (Object)null) { return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(trophyPrefabName); if ((Object)(object)itemPrefab == (Object)null) { return; } m_visualTrophy = Object.Instantiate<GameObject>(itemPrefab, ((Component)this).transform); ((Object)m_visualTrophy).name = "Mounted_" + trophyPrefabName; Component[] componentsInChildren = m_visualTrophy.GetComponentsInChildren<Component>(true); foreach (Component val in componentsInChildren) { if (!(val is Transform) && !(val is MeshFilter) && !(val is MeshRenderer) && !(val is SkinnedMeshRenderer)) { Object.Destroy((Object)(object)val); } } float num = 0.75f; if (trophyPrefabName.Contains("Troll") || trophyPrefabName.Contains("Lox") || trophyPrefabName.Contains("SeekerQueen")) { num = 0.38f; } m_visualTrophy.transform.localPosition = new Vector3(0f, 0.98f, 0.08f); m_visualTrophy.transform.localRotation = Quaternion.identity; m_visualTrophy.transform.localScale = Vector3.one * num; CreateEyeEmbers(); } private void CreateEyeEmbers() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)m_visualTrophy == (Object)null)) { m_eyeGlow = new GameObject("EyeEmbers"); m_eyeGlow.transform.SetParent(m_visualTrophy.transform, false); m_eyeGlow.transform.localPosition = new Vector3(0f, 0.12f, 0.18f); GameObject val = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val).name = "LeftEmber"; val.transform.SetParent(m_eyeGlow.transform, false); val.transform.localPosition = new Vector3(-0.065f, 0f, 0f); val.transform.localScale = Vector3.one * 0.045f; Object.Destroy((Object)(object)val.GetComponent<Collider>()); GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)obj).name = "RightEmber"; obj.transform.SetParent(m_eyeGlow.transform, false); obj.transform.localPosition = new Vector3(0.065f, 0f, 0f); obj.transform.localScale = Vector3.one * 0.045f; Object.Destroy((Object)(object)obj.GetComponent<Collider>()); Material val2 = new Material(Shader.Find("Unlit/Color") ?? Shader.Find("Standard") ?? OdinsEyeGlb.FindPieceShader()); Color val3 = default(Color); ((Color)(ref val3))..ctor(0.22f, 0.74f, 0.98f, 1f); if (val2.HasProperty("_Color")) { val2.color = val3; } if (val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); val2.SetColor("_EmissionColor", val3 * 2f); } val.GetComponent<Renderer>().material = val2; obj.GetComponent<Renderer>().material = val2; } } public List<Character> ScanThreats() { //IL_0020: 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_0047: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) List<Character> list = new List<Character>(); float num = ((OdinsEyePlugin.ThreatScanRange != null) ? OdinsEyePlugin.ThreatScanRange.Value : 35f); Vector3 cameraEyePosition = GetCameraEyePosition(); Vector3 val = (((Object)(object)m_headPivot != (Object)null) ? m_headPivot.forward : ((Component)this).transform.forward); RaycastHit val3 = default(RaycastHit); foreach (Character allCharacter in Character.GetAllCharacters()) { if (!((Object)(object)allCharacter == (Object)null) && !allCharacter.IsPlayer() && !allCharacter.IsTamed() && !allCharacter.IsDead()) { Vector3 val2 = ((Component)allCharacter).transform.position - cameraEyePosition; if (!(((Vector3)(ref val2)).magnitude > num) && !(Vector3.Angle(val, val2) > 55f) && (!Physics.Linecast(cameraEyePosition, allCharacter.GetCenterPoint(), ref val3) || !((Object)(object)((Component)((RaycastHit)(ref val3)).collider).gameObject != (Object)(object)((Component)allCharacter).gameObject) || ((Component)((RaycastHit)(ref val3)).collider).transform.IsChildOf(((Component)allCharacter).transform))) { list.Add(allCharacter); } } } return list; } public string GetHoverText() { string trophyPrefab = GetTrophyPrefab(); string cameraName = GetCameraName(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<color=#38bdf8><b>[Odin's Eye: " + cameraName + "]</b></color>\n"); if (string.IsNullOrEmpty(trophyPrefab)) { stringBuilder.Append("[<color=yellow><b>$KEY_Use</b></color>] Mount Monster Trophy from Inventory"); } else { stringBuilder.Append("Mounted: <color=yellow>" + GetTrophyDisplayName(trophyPrefab) + "</color>\n"); stringBuilder.Append("[<color=yellow><b>$KEY_Use</b></color>] Swap Trophy\n"); stringBuilder.Append("[<color=yellow><b><Shift> + $KEY_Use</b></color>] Rename Camera\n"); stringBuilder.Append("[<color=yellow><b><Alt> + $KEY_Use</b></color>] Dismount Trophy"); } return Localization.instance.Localize(stringBuilder.ToString()); } public string GetHoverName() { return "Odin's Eyeera"; } public float GetHoverOffset() { return 0f; } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold) { return false; } Player val = (Player)(object)((user is Player) ? user : null); if ((Object)(object)val == (Object)null) { return false; } if ((Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) && (Object)(object)TextInput.instance != (Object)null) { TextInput.instance.RequestText((TextReceiver)(object)this, "Camera Name:", 24); return true; } if (alt) { string trophyPrefab = GetTrophyPrefab(); if (!string.IsNullOrEmpty(trophyPrefab)) { ReturnTrophyToPlayer(val, trophyPrefab); m_nview.GetZDO().Set("OE_Trophy", ""); m_nview.InvokeRPC(ZNetView.Everybody, "RPC_SetTrophy", new object[1] { "" }); ((Character)val).Message((MessageType)2, "Dismounted trophy from camera.", 0, (Sprite)null, false); return true; } return false; } ItemData val2 = FindTrophyInInventory(val); if (val2 == null) { ((Character)val).Message((MessageType)2, "You need a monster trophy in your inventory to mount!", 0, (Sprite)null, false); return false; } string trophyPrefab2 = GetTrophyPrefab(); if (!string.IsNullOrEmpty(trophyPrefab2)) { ReturnTrophyToPlayer(val, trophyPrefab2); } string name = ((Object)val2.m_dropPrefab).name; ((Humanoid)val).GetInventory().RemoveOneItem(val2); m_nview.GetZDO().Set("OE_Trophy", name); m_nview.InvokeRPC(ZNetView.Everybody, "RPC_SetTrophy", new object[1] { name }); ((Character)val).Message((MessageType)2, "Mounted " + GetTrophyDisplayName(name) + " onto Odin's Eye!", 0, (Sprite)null, false); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } private ItemData FindTrophyInInventory(Player player) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Invalid comparison between Unknown and I4 if ((Object)(object)player == (Object)null || ((Humanoid)player).GetInventory() == null) { return null; } foreach (ItemData allItem in ((Humanoid)player).GetInventory().GetAllItems()) { if (allItem != null && !((Object)(object)allItem.m_dropPrefab == (Object)null) && ((int)allItem.m_shared.m_itemType == 13 || ((Object)allItem.m_dropPrefab).name.StartsWith("Trophy", StringComparison.OrdinalIgnoreCase))) { return allItem; } } return null; } private void ReturnTrophyToPlayer(Player player, string trophyPrefabName) { //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_0071: 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_007b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)player == (Object)null || string.IsNullOrEmpty(trophyPrefabName) || (Object)(object)ObjectDB.instance == (Object)null) { return; } GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(trophyPrefabName); if (!((Object)(object)itemPrefab == (Object)null)) { ItemDrop component = itemPrefab.GetComponent<ItemDrop>(); if (!((Object)(object)component == (Object)null) && !((Humanoid)player).GetInventory().AddItem(itemPrefab, 1)) { ItemDrop.DropItem(component.m_itemData, 1, ((Component)player).transform.position + Vector3.up * 0.5f, Quaternion.identity); } } } public string GetText() { return GetCameraName(); } public void SetText(string text) { if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { m_nview.GetZDO().Set("OE_Name", (text != null) ? text.Trim() : ""); } } private void StripResidualStationComponents() { CraftingStation[] componentsInChildren = ((Component)this).GetComponentsInChildren<CraftingStation>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } StationExtension[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<StationExtension>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } CircleProjector[] componentsInChildren3 = ((Component)this).GetComponentsInChildren<CircleProjector>(true); foreach (CircleProjector val in componentsInChildren3) { if ((Object)(object)((Component)val).gameObject == (Object)(object)((Component)this).gameObject) { Object.DestroyImmediate((Object)(object)val); } else { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } } EffectArea[] componentsInChildren4 = ((Component)this).GetComponentsInChildren<EffectArea>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren4[i]); } Sign[] componentsInChildren5 = ((Component)this).GetComponentsInChildren<Sign>(true); for (int i = 0; i < componentsInChildren5.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren5[i]); } ItemStand[] componentsInChildren6 = ((Component)this).GetComponentsInChildren<ItemStand>(true); for (int i = 0; i < componentsInChildren6.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren6[i]); } Container[] componentsInChildren7 = ((Component)this).GetComponentsInChildren<Container>(true); for (int i = 0; i < componentsInChildren7.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren7[i]); } HoverText[] componentsInChildren8 = ((Component)this).GetComponentsInChildren<HoverText>(true); for (int i = 0; i < componentsInChildren8.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren8[i]); } Piece component = ((Component)this).GetComponent<Piece>(); if ((Object)(object)component != (Object)null) { component.m_craftingStation = null; } } } public static class OdinsEyeGlb { [Serializable] private class GLTFRoot { public GLTFNode[] nodes; public GLTFMesh[] meshes; public GLTFMaterial[] materials; public GLTFAccessor[] accessors; public GLTFBufferView[] bufferViews; public GLTFTexture[] textures; public GLTFImage[] images; } [Serializable] private class GLTFMesh { public string name; public GLTFPrimitive[] primitives; } [Serializable] private class GLTFPrimitive { public GLTFAttributes attributes; public int indices = -1; public int material = -1; } [Serializable] private class GLTFAttributes { public int POSITION = -1; public int NORMAL = -1; public int TEXCOORD_0 = -1; } [Serializable] private class GLTFNode { public string name; public int mesh = -1; public int[] children; } [Serializable] private class GLTFMaterial { public string name; public GLTFPBR pbrMetallicRoughness; public GLTFTextureInfo normalTexture; } [Serializable] private class GLTFPBR { public float[] baseColorFactor; public GLTFTextureInfo baseColorTexture; } [Serializable] private class GLTFTextureInfo { public int index = -1; } [Serializable] private class GLTFImage { public string mimeType; public int bufferView = -1; public string name; } [Serializable] private class GLTFTexture { public int source = -1; } [Serializable] private class GLTFAccessor { public int bufferView; public int byteOffset; public int componentType; public int count; public string type; } [Serializable] private class GLTFBufferView { public int buffer; public int byteOffset; public int byteLength; public int byteStride; } private static readonly HashSet<int> HeadParts = new HashSet<int> { 1, 4, 5, 8, 12, 13, 21 }; private const float HingeRawX = 0.026f; private const float HingeRawY = 0.611f; private const float HingeRawZ = 0f; private const float WallOffsetZ = 0.33f; public static string ResolveModelPath() { string[] array = new string[5] { Path.Combine(OdinsEyePlugin.PluginDirectory ?? "", "cam.glb"), Path.Combine(Paths.PluginPath ?? "", "DFG-OdinsEye", "cam.glb"), Path.Combine(Paths.PluginPath ?? "", "OdinsEye", "cam.glb"), Path.Combine(Paths.PluginPath ?? "", "cam.glb"), "C:\\Users\\dhugh\\Documents\\MyMods\\OdinsEye\\cam.glb" }; foreach (string text in array) { if (!string.IsNullOrEmpty(text) && File.Exists(text)) { return text; } } return null; } public static string ResolveConsoleModelPath() { string[] array = new string[5] { Path.Combine(OdinsEyePlugin.PluginDirectory ?? "", "console.glb"), Path.Combine(Paths.PluginPath ?? "", "DFG-OdinsEye", "console.glb"), Path.Combine(Paths.PluginPath ?? "", "OdinsEye", "console.glb"), Path.Combine(Paths.PluginPath ?? "", "console.glb"), "C:\\Users\\dhugh\\Documents\\MyMods\\OdinsEye\\console.glb" }; foreach (string text in array) { if (!string.IsNullOrEmpty(text) && File.Exists(text)) { return text; } } return null; } private static bool ExtractGlbChunks(string glbPath, out string json, out byte[] binData) { json = null; binData = null; if (string.IsNullOrEmpty(glbPath) || !File.Exists(glbPath)) { return false; } try { byte[] array = File.ReadAllBytes(glbPath); if (array.Length < 20 || BitConverter.ToUInt32(array, 0) != 1179937895) { OdinsEyePlugin.Log.LogError((object)("Odin's Eye: " + Path.GetFileName(glbPath) + " is not a valid GLB file.")); return false; } int num = 12; while (num < array.Length && num + 8 <= array.Length) { uint num2 = BitConverter.ToUInt32(array, num); uint num3 = BitConverter.ToUInt32(array, num + 4); num += 8; switch (num3) { case 1313821514u: json = Encoding.UTF8.GetString(array, num, (int)num2); break; case 5130562u: binData = new byte[num2]; Buffer.BlockCopy(array, num, binData, 0, (int)num2); break; } num += (int)num2; num = (num + 3) & -4; } return !string.IsNullOrEmpty(json) && binData != null; } catch (Exception ex) { OdinsEyePlugin.Log.LogError((object)("Odin's Eye: error reading GLB " + glbPath + ": " + ex.Message)); return false; } } public static bool AttachModel(GameObject camPrefab) { if ((Object)(object)camPrefab == (Object)null) { return false; } string text = ResolveModelPath(); if (string.IsNullOrEmpty(text)) { OdinsEyePlugin.Log.LogWarning((object)"Odin's Eye: cam.glb not found, using fallback visual."); return false; } try { if (!ExtractGlbChunks(text, out var json, out var binData)) { OdinsEyePlugin.Log.LogError((object)"Odin's Eye: Failed to extract JSON/BIN from cam.glb."); return false; } return BuildModelHierarchy(camPrefab, json, binData); } catch (Exception ex) { OdinsEyePlugin.Log.LogError((object)("Odin's Eye: exception building cam model: " + ex)); return false; } } public static bool AttachConsoleModel(GameObject consolePrefab) { if ((Object)(object)consolePrefab == (Object)null) { return false; } string text = ResolveConsoleModelPath(); if (string.IsNullOrEmpty(text)) { OdinsEyePlugin.Log.LogWarning((object)"Odin's Eye: console.glb not found, using fallback visual."); return false; } try { if (!ExtractGlbChunks(text, out var json, out var binData)) { OdinsEyePlugin.Log.LogError((object)"Odin's Eye: Failed to extract JSON/BIN from console.glb."); return false; } return BuildConsoleHierarchy(consolePrefab, json, binData); } catch (Exception ex) { OdinsEyePlugin.Log.LogError((object)("Odin's Eye: exception building console model: " + ex)); return false; } } private static bool BuildConsoleHierarchy(GameObject consolePrefab, string json, byte[] binData) { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Expected O, but got Unknown //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_05b1: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_05fe: Unknown result type (might be due to invalid IL or missing references) //IL_0603: Unknown result type (might be due to invalid IL or missing references) //IL_060e: 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_061b: Expected O, but got Unknown //IL_0630: Unknown result type (might be due to invalid IL or missing references) //IL_064f: Unknown result type (might be due to invalid IL or missing references) //IL_0685: Unknown result type (might be due to invalid IL or missing references) //IL_068a: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06b2: Unknown result type (might be due to invalid IL or missing references) //IL_06d8: Unknown result type (might be due to invalid IL or missing references) //IL_0703: Unknown result type (might be due to invalid IL or missing references) //IL_0708: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_0730: Unknown result type (might be due to invalid IL or missing references) //IL_0756: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Expected O, but got Unknown //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_04e8: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Expected O, but got Unknown GLTFRoot gLTFRoot = JsonConvert.DeserializeObject<GLTFRoot>(json); if (gLTFRoot == null || gLTFRoot.meshes == null || gLTFRoot.meshes.Length == 0) { OdinsEyePlugin.Log.LogError((object)"Odin's Eye: failed to deserialize GLTF from console.glb."); return false; } Shader val = FindPieceShader(); GLTFBufferView[] bufferViews = gLTFRoot.bufferViews ?? new GLTFBufferView[0]; GLTFAccessor[] array = gLTFRoot.accessors ?? new GLTFAccessor[0]; GLTFImage[] images = gLTFRoot.images ?? new GLTFImage[0]; GLTFTexture[] array2 = gLTFRoot.textures ?? new GLTFTexture[0]; GLTFMaterial[] array3 = gLTFRoot.materials ?? new GLTFMaterial[0]; Dictionary<int, Texture2D> texCache = new Dictionary<int, Texture2D>(); Func<int, Texture2D> func = delegate(int imgIdx) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown if (imgIdx < 0 || imgIdx >= images.Length) { return (Texture2D)null; } if (texCache.TryGetValue(imgIdx, out var value)) { return value; } GLTFImage gLTFImage = images[imgIdx]; if (gLTFImage.bufferView < 0 || gLTFImage.bufferView >= bufferViews.Length) { return (Texture2D)null; } GLTFBufferView gLTFBufferView = bufferViews[gLTFImage.bufferView]; if (gLTFBufferView.byteOffset + gLTFBufferView.byteLength > binData.Length) { return (Texture2D)null; } byte[] array12 = new byte[gLTFBufferView.byteLength]; Buffer.BlockCopy(binData, gLTFBufferView.byteOffset, array12, 0, gLTFBufferView.byteLength); Texture2D val11 = new Texture2D(2, 2, (TextureFormat)4, false); if (ImageConversion.LoadImage(val11, array12)) { ((Texture)val11).wrapMode = (TextureWrapMode)0; ((Texture)val11).filterMode = (FilterMode)1; texCache[imgIdx] = val11; return val11; } Object.Destroy((Object)(object)val11); return (Texture2D)null; }; Material[] array4 = (Material[])(object)new Material[array3.Length]; for (int num = 0; num < array3.Length; num++) { GLTFMaterial gLTFMaterial = array3[num]; Material val2 = new Material(val); ((Object)val2).name = gLTFMaterial.name ?? $"ConsoleMat_{num}"; if (gLTFMaterial.pbrMetallicRoughness != null && gLTFMaterial.pbrMetallicRoughness.baseColorTexture != null) { int index = gLTFMaterial.pbrMetallicRoughness.baseColorTexture.index; if (index >= 0 && index < array2.Length) { int source = array2[index].source; Texture2D val3 = func(source); if ((Object)(object)val3 != (Object)null) { val2.mainTexture = (Texture)(object)val3; if (val2.HasProperty("_MainTex")) { val2.SetTexture("_MainTex", (Texture)(object)val3); } } } } if (gLTFMaterial.normalTexture != null && gLTFMaterial.normalTexture.index >= 0 && gLTFMaterial.normalTexture.index < array2.Length) { int source2 = array2[gLTFMaterial.normalTexture.index].source; Texture2D val4 = func(source2); if ((Object)(object)val4 != (Object)null && val2.HasProperty("_BumpMap")) { val2.SetTexture("_BumpMap", (Texture)(object)val4); val2.EnableKeyword("_NORMALMAP"); } } array4[num] = val2; } GameObject val5 = new GameObject("OdinsEyeConsoleModel"); val5.transform.SetParent(consolePrefab.transform, false); val5.transform.localPosition = Vector3.zero; val5.transform.localRotation = Quaternion.identity; for (int num2 = 0; num2 < gLTFRoot.meshes.Length; num2++) { GLTFMesh gLTFMesh = gLTFRoot.meshes[num2]; if (gLTFMesh.primitives == null || gLTFMesh.primitives.Length == 0) { continue; } GLTFPrimitive gLTFPrimitive = gLTFMesh.primitives[0]; if (gLTFPrimitive.attributes == null || gLTFPrimitive.attributes.POSITION < 0 || gLTFPrimitive.attributes.POSITION >= array.Length) { continue; } Vector3[] array5 = ReadVec3Accessor(array[gLTFPrimitive.attributes.POSITION], bufferViews, binData); if (array5 == null || array5.Length == 0) { continue; } Vector3[] array6 = ((gLTFPrimitive.attributes.NORMAL >= 0 && gLTFPrimitive.attributes.NORMAL < array.Length) ? ReadVec3Accessor(array[gLTFPrimitive.attributes.NORMAL], bufferViews, binData) : null); Vector2[] array7 = ((gLTFPrimitive.attributes.TEXCOORD_0 >= 0 && gLTFPrimitive.attributes.TEXCOORD_0 < array.Length) ? ReadVec2Accessor(array[gLTFPrimitive.attributes.TEXCOORD_0], bufferViews, binData) : null); int[] array8 = ((gLTFPrimitive.indices >= 0 && gLTFPrimitive.indices < array.Length) ? ReadIndicesAccessor(array[gLTFPrimitive.indices], bufferViews, binData) : null); Vector3[] array9 = (Vector3[])(object)new Vector3[array5.Length]; Vector3[] array10 = (Vector3[])(object)new Vector3[array5.Length]; for (int num3 = 0; num3 < array5.Length; num3++) { array9[num3] = array5[num3] * 1.35f; array10[num3] = ((array6 != null && num3 < array6.Length) ? array6[num3] : Vector3.up); } Mesh val6 = new Mesh(); ((Object)val6).name = $"ConsolePart_{num2}"; val6.indexFormat = (IndexFormat)1; val6.vertices = array9; val6.normals = array10; if (array7 != null && array7.Length == array9.Length) { val6.uv = array7; } if (array8 != null) { int[] array11 = new int[array8.Length]; for (int num4 = 0; num4 < array8.Length; num4 += 3) { array11[num4] = array8[num4]; array11[num4 + 1] = array8[num4 + 2]; array11[num4 + 2] = array8[num4 + 1]; } val6.triangles = array11; } val6.RecalculateBounds(); GameObject val7 = new GameObject($"Part_{num2}"); val7.transform.SetParent(val5.transform, false); val7.transform.localPosition = Vector3.zero; val7.transform.localRotation = Quaternion.identity; val7.AddComponent<MeshFilter>().sharedMesh = val6; MeshRenderer obj = val7.AddComponent<MeshRenderer>(); Material sharedMaterial = (Material)((gLTFPrimitive.material >= 0 && gLTFPrimitive.material < array4.Length && (Object)(object)array4[gLTFPrimitive.material] != (Object)null) ? ((object)array4[gLTFPrimitive.material]) : ((object)new Material(val))); ((Renderer)obj).sharedMaterial = sharedMaterial; } GameObject obj2 = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)obj2).name = "ScryingScreenQuad"; obj2.transform.SetParent(val5.transform, false); Object.DestroyImmediate((Object)(object)obj2.GetComponent<Collider>()); obj2.transform.localPosition = new Vector3(-0.18495f, 0.53055f, -0.221f); obj2.transform.localRotation = Quaternion.Euler(-24.9f, 0f, 0f); obj2.transform.localScale = new Vector3(0.48f, 0.36f, 1f); Material val8 = new Material(FindScreenShader()) { name = "ScryingScreenMat", color = Color.white }; if (val8.HasProperty("_Color")) { val8.SetColor("_Color", Color.white); } if (val8.HasProperty("_BaseColor")) { val8.SetColor("_BaseColor", Color.white); } if (val8.HasProperty("_Cull")) { val8.SetInt("_Cull", 0); } ((Renderer)obj2.GetComponent<MeshRenderer>()).sharedMaterial = val8; GameObject val9 = new GameObject("ScreenGlowLight"); val9.transform.SetParent(val5.transform, false); val9.transform.localPosition = new Vector3(-0.18495f, 0.53055f, -0.366f); Light obj3 = val9.AddComponent<Light>(); obj3.type = (LightType)2; obj3.color = new Color(0.35f, 0.75f, 1f); obj3.intensity = 0.5f; obj3.range = 1.3f; obj3.shadows = (LightShadows)0; GameObject val10 = new GameObject("GaugeGlowLight"); val10.transform.SetParent(val5.transform, false); val10.transform.localPosition = new Vector3(0.3321f, 0.47654998f, -0.01215f); Light obj4 = val10.AddComponent<Light>(); obj4.type = (LightType)2; obj4.color = new Color(1f, 0.42f, 0.05f); obj4.intensity = 0.85f; obj4.range = 1.4f; obj4.shadows = (LightShadows)0; OdinsEyePlugin.Log.LogInfo((object)"Odin's Eye: successfully built 3D console model from console.glb!"); return true; } public static bool AttachScreenModel(GameObject screenPrefab, float scale = 1f) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Expected O, but got Unknown //IL_00e7: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_030b: 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_0338: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Expected O, but got Unknown //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)screenPrefab == (Object)null) { return false; } Shader obj = FindPieceShader(); Shader val = FindScreenShader(); GameObject modelRoot = new GameObject("OdinsEyeScreenModel"); modelRoot.transform.SetParent(screenPrefab.transform, false); modelRoot.transform.localPosition = Vector3.zero; modelRoot.transform.localRotation = Quaternion.identity; Material val2 = new Material(obj) { name = "ScreenFrameWoodMat", color = new Color(0.28f, 0.2f, 0.14f) }; if (val2.HasProperty("_Color")) { val2.SetColor("_Color", new Color(0.28f, 0.2f, 0.14f)); } if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", new Color(0.28f, 0.2f, 0.14f)); } Material val3 = new Material(obj) { name = "ScreenFrameIronMat", color = new Color(0.18f, 0.18f, 0.2f) }; if (val3.HasProperty("_Color")) { val3.SetColor("_Color", new Color(0.18f, 0.18f, 0.2f)); } if (val3.HasProperty("_BaseColor")) { val3.SetColor("_BaseColor", new Color(0.18f, 0.18f, 0.2f)); } if ((Object)(object)ZNetScene.instance != (Object)null) { GameObject val4 = ZNetScene.instance.GetPrefab("piece_chest_wood") ?? ZNetScene.instance.GetPrefab("piece_workbench"); if ((Object)(object)val4 != (Object)null) { Renderer componentInChildren = val4.GetComponentInChildren<Renderer>(true); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.sharedMaterial != (Object)null && (Object)(object)componentInChildren.sharedMaterial.mainTexture != (Object)null) { val2.mainTexture = componentInChildren.sharedMaterial.mainTexture; if (val2.HasProperty("_MainTex")) { val2.SetTexture("_MainTex", componentInChildren.sharedMaterial.mainTexture); } } } } Action<string, Vector3, Vector3, Material> obj2 = delegate(string name, Vector3 localPos, Vector3 localScale, Material mat) { //IL_002a: 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_0046: Unknown result type (might be due to invalid IL or missing references) GameObject obj5 = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj5).name = name; obj5.transform.SetParent(modelRoot.transform, false); obj5.transform.localPosition = localPos; obj5.transform.localRotation = Quaternion.identity; obj5.transform.localScale = localScale; Object.DestroyImmediate((Object)(object)obj5.GetComponent<Collider>()); ((Renderer)obj5.GetComponent<MeshRenderer>()).sharedMaterial = mat; }; obj2("BackPlate", new Vector3(0f, 0f, 0.015f), new Vector3(1.28f * scale, 0.82f * scale, 0.03f), val2); float num = Mathf.Max(0.07f, 0.07f * Mathf.Sqrt(scale)); float num2 = 0.615f * scale; float num3 = 0.395f * scale; obj2("FrameTop", new Vector3(0f, num3, 0.045f), new Vector3(1.3f * scale, num, num), val2); obj2("FrameBottom", new Vector3(0f, 0f - num3, 0.045f), new Vector3(1.3f * scale, num, num), val2); obj2("FrameLeft", new Vector3(0f - num2, 0f, 0.045f), new Vector3(num, 0.72f * scale, num), val2); obj2("FrameRight", new Vector3(num2, 0f, 0.045f), new Vector3(num, 0.72f * scale, num), val2); float num4 = Mathf.Max(0.09f, 0.09f * Mathf.Sqrt(scale)); obj2("CornerTL", new Vector3(0f - num2, num3, 0.082f), new Vector3(num4, num4, 0.012f), val3); obj2("CornerTR", new Vector3(num2, num3, 0.082f), new Vector3(num4, num4, 0.012f), val3); obj2("CornerBL", new Vector3(0f - num2, 0f - num3, 0.082f), new Vector3(num4, num4, 0.012f), val3); obj2("CornerBR", new Vector3(num2, 0f - num3, 0.082f), new Vector3(num4, num4, 0.012f), val3); GameObject obj3 = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)obj3).name = "ScryingScreenQuad"; obj3.transform.SetParent(modelRoot.transform, false); Object.DestroyImmediate((Object)(object)obj3.GetComponent<Collider>()); obj3.transform.localPosition = new Vector3(0f, 0f, 0.042f); obj3.transform.localRotation = Quaternion.identity; obj3.transform.localScale = new Vector3(1.16f * scale, 0.72f * scale, 1f); Material val5 = new Material(val) { name = "ScryingScreenMat", color = Color.white }; if (val5.HasProperty("_Color")) { val5.SetColor("_Color", Color.white); } if (val5.HasProperty("_BaseColor")) { val5.SetColor("_BaseColor", Color.white); } if (val5.HasProperty("_Cull")) { val5.SetInt("_Cull", 0); } ((Renderer)obj3.GetComponent<MeshRenderer>()).sharedMaterial = val5; GameObject val6 = new GameObject("ScreenGlowLight"); val6.transform.SetParent(modelRoot.transform, false); val6.transform.localPosition = new Vector3(0f, 0f, 0.25f * scale); Light obj4 = val6.AddComponent<Light>(); obj4.type = (LightType)2; obj4.color = new Color(0.35f, 0.75f, 1f); obj4.intensity = Mathf.Clamp(0.55f * Mathf.Sqrt(scale), 0.55f, 1.6f); obj4.range = 2.5f * scale; obj4.shadows = (LightShadows)0; OdinsEyePlugin.Log.LogInfo((object)$"Odin's Eye: successfully attached 3D screen model for {((Object)screenPrefab).name} (scale: {scale:0.0}x)!"); return true; } private static bool BuildModelHierarchy(GameObject camPrefab, string json, byte[] binData) { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Expected O, but got Unknown //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Expected O, but got Unknown //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Expected O, but got Unknown //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0500: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05d7: Expected O, but got Unknown //IL_054e: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_056a: Unknown result type (might be due to invalid IL or missing references) //IL_056f: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0681: Unknown result type (might be due to invalid IL or missing references) //IL_0686: Unknown result type (might be due to invalid IL or missing references) //IL_0694: Unknown result type (might be due to invalid IL or missing references) //IL_069a: Unknown result type (might be due to invalid IL or missing references) //IL_06a4: Unknown result type (might be due to invalid IL or missing references) //IL_06aa: Unknown result type (might be due to invalid IL or missing references) //IL_06b4: Unknown result type (might be due to invalid IL or missing references) //IL_05b5: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_06f0: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_0589: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Unknown result type (might be due to invalid IL or missing references) //IL_05a5: Unknown result type (might be due to invalid IL or missing references) //IL_05aa: Unknown result type (might be due to invalid IL or missing references) //IL_0703: Expected O, but got Unknown GLTFRoot gLTFRoot = JsonConvert.DeserializeObject<GLTFRoot>(json); if (gLTFRoot == null || gLTFRoot.meshes == null) { OdinsEyePlugin.Log.LogError((object)"Odin's Eye: failed to deserialize GLTF from cam.glb."); return false; } Shader val = FindPieceShader(); GLTFBufferView[] bufferViews = gLTFRoot.bufferViews ?? new GLTFBufferView[0]; GLTFAccessor[] array = gLTFRoot.accessors ?? new GLTFAccessor[0]; GLTFImage[] images = gLTFRoot.images ?? new GLTFImage[0]; GLTFTexture[] array2 = gLTFRoot.textures ?? new GLTFTexture[0]; GLTFMaterial[] array3 = gLTFRoot.materials ?? new GLTFMaterial[0]; Dictionary<int, Texture2D> texCache = new Dictionary<int, Texture2D>(); Func<int, Texture2D> func = delegate(int imgIdx) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown if (imgIdx < 0 || imgIdx >= images.Length) { return (Texture2D)null; } if (texCache.TryGetValue(imgIdx, out var value)) { return value; } GLTFImage gLTFImage = images[imgIdx]; if (gLTFImage.bufferView < 0 || gLTFImage.bufferView >= bufferViews.Length) { return (Texture2D)null; } GLTFBufferView gLTFBufferView = bufferViews[gLTFImage.bufferView]; if (gLTFBufferView.byteOffset + gLTFBufferView.byteLength > binData.Length) { return (Texture2D)null; } byte[] array12 = new byte[gLTFBufferView.byteLength]; Buffer.BlockCopy(binData, gLTFBufferView.byteOffset, array12, 0, gLTFBufferView.byteLength); Texture2D val14 = new Texture2D(2, 2, (TextureFormat)4, false); if (ImageConversion.LoadImage(val14, array12)) { ((Texture)val14).wrapMode = (TextureWrapMode)0; ((Texture)val14).filterMode = (FilterMode)1; texCache[imgIdx] = val14; return val14; } Object.Destroy((Object)(object)val14); return (Texture2D)null; }; Material[] array4 = (Material[])(object)new Material[array3.Length]; for (int num = 0; num < array3.Length; num++) { GLTFMaterial gLTFMaterial = array3[num]; Material val2 = new Material(val); ((Object)val2).name = gLTFMaterial.name ?? $"Mat_{num}"; if (gLTFMaterial.pbrMetallicRoughness != null && gLTFMaterial.pbrMetallicRoughness.baseColorTexture != null) { int index = gLTFMaterial.pbrMetallicRoughness.baseColorTexture.index; if (index >= 0 && index < array2.Length) { int source = array2[index].source; Texture2D val3 = func(source); if ((Object)(object)val3 != (Object)null) { val2.mainTexture = (Texture)(object)val3; if (val2.HasProperty("_MainTex")) { val2.SetTexture("_MainTex", (Texture)(object)val3); } } } } if (num == 15) { val2.EnableKeyword("_EMISSION"); Color val4 = new Color(0.18f, 0.7f, 1f) * 1.8f; if (val2.HasProperty("_EmissionColor")) { val2.SetColor("_EmissionColor", val4); } if (val2.HasProperty("_EmissionMap") && (Object)(object)val2.mainTexture != (Object)null) { val2.SetTexture("_EmissionMap", val2.mainTexture); } } array4[num] = val2; } GameObject val5 = new GameObject("OdinsEyeCameraModel"); val5.transform.SetParent(camPrefab.transform, false); val5.transform.localPosition = Vector3.zero; val5.transform.localRotation = Quaternion.identity; GameObject val6 = new GameObject("StaticBase"); val6.transform.SetParent(val5.transform, false); val6.transform.localPosition = Vector3.zero; val6.transform.localRotation = Quaternion.identity; Vector3 localPosition = default(Vector3); ((Vector3)(ref localPosition))..ctor(0f, 0.611f, 0.356f); GameObject val7 = new GameObject("HeadPivot"); val7.transform.SetParent(val5.transform, false); val7.transform.localPosition = localPosition; val7.transform.localRotation = Quaternion.identity; GameObject val8 = new GameObject("SurveillanceSensor"); val8.transform.SetParent(val7.transform, false); val8.transform.localPosition = new Vector3(0f, 0.134f, 0.325f); val8.transform.localRotation = Quaternion.identity; Camera obj = val8.AddComponent<Camera>(); ((Behaviour)obj).enabled = false; obj.nearClipPlane = 0.15f; obj.farClipPlane = 80f; obj.fieldOfView = 60f; obj.clearFlags = (CameraClearFlags)1; for (int num2 = 0; num2 < gLTFRoot.meshes.Length; num2++) { GLTFMesh gLTFMesh = gLTFRoot.meshes[num2]; if (gLTFMesh.primitives == null || gLTFMesh.primitives.Length == 0) { continue; } GLTFPrimitive gLTFPrimitive = gLTFMesh.primitives[0]; if (gLTFPrimitive.attributes == null || gLTFPrimitive.attributes.POSITION < 0 || gLTFPrimitive.attributes.POSITION >= array.Length) { continue; } Vector3[] array5 = ReadVec3Accessor(array[gLTFPrimitive.attributes.POSITION], bufferViews, binData); if (array5 == null || array5.Length == 0) { continue; } Vector3[] array6 = ((gLTFPrimitive.attributes.NORMAL >= 0 && gLTFPrimitive.attributes.NORMAL < array.Length) ? ReadVec3Accessor(array[gLTFPrimitive.attributes.NORMAL], bufferViews, binData) : null); Vector2[] array7 = ((gLTFPrimitive.attributes.TEXCOORD_0 >= 0 && gLTFPrimitive.attributes.TEXCOORD_0 < array.Length) ? ReadVec2Accessor(array[gLTFPrimitive.attributes.TEXCOORD_0], bufferViews, binData) : null); int[] array8 = ((gLTFPrimitive.indices >= 0 && gLTFPrimitive.indices < array.Length) ? ReadIndicesAccessor(array[gLTFPrimitive.indices], bufferViews, binData) : null); bool flag = HeadParts.Contains(num2); Transform val9 = (flag ? val7.transform : val6.transform); Vector3[] array9 = (Vector3[])(object)new Vector3[array5.Length]; Vector3[] array10 = (Vector3[])(object)new Vector3[array5.Length]; for (int num3 = 0; num3 < array5.Length; num3++) { Vector3 val10 = array5[num3]; if (flag) { float num4 = val10.x - 0.026f; float num5 = val10.y - 0.611f; float num6 = val10.z - 0f; array9[num3] = new Vector3(0f - num6, num5, num4); } else { array9[num3] = new Vector3(0f - val10.z, val10.y, val10.x + 0.33f); } if (array6 != null && num3 < array6.Length) { Vector3 val11 = array6[num3]; array10[num3] = new Vector3(0f - val11.z, val11.y, val11.x); } else { array10[num3] = Vector3.up; } } Mesh val12 = new Mesh(); ((Object)val12).name = $"PartMesh_{num2}"; val12.vertices = array9; val12.normals = array10; if (array7 != null && array7.Length == array9.Length) { val12.uv = array7; } if (array8 != null) { int[] array11 = new int[array8.Length]; for (int num7 = 0; num7 < array8.Length; num7 += 3) { array11[num7] = array8[num7]; array11[num7 + 1] = array8[num7 + 2]; array11[num7 + 2] = array8[num7 + 1]; } val12.triangles = array11; } val12.RecalculateBounds(); GameObject val13 = new GameObject($"Part_{num2}"); val13.transform.SetParent(val9, false); val13.transform.localPosition = Vector3.zero; val13.transform.localRotation = Quaternion.identity; val13.AddComponent<MeshFilter>().sharedMesh = val12; MeshRenderer obj2 = val13.AddComponent<MeshRenderer>(); Material sharedMaterial = (Material)((gLTFPrimitive.material >= 0 && gLTFPrimitive.material < array4.Length && (Object)(object)array4[gLTFPrimitive.material] != (Object)null) ? ((object)array4[gLTFPrimitive.material]) : ((object)new Material(val))); ((Renderer)obj2).sharedMaterial = sharedMaterial; } OdinsEyePlugin.Log.LogInfo((object)"Odin's Eye: successfully built 3D camera model from cam.glb!"); return true; } public static Shader FindPieceShader() { string[] array = new string[4] { "Custom/Piece", "Custom/StaticObject", "Custom/Creature", "Standard" }; for (int i = 0; i < array.Length; i++) { Shader val = Shader.Find(array[i]); if ((Object)(object)val != (Object)null) { return val; } } if ((Object)(object)ZNetScene.instance != (Object)null) { array = new string[4] { "piece_workbench", "piece_chest_wood", "piece_stonecutter", "piece_bed" }; foreach (string text in array) { GameObject prefab = ZNetScene.instance.GetPrefab(text); if ((Object)(object)prefab != (Object)null) { Renderer componentInChildren = prefab.GetComponentInChildren<Renderer>(true); if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.sharedMaterial != (Object)null && (Object)(object)componentInChildren.sharedMaterial.shader != (Object)null) { return componentInChildren.sharedMaterial.shader; } } } } try { Shader[] array2 = Resources.FindObjectsOfTypeAll<Shader>(); foreach (Shader val2 in array2) { if (!((Object)(object)val2 == (Object)null)) { switch (((Object)val2).name) { case "Custom/Piece": case "Custom/StaticObject": case "Custom/Creature": case "Standard": return val2; } } } } catch { } return Shader.Find("Sprites/Default") ?? Shader.Find("UI/Default") ?? Shader.Find("Legacy Shaders/Diffuse") ?? Shader.Find("Hidden/InternalErrorShader"); } public static Shader FindScreenShader() { Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("UI/Default") ?? Shader.Find("Unlit/Texture"); if ((Object)(object)val != (Object)null) { return val; } return FindPieceShader(); } private static Vector3[] ReadVec3Accessor(GLTFAccessor accessor, GLTFBufferView[] bufferViews, byte[] binData) { //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) if (accessor == null || accessor.bufferView < 0 || accessor.bufferView >= bufferViews.Length) { return null; } GLTFBufferView gLTFBufferView = bufferViews[accessor.bufferView]; int num = gLTFBufferView.byteOffset + accessor.byteOffset; int count = accessor.count; int num2 = ((gLTFBufferView.byteStride > 0) ? gLTFBufferView.byteStride : 12); Vector3[] array = (Vector3[])(object)new Vector3[count]; for (int i = 0; i < count; i++) { int num3 = num + i * num2; if (num3 + 12 <= binData.Length) { array[i] = new Vector3(BitConverter.ToSingle(binData, num3), BitConverter.ToSingle(binData, num3 + 4), BitConverter.ToSingle(binData, num3 + 8)); } } return array; } private static Vector2[] ReadVec2Accessor(GLTFAccessor accessor, GLTFBufferView[] bufferViews, byte[] binData) { //IL_008c: 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 (accessor == null || accessor.bufferView < 0 || accessor.bufferView >= bufferViews.Length) { return null; } GLTFBufferView gLTFBufferView = bufferViews[accessor.bufferView]; int num = gLTFBufferView.byteOffset + accessor.byteOffset; int count = accessor.count; int num2 = ((gLTFBufferView.byteStride > 0) ? gLTFBufferView.byteStride : 8); Vector2[] array = (Vector2[])(object)new Vector2[count]; for (int i = 0; i < count; i++) { int num3 = num + i * num2; if (num3 + 8 <= binData.Length) { float num4 = BitConverter.ToSingle(binData, num3); float num5 = BitConverter.ToSingle(binData, num3 + 4); array[i] = new Vector2(num4, 1f - num5); } } return array; } private static int[] ReadIndicesAccessor(GLTFAccessor accessor, GLTFBufferView[] bufferViews, byte[] binData) { if (accessor == null || accessor.bufferView < 0 || accessor.bufferView >= bufferViews.Length) { return null; } GLTFBufferView gLTFBufferView = bufferViews[accessor.bufferView]; int num = gLTFBufferView.byteOffset + accessor.byteOffset; int count = accessor.count; int[] array = new int[count]; if (accessor.componentType == 5123) { int num2 = ((gLTFBufferView.byteStride > 0) ? gLTFBufferView.byteStride : 2); for (int i = 0; i < count; i++) { int num3 = num + i * num2; if (num3 + 2 <= binData.Length) { array[i] = BitConverter.ToUInt16(binData, num3); } } } else if (accessor.componentType == 5125) { int num4 = ((gLTFBufferView.byteStride > 0) ? gLTFBufferView.byteStride : 4); for (int j = 0; j < count; j++) { int num5 = num + j * num4; if (num5 + 4 <= binData.Length) { array[j] = (int)BitConverter.ToUInt32(binData, num5); } } } else if (accessor.componentType == 5121) { int num6 = ((gLTFBufferView.byteStride <= 0) ? 1 : gLTFBufferView.byteStride); for (int k = 0; k < count; k++) { int num7 = num + k * num6; if (num7 < binData.Length) { array[k] = binData[num7]; } } } return array; } } public class OdinsEyeOrb : MonoBehaviour, Hoverable, Interactable, TextReceiver { public static readonly List<OdinsEyeOrb> AllOrbs = new List<OdinsEyeOrb>(); private ZNetView m_nview; private GameObject m_orbVisual; private Renderer m_orbRenderer; private Material m_orbMaterial; private RenderTexture m_renderTexture; private float m_renderTimer; private int m_selectedCameraIndex; public RenderTexture FeedTexture => m_renderTexture; private void Awake() { m_nview = ((Component)this).GetComponent<ZNetView>(); StripResidualStationComponents(); SetupOrbVisual(); } private void StripResidualStationComponents() { CraftingStation[] componentsInChildren = ((Component)this).GetComponentsInChildren<CraftingStation>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } StationExtension[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<StationExtension>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } CircleProjector[] componentsInChildren3 = ((Component)this).GetComponentsInChildren<CircleProjector>(true); foreach (CircleProjector val in componentsInChildren3) { if ((Object)(object)((Component)val).gameObject == (Object)(object)((Component)this).gameObject) { Object.DestroyImmediate((Object)(object)val); } else { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); } } EffectArea[] componentsInChildren4 = ((Component)this).GetComponentsInChildren<EffectArea>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren4[i]); } Sign[] componentsInChildren5 = ((Component)this).GetComponentsInChildren<Sign>(true); for (int i = 0; i < componentsInChildren5.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren5[i]); } ItemStand[] componentsInChildren6 = ((Component)this).GetComponentsInChildren<ItemStand>(true); for (int i = 0; i < componentsInChildren6.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren6[i]); } Container[] componentsInChildren7 = ((Component)this).GetComponentsInChildren<Container>(true); for (int i = 0; i < componentsInChildren7.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren7[i]); } HoverText[] componentsInChildren8 = ((Component)this).GetComponentsInChildren<HoverText>(true); for (int i = 0; i < componentsInChildren8.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren8[i]); } Piece component = ((Component)this).GetComponent<Piece>(); if ((Object)(object)component != (Object)null) { component.m_craftingStation = null; } } private void OnEnable() { if (!AllOrbs.Contains(this)) { AllOrbs.Add(this); } } private void OnDisable() { AllOrbs.Remove(this); } private void OnDestroy() { if ((Object)(object)m_renderTexture != (Object)null) { if ((Object)(object)RenderTexture.active == (Object)(object)m_renderTexture) { RenderTexture.active = null; } m_renderTexture.Release(); Object.Destroy((Object)(object)m_renderTexture); m_renderTexture = null; } if ((Object)(object)m_orbMaterial != (Object)null) { Object.Destroy((Object)(object)m_orbMaterial); m_orbMaterial = null; } } private void SetupOrbVisual() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Expected O, but got Unknown //IL_0202: 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_0283: Unknown result type (might be due to invalid IL or missing references) Transform val = null; Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true); foreach (Transform val2 in componentsInChildren) { if (((Object)val2).name == "ScryingScreenQuad") { val = val2; break; } } if ((Object)(object)val == (Object)null) { GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)obj).name = "ScryingScreenQuad"; obj.transform.SetParent(((Component)this).transform, false); Object.Destroy((Object)(object)obj.GetComponent<Collider>()); obj.transform.localPosition = new Vector3(-0.18495f, 0.53055f, -0.221f); obj.transform.localRotation = Quaternion.Euler(-24.9f, 0f, 0f); obj.transform.localScale = new Vector3(0.48f, 0.36f, 1f); val = obj.transform; } m_orbVisual = ((Component)val).gameObject; m_orbRenderer = m_orbVisual.GetComponent<Renderer>(); if ((Object)(object)m_renderTexture == (Object)null) { m_renderTexture = new RenderTexture(384, 288, 16, (RenderTextureFormat)0) { name = "ScryingConsoleRT_" + ((Object)this).GetInstanceID(), wrapMode = (TextureWrapMode)1, filterMode = (FilterMode)1 }; m_renderTexture.Create(); } Shader val3 = OdinsEyeGlb.FindScreenShader(); m_orbMaterial = new Material(val3) { name = "ConsoleScreenMaterial_" + ((Object)this).GetInstanceID() }; m_orbMaterial.mainTexture = (Texture)(object)m_renderTexture; if (m_orbMaterial.HasProperty("_MainTex")) { m_orbMaterial.SetTexture("_MainTex", (Texture)(object)m_renderTexture); } if (m_orbMaterial.HasProperty("_BaseMap")) { m_orbMaterial.SetTexture("_BaseMap", (Texture)(object)m_renderTexture); } if (m_orbMaterial.HasProperty("_Color")) { m_orbMaterial.SetColor("_Color", Color.white); } if (m_orbMaterial.HasProperty("_BaseColor")) { m_orbMaterial.SetColor("_BaseColor", Color.white); } if (m_orbMaterial.HasProperty("_Cull")) { m_orbMaterial.SetInt("_Cull", 0); } if (m_orbMaterial.HasProperty("_EmissionColor")) { m_orbMaterial.EnableKeyword("_EMISSION"); m_orbMaterial.SetColor("_EmissionColor", Color.white); m_orbMaterial.SetTexture("_EmissionMap", (Texture)(object)m_renderTexture); } if ((Object)(object)m_orbRenderer != (Object)null) { m_orbRenderer.material = m_orbMaterial; } RenderStandbyScreen(); WearNTear component = ((Component)this).GetComponent<WearNTear>(); if (!((Object)(object)component != (Object)null)) { return; } try { FieldRef<WearNTear, List<Renderer>> obj2 = AccessTools.FieldRefAccess<WearNTear, List<Renderer>>("m_renderers"); ((obj2 != null) ? obj2.Invoke(component) : null)?.RemoveAll((Renderer r) => (Object)(object)r == (Object)null); } catch { } } private void Update() { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid()) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } float num = Vector3.Distance(((Component)this).transform.position, ((Component)localPlayer).transform.position); float num2 = ((OdinsEyePlugin.ProximityDistance != null) ? OdinsEyePlugin.ProximityDistance.Value : 18f); if (!(num > num2)) { int num3 = ((OdinsEyePlugin.OrbRenderFps != null) ? OdinsEyePlugin.OrbRenderFps.Value : 10); if (num3 <= 0) { num3 = 10; } float num4 = 1f / (float)num3; m_renderTimer += Time.deltaTime; if (m_renderTimer >= num4) { m_renderTimer = 0f; RenderActiveFeed(); } } } private void RenderActiveFeed() { OdinsEyeCamera activeCamera = GetActiveCamera(); if ((Object)(object)activeCamera != (Object)null && (Object)(object)m_renderTexture != (Object)null) { activeCamera.RenderToTexture(m_renderTexture); } else { RenderStandbyScreen(); } } private void RenderStandbyScreen() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)m_renderTexture == (Object)null)) { RenderTexture active = RenderTexture.active; RenderTexture.active = m_renderTexture; GL.Clear(true, true, new Color(0.04f, 0.08f, 0.14f, 1f)); RenderTexture.active = active; } } public OdinsEyeCamera GetActiveCamera() { if (OdinsEyeCamera.AllCameras.Count == 0) { return null; } if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { string value = m_nview.GetZDO().GetString("DH_TargetCamName", ""); if (!string.IsNullOrEmpty(value)) { for (int i = 0; i < OdinsEyeCamera.AllCameras.Count; i++) { if (OdinsEyeCamera.AllCameras[i].GetCameraName().Equals(value, StringComparison.OrdinalIgnoreCase)) { return OdinsEyeCamera.AllCameras[i]; } } } int num = m_nview.GetZDO().GetInt("DH_SelectedCamIndex", 0); if (num >= 0 && num < OdinsEyeCamera.AllCameras.Count) { return OdinsEyeCamera.AllCameras[num]; } } if (m_selectedCameraIndex >= 0 && m_selectedCameraIndex < OdinsEyeCamera.AllCameras.Count) { return OdinsEyeCamera.AllCameras[m_selectedCameraIndex]; } return OdinsEyeCamera.AllCameras[0]; } public void SelectCamera(int index, string explicitName = null) { if (index >= 0 && index < OdinsEyeCamera.AllCameras.Count) { m_selectedCameraIndex = index; string text = explicitName ?? OdinsEyeCamera.AllCameras[index].GetCameraName(); if ((Object)(object)m_nview != (Object)null && m_nview.IsValid()) { m_nview.GetZDO().Set("DH_SelectedCamIndex", index); m_nview.GetZDO().Set("DH_TargetCamName", text); } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { ((Character)localPlayer).Message((MessageType)2, "Console feed set: " + text, 0, (Sprite)null, false); } } } public void CycleCamera(int direction = 1) { if (OdinsEyeCamera.AllCameras.Count != 0) { OdinsEyeCamera activeCamera = GetActiveCamera(); int num = ((((Object)(object)activeCamera != (Object)null) ? OdinsEyeCamera.AllCameras.IndexOf(activeCamera) : 0) + direction) % OdinsEyeCamera.AllCameras.Count; if (num < 0) { num += OdinsEyeCamera.AllCameras.Count; } SelectCamera(num); } } public string GetHoverText() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("<color=#38bdf8><b>[Odin's Eye Console]</b></color>\n"); OdinsEyeCamera activeCamera = GetActiveCamera(); if ((Object)(object)activeCamera != (Object)null) { int count = OdinsEyeCamera.AllCameras.Count; int num = OdinsEyeCamera.AllCameras.IndexOf(activeCamera) + 1; stringBuilder.Append($"Feed [{num}/{count}]: <color=yellow>{activeCamera.GetCameraName()}</color>\n"); stringBuilder.Append("[<color=yellow><b>$KEY_Use</b></color>] Enter Scrying View\n"); stringBuilder.Append("[<color=yellow><b><Shift> + $KEY_Use</b></color>] Next Camera\n"); stringBuilder.Append("[<color=yellow><b><Alt> + $KEY_Use</b></color>] Configure Camera"); } else { stringBuilder.Append("<i>No Odin's Eye Cameras detected in world.</i>\n"); stringBuilder.Append("[<color=yellow><b><Alt> + $KEY_Use</b></color>] Configure Camera"); } return Localization.instance.Localize(stringBuilder.ToString()); } public string GetHoverName() { return "Odin's Eye Console"; } public float GetHoverOffset() { return 0f; } public bool Interact(Humanoid user, bool hold, bool alt) { if (hold) { return false; } Player val = (Player)(object)((user is Player) ? user : null); if ((Object)(object)val == (Object)null) { return false; } if (alt && (Object)(object)TextInput.instance != (Object)null) { TextInput.instance.RequestText((TextReceiver)(object)this, "Target Camera (Name or #):", 24); return true; } if (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) { CycleCamera(); return true; } if (OdinsEyeCamera.AllCameras.Count == 0) { ((Character)val).Message((MessageType)2, "No Odin's Eye cameras are active to view!", 0, (Sprite)null, false); return false; } ScryingSession.StartScrying(this, GetActiveCamera()); return true; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetText() { OdinsEyeCamera activeCamera = GetActiveCamera(); if (!((Object)(object)activeCamera != (Object)null)) { return ""; } return activeCamera.GetCameraName(); } public void SetText(string text) { if (string.IsNullOrEmpty(text)) { return; } text = text.Trim(); if (int.TryParse(text, out var result) && result >= 1 && result <= OdinsEyeCamera.AllCameras.Count) { SelectCamera(result - 1); return; } int num = -1; int num2 = -1; for (int i = 0; i < OdinsEyeCamera.AllCameras.Count; i++) { string cameraName = OdinsEyeCamera.AllCameras[i].GetCameraName(); if (cameraName.Equals(text, StringComparison.OrdinalIgnoreCase)) { num = i; break; } if (num2 < 0 && cameraName.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0) { num2 = i; } } int num3 = ((num >= 0) ? num : num2); if (num3 >= 0) { SelectCamera(num3, OdinsEyeCamera.AllCameras[num3].GetCameraName()); return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer != (Object)null) { ((Character)localPlayer).Message((MessageType)2, "No camera matching '" + text + "' found", 0, (Sprite)null, false); } } } internal static class OdinsEyePieces { internal const string CamPrefabName = "DFG_OdinsEyeCam"; internal const string OrbPrefabName = "DFG_OdinsEyeOrb"; internal const string ScreenPrefabName = "DFG_OdinsEyeScreen"; internal const string ScreenLargePrefabName = "DFG_OdinsEyeScreen_Large"; internal const string ScreenHugePrefabName = "DFG_OdinsEyeScreen_Huge"; private static readonly string[] BaseStandCandidates = new string[4] { "itemstand_v", "itemstand", "piece_chest_wood", "piece_workbench" }; private static readonly string[] BaseOrbCandidates = new string[3] { "piece_stonecutter", "piece_chest_wood", "piece_workbench" }; private static readonly string[] BaseScreenCandidates = new string[6] { "sign", "piece_sign", "itemstand_v", "itemstand", "piece_chest_wood", "piece_workbench" }; private static bool s_camPrefabRegistered; private static bool s_orbPrefabRegistered; private static bool s_screenPrefabRegistered; private static bool s_screenLargePrefabRegistered; private static bool s_screenHugePrefabRegistered; private static bool s_camPieceRegistered; private static bool s_orbPieceRegistered; private static bool s_screenPieceRegistered; private static bool s_screenLargePieceRegistered; private static bool s_screenHugePieceRegistered; private static GameObject s_camPrefab; private static GameObject s_orbPrefab; private static GameObject s_screenPrefab; private static GameObject s_screenLargePrefab; private static GameObject s_screenHugePrefab; private static float s_registrationTimer; private static readonly Dictionary<string, ItemDrop> s_cachedRequirementItems = new Dictionary<string, ItemDrop>(); private static MethodInfo s_addKnownPieceMethod; private static MethodInfo s_updateAvailablePiecesListMethod; private static readonly Dictionary<string, Sprite> s_customIcons = new Dictionary<string, Sprite>(StringComparer.OrdinalIgnoreCase); internal static void Initialize() { PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable; } internal static void Shutdown() { PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable; s_cachedRequirementItems.Clear(); s_customIcons.Clear(); s_camPrefabRegistered = false; s_orbPrefabRegistered = false; s_screenPrefabRegistered = false; s_screenLargePrefabRegistered = false; s_screenHugePrefabRegistered = false; s_camPieceRegistered = false; s_orbPieceRegistered = false; s_screenPieceRegistered = false; s_screenLargePieceRegistered = false; s_screenHugePieceRegistered = false; s_camPrefab = null; s_orbPrefab = null; s_screenPrefab = null; s_screenLargePrefab = null; s_screenHugePrefab = null; s_registrationTimer = 0f; } internal static void Update() { if (OdinsEyePlugin.Enabled.Value) { TryRegisterContent(); EnsureLocalPlayerKnownPieces(); } } private static void OnVanillaPrefabsAvailable() { s_registrationTimer = 0f; TryRegisterPrefabs(); } private static GameObject FindSourcePrefab(string[] candidates) { foreach (string text in candidates) { GameObject prefab = PrefabManager.Instance.GetPrefab(text); if ((Object)(object)prefab == (Object)null && (Object)(object)ZNetScene.instance != (Object)null) { prefab = ZNetScene.instance.GetPrefab(text); } if ((Object)(object)prefab != (Object)null) { return prefab; } } return null; } private static void TryRegisterPrefabs() { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_02bb: Unknown result type (might be due to invalid IL or missing references) if (!OdinsEyePlugin.Enabled.Value) { return; } if (!s_camPrefabRegistered) { try { GameObject val = FindSourcePrefab(BaseStandCandidates); if ((Object)(object)val != (Object)null) { GameObject val2 = PrefabManager.Instance.CreateClonedPrefab("DFG_OdinsEyeCam", val); if ((Object)(object)val2 != (Object)null) { StripVanillaStationComponents(val2); Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } OdinsEyeGlb.AttachModel(val2); Collider[] componentsInChildren2 = val2.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } Rigidbody[] componentsInChildren3 = val2.GetComponentsInChildren<Rigidbody>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } BoxCollider val3 = val2.AddComponent<BoxCollider>(); val3.center = new Vector3(0f, 0.49f, 0.25f); val3.size = new Vector3(0.35f, 0.98f, 0.48f); int num = LayerMask.NameToLayer("piece"); if (num >= 0) { ((Component)val3).gameObject.layer = num; } WearNTear component = val2.GetComponent<WearNTear>(); if ((Object)(object)component != (Object)null) { component.m_noSupportWear = true; component.m_noRoofWear = true; component.m_staticPosition = true; } if ((Object)(object)val2.GetComponent<OdinsEyeCamera>() == (Object)null) { val2.AddComponent<OdinsEyeCamera>(); } PrefabManager.Instance.AddPrefab(val2); s_camPrefab = val2; s_camPrefabRegistered = true; OdinsEyePlugin.Log.LogInfo((object)("Odin's Eye: registered prefab DFG_OdinsEyeCam (cloned from " + ((Object)val).name + ")")); } } } catch (Exception ex) { OdinsEyePlugin.Log.LogError((object)("Odin's Eye: failed to clone camera prefab: " + ex)); } } if (!s_orbPrefabRegistered) { try { GameObject val4 = FindSourcePrefab(BaseOrbCandidates); if ((Object)(object)val4 != (Object)null) { GameObject val5 = PrefabManager.Instance.CreateClonedPrefab("DFG_OdinsEyeOrb", val4); if ((Object)(object)val5 != (Object)null) { StripVanillaStationComponents(val5); Renderer[] componentsInChildren = val5.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].enabled = false; } OdinsEyeGlb.AttachConsoleModel(val5); Collider[] componentsInChildren2 = val5.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } Rigidbody[] componentsInChildren3 = val5.GetComponentsInChildren<Rigidbody>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren3[i]); } BoxCollider val6 = val5.AddComponent<BoxCollider>(); val6.center = new Vector3(0f, 0.4f, 0f); val6.size = new Vector3(1.35f, 0.8f, 0.7f); int num2 = LayerMask.NameToLayer("piece"); if (num2 >= 0) { ((Component)val6).gameObject.layer = num2; } WearNTear component2 = val5.GetComponent<WearNTear>(); if ((Object)(object)component2 != (Object)null) { component2.m_noSupportWear = true; component2.m_noRoofWear = true; component2.m_staticPosition = true; } if ((Object)(object)val5.GetComponent<OdinsEyeOrb>() == (Object)null) { val5.AddComponent<OdinsEyeOrb>(); } PrefabManager.Instance.AddPrefab(val5); s_orbPrefab = val5; s_orbPrefabRegistered = true; OdinsEyePlugin.Log.LogInfo((object)("Odin's Eye: registered prefab DFG_OdinsEyeOrb (cloned from " + ((Object)val4).name + ")")); } } } catch (Exception ex2) { OdinsEyePlugin.Log.LogError((object)("Odin's Eye: failed to clone orb prefab: " + ex2)); } } CreateScreenPrefab("DFG_OdinsEyeScreen", 1f, 512, 384, ref s_screenPrefabRegistered, ref s_screenPrefab); CreateScreenPrefab("DFG_OdinsEyeScreen_Large", 1.8f, 768, 576, ref s_screenLargePrefabRegistered, ref s_screenLargePrefab); CreateScreenPrefab("DFG_OdinsEyeScreen_Huge", 3.2f, 1024, 768, ref s_screenHugePrefabRegistered, ref s_screenHugePrefab); } private static void StripVanillaStationComponents(GameObject root) { if ((Object)(object)root == (Object)null) { return; } CraftingStation[] componentsInChildren = root.GetComponentsInChildren<CraftingStation>(true); foreach (CraftingStation val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } if ((Object)(object)val.m_areaMarker != (Object)null && (Object)(object)val.m_areaMarker != (Object)(object)root) { Object.DestroyImmediate((Object)(object)val.m_areaMarker); } if ((Object)(object)val.m_inUseObject != (Object)null && (Object)(object)val.m_inUseObject != (Object)(object)root) { Object.DestroyImmediate((Object)(object)val.m_inUseObject); } if ((Object)(object)val.m_haveFireObject != (Object)null && (Object)(object)val.m_haveFireObject != (Object)(object)root) { Object.DestroyImmediate((Object)(object)val.m_haveFireObject); } if ((Object)(object)val.m_effectAreaCollider != (Object)null) { if ((Object)(object)((Component)val.m_effectAreaCollider).gameObject == (Object)(object)root) { Object.DestroyImmediate((Object)(object)val.m_effectAreaCollider); } else { Object.DestroyImmediate((Object)(object)((Component)val.m_effectAreaCollider).gameObject); } } Object.DestroyImmediate((Object)(object)val); } StationExtension[] componentsInChildren2 = root.GetComponentsInChildren<StationExtension>(true); for (int j = 0; j < componentsInChildren2.Length; j++) { if ((Object)(object)componentsInChildren2[j] != (Object)null) { Object.DestroyImmediate((Object)(object)componentsInChildren2[j]); } } CircleProjector[] componentsInChildren3 = root.GetComponentsInChildren<CircleProjector>(true); for (int k = 0; k < componentsInChildren3.Length; k++) { if (!((Object)(object)componentsInChildren3[k] == (Object)null)) { if ((Object)(object)((Component)componentsInChildren3[k]).gameObject == (Object)(object)root) { Object.DestroyImmediate((Object)(object)componentsInChildren3[k]); } else { Object.DestroyImmediate((Object)(object)((Component)componentsInChildren3[k]).gameObject); } } } EffectArea[] componentsInChildren4 = root.GetComponentsInChildren<EffectArea>(true); for (int l = 0; l < componentsInChildren4.Length; l++) { if ((Object)(object)componentsInChildren4[l] == (Object)null) { continue; } Collider[] components = ((Component)componentsInChildren4[l]).GetComponents<Collider>(); for (int m = 0; m < components.Length; m++) { if ((Object)(object)components[m] != (Object)null && components[m].isTrigger) { if ((Object)(object)((Component)components[m]).gameObject == (Object)(object)root) { Object.DestroyImmediate((Object)(object)components[m]); } else { Object.DestroyImmediate((Object)(object)((Component)components[m]).gameObject); } } } Object.DestroyImmediate((Object)(object)componentsInChildren4[l]); } Container[] componentsInChildren5 = root.GetComponentsInChildren<Container>(true); for (int n = 0; n < componentsInChildren5.Length; n++) { if ((Object)(object)componentsInChildren5[n] != (Object)null) { Object.DestroyImmediate((Object)(object)componentsInChildren5[n]); } } Sign[] componentsInChildren6 = root.GetComponentsInChildren<Sign>(true); for (int num = 0; num < componentsInChildren6.Length; num++) { if ((Object)(object)componentsInChildren6[num] != (Object)null) { Object.DestroyImmediate((Object)(object)componentsInChildren6[num]); } } ItemStand[] componentsInChildren7 = root.GetComponentsInChildren<ItemStand>(true); for (int num2 = 0; num2 < componentsInChildren7.Length; num2++) { if ((Object)(object)componentsInChildren7[num2] != (Object)null) { Object.DestroyImmediate((Object)(object)componentsInChildren7[num2]); } } HoverText[] componentsInChildren8 = root.GetComponentsInChildren<HoverText>(true); for (int num3 = 0; num3 < componentsInChildren8.Length; num3++) { if ((Object)(object)componentsInChildren8[num3] != (Object)null) { Object.DestroyImmediate((Object)(object)componentsInChildren8[num3]); } } Piece component = root.GetComponent<Piece>(); if ((Object)(object)component != (Object)null) { component.m_craftingStation = null; } } private static void CreateScreenPrefab(string prefabName, float scale, int texWidth, int texHeight, ref bool isRegistered, ref GameObject prefabStore) { //IL_00d5: 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) if (isRegistered) { return; } try { GameObject val = FindSourcePrefab(BaseScreenCandidates); if ((Object)(object)val == (Object)null) { return; } GameObject val2 = PrefabManager.Instance.CreateClonedPrefab(prefabName, val); if (!((Object)(object)val2 == (Object)null)) { StripVanillaStationComponents(val2); Renderer[] componentsInChildren = val2.GetComponentsInChildren<Renderer>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildre