Please disclose if your mod was created primarily 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 ChestSnap v0.1.1
ChestSnap.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ChestSnap.Config; using ChestSnap.DebugVisuals; using ChestSnap.Helpers; using ChestSnap.Helpers.Yaml; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.ObjectPool; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.BufferedDeserialization; using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators; using YamlDotNet.Serialization.Callbacks; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_utils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = "")] [assembly: AssemblyCompany("ChestSnap")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+92689108838791c2d001d18050943d119a798226")] [assembly: AssemblyProduct("ChestSnap")] [assembly: AssemblyTitle("ChestSnap")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 ChestSnap { public static class Consts { public const string ModName = "ChestSnap"; public const string ModAuthor = "Frogger"; public const string ModVersion = "0.1.1"; public const string ModGuid = "com.Frogger.ChestSnap"; public const string MainSceneName = "main"; } public static class Log { private static ManualLogSource? _logger; private static BaseUnityPlugin _plugin; public static void Initialize(BaseUnityPlugin plugin) { _plugin = plugin; _logger = GetProtectedLogger(_plugin); } private static ManualLogSource GetProtectedLogger(object instance) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown if (instance == null) { throw new ArgumentNullException("instance"); } Type type = instance.GetType(); PropertyInfo property = type.GetProperty("Logger", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (property == null) { throw new MissingMemberException(type.FullName, "Logger"); } MethodInfo getMethod = property.GetGetMethod(nonPublic: true); if (getMethod == null) { throw new MissingMethodException("Property " + type.FullName + ".Logger does not have a getter"); } ManualLogSource val = (ManualLogSource)getMethod.Invoke(instance, null); return val ?? throw new Exception("Failed to get Logger"); } public static void Info(string message, bool insertTimestamp = false) { if (_logger != null) { if (insertTimestamp) { message = DateTime.Now.ToString("G") + message; } _logger.LogInfo((object)message); } } public static void Error(Exception ex, string message = "", bool insertTimestamp = false) { if (_logger != null) { if (insertTimestamp) { message = DateTime.Now.ToString("G") + message; } if (string.IsNullOrEmpty(message)) { message += Environment.NewLine; } _logger.LogError((object)(message + ex)); } } public static void Error(string message, bool insertTimestamp = false) { if (_logger != null) { if (insertTimestamp) { message = DateTime.Now.ToString("G") + message; } _logger.LogError((object)message); } } public static void Warning(Exception ex, string message, bool insertTimestamp = false) { if (_logger != null) { if (insertTimestamp) { message = DateTime.Now.ToString("G") + message; } if (string.IsNullOrEmpty(message)) { message += Environment.NewLine; } _logger.LogWarning((object)(message + ex)); } } public static void Warning(string message, bool insertTimestamp = false) { if (_logger != null) { if (insertTimestamp) { message = DateTime.Now.ToString("G") + message; } _logger.LogWarning((object)message); } } } [BepInPlugin("com.Frogger.ChestSnap", "ChestSnap", "0.1.1")] public class Plugin : BaseUnityPlugin { private Harmony _harmony = null; public static Plugin? Instance { get; private set; } private void Awake() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown Instance = this; Log.Initialize((BaseUnityPlugin)(object)this); if (Helper.IsDedicatedServer()) { Log.Error("com.Frogger.ChestSnap is intended to be ran only on clients, you as a server admin shall not install it an a dedicated server"); return; } _harmony = new Harmony("com.Frogger.ChestSnap"); _harmony.PatchAll(); ConfigsContainer.InitializeConfiguration((BaseUnityPlugin)(object)this); GameObject val = new GameObject("DebugOverlay"); val.AddComponent<DebugOverlayManager>(); Object.DontDestroyOnLoad((Object)(object)val); } } [HarmonyPatch(typeof(Terminal))] [HarmonyWrapSafe] internal static class TerminalCommands { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<Vector3, Vector3> <>9__0_2; public static ConsoleEventFailable <>9__0_0; internal object <Postfix>b__0_0(ConsoleEventArgs args) { <>c__DisplayClass0_0 CS$<>8__locals0 = new <>c__DisplayClass0_0(); if ((Object)(object)DebugOverlayManager.Instance == (Object)null) { ((Terminal)Console.instance).AddString("DebugOverlayManager is not initialized yet, this should never happen"); Log.Error("[generate_snap_points] DebugOverlayManager is not initialized yet, this should never happen"); return false; } bool onlyBottom = false; if (args.Length >= 2) { string value = args[1]; if (string.IsNullOrEmpty(value)) { onlyBottom = false; } else { if (!bool.TryParse(value, out var result)) { ((Terminal)Console.instance).AddString("Invalid argument, onlyBottom excepts only 'true' and false'"); return false; } onlyBottom = result; } } Player localPlayer = Player.m_localPlayer; object obj; if (localPlayer == null) { obj = null; } else { Piece hoveringPiece = localPlayer.m_hoveringPiece; obj = ((hoveringPiece != null) ? ((Component)hoveringPiece).gameObject : null); } GameObject val = (GameObject)obj; if ((Object)(object)val == (Object)null) { ((Terminal)Console.instance).AddString("You are not hovering with hammer any piece right now"); return false; } CS$<>8__locals0.pieceTransform = val.transform; List<BoundData> bounds = BoundsComputer.ComputeBounds(CS$<>8__locals0.pieceTransform); List<Vector3> source = BoundsComputer.FindOuterCorners(bounds, onlyBottom); source = (from x in source select CS$<>8__locals0.pieceTransform.InverseTransformPoint(x) into x select x.Round(1)).ToList(); Dictionary<string, Vector3[]> dictionary = new Dictionary<string, Vector3[]>(ConfigsContainer.SnappointLookup); dictionary.Remove(Utils.GetPrefabName(val)); dictionary.Add(Utils.GetPrefabName(val), source.ToArray()); ConfigsContainer.UpdateSnappointLookup(dictionary); return true; } internal Vector3 <Postfix>b__0_2(Vector3 x) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) return x.Round(1); } } [CompilerGenerated] private sealed class <>c__DisplayClass0_0 { public Transform pieceTransform; internal Vector3 <Postfix>b__1(Vector3 x) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return pieceTransform.InverseTransformPoint(x); } } [HarmonyPostfix] [HarmonyPatch("InitTerminal")] private static void Postfix() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEventFailable val = delegate(ConsoleEventArgs args) { if ((Object)(object)DebugOverlayManager.Instance == (Object)null) { ((Terminal)Console.instance).AddString("DebugOverlayManager is not initialized yet, this should never happen"); Log.Error("[generate_snap_points] DebugOverlayManager is not initialized yet, this should never happen"); return false; } bool onlyBottom = false; if (args.Length >= 2) { string value = args[1]; if (string.IsNullOrEmpty(value)) { onlyBottom = false; } else { if (!bool.TryParse(value, out var result)) { ((Terminal)Console.instance).AddString("Invalid argument, onlyBottom excepts only 'true' and false'"); return false; } onlyBottom = result; } } Player localPlayer = Player.m_localPlayer; object obj2; if (localPlayer == null) { obj2 = null; } else { Piece hoveringPiece = localPlayer.m_hoveringPiece; obj2 = ((hoveringPiece != null) ? ((Component)hoveringPiece).gameObject : null); } GameObject val2 = (GameObject)obj2; if ((Object)(object)val2 == (Object)null) { ((Terminal)Console.instance).AddString("You are not hovering with hammer any piece right now"); return false; } Transform pieceTransform = val2.transform; List<BoundData> bounds = BoundsComputer.ComputeBounds(pieceTransform); List<Vector3> source = BoundsComputer.FindOuterCorners(bounds, onlyBottom); source = (from x in source select pieceTransform.InverseTransformPoint(x) into x select x.Round(1)).ToList(); Dictionary<string, Vector3[]> dictionary = new Dictionary<string, Vector3[]>(ConfigsContainer.SnappointLookup); dictionary.Remove(Utils.GetPrefabName(val2)); dictionary.Add(Utils.GetPrefabName(val2), source.ToArray()); ConfigsContainer.UpdateSnappointLookup(dictionary); return true; }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("generate_snap_points", "[onlyBottom:bool](optional) - Generate snap points for a building piece you are currently hovering with hammer. This points will be added to the config", (ConsoleEventFailable)obj, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } } namespace ChestSnap.Patch { [HarmonyPatch] internal static class AddSnapPointsPatch { [HarmonyPostfix] [HarmonyPatch(typeof(ZNetScene), "Awake")] private static void AddSnappointsAtStart() { if (Helper.IsMainScene() && !Helper.IsDedicatedServer()) { SnappointHelper.RecreateSnappoints(); } } } } namespace ChestSnap.Helpers { public static class EmbeddedFileLoader { public static Stream? GetStream(string fileName, bool searchInAllAssemblies = false) { string fileName2 = fileName; IEnumerable<Assembly> enumerable = ((!searchInAllAssemblies) ? new <>z__ReadOnlySingleElementList<Assembly>(Assembly.GetExecutingAssembly()) : (from asm in AppDomain.CurrentDomain.GetAssemblies() where !asm.IsDynamic select asm)); foreach (Assembly item in enumerable) { try { string[] manifestResourceNames = item.GetManifestResourceNames(); string text = manifestResourceNames.FirstOrDefault((string x) => x.ToLower().EndsWith(fileName2.ToLower())); if (text == null) { continue; } Stream manifestResourceStream = item.GetManifestResourceStream(text); if (manifestResourceStream == null) { Log.Warning("Не удалось получить поток для ресурса: " + fileName2); return null; } return manifestResourceStream; } catch (Exception ex) { Log.Error(ex, "Failed to extract resource from assembly '" + item.FullName + "'"); } } Log.Warning("Resource '" + fileName2 + "' not found"); return null; } public static List<string> GetResources() { List<string> list = new List<string>(); Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); Assembly[] array = assemblies; foreach (Assembly assembly in array) { string[] manifestResourceNames = assembly.GetManifestResourceNames(); list.AddRange(manifestResourceNames); } return list; } public static string? GetText(string fileName, bool searchInAllAssemblies = false) { using Stream stream = GetStream(fileName, searchInAllAssemblies); if (stream == null) { return null; } try { using StreamReader streamReader = new StreamReader(stream); return streamReader.ReadToEnd(); } catch (Exception ex) { Log.Error(ex, "Failed to read from stream " + fileName); } return null; } } public static class Helper { public static bool IsMainScene() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) Scene activeScene = SceneManager.GetActiveScene(); return ((Scene)(ref activeScene)).IsValid() && ((Scene)(ref activeScene)).name == "main"; } public static bool IsServer() { GameServerClientState gameServerClientState = GetGameServerClientState(); return gameServerClientState == GameServerClientState.Server; } public static bool IsDedicatedServer() { GameServerClientState gameServerClientState = GetGameServerClientState(); return gameServerClientState == GameServerClientState.DedicatedServer; } public static GameServerClientState GetGameServerClientState() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)SystemInfo.graphicsDeviceType == 4) { return GameServerClientState.DedicatedServer; } ZNet instance = ZNet.instance; bool? flag = ((instance != null) ? new bool?(instance.IsServer()) : null); if (1 == 0) { } GameServerClientState result = (flag.HasValue ? ((!flag.GetValueOrDefault()) ? GameServerClientState.Client : GameServerClientState.Server) : GameServerClientState.Unknown); if (1 == 0) { } return result; } } public enum GameServerClientState { Unknown, Client, Server, DedicatedServer } public static class IntExtensions { public static int[] Range(this int count) { int[] array = new int[count]; for (int i = 0; i < count; i = checked(i + 1)) { array[i] = i; } return array; } } public static class SnappointHelper { [CompilerGenerated] private sealed class <>c__DisplayClass2_0 { public string onlyForAPrefab; public int? onlyForAPrefabHash; internal bool <RecreateSnappointsRoutine>b__0(KeyValuePair<string, Vector3[]> x) { return x.Key == onlyForAPrefab; } internal bool <RecreateSnappointsRoutine>b__5(KeyValuePair<ZDO, ZNetView> x) { return string.IsNullOrEmpty(onlyForAPrefab) || x.Key.m_prefab == onlyForAPrefabHash; } } [CompilerGenerated] private sealed class <RecreateSnappointsRoutine>d__2 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public string onlyForAPrefab; private <>c__DisplayClass2_0 <>8__1; private Dictionary<string, Vector3[]> <snappointLookup>5__2; private Dictionary<int, Vector3[]> <snappointLookupByHash>5__3; private Dictionary<int, GameObject[]> <objectsOnScene>5__4; private Dictionary<string, Vector3[]>.Enumerator <>s__5; private KeyValuePair<string, Vector3[]> <pair>5__6; private GameObject <prefab>5__7; private Dictionary<int, GameObject[]>.Enumerator <>s__8; private KeyValuePair<int, GameObject[]> <pair>5__9; private int <prefabHash>5__10; private Vector3[] <points>5__11; private GameObject[] <>s__12; private int <>s__13; private GameObject <instance>5__14; private Transform <transform>5__15; private GameObject[] <>s__16; private int <>s__17; private GameObject <instance>5__18; private Transform <transform>5__19; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RecreateSnappointsRoutine>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { switch (<>1__state) { case -3: case 1: try { } finally { <>m__Finally1(); } break; case -4: case 2: try { } finally { <>m__Finally2(); } break; } <>8__1 = null; <snappointLookup>5__2 = null; <snappointLookupByHash>5__3 = null; <objectsOnScene>5__4 = null; <>s__5 = default(Dictionary<string, Vector3[]>.Enumerator); <pair>5__6 = default(KeyValuePair<string, Vector3[]>); <prefab>5__7 = null; <>s__8 = default(Dictionary<int, GameObject[]>.Enumerator); <pair>5__9 = default(KeyValuePair<int, GameObject[]>); <points>5__11 = null; <>s__12 = null; <instance>5__14 = null; <transform>5__15 = null; <>s__16 = null; <instance>5__18 = null; <transform>5__19 = null; <>1__state = -2; } private bool MoveNext() { bool result; try { <>c__DisplayClass2_0 <>c__DisplayClass2_; string text; switch (<>1__state) { default: result = false; break; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass2_0(); <>8__1.onlyForAPrefab = onlyForAPrefab; <snappointLookup>5__2 = ConfigsContainer.SnappointLookup; if (!string.IsNullOrEmpty(<>8__1.onlyForAPrefab)) { <snappointLookup>5__2 = <snappointLookup>5__2.Where<KeyValuePair<string, Vector3[]>>((KeyValuePair<string, Vector3[]> x) => x.Key == <>8__1.onlyForAPrefab).ToDictionary((KeyValuePair<string, Vector3[]> x) => x.Key, (KeyValuePair<string, Vector3[]> x) => x.Value); } <>s__5 = <snappointLookup>5__2.GetEnumerator(); <>1__state = -3; goto IL_0196; case 1: <>1__state = -3; <prefab>5__7 = null; <pair>5__6 = default(KeyValuePair<string, Vector3[]>); goto IL_0196; case 2: { <>1__state = -4; <transform>5__19 = null; <instance>5__18 = null; goto IL_051d; } IL_0196: if (<>s__5.MoveNext()) { <pair>5__6 = <>s__5.Current; if (!Object.op_Implicit((Object)(object)ZNetScene.instance)) { result = false; <>m__Finally1(); break; } <prefab>5__7 = ZNetScene.instance.GetPrefab(<pair>5__6.Key); if (Object.op_Implicit((Object)(object)<prefab>5__7)) { RecreateSnappointsInObject(<prefab>5__7, <pair>5__6.Value); } <>2__current = null; <>1__state = 1; result = true; break; } <>m__Finally1(); <>s__5 = default(Dictionary<string, Vector3[]>.Enumerator); if (!Object.op_Implicit((Object)(object)ZNetScene.instance)) { result = false; break; } <snappointLookupByHash>5__3 = <snappointLookup>5__2.ToDictionary<KeyValuePair<string, Vector3[]>, int, Vector3[]>((KeyValuePair<string, Vector3[]> x) => StringExtensionMethods.GetStableHashCode(x.Key), (KeyValuePair<string, Vector3[]> x) => x.Value); <>c__DisplayClass2_ = <>8__1; text = <>8__1.onlyForAPrefab; <>c__DisplayClass2_.onlyForAPrefabHash = ((text != null) ? new int?(StringExtensionMethods.GetStableHashCode(text)) : null); <objectsOnScene>5__4 = (from x in ZNetScene.instance.m_instances where string.IsNullOrEmpty(<>8__1.onlyForAPrefab) || x.Key.m_prefab == <>8__1.onlyForAPrefabHash group x by x.Key.m_prefab).ToDictionary((IGrouping<int, KeyValuePair<ZDO, ZNetView>> x) => x.Key, (IGrouping<int, KeyValuePair<ZDO, ZNetView>> x) => x.Select((KeyValuePair<ZDO, ZNetView> g) => ((Component)g.Value).gameObject).ToArray()); <>s__8 = <objectsOnScene>5__4.GetEnumerator(); <>1__state = -4; goto IL_0559; IL_0559: while (true) { if (<>s__8.MoveNext()) { <pair>5__9 = <>s__8.Current; if (!Object.op_Implicit((Object)(object)ZNetScene.instance)) { result = false; <>m__Finally2(); break; } <prefabHash>5__10 = <pair>5__9.Key; if (!<snappointLookupByHash>5__3.TryGetValue(<prefabHash>5__10, out <points>5__11)) { if (Object.op_Implicit((Object)(object)DebugOverlayManager.Instance)) { <>s__12 = <pair>5__9.Value; for (<>s__13 = 0; <>s__13 < <>s__12.Length; <>s__13++) { <instance>5__14 = <>s__12[<>s__13]; <transform>5__15 = <instance>5__14.transform; DebugOverlayManager.Instance.UnregisterPoints(<transform>5__15); DebugOverlayManager.Instance.UnregisterObject(<transform>5__15); <transform>5__15 = null; <instance>5__14 = null; } <>s__12 = null; } continue; } <>s__16 = <pair>5__9.Value; <>s__17 = 0; goto IL_052b; } <>m__Finally2(); <>s__8 = default(Dictionary<int, GameObject[]>.Enumerator); _activeCoroutine = null; result = false; break; } break; IL_051d: <>s__17++; goto IL_052b; IL_052b: if (<>s__17 < <>s__16.Length) { <instance>5__18 = <>s__16[<>s__17]; if (!Object.op_Implicit((Object)(object)<instance>5__18)) { goto IL_051d; } <transform>5__19 = <instance>5__18.transform; if (Object.op_Implicit((Object)(object)DebugOverlayManager.Instance)) { DebugOverlayManager.Instance.UnregisterPoints(<transform>5__19); DebugOverlayManager.Instance.UnregisterObject(<transform>5__19); } RecreateSnappointsInObject(<instance>5__18, <points>5__11); if (Object.op_Implicit((Object)(object)DebugOverlayManager.Instance)) { DebugOverlayManager.Instance.RegisterObject(<transform>5__19); DebugOverlayManager.Instance.RegisterSnapPoints(<transform>5__19); } <>2__current = null; <>1__state = 2; result = true; break; } <>s__16 = null; <points>5__11 = null; <pair>5__9 = default(KeyValuePair<int, GameObject[]>); goto IL_0559; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>s__5).Dispose(); } private void <>m__Finally2() { <>1__state = -1; ((IDisposable)<>s__8).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static Coroutine? _activeCoroutine; public static void RecreateSnappoints(string? onlyForAPrefab = null) { if (Object.op_Implicit((Object)(object)Plugin.Instance) && Helper.IsMainScene() && !Helper.IsDedicatedServer() && Object.op_Implicit((Object)(object)ZNetScene.instance)) { if (_activeCoroutine != null) { ((MonoBehaviour)Plugin.Instance).StopCoroutine(_activeCoroutine); } _activeCoroutine = ((MonoBehaviour)Plugin.Instance).StartCoroutine(RecreateSnappointsRoutine(onlyForAPrefab)); } } [IteratorStateMachine(typeof(<RecreateSnappointsRoutine>d__2))] private static IEnumerator RecreateSnappointsRoutine(string? onlyForAPrefab = null) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RecreateSnappointsRoutine>d__2(0) { onlyForAPrefab = onlyForAPrefab }; } public static void RecreateSnappointsInObject(GameObject obj, Vector3[] points) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < obj.transform.childCount; i = checked(i + 1)) { Transform child = obj.transform.GetChild(i); if (((Component)child).CompareTag("snappoint")) { ((Object)child).name = ((Object)child).name + " [Destroyed]"; Object.Destroy((Object)(object)((Component)child).gameObject); } } foreach (Vector3 localPosition in points) { GameObject val = new GameObject("_snappoint"); val.transform.parent = obj.transform; val.transform.localPosition = localPosition; val.tag = "snappoint"; val.SetActive(false); } } } public static class VectorExtensions { public static Vector2 Round(this Vector2 vector, int n) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) return new Vector2((float)Math.Round(vector.x, n), (float)Math.Round(vector.y, n)); } public static Vector3 Round(this Vector3 vector, int n) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) return new Vector3((float)Math.Round(vector.x, n), (float)Math.Round(vector.y, n), (float)Math.Round(vector.z, n)); } } } namespace ChestSnap.Helpers.Yaml { public sealed class Vector3YamlConverter : IYamlTypeConverter { public bool Accepts(Type type) { return type == typeof(Vector3); } public object? ReadYaml(IParser parser, Type type, ObjectDeserializer rootDeserializer) { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) YamlDotNet.Core.Events.Scalar scalar = parser.Consume<YamlDotNet.Core.Events.Scalar>(); string text = scalar.Value.TrimStart(new char[1] { '(' }).TrimEnd(new char[1] { ')' }); string[] array = text.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (array.Length != 3) { Mark start = scalar.Start; Mark end = scalar.End; throw new YamlException(in start, in end, $"Expected 3 components for Vector3, got {array.Length}"); } return (object)new Vector3(float.Parse(array[0], CultureInfo.InvariantCulture), float.Parse(array[1], CultureInfo.InvariantCulture), float.Parse(array[2], CultureInfo.InvariantCulture)); } public void WriteYaml(IEmitter emitter, object? value, Type type, ObjectSerializer serializer) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Vector3 val = (Vector3)value; emitter.Emit(new YamlDotNet.Core.Events.Scalar(FormattableString.Invariant($"({val.x}, {val.y}, {val.z})"))); } } } namespace ChestSnap.DebugVisuals { public static class BoundsComputer { [Serializable] public class Config { public float minSize = 0.1f; public float mergeThreshold = 0.7f; public int maxBounds = 16; public bool removeContained = true; public bool mergeOverlapping = true; public string[] ignoreTags = Array.Empty<string>(); public static Config Default => new Config(); } private class Vector3EqualityComparer : IEqualityComparer<Vector3> { private readonly float _epsilon; public Vector3EqualityComparer(float epsilon) { _epsilon = epsilon; } public bool Equals(Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Vector3.Distance(a, b) < _epsilon; } public int GetHashCode(Vector3 obj) { return ((object)(Vector3)(ref obj)).GetHashCode(); } } public static List<BoundData> ComputeBounds(Transform obj, Config? config = null) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) if (config == null) { config = Config.Default; } Collider[] componentsInChildren = ((Component)obj).GetComponentsInChildren<Collider>(true); List<BoundData> list = new List<BoundData>(); Collider[] array = componentsInChildren; foreach (Collider val in array) { if (!((Object)(object)val == (Object)null) && ShouldProcess(val, config) && TryCreateBound(val, out var bound) && !(((Vector3)(ref bound.m_size)).sqrMagnitude < config.minSize * config.minSize)) { list.Add(bound); } } if (config.removeContained) { RemoveContainedBounds(list); } if (config.mergeOverlapping) { MergeOverlappingBounds(list, config.mergeThreshold); } ClampBoundsCount(list, config.maxBounds, config.mergeThreshold); return list; } private static bool ShouldProcess(Collider collider, Config config) { if (!collider.enabled || !((Component)collider).gameObject.activeInHierarchy) { return false; } if (collider.isTrigger) { return false; } string[] ignoreTags = config.ignoreTags; foreach (string text in ignoreTags) { if (((Component)collider).CompareTag(text)) { return false; } } return true; } private static bool TryCreateBound(Collider collider, out BoundData bound) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) bound = default(BoundData); Transform transform = ((Component)collider).transform; Vector3 lossyScale = transform.lossyScale; BoxCollider val = (BoxCollider)(object)((collider is BoxCollider) ? collider : null); if (val == null) { SphereCollider val2 = (SphereCollider)(object)((collider is SphereCollider) ? collider : null); if (val2 == null) { CapsuleCollider val3 = (CapsuleCollider)(object)((collider is CapsuleCollider) ? collider : null); if (val3 == null) { MeshCollider val4 = (MeshCollider)(object)((collider is MeshCollider) ? collider : null); if (val4 != null && (Object)(object)val4.sharedMesh != (Object)null) { bound = CreateMeshBound(val4, transform, lossyScale); return true; } return false; } bound = CreateCapsuleBound(val3, transform, lossyScale); return true; } bound = CreateSphereBound(val2, transform, lossyScale); return true; } bound = CreateBoxBound(val, transform, lossyScale); return true; } private static BoundData CreateBoxBound(BoxCollider box, Transform t, Vector3 scale) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) BoundData result = default(BoundData); result.m_pos = t.TransformPoint(box.center); result.m_rot = t.rotation; result.m_size = Vector3.Scale(box.size, scale); return result; } private static BoundData CreateSphereBound(SphereCollider sphere, Transform t, Vector3 scale) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(new float[3] { Mathf.Abs(scale.x), Mathf.Abs(scale.y), Mathf.Abs(scale.z) }); float num2 = sphere.radius * num * 2f; BoundData result = default(BoundData); result.m_pos = t.TransformPoint(sphere.center); result.m_rot = Quaternion.identity; result.m_size = new Vector3(num2, num2, num2); return result; } private static BoundData CreateCapsuleBound(CapsuleCollider capsule, Transform t, Vector3 scale) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) (float maxRadScale, float heightScale) capsuleScales = GetCapsuleScales(capsule.direction, scale); float item = capsuleScales.maxRadScale; float item2 = capsuleScales.heightScale; float num = capsule.radius * item; float num2 = Mathf.Max(capsule.height * item2, num * 2f); float num3 = num * 2f; int direction = capsule.direction; if (1 == 0) { } Vector3 val = (Vector3)(direction switch { 0 => new Vector3(num2, num3, num3), 2 => new Vector3(num3, num3, num2), _ => new Vector3(num3, num2, num3), }); if (1 == 0) { } Vector3 size = val; BoundData result = default(BoundData); result.m_pos = t.TransformPoint(capsule.center); result.m_rot = t.rotation; result.m_size = size; return result; } private static (float maxRadScale, float heightScale) GetCapsuleScales(int direction, Vector3 scale) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } (float, float) result = direction switch { 0 => (Mathf.Max(Mathf.Abs(scale.y), Mathf.Abs(scale.z)), Mathf.Abs(scale.x)), 2 => (Mathf.Max(Mathf.Abs(scale.x), Mathf.Abs(scale.y)), Mathf.Abs(scale.z)), _ => (Mathf.Max(Mathf.Abs(scale.x), Mathf.Abs(scale.z)), Mathf.Abs(scale.y)), }; if (1 == 0) { } return result; } private static BoundData CreateMeshBound(MeshCollider mesh, Transform t, Vector3 scale) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = mesh.sharedMesh.bounds; BoundData result = default(BoundData); result.m_pos = t.TransformPoint(((Bounds)(ref bounds)).center); result.m_rot = t.rotation; result.m_size = Vector3.Scale(((Bounds)(ref bounds)).size, scale); return result; } private static void RemoveContainedBounds(List<BoundData> bounds) { //IL_001e: 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) checked { for (int num = bounds.Count - 1; num >= 0; num--) { for (int i = 0; i < bounds.Count; i++) { if (num != i && IsContained(bounds[num], bounds[i])) { bounds.RemoveAt(num); break; } } } } } private static bool IsContained(BoundData inner, BoundData outer) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_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) float num = ((Vector3)(ref outer.m_size)).magnitude * 0.5f; float num2 = ((Vector3)(ref inner.m_size)).magnitude * 0.5f; Vector3 val = outer.m_pos - inner.m_pos; float magnitude = ((Vector3)(ref val)).magnitude; return magnitude + num2 < num; } private static void MergeOverlappingBounds(List<BoundData> bounds, float threshold) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) checked { bool flag; do { flag = false; for (int i = 0; i < bounds.Count; i++) { if (flag) { break; } for (int j = i + 1; j < bounds.Count; j++) { if (flag) { break; } if (OverlapRatio(bounds[i], bounds[j]) > threshold) { bounds[i] = MergeBounds(bounds[i], bounds[j]); bounds.RemoveAt(j); flag = true; } } } } while (flag); } } private static float OverlapRatio(BoundData a, BoundData b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_0039: 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_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) Vector3 val = a.m_pos - a.m_size * 0.5f; Vector3 val2 = a.m_pos + a.m_size * 0.5f; Vector3 val3 = b.m_pos - b.m_size * 0.5f; Vector3 val4 = b.m_pos + b.m_size * 0.5f; Vector3 val5 = Vector3.Max(Vector3.zero, Vector3.Min(val2, val4) - Vector3.Max(val, val3)); float num = val5.x * val5.y * val5.z; float num2 = Mathf.Min(a.m_size.x * a.m_size.y * a.m_size.z, b.m_size.x * b.m_size.y * b.m_size.z); return (num2 > 0f) ? (num / num2) : 0f; } private static BoundData MergeBounds(BoundData a, BoundData b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_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_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Min(a.m_pos - a.m_size * 0.5f, b.m_pos - b.m_size * 0.5f); Vector3 val2 = Vector3.Max(a.m_pos + a.m_size * 0.5f, b.m_pos + b.m_size * 0.5f); BoundData result = default(BoundData); result.m_pos = (val + val2) * 0.5f; result.m_rot = Quaternion.Slerp(a.m_rot, b.m_rot, 0.5f); result.m_size = val2 - val; return result; } private static void ClampBoundsCount(List<BoundData> bounds, int maxCount, float mergeThreshold) { float num = mergeThreshold; while (bounds.Count > maxCount) { num = Mathf.Max(0f, num - 0.1f); MergeOverlappingBounds(bounds, num); if (num <= 0f) { RemoveSmallestBounds(bounds, checked(bounds.Count - maxCount)); break; } } } private static void RemoveSmallestBounds(List<BoundData> bounds, int count) { bounds.Sort((BoundData a, BoundData b) => ((Vector3)(ref a.m_size)).sqrMagnitude.CompareTo(((Vector3)(ref b.m_size)).sqrMagnitude)); bounds.RemoveRange(0, count); } public static List<Vector3> FindOuterCorners(List<BoundData>? bounds, bool onlyBottom = false) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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) List<Vector3> result = new List<Vector3>(); if (bounds == null || bounds.Count == 0) { return result; } if (bounds.Count == 1) { return GetBoundCorners(bounds[0], onlyBottom); } List<Vector3> list = new List<Vector3>(); foreach (BoundData bound in bounds) { list.AddRange(GetBoundCorners(bound, onlyBottom: false)); } List<Vector3> list2 = new List<Vector3>(); foreach (Vector3 item in list) { if (!IsInsideAnyBound(item, bounds)) { list2.Add(item); } } if (onlyBottom) { list2 = FilterBottomCorners(list2); } return ComputeConvexHull(list2, onlyBottom); } private static List<Vector3> GetBoundCorners(BoundData bound, bool onlyBottom) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3>(8); Vector3 val = bound.m_size * 0.5f; Vector3 pos = bound.m_pos; Vector3[] array = (Vector3[])(object)new Vector3[8] { new Vector3(-1f, -1f, -1f), new Vector3(-1f, -1f, 1f), new Vector3(-1f, 1f, -1f), new Vector3(-1f, 1f, 1f), new Vector3(1f, -1f, -1f), new Vector3(1f, -1f, 1f), new Vector3(1f, 1f, -1f), new Vector3(1f, 1f, 1f) }; Vector3[] array2 = array; foreach (Vector3 val2 in array2) { if (!onlyBottom || !(val2.y > 0f)) { Vector3 val3 = Vector3.Scale(val, val2); Vector3 item = pos + bound.m_rot * val3; list.Add(item); } } return list; } private static bool IsInsideAnyBound(Vector3 point, List<BoundData> bounds) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) foreach (BoundData bound in bounds) { Vector3 val = Quaternion.Inverse(bound.m_rot) * (point - bound.m_pos); Vector3 val2 = bound.m_size * 0.5f; if (Mathf.Abs(val.x) < val2.x - 0.001f && Mathf.Abs(val.y) < val2.y - 0.001f && Mathf.Abs(val.z) < val2.z - 0.001f) { return true; } } return false; } private static List<Vector3> FilterBottomCorners(List<Vector3> corners) { if (corners.Count == 0) { return corners; } float minY = corners.Min((Vector3 c) => c.y); return corners.Where((Vector3 c) => c.y <= minY + 0.05f).ToList(); } private static List<Vector3> ComputeConvexHull(List<Vector3> points, bool is2D) { if (points.Count <= 3) { return points; } return is2D ? ConvexHull2D(points) : ConvexHull3D(points); } private static List<Vector3> ConvexHull2D(List<Vector3> points) { //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) if (points.Count <= 3) { return new List<Vector3>(points); } List<Vector3> list = (from p in points orderby p.x, p.z select p).ToList(); List<Vector3> list2 = new List<Vector3>(); checked { foreach (Vector3 item in list) { while (list2.Count >= 2 && Cross2D(list2[list2.Count - 2], list2[list2.Count - 1], item) <= 0f) { list2.RemoveAt(list2.Count - 1); } list2.Add(item); } List<Vector3> list3 = new List<Vector3>(); for (int num = list.Count - 1; num >= 0; num--) { Vector3 val = list[num]; while (list3.Count >= 2 && Cross2D(list3[list3.Count - 2], list3[list3.Count - 1], val) <= 0f) { list3.RemoveAt(list3.Count - 1); } list3.Add(val); } list2.RemoveAt(list2.Count - 1); list3.RemoveAt(list3.Count - 1); list2.AddRange(list3); return list2; } } private static float Cross2D(Vector3 o, Vector3 a, Vector3 b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) return (a.x - o.x) * (b.z - o.z) - (a.z - o.z) * (b.x - o.x); } private static List<Vector3> ConvexHull3D(List<Vector3> points) { List<Vector3> list = new List<Vector3>(); List<float> list2 = (from y in points.Select((Vector3 p) => Mathf.Round(p.y / 0.1f) * 0.1f).Distinct() orderby y select y).ToList(); foreach (float y2 in list2) { List<Vector3> list3 = points.Where((Vector3 p) => Mathf.Abs(p.y - y2) < 0.1f).ToList(); list.AddRange((list3.Count > 2) ? ConvexHull2D(list3) : list3); } return list.Distinct(new Vector3EqualityComparer(0.001f)).ToList(); } } public class DebugOverlayManager : MonoBehaviour { private struct LabelWidget { public GameObject root; public TextMeshProUGUI text; public Image background; public RectTransform rt; } private struct TrackedObject { public Transform transform; public List<BoundData>? bounds; } private struct TrackedPoint { public Transform transform; public Vector3 localPos; } private class OverlayGraphic : Graphic { private struct LineDef { public Vector2 a; public Vector2 b; public float width; public Color32 color; } private struct CircleDef { public Vector2 center; public float radius; public Color32 color; public int segments; } private readonly List<LineDef> _lines = new List<LineDef>(256); private readonly List<CircleDef> _circles = new List<CircleDef>(64); protected override void UpdateMaterial() { ((Graphic)this).UpdateMaterial(); ((Graphic)this).canvasRenderer.materialCount = 1; ((Graphic)this).canvasRenderer.SetMaterial(Graphic.defaultGraphicMaterial, (Texture)(object)Texture2D.whiteTexture); } public void Clear() { _lines.Clear(); _circles.Clear(); } public void AddLine(Vector2 a, Vector2 b, float width, Color lineColor) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) _lines.Add(new LineDef { a = a, b = b, width = width, color = Color32.op_Implicit(lineColor) }); } public void AddCircle(Vector2 center, float radius, Color color, int segments) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) _circles.Add(new CircleDef { center = center, radius = radius, color = Color32.op_Implicit(color), segments = Mathf.Max(segments, 4) }); } protected override void OnPopulateMesh(VertexHelper vh) { ((Graphic)this).OnPopulateMesh(vh); vh.Clear(); foreach (LineDef line in _lines) { PopulateLine(vh, line); } foreach (CircleDef circle in _circles) { PopulateCircle(vh, circle); } } private void PopulateLine(VertexHelper vh, LineDef l) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) Vector2 val = ScreenToLocal(l.a); Vector2 val2 = ScreenToLocal(l.b); Vector2 val3 = val2 - val; checked { if (!(((Vector2)(ref val3)).sqrMagnitude < 0.001f)) { Vector2 val4 = new Vector2(0f - ((Vector2)(ref val3)).normalized.y, ((Vector2)(ref val3)).normalized.x) * (l.width * 0.5f); int currentVertCount = vh.currentVertCount; vh.AddVert(Vector2.op_Implicit(val + val4), l.color, Vector4.op_Implicit(Vector2.zero)); vh.AddVert(Vector2.op_Implicit(val - val4), l.color, Vector4.op_Implicit(Vector2.zero)); vh.AddVert(Vector2.op_Implicit(val2 - val4), l.color, Vector4.op_Implicit(Vector2.zero)); vh.AddVert(Vector2.op_Implicit(val2 + val4), l.color, Vector4.op_Implicit(Vector2.zero)); vh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2); vh.AddTriangle(currentVertCount, currentVertCount + 2, currentVertCount + 3); } } } private void PopulateCircle(VertexHelper vh, CircleDef c) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) Vector2 val = ScreenToLocal(c.center); int segments = c.segments; int currentVertCount = vh.currentVertCount; vh.AddVert(Vector2.op_Implicit(val), c.color, Vector4.op_Implicit(Vector2.zero)); float num = (float)Math.PI * 2f / (float)segments; checked { for (int i = 0; i <= segments; i++) { float num2 = (float)i * num; Vector2 val2 = val + new Vector2(Mathf.Cos(num2), Mathf.Sin(num2)) * c.radius; vh.AddVert(Vector2.op_Implicit(val2), c.color, Vector4.op_Implicit(Vector2.zero)); if (i > 0) { vh.AddTriangle(currentVertCount, currentVertCount + i, currentVertCount + i + 1); } } } } private Vector2 ScreenToLocal(Vector2 screenPos) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) Vector2 result = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(((Graphic)this).rectTransform, screenPos, (Camera)null, ref result); return result; } } [Header("Rendering")] public float lineWidth = 1.5f; public float pointRadius = 5f; public float sizeModifier = 0.5f; public int pointSegments = 4; [Header("Labels")] public int labelFontSize = 10; public Color labelTextColor = Color.white; public Color labelBackgroundColor = new Color(0f, 0f, 0f, 0.7f); public Vector2 labelPadding = new Vector2(4f, 2f); public Vector2 labelOffset = new Vector2(6f, 6f); public string labelFormat = "0.##"; public TMP_FontAsset? labelFont; private Canvas _canvas = null; private OverlayGraphic _graphic = null; private Camera? _cam; private readonly List<TrackedObject> _objects = new List<TrackedObject>(); private readonly List<TrackedPoint> _points = new List<TrackedPoint>(); private readonly List<LabelWidget> _labelPool = new List<LabelWidget>(); private int _labelsUsed; private static readonly int[] _edgeA = new int[12] { 0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3 }; private static readonly int[] _edgeB = new int[12] { 1, 2, 3, 0, 5, 6, 7, 4, 4, 5, 6, 7 }; private static readonly Vector3[] _cornerSigns = (Vector3[])(object)new Vector3[8] { new Vector3(-1f, -1f, -1f), new Vector3(1f, -1f, -1f), new Vector3(1f, 1f, -1f), new Vector3(-1f, 1f, -1f), new Vector3(-1f, -1f, 1f), new Vector3(1f, -1f, 1f), new Vector3(1f, 1f, 1f), new Vector3(-1f, 1f, 1f) }; private readonly Vector3[] _corners = (Vector3[])(object)new Vector3[8]; private readonly Vector2[] _screen = (Vector2[])(object)new Vector2[8]; public static DebugOverlayManager? Instance { get; private set; } private void Awake() { if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } Instance = this; BuildCanvas(); } private void OnDestroy() { if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } private void LateUpdate() { if (Helper.IsMainScene()) { if ((Object)(object)_cam == (Object)null || !((Behaviour)_cam).isActiveAndEnabled) { _cam = Camera.main; } _graphic.Clear(); BeginLabels(); if (ConfigsContainer.ShowDebugVisuals == DebugVisualsDisplayMode.Hidden || (Object)(object)_cam == (Object)null) { EndLabels(); ((Graphic)_graphic).SetVerticesDirty(); return; } CleanupNulls(); DrawTrackedBoxes(); DrawSnapPoints(); EndLabels(); ((Graphic)_graphic).SetVerticesDirty(); } } public void RegisterObject(Transform target) { Transform target2 = target; if (!((Object)(object)target2 == (Object)null) && !_objects.Any((TrackedObject x) => (Object)(object)x.transform == (Object)(object)target2)) { _objects.Add(new TrackedObject { transform = target2, bounds = BoundsComputer.ComputeBounds(target2) }); } } public void UnregisterObject(Transform target) { Transform target2 = target; if (!((Object)(object)target2 == (Object)null)) { _objects.RemoveAll((TrackedObject o) => (Object)(object)o.transform == (Object)(object)target2); } } public void RegisterSnapPoints(Transform parent) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) Transform parent2 = parent; if ((Object)(object)parent2 == (Object)null || _points.Any((TrackedPoint x) => (Object)(object)x.transform == (Object)(object)parent2)) { return; } for (int i = 0; i < parent2.childCount; i = checked(i + 1)) { Transform child = parent2.GetChild(i); if ((((Component)child).tag == "snappoint" || ((Object)child).name == "_snappoint") && !((Object)child).name.Contains("[Destroyed]")) { _points.Add(new TrackedPoint { transform = parent2, localPos = child.localPosition }); } } } public void UnregisterPoints(Transform parent) { Transform parent2 = parent; int num = _points.RemoveAll((TrackedPoint p) => (Object)(object)p.transform == (Object)(object)parent2); } public void ClearAll() { _objects.Clear(); _points.Clear(); } private void BuildCanvas() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("DebugOverlay_Canvas"); val.transform.SetParent(((Component)this).transform, false); _canvas = val.AddComponent<Canvas>(); _canvas.renderMode = (RenderMode)0; _canvas.sortingOrder = 32767; CanvasScaler val2 = val.AddComponent<CanvasScaler>(); val2.uiScaleMode = (ScaleMode)1; val2.referenceResolution = new Vector2(1920f, 1080f); val2.matchWidthOrHeight = 0.5f; GameObject val3 = new GameObject("Graphic"); val3.transform.SetParent(val.transform, false); RectTransform val4 = val3.AddComponent<RectTransform>(); val4.anchorMin = Vector2.zero; val4.anchorMax = Vector2.one; val4.offsetMin = Vector2.zero; val4.offsetMax = Vector2.zero; _graphic = val3.AddComponent<OverlayGraphic>(); ((Graphic)_graphic).raycastTarget = false; } private LabelWidget CreateLabel() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("DebugLabel"); val.transform.SetParent(((Component)_canvas).transform, false); RectTransform val2 = val.AddComponent<RectTransform>(); val2.pivot = new Vector2(0f, 0f); Image val3 = val.AddComponent<Image>(); ((Graphic)val3).color = labelBackgroundColor; ((Graphic)val3).raycastTarget = false; GameObject val4 = new GameObject("Text"); val4.transform.SetParent(val.transform, false); RectTransform val5 = val4.AddComponent<RectTransform>(); val5.anchorMin = Vector2.zero; val5.anchorMax = Vector2.one; val5.offsetMin = labelPadding; val5.offsetMax = -labelPadding; val4.SetActive(false); TextMeshProUGUI val6 = val4.AddComponent<TextMeshProUGUI>(); ((TMP_Text)val6).fontSize = labelFontSize; ((Graphic)val6).color = labelTextColor; ((TMP_Text)val6).alignment = (TextAlignmentOptions)514; ((TMP_Text)val6).overflowMode = (TextOverflowModes)0; ((TMP_Text)val6).textWrappingMode = (TextWrappingModes)0; ((Graphic)val6).raycastTarget = false; ((TMP_Text)val6).richText = false; if ((Object)(object)labelFont != (Object)null) { ((TMP_Text)val6).font = labelFont; } val4.SetActive(true); ContentSizeFitter val7 = val.AddComponent<ContentSizeFitter>(); val7.horizontalFit = (FitMode)2; val7.verticalFit = (FitMode)2; LayoutElement val8 = val4.AddComponent<LayoutElement>(); val8.ignoreLayout = false; val.SetActive(false); LabelWidget result = default(LabelWidget); result.root = val; result.text = val6; result.background = val3; result.rt = val2; return result; } private LabelWidget AcquireLabel() { if (_labelsUsed >= _labelPool.Count) { _labelPool.Add(CreateLabel()); } LabelWidget result = _labelPool[_labelsUsed]; checked { _labelsUsed++; return result; } } private void BeginLabels() { _labelsUsed = 0; } private void EndLabels() { for (int i = 0; i < _labelPool.Count; i = checked(i + 1)) { bool flag = i < _labelsUsed; if (_labelPool[i].root.activeSelf != flag) { _labelPool[i].root.SetActive(flag); } } } private void PlaceLabel(Vector2 screenPos, string content) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) LabelWidget labelWidget = AcquireLabel(); ((TMP_Text)labelWidget.text).text = content; ((TMP_Text)labelWidget.text).fontSize = labelFontSize; ((Graphic)labelWidget.text).color = labelTextColor; ((Graphic)labelWidget.background).color = labelBackgroundColor; RectTransform rectTransform = ((TMP_Text)labelWidget.text).rectTransform; rectTransform.offsetMin = labelPadding; rectTransform.offsetMax = -labelPadding; Vector2 anchoredPosition = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(((Component)_canvas).GetComponent<RectTransform>(), screenPos + labelOffset, (Camera)null, ref anchoredPosition); labelWidget.rt.anchoredPosition = anchoredPosition; labelWidget.root.SetActive(true); LayoutRebuilder.ForceRebuildLayoutImmediate(labelWidget.rt); } private void DrawTrackedBoxes() { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) DebugVisualsDisplayMode showDebugVisuals = ConfigsContainer.ShowDebugVisuals; if (showDebugVisuals == DebugVisualsDisplayMode.Hidden || !ConfigsContainer.DrawBounds) { return; } Transform val = null; try { Player localPlayer = Player.m_localPlayer; object obj; if (localPlayer == null) { obj = null; } else { Piece hoveringPiece = localPlayer.m_hoveringPiece; obj = ((hoveringPiece != null) ? ((Component)hoveringPiece).gameObject.transform : null); } val = (Transform)obj; } catch (NullReferenceException) { } foreach (TrackedObject @object in _objects) { List<BoundData> bounds = @object.bounds; if (bounds == null || (showDebugVisuals == DebugVisualsDisplayMode.OnHover && (Object)(object)@object.transform != (Object)(object)val)) { continue; } foreach (BoundData item in bounds) { DrawBoxWorld(item.m_pos, item.m_rot, item.m_size, ConfigsContainer.BoundsColor); } if (showDebugVisuals != DebugVisualsDisplayMode.OnHover) { continue; } break; } } private void DrawBox(Transform parent, BoundData bd) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //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) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0135: 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_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_cam == (Object)null) { return; } Vector3 val = bd.m_size * 0.5f; _corners[0] = new Vector3(0f - val.x, 0f - val.y, 0f - val.z); _corners[1] = new Vector3(val.x, 0f - val.y, 0f - val.z); _corners[2] = new Vector3(val.x, val.y, 0f - val.z); _corners[3] = new Vector3(0f - val.x, val.y, 0f - val.z); _corners[4] = new Vector3(0f - val.x, 0f - val.y, val.z); _corners[5] = new Vector3(val.x, 0f - val.y, val.z); _corners[6] = new Vector3(val.x, val.y, val.z); _corners[7] = new Vector3(0f - val.x, val.y, val.z); checked { for (int i = 0; i < 8; i++) { Vector3 val2 = parent.TransformPoint(bd.m_pos + bd.m_rot * _corners[i]); Vector3 val3 = _cam.WorldToViewportPoint(val2); if (val3.z <= 0f) { return; } _screen[i] = Vector2.op_Implicit(_cam.WorldToScreenPoint(val2)); } for (int j = 0; j < 12; j++) { _graphic.AddLine(_screen[_edgeA[j]], _screen[_edgeB[j]], lineWidth, ConfigsContainer.BoundsColor); } } } private void DrawBoxWorld(Vector3 worldCenter, Quaternion worldRot, Vector3 size, Color color) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL