using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Text.RegularExpressions; using UnityEngine; 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: AssemblyCompany("Nebula.Utils")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Nebula.Utils")] [assembly: AssemblyTitle("Nebula.Utils")] [assembly: AssemblyVersion("1.0.0.0")] namespace Nebula.Utils; public static class GameObjectUtils { public static T FirstByName(this IEnumerable values, string name) where T : Object { Object obj = values.FirstOf((Object o) => o.name == name); return (T)(object)((obj is T) ? obj : null); } public static GameObject GetRootObject(string name) { //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 ((IEnumerable)(object)((Scene)(ref activeScene)).GetRootGameObjects()).FirstByName(name); } public static CUIMenu GetMenu(string path) { return ((Component)GetRootObject("# CUI_2D").transform.FindChild("Camera/ROOT_Menus/" + path)).GetComponent(); } public static void CopyParentLayer(this GameObject go) { go.layer = ((Component)go.transform.parent).gameObject.layer; } } [Obsolete("Linq is present in this version of dotnet without an external assembly. Therefore, this class and its extension methods should no longer be used.")] public static class LinqSubstitute { public static int Count(this IEnumerable values) { return new List(values).Count; } public static T FirstOf(this IEnumerable values, Func predicate) { foreach (T value in values) { if (predicate(value)) { return value; } } return default(T); } public static IEnumerable Remap(this IEnumerable values, Func remapper) { foreach (T item in values) { yield return remapper(item); } } public static Dictionary Zipper(this IEnumerable keys, IEnumerable values) { List list = new List(keys); List list2 = new List(values); if (list.Count != list2.Count) { throw new ArgumentException("Keys and values are not the same length"); } Dictionary dictionary = new Dictionary(); for (int i = 0; i < list.Count; i++) { dictionary.Add(list[i], list2[i]); } return dictionary; } } public static class MathUtils { public static float CanonicalMod(this float a, float b) { return a - b * Mathf.Floor(a / b); } public static int CanonicalMod(this int a, int b) { return (int)((float)a).CanonicalMod((float)b); } public static Vector3 GetOffset(this Vector3 size, Pivot pivot) { //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) //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_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected I4, but got Unknown //IL_0039: 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_0063: 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) //IL_0067: 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_006a: Invalid comparison between Unknown and I4 //IL_004e: 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_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_006e: 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_0072: Invalid comparison between Unknown and I4 //IL_00a6: 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) Vector3 zero = Vector3.zero; switch ((int)pivot) { case 0: case 3: case 6: zero.x = size.x / 2f; break; case 2: case 5: case 8: zero.x = (0f - size.x) / 2f; break; } if ((int)pivot > 2) { if (pivot - 6 <= 2) { zero.y = size.y / 2f; } } else { zero.y = (0f - size.y) / 2f; } return zero; } } public static class TextUtils { public static string SpacePascalCase(this string pascal) { return Regex.Replace(pascal, "[a-z][A-Z]", (Match m) => m.Value[0] + " " + m.Value[1]); } public static string PascalNameToTitle(this string pascal, bool uppercase = true) { string text = pascal.SpacePascalCase().Replace(".", " // "); if (uppercase) { text = text.ToUpper(); } return text; } public static int GetLineCount(this string multilineStr) { return multilineStr.Split(new char[1] { '\n' }).Length; } } public static class PluginInfo { public const string PLUGIN_GUID = "Nebula.Utils"; public const string PLUGIN_NAME = "Nebula.Utils"; public const string PLUGIN_VERSION = "1.0.0"; }