Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of OmniumLib v0.9.0
OmniumLib.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("Omniscye")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a63a05b5692081e245cc708d987b8804730213b3")] [assembly: AssemblyProduct("OmniumLib")] [assembly: AssemblyTitle("OmniumLib")] [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 Empress.OmniumLib { [BepInPlugin("dev.empress.omniumlib", "OmniumLib", "1.1.0")] public sealed class OmniumLibPlugin : BaseUnityPlugin { public const string PluginGuid = "dev.empress.omniumlib"; public const string PluginName = "OmniumLib"; public const string PluginVersion = "1.1.0"; internal static ManualLogSource Log; internal static Harmony Harmony; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Harmony = new Harmony("dev.empress.omniumlib"); if ((Object)(object)OmnLibHost.Instance == (Object)null) { OmnLibHost.Create(); } SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) try { Events.RaiseSceneLoaded(scene, mode); } catch (Exception arg) { Log.LogError((object)$"[OmniumLib] Events.RaiseSceneLoaded failed: {arg}"); } }; ((BaseUnityPlugin)this).Logger.LogInfo((object)"OmniumLib 1.1.0 ready."); } private void OnDestroy() { try { Harmony harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } catch { } } } public static class Events { public static event Action<Scene, LoadSceneMode> SceneLoaded; public static event Action BundlesReady; public static event Action<bool> FocusChanged; internal static void RaiseSceneLoaded(Scene s, LoadSceneMode m) { //IL_000b: 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) Events.SceneLoaded?.Invoke(s, m); } internal static void RaiseBundlesReady() { Events.BundlesReady?.Invoke(); } internal static void RaiseFocus(bool hasFocus) { Events.FocusChanged?.Invoke(hasFocus); } } public sealed class OmnLibHost : MonoBehaviour { public static OmnLibHost Instance { get; internal set; } public static void Create() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)Instance)) { GameObject val = new GameObject("OmniumLibHost"); Object.DontDestroyOnLoad((Object)(object)val); Instance = val.AddComponent<OmnLibHost>(); } } public void Run(IEnumerator routine) { ((MonoBehaviour)this).StartCoroutine(routine); } } public static class BundleGate { [CompilerGenerated] private sealed class <>c__DisplayClass0_0 { public bool eventFired; internal void <WaitForRepoLibBundles>b__0() { eventFired = true; } } [CompilerGenerated] private sealed class <>c__DisplayClass0_1 { public FieldInfo opsField; internal int <WaitForRepoLibBundles>b__1() { object value = opsField.GetValue(null); if (value is ICollection collection) { return collection.Count; } PropertyInfo propertyInfo = value?.GetType().GetProperty("Count", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); return (propertyInfo != null) ? ((int)propertyInfo.GetValue(value)) : 0; } } [CompilerGenerated] private sealed class <WaitForRepoLibBundles>d__0 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public float timeoutSec; public float pollSec; public bool verbose; private <>c__DisplayClass0_0 <>8__1; private float <timeout>5__2; private float <poll>5__3; private float <deadline>5__4; private Type <bundleLoader>5__5; private Delegate <evtHandler>5__6; private Func<int> <getOps>5__7; private EventInfo <onAllLoaded>5__8; private Action <handler>5__9; private Exception <e>5__10; private <>c__DisplayClass0_1 <>8__11; private string <why>5__12; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitForRepoLibBundles>d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>8__1 = null; <bundleLoader>5__5 = null; <evtHandler>5__6 = null; <getOps>5__7 = null; <onAllLoaded>5__8 = null; <handler>5__9 = null; <e>5__10 = null; <>8__11 = null; <why>5__12 = null; <>1__state = -2; } private bool MoveNext() { //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>8__1 = new <>c__DisplayClass0_0(); <timeout>5__2 = Mathf.Max(1f, timeoutSec); <poll>5__3 = Mathf.Max(0.05f, pollSec); <deadline>5__4 = Time.realtimeSinceStartup + <timeout>5__2; <bundleLoader>5__5 = TypeCache.FindType("REPOLib.BundleLoader"); if (<bundleLoader>5__5 == null) { OmniumLibPlugin.Log.LogDebug((object)"[OmniumLib] REPOLib not detected; skipping bundle wait."); return false; } <>8__1.eventFired = false; <evtHandler>5__6 = null; try { <onAllLoaded>5__8 = <bundleLoader>5__5.GetEvent("OnAllBundlesLoaded", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (<onAllLoaded>5__8?.EventHandlerType != null) { <handler>5__9 = delegate { <>8__1.eventFired = true; }; <evtHandler>5__6 = Delegate.CreateDelegate(<onAllLoaded>5__8.EventHandlerType, <handler>5__9.Target, <handler>5__9.Method); <onAllLoaded>5__8.AddEventHandler(null, <evtHandler>5__6); <handler>5__9 = null; } <onAllLoaded>5__8 = null; } catch (Exception ex) { <e>5__10 = ex; OmniumLibPlugin.Log.LogDebug((object)("[OmniumLib] REPOLib event hook failed: " + <e>5__10.Message)); } <getOps>5__7 = null; try { <>8__11 = new <>c__DisplayClass0_1(); <>8__11.opsField = <bundleLoader>5__5.GetField("_operations", BindingFlags.Static | BindingFlags.NonPublic); if (<>8__11.opsField != null) { <getOps>5__7 = delegate { object value = <>8__11.opsField.GetValue(null); if (value is ICollection collection) { return collection.Count; } PropertyInfo propertyInfo = value?.GetType().GetProperty("Count", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); return (propertyInfo != null) ? ((int)propertyInfo.GetValue(value)) : 0; }; } <>8__11 = null; } catch { } OmniumLibPlugin.Log.LogInfo((object)$"[OmniumLib] Waiting for REPOLib bundles (timeout {<timeout>5__2:0.0}s)…"); break; case 1: <>1__state = -1; break; } if (Time.realtimeSinceStartup < <deadline>5__4 && !<>8__1.eventFired && (<getOps>5__7 == null || <getOps>5__7() != 0)) { if (verbose) { <why>5__12 = (<>8__1.eventFired ? "event fired" : ((<getOps>5__7 == null) ? "unknown (no ops field)" : $"ops={<getOps>5__7()}")); OmniumLibPlugin.Log.LogInfo((object)("[OmniumLib] Waiting… " + <why>5__12)); <why>5__12 = null; } <>2__current = (object)new WaitForSecondsRealtime(<poll>5__3); <>1__state = 1; return true; } if ((object)<evtHandler>5__6 != null) { try { <bundleLoader>5__5.GetEvent("OnAllBundlesLoaded", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.RemoveEventHandler(null, <evtHandler>5__6); } catch { } } OmniumLibPlugin.Log.LogInfo((object)"[OmniumLib] REPOLib bundle gate cleared."); Events.RaiseBundlesReady(); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(<WaitForRepoLibBundles>d__0))] public static IEnumerator WaitForRepoLibBundles(float timeoutSec = 25f, float pollSec = 0.25f, bool verbose = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitForRepoLibBundles>d__0(0) { timeoutSec = timeoutSec, pollSec = pollSec, verbose = verbose }; } } public static class TypeCache { private static readonly Dictionary<string, Type> _byFull = new Dictionary<string, Type>(); private static readonly Dictionary<string, Type> _byShort = new Dictionary<string, Type>(StringComparer.Ordinal); private static float _lastSweep; private static readonly object _lock = new object(); public static Type FindType(string fullNameOrShort) { if (string.IsNullOrEmpty(fullNameOrShort)) { return null; } lock (_lock) { if (_byFull.TryGetValue(fullNameOrShort, out Type value)) { return value; } if (_byShort.TryGetValue(fullNameOrShort, out value)) { return value; } SweepAssemblies(); if (_byFull.TryGetValue(fullNameOrShort, out value)) { return value; } if (_byShort.TryGetValue(fullNameOrShort, out value)) { return value; } } return null; } private static void SweepAssemblies() { if (Time.realtimeSinceStartup - _lastSweep < 0.5f) { return; } _lastSweep = Time.realtimeSinceStartup; try { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type[] types; try { types = assembly.GetTypes(); } catch { continue; } Type[] array = types; foreach (Type type in array) { if (!(type == null)) { string fullName = type.FullName; string name = type.Name; if (!string.IsNullOrEmpty(fullName)) { _byFull[fullName] = type; } if (!string.IsNullOrEmpty(name) && !_byShort.ContainsKey(name)) { _byShort[name] = type; } } } } } catch (Exception ex) { ManualLogSource log = OmniumLibPlugin.Log; if (log != null) { log.LogDebug((object)("[OmniumLib] Type sweep failed: " + ex.Message)); } } } } public static class PlayerLocator { private static Transform _cached; private static float _lastCheck; public static Transform GetPlayer(bool forceRefresh = false, bool log = false) { if (!forceRefresh && Object.op_Implicit((Object)(object)_cached) && Time.realtimeSinceStartup - _lastCheck < 1f) { return _cached; } _lastCheck = Time.realtimeSinceStartup; Transform val = null; try { Type type = TypeCache.FindType("PlayerController"); if (type != null) { object? obj = type.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null); Component val2 = (Component)((obj is Component) ? obj : null); if (Object.op_Implicit((Object)(object)val2)) { val = val2.transform; } if (Object.op_Implicit((Object)(object)val) && log) { OmniumLibPlugin.Log.LogInfo((object)"[OmniumLib] Player via PlayerController.instance"); } } if ((Object)(object)val == (Object)null) { Type type2 = TypeCache.FindType("PlayerAvatar"); if (type2 != null) { Object[] array = Object.FindObjectsOfType(type2); Object[] array2 = array; foreach (Object obj2 in array2) { bool flag = false; try { FieldInfo field = type2.GetField("isLocal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { flag = (bool)(field.GetValue(obj2) ?? ((object)false)); } } catch { } if (!flag) { continue; } object? obj4 = type2.GetField("playerTransform", BindingFlags.Instance | BindingFlags.Public)?.GetValue(obj2); Transform val3 = (Transform)((obj4 is Transform) ? obj4 : null); if (Object.op_Implicit((Object)(object)val3)) { val = val3; if (log) { OmniumLibPlugin.Log.LogInfo((object)"[OmniumLib] Player via PlayerAvatar.local"); } } break; } if ((Object)(object)val == (Object)null && array.Length != 0) { Object obj5 = array[0]; Object obj6 = ((obj5 is Component) ? obj5 : null); Transform val4 = ((obj6 != null) ? ((Component)obj6).transform : null); if (Object.op_Implicit((Object)(object)val4)) { val = val4; if (log) { OmniumLibPlugin.Log.LogInfo((object)"[OmniumLib] Player via first PlayerAvatar transform"); } } } } } if ((Object)(object)val == (Object)null) { GameObject val5 = GameObject.FindGameObjectWithTag("Player"); if (Object.op_Implicit((Object)(object)val5)) { val = val5.transform; if (log) { OmniumLibPlugin.Log.LogInfo((object)"[OmniumLib] Player via tag 'Player'"); } } } if ((Object)(object)val == (Object)null && Object.op_Implicit((Object)(object)Camera.main)) { val = ((Component)Camera.main).transform.root; if (log) { OmniumLibPlugin.Log.LogInfo((object)"[OmniumLib] Player via Camera.main.root"); } } } catch (Exception ex) { OmniumLibPlugin.Log.LogError((object)("[OmniumLib] PlayerLocator failed: " + ex)); } _cached = val; return val; } } public sealed class ObjectIndex { private List<GameObject> _all = new List<GameObject>(); private DateTime _lastBuild; public IReadOnlyList<GameObject> All => _all; public void Rebuild(bool force = false) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) if (!force && (DateTime.Now - _lastBuild).TotalSeconds < 2.0) { return; } _lastBuild = DateTime.Now; try { Scene activeScene = SceneManager.GetActiveScene(); List<GameObject> list = new List<GameObject>(); GameObject[] rootGameObjects = ((Scene)(ref activeScene)).GetRootGameObjects(); foreach (GameObject root in rootGameObjects) { Collect(root, list); } _all = list; } catch (Exception ex) { OmniumLibPlugin.Log.LogError((object)("[OmniumLib] ObjectIndex rebuild failed: " + ex)); } } public IEnumerable<GameObject> SearchByName(string containsLower) { string containsLower2 = containsLower; if (string.IsNullOrEmpty(containsLower2)) { return _all; } return _all.Where((GameObject go) => Object.op_Implicit((Object)(object)go) && ((Object)go).name != null && ((Object)go).name.ToLowerInvariant().Contains(containsLower2)); } public static string GetPath(Transform tr) { if (!Object.op_Implicit((Object)(object)tr)) { return "<null>"; } Stack<string> stack = new Stack<string>(); while (Object.op_Implicit((Object)(object)tr)) { stack.Push(((Object)tr).name); tr = tr.parent; } return string.Join("/", stack); } private void Collect(GameObject root, List<GameObject> list) { if (Object.op_Implicit((Object)(object)root)) { list.Add(root); Transform transform = root.transform; for (int i = 0; i < transform.childCount; i++) { Collect(((Component)transform.GetChild(i)).gameObject, list); } } } } public sealed class InputGuard { private readonly List<Behaviour> _disabled = new List<Behaviour>(); private CursorLockMode _prevLock; private bool _prevVisible; private CharacterController _cc; private bool _ccPrev; private Rigidbody _rb; private bool _rbPrevKinematic; private bool _rbPrevDetect; public bool RespectLoaders { get; set; } = true; public void Begin() { //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_04bf: Unknown result type (might be due to invalid IL or missing references) try { _prevLock = Cursor.lockState; _prevVisible = Cursor.visible; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; _disabled.Clear(); _cc = null; _rb = null; Transform player = PlayerLocator.GetPlayer(); if (Object.op_Implicit((Object)(object)player)) { List<Behaviour> list = new List<Behaviour>(); list.AddRange(((Component)player).GetComponentsInChildren<Behaviour>(true)); if (Object.op_Implicit((Object)(object)Camera.main)) { list.AddRange(((Component)Camera.main).GetComponentsInChildren<Behaviour>(true)); } foreach (Behaviour item in list) { if (!Object.op_Implicit((Object)(object)item) || !item.enabled) { continue; } Type type = ((object)item).GetType(); if (type == typeof(Camera) || type == typeof(AudioListener)) { continue; } string text = ""; try { text = type.Assembly.GetName().Name ?? ""; } catch { } bool flag = text.Equals("Assembly-CSharp", StringComparison.OrdinalIgnoreCase) || text.Equals("Assembly-CSharp-firstpass", StringComparison.OrdinalIgnoreCase) || text.StartsWith("UnityEngine", StringComparison.OrdinalIgnoreCase) || text.StartsWith("Unity.", StringComparison.OrdinalIgnoreCase); bool flag2 = text.IndexOf("RepoLib", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("REPOLib", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("OmniumLib", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("OmniumLibrary", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("BepInEx", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Harmony", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Thunderstore", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Plugin", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Mod", StringComparison.OrdinalIgnoreCase) >= 0; if (RespectLoaders && (!flag || flag2)) { continue; } string name = type.Name; bool flag3 = name.Contains("Mouse") || name.Contains("Look") || name.Contains("Locomotion") || name.Contains("Motor") || name.Contains("Movement") || (name.Contains("Input") && (name.Contains("Player") || name.Contains("Character") || name.Contains("Camera"))) || (name.Contains("Controller") && (name.Contains("Player") || name.Contains("Character") || name.Contains("FirstPerson") || name.Contains("ThirdPerson") || name.Contains("Camera"))); string text2 = ((Object.op_Implicit((Object)(object)item) && Object.op_Implicit((Object)(object)((Component)item).gameObject)) ? ((Object)((Component)item).gameObject).name : string.Empty); if (RespectLoaders) { string text3 = name.ToLowerInvariant(); if (text3.Contains("ui") || text3.Contains("canvas") || text3.Contains("graphic")) { flag3 = false; } if (text2.IndexOf("HUD", StringComparison.OrdinalIgnoreCase) >= 0) { flag3 = false; } if (text2.IndexOf("REPOLib", StringComparison.OrdinalIgnoreCase) >= 0) { flag3 = false; } if (text2.IndexOf("OmniumLib", StringComparison.OrdinalIgnoreCase) >= 0) { flag3 = false; } } if (flag3) { item.enabled = false; _disabled.Add(item); } } _cc = ((Component)player).GetComponent<CharacterController>(); if (Object.op_Implicit((Object)(object)_cc)) { _ccPrev = ((Collider)_cc).enabled; ((Collider)_cc).enabled = false; } _rb = ((Component)player).GetComponent<Rigidbody>(); if (Object.op_Implicit((Object)(object)_rb)) { _rbPrevKinematic = _rb.isKinematic; _rbPrevDetect = _rb.detectCollisions; _rb.isKinematic = true; _rb.detectCollisions = false; _rb.velocity = Vector3.zero; } } Events.RaiseFocus(hasFocus: true); OmniumLibPlugin.Log.LogInfo((object)"[OmniumLib] InputGuard: ENABLED"); } catch (Exception ex) { OmniumLibPlugin.Log.LogError((object)("[OmniumLib] InputGuard.Begin failed: " + ex)); } } public void End() { //IL_00aa: Unknown result type (might be due to invalid IL or missing references) try { foreach (Behaviour item in _disabled) { if (Object.op_Implicit((Object)(object)item)) { item.enabled = true; } } _disabled.Clear(); if (Object.op_Implicit((Object)(object)_cc)) { ((Collider)_cc).enabled = _ccPrev; } if (Object.op_Implicit((Object)(object)_rb)) { _rb.isKinematic = _rbPrevKinematic; _rb.detectCollisions = _rbPrevDetect; } Cursor.lockState = _prevLock; Cursor.visible = _prevVisible; Events.RaiseFocus(hasFocus: false); OmniumLibPlugin.Log.LogInfo((object)"[OmniumLib] InputGuard: DISABLED"); } catch (Exception ex) { OmniumLibPlugin.Log.LogError((object)("[OmniumLib] InputGuard.End failed: " + ex)); } } } public sealed class LevelDebugVis : MonoBehaviour { private static LevelDebugVis _instance; [Header("Visuals")] public float MarkerScale = 0.35f; public float PathMarkerScale = 0.22f; public Color LevelPointColor = new Color(0.2f, 1f, 0.4f, 0.85f); public Color PathPointColor = new Color(1f, 0.1f, 0.1f, 1f); public float Emission = 3f; public float LineWidth = 0.02f; private GameObject _root; private Material _unlitMat; public static bool Active => Object.op_Implicit((Object)(object)_instance) && Object.op_Implicit((Object)(object)_instance._root) && _instance._root.activeSelf; public static void Enable(bool on = true) { if (on) { Ensure(); } else { Disable(); } } public static void Disable() { if (Object.op_Implicit((Object)(object)_instance)) { if (Object.op_Implicit((Object)(object)_instance._root)) { Object.Destroy((Object)(object)_instance._root); } Object.Destroy((Object)(object)_instance); _instance = null; } } public static void Rebuild() { if (Object.op_Implicit((Object)(object)_instance)) { _instance.Build(); } } private static void Ensure() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_instance)) { _instance.Build(); return; } GameObject val = (GameObject)(Object.op_Implicit((Object)(object)OmnLibHost.Instance) ? ((object)((Component)OmnLibHost.Instance).gameObject) : ((object)new GameObject("OmniumLibHost"))); if (!Object.op_Implicit((Object)(object)OmnLibHost.Instance)) { OmnLibHost.Instance = val.AddComponent<OmnLibHost>(); } _instance = val.AddComponent<LevelDebugVis>(); _instance.Build(); } private void OnEnable() { Events.SceneLoaded += OnSceneLoaded; } private void OnDisable() { Events.SceneLoaded -= OnSceneLoaded; } private void OnSceneLoaded(Scene s, LoadSceneMode m) { Build(); } private void Build() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown //IL_00e9: 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) //IL_0356: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) try { if (Object.op_Implicit((Object)(object)_root)) { Object.Destroy((Object)(object)_root); } _root = new GameObject("OmniumLib_LevelVis"); Object.DontDestroyOnLoad((Object)(object)_root); _unlitMat = MakeMat(); Type type = TypeCache.FindType("LevelPoint"); if (type == null) { OmniumLibPlugin.Log.LogWarning((object)"[OmniumLib] LevelDebugVis: LevelPoint type not found; nothing to draw."); return; } Object[] array = Object.FindObjectsOfType(type); List<Component> list = new List<Component>(); Object[] array2 = array; foreach (Object val in array2) { Component val2 = (Component)(object)((val is Component) ? val : null); if (val2 != null) { list.Add(val2); } } foreach (Component item2 in list) { Transform transform = item2.transform; MakeMarker(_root.transform, transform.position, MarkerScale, LevelPointColor, "LevelPoint"); } Type type2 = type; BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo fieldInfo = type2.GetField("ConnectedPoints", bindingAttr) ?? type2.GetField("Connections", bindingAttr) ?? type2.GetField("Neighbors", bindingAttr) ?? type2.GetField("Adjacent", bindingAttr); if (fieldInfo != null) { HashSet<ulong> hashSet = new HashSet<ulong>(); foreach (Component item3 in list) { object value = fieldInfo.GetValue(item3); if (value == null) { continue; } IEnumerable<object> enumerable = null; if (value is IEnumerable<object> enumerable2) { enumerable = enumerable2; } else if (value is IEnumerable enumerable3) { List<object> list2 = new List<object>(); foreach (object item4 in enumerable3) { list2.Add(item4); } enumerable = list2; } if (enumerable == null) { continue; } foreach (object item5 in enumerable) { if (item5 == null) { continue; } Transform transform2 = item3.transform; Transform val3 = null; Component val4 = (Component)((item5 is Component) ? item5 : null); if (val4 != null) { val3 = val4.transform; } else { Type type3 = item5.GetType(); if (type3 == type2) { object obj = ((item5 is Component) ? item5 : null); val3 = ((obj != null) ? ((Component)obj).transform : null); } if ((Object)(object)val3 == (Object)null) { PropertyInfo property = type3.GetProperty("transform", bindingAttr); if (property != null) { object? value2 = property.GetValue(item5, null); val3 = (Transform)((value2 is Transform) ? value2 : null); } } } if (Object.op_Implicit((Object)(object)val3)) { ulong item = HashPair(((Object)transform2).GetInstanceID(), ((Object)val3).GetInstanceID()); if (!hashSet.Contains(item)) { hashSet.Add(item); MakeLine(_root.transform, transform2.position, val3.position, PathPointColor); Vector3 pos = Vector3.Lerp(transform2.position, val3.position, 0.5f); MakeMarker(_root.transform, pos, PathMarkerScale, PathPointColor, "Path"); } } } } } else { OmniumLibPlugin.Log.LogInfo((object)"[OmniumLib] LevelDebugVis: No 'ConnectedPoints' field detected; drew LevelPoint markers only."); } OmniumLibPlugin.Log.LogInfo((object)$"[OmniumLib] LevelDebugVis built: {_root.transform.childCount} visuals."); } catch (Exception ex) { OmniumLibPlugin.Log.LogError((object)("[OmniumLib] LevelDebugVis.Build failed: " + ex)); } } private static ulong HashPair(int a, int b) { uint num = (uint)a; uint num2 = (uint)b; if (num2 < num) { uint num3 = num; num = num2; num2 = num3; } return ((ulong)num << 32) | num2; } private void MakeMarker(Transform parent, Vector3 pos, float scale, Color color, string label) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val).name = "OmniumVis_" + label; val.layer = 0; val.transform.SetParent(parent, false); val.transform.position = pos; val.transform.localScale = new Vector3(scale, scale, scale); MeshRenderer component = val.GetComponent<MeshRenderer>(); if (Object.op_Implicit((Object)(object)component)) { ((Renderer)component).sharedMaterial = MakeColorMat(color, Emission); } Collider component2 = val.GetComponent<Collider>(); if (Object.op_Implicit((Object)(object)component2)) { component2.enabled = false; } } private void MakeLine(Transform parent, Vector3 a, Vector3 b, Color color) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("OmniumVis_PathLine"); val.transform.SetParent(parent, false); LineRenderer val2 = val.AddComponent<LineRenderer>(); val2.positionCount = 2; val2.SetPositions((Vector3[])(object)new Vector3[2] { a, b }); val2.startWidth = LineWidth; val2.endWidth = LineWidth; val2.numCapVertices = 4; val2.numCornerVertices = 4; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)val2).receiveShadows = false; val2.useWorldSpace = true; ((Renderer)val2).allowOcclusionWhenDynamic = false; ((Renderer)val2).sharedMaterial = MakeColorMat(color, Emission); } private Material MakeMat() { //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_00be: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown string[] array = new string[8] { "Unlit/Color", "Universal Render Pipeline/Unlit", "HDRP/Unlit", "Unlit/Texture", "Sprites/Default", "UI/Default", "Standard", "Hidden/Internal-Colored" }; Shader val = null; string[] array2 = array; foreach (string text in array2) { val = Shader.Find(text); if (Object.op_Implicit((Object)(object)val)) { break; } } if (!Object.op_Implicit((Object)(object)val)) { Material val2 = new Material(Shader.Find("Sprites/Default")); ((Object)val2).hideFlags = (HideFlags)61; return val2; } return new Material(val) { hideFlags = (HideFlags)61 }; } private Material MakeColorMat(Color c, float emission) { //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_002e: Expected O, but got Unknown //IL_0043: 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_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) Material val = (((Object)(object)_unlitMat != (Object)null) ? _unlitMat : MakeMat()); Material val2 = new Material(val) { hideFlags = (HideFlags)61 }; if (val2.HasProperty("_Color")) { val2.SetColor("_Color", c); } if (val2.HasProperty("_BaseColor")) { val2.SetColor("_BaseColor", c); } try { if (val2.HasProperty("_EmissionColor")) { val2.EnableKeyword("_EMISSION"); val2.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1; val2.SetColor("_EmissionColor", c * emission); } } catch { } return val2; } } } namespace OmniumLib { [BepInPlugin("Omniscye.OmniumLib", "OmniumLib", "1.0")] public class OmniumLib : BaseUnityPlugin { internal static OmniumLib Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } private void Awake() { Instance = this; ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //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_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } }