Decompiled source of WhiteKnuckleCustomTrainer v2.1.0
BepInEx/plugins/ImuiBepInEx.dll
Decompiled 3 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using Imui.Controls; using Imui.Core; using Imui.IO; using Imui.IO.Events; using Imui.IO.Rendering; using Imui.IO.Touch; using Imui.IO.UGUI; using Imui.IO.Utility; using Imui.Rendering; using Imui.Style; using Imui.Utility; using ImuiBepInEx; using Microsoft.CodeAnalysis; using Unity.Collections; using Unity.Collections.LowLevel.Unsafe; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.InputSystem.LowLevel; using UnityEngine.InputSystem.Utilities; using UnityEngine.Rendering; using UnityEngine.TextCore; using UnityEngine.TextCore.LowLevel; using UnityEngine.TextCore.Text; using UnityEngine.U2D; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ImuiBepInEx")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+9c6abab97a642debc44544985a6ada35257126b8")] [assembly: AssemblyProduct("ImuiBepInEx")] [assembly: AssemblyTitle("ImuiBepInEx")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsUnmanagedAttribute : Attribute { } } internal class ImuiAssertException : Exception { public ImuiAssertException(string message) : base(message) { } } internal static class ImAssert { [HideInCallstack] [Conditional("IMUI_DEBUG")] public static void IsTrue(bool value, string message) { if (!value) { throw new ImuiAssertException(message); } } [HideInCallstack] [Conditional("IMUI_DEBUG")] public static void IsFalse(bool value, string message) { if (value) { throw new ImuiAssertException(message); } } } namespace Imui.Utility { public struct ImCircularBuffer<T> { public readonly int Capacity; public int Head; public int Count; public T[] Array; public ref T this[Index index] { [MethodImpl(MethodImplOptions.AggressiveInlining)] get { return ref Array[(Head + (index.IsFromEnd ? (Count - index.Value) : index.Value)) % Capacity]; } } public ImCircularBuffer(int capacity) { Capacity = capacity; Head = 0; Count = 0; Array = new T[capacity]; } public ImCircularBuffer(T[] array) { if (array == null) { throw new ArgumentNullException("array"); } Capacity = array.Length; Head = 0; Count = 0; Array = array; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public ref T Get(int index) { return ref Array[(Head + index) % Capacity]; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Set(int index, T value) { Array[(Head + index) % Capacity] = value; } public void Clear() { Head = 0; Count = 0; } public int PushBack(T value) { Head = (Head - 1) % Capacity; if (Head < 0) { Head += Capacity; } Array[Head] = value; if (Count < Capacity) { Count++; } return Head; } public bool TryPopBack(out T value) { if (Count == 0) { value = default(T); return false; } value = Array[Head]; Head = (Head + 1) % Capacity; Count--; return true; } public int PushFront(T value) { int num = (Head + Count) % Capacity; Array[num] = value; if (Count == Capacity) { Head = (Head + 1) % Capacity; } else { Count++; } return num; } public bool TryPeekFront(out T value) { if (Count == 0) { value = default(T); return false; } value = Array[(Head + Count - 1) % Capacity]; return true; } public bool TryPopFront(out T value) { if (Count == 0) { value = default(T); return false; } value = Array[(Head + Count - 1) % Capacity]; Count--; return true; } } internal struct ImDynamicArray<T> { public int Count; public T[] Array; public ImDynamicArray(int capacity) { Array = new T[capacity]; Count = 0; } public bool RemoveAtFast(int index) { if (index < 0 || index >= Count) { throw new IndexOutOfRangeException($"{index} out of range, count: {Count}"); } Array[index] = Array[Count - 1]; Count--; return true; } public void RemoveAt(int index) { if (index < 0 || index >= Count) { throw new IndexOutOfRangeException($"{index} out of range, count: {Count}"); } System.Array.Copy(Array, index + 1, Array, index, --Count - index); } public void Add(T value) { EnsureCapacity(Count + 1); Array[Count++] = value; } public void Push(in T value) { EnsureCapacity(Count + 1); Array[Count++] = value; } public bool TryPop(out T value) { if (Count > 0) { value = Pop(); return true; } value = default(T); return false; } public T Pop() { return Array[--Count]; } public T TryPeek(T @default = default(T)) { if (Count == 0) { return @default; } return Peek(); } public bool TryPeek(out T value) { if (Count == 0) { value = default(T); return false; } value = Peek(); return true; } public ref T Peek() { return ref Array[Count - 1]; } public void Clear(bool zero) { if (zero) { for (int i = 0; i < Count; i++) { Array[i] = default(T); } } Count = 0; } public static implicit operator ReadOnlySpan<T>(ImDynamicArray<T> array) { return ((ReadOnlySpan<T>)array.Array).Slice(0, array.Count); } private void EnsureCapacity(int count) { if (count > Array.Length) { int num; for (num = Array.Length * 2; num < count; num *= 2) { } System.Array.Resize(ref Array, num); } } } internal readonly struct ImEnumValue<TEnum> where TEnum : struct, Enum { private readonly long longValue; private readonly ulong ulongValue; private readonly bool signed; public ImEnumValue(long value) { longValue = value; ulongValue = 0uL; signed = true; } public ImEnumValue(ulong value) { longValue = 0L; ulongValue = value; signed = false; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ImEnumValue<TEnum>operator |(ImEnumValue<TEnum> val0, TEnum val1) { return val0 | ImEnumUtility<TEnum>.ToValue(val1); } public static ImEnumValue<TEnum>operator |(ImEnumValue<TEnum> val0, ImEnumValue<TEnum> val1) { if (!val0.signed) { return val0.ulongValue | val1.ulongValue; } return val0.longValue | val1.longValue; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ImEnumValue<TEnum>operator &(ImEnumValue<TEnum> val0, TEnum val1) { return val0 & ImEnumUtility<TEnum>.ToValue(val1); } public static ImEnumValue<TEnum>operator &(ImEnumValue<TEnum> val0, ImEnumValue<TEnum> val1) { if (!val0.signed) { return val0.ulongValue & val1.ulongValue; } return val0.longValue & val1.longValue; } public static ImEnumValue<TEnum>operator ~(ImEnumValue<TEnum> val) { if (!val.signed) { return ~val.ulongValue; } return ~val.longValue; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator ==(ImEnumValue<TEnum> val0, TEnum val1) { return val0 == ImEnumUtility<TEnum>.ToValue(val1); } public static bool operator ==(ImEnumValue<TEnum> val0, ImEnumValue<TEnum> val1) { return val0.Equals(val1); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static bool operator !=(ImEnumValue<TEnum> val0, TEnum val1) { return val0 != ImEnumUtility<TEnum>.ToValue(val1); } public static bool operator !=(ImEnumValue<TEnum> val0, ImEnumValue<TEnum> val1) { return !val0.Equals(val1); } public static bool operator ==(ImEnumValue<TEnum> val0, int val1) { return val0.Equals(val1); } public static bool operator !=(ImEnumValue<TEnum> val0, int val1) { return !val0.Equals(val1); } public static implicit operator ImEnumValue<TEnum>(int val) { if (!ImEnumUtility<TEnum>.Signed) { return new ImEnumValue<TEnum>((ulong)val); } return new ImEnumValue<TEnum>(val); } public static implicit operator ImEnumValue<TEnum>(long val) { return new ImEnumValue<TEnum>(val); } public static implicit operator ImEnumValue<TEnum>(ulong val) { return new ImEnumValue<TEnum>(val); } public TEnum ToEnumType() { if (!signed) { return ImEnumUtility<TEnum>.FromValueUnsigned(ulongValue); } return ImEnumUtility<TEnum>.FromValueSigned(longValue); } public bool Equals(ImEnumValue<TEnum> other) { if (signed != other.signed || !signed) { return ulongValue == other.ulongValue; } return longValue == other.longValue; } public override bool Equals(object obj) { if (obj is ImEnumValue<TEnum> other) { return Equals(other); } return false; } public override int GetHashCode() { return HashCode.Combine(longValue, ulongValue, signed); } } internal static class ImEnumUtility<TEnum> where TEnum : struct, Enum { public const string FLAGS_SEPARATOR = " | "; public static readonly bool IsFlags = typeof(TEnum).GetCustomAttribute<FlagsAttribute>() != null; public static readonly string[] Names = Enum.GetNames(typeof(TEnum)); public static readonly TEnum[] Values = Enum.GetValues(typeof(TEnum)) as TEnum[]; public static readonly Type Type = Enum.GetUnderlyingType(typeof(TEnum)); public static readonly string TypeName = Type.Name; public static readonly bool Signed = Type == typeof(sbyte) || Type == typeof(short) || Type == typeof(int) || Type == typeof(long); public static ImEnumValue<TEnum> ToValue(TEnum e) { if (!Signed) { return ToValueUnsigned(e); } return ToValueSigned(e); } public static bool IsFlagSet(TEnum value, TEnum flag) { if (!IsFlags) { return false; } if (ToValue(flag) == 0) { return ToValue(value) == 0; } return (ToValue(value) & flag) == flag; } public static void SetFlag(ref TEnum value, TEnum flag, bool active) { if (IsFlags) { ImEnumValue<TEnum> imEnumValue = ToValue(value); ImEnumValue<TEnum> imEnumValue2 = ToValue(flag); if (imEnumValue2 == 0 && active) { imEnumValue = 0; } if (imEnumValue2 != 0 && active) { imEnumValue |= imEnumValue2; } if (imEnumValue2 != 0 && !active) { imEnumValue &= ~imEnumValue2; } value = imEnumValue.ToEnumType(); } } public static int Format(TEnum value, Span<char> output, string flagsSeparator = " | ") { if (!IsFlags) { int num = Array.IndexOf(Values, value); if (num < 0) { return 0; } if (!((ReadOnlySpan<char>)Names[num]).TryCopyTo(output)) { return 0; } return Names[num].Length; } ReadOnlySpan<char> readOnlySpan = flagsSeparator; int num2 = 0; ImEnumValue<TEnum> imEnumValue = ToValue(value); bool flag = imEnumValue == 0; for (int i = 0; i < Values.Length; i++) { ImEnumValue<TEnum> imEnumValue2 = ToValue(Values[i]); if (!((imEnumValue2 | value) == imEnumValue) || !(imEnumValue2 != 0 || flag)) { continue; } int num3; if (num2 != 0) { num3 = num2; if (!readOnlySpan.TryCopyTo(output.Slice(num3, output.Length - num3))) { return num2; } num2 += readOnlySpan.Length; } ReadOnlySpan<char> readOnlySpan2 = Names[i]; num3 = num2; if (readOnlySpan2.TryCopyTo(output.Slice(num3, output.Length - num3))) { num2 += readOnlySpan2.Length; if (flag) { break; } continue; } return num2; } return num2; } public static TEnum FromValueUnsigned(ulong value) { if (Type == typeof(byte)) { byte b = (byte)value; return UnsafeUtility.As<byte, TEnum>(ref b); } if (Type == typeof(ushort)) { ushort num = (ushort)value; return UnsafeUtility.As<ushort, TEnum>(ref num); } if (Type == typeof(uint)) { uint num2 = (uint)value; return UnsafeUtility.As<uint, TEnum>(ref num2); } if (Type == typeof(ulong)) { return UnsafeUtility.As<ulong, TEnum>(ref value); } throw new Exception($"Underlying type of {typeof(TEnum)} is signed"); } public static TEnum FromValueSigned(long value) { if (Type == typeof(sbyte)) { sbyte b = (sbyte)value; return UnsafeUtility.As<sbyte, TEnum>(ref b); } if (Type == typeof(short)) { short num = (short)value; return UnsafeUtility.As<short, TEnum>(ref num); } if (Type == typeof(int)) { int num2 = (int)value; return UnsafeUtility.As<int, TEnum>(ref num2); } if (Type == typeof(long)) { return UnsafeUtility.As<long, TEnum>(ref value); } throw new Exception($"Underlying type of {typeof(TEnum)} is unsigned"); } public static long ToValueSigned(TEnum value) { if (Type == typeof(sbyte)) { return UnsafeUtility.As<TEnum, sbyte>(ref value); } if (Type == typeof(short)) { return UnsafeUtility.As<TEnum, short>(ref value); } if (Type == typeof(int)) { return UnsafeUtility.As<TEnum, int>(ref value); } if (Type == typeof(long)) { return UnsafeUtility.As<TEnum, long>(ref value); } throw new Exception($"Underlying type of {typeof(TEnum)} is unsigned"); } public static ulong ToValueUnsigned(TEnum value) { if (Type == typeof(byte)) { return UnsafeUtility.As<TEnum, byte>(ref value); } if (Type == typeof(ushort)) { return UnsafeUtility.As<TEnum, ushort>(ref value); } if (Type == typeof(uint)) { return UnsafeUtility.As<TEnum, uint>(ref value); } if (Type == typeof(ulong)) { return UnsafeUtility.As<TEnum, ulong>(ref value); } throw new Exception($"Underlying type of {typeof(TEnum)} is signed"); } } public static class ImProfiler { [MethodImpl(MethodImplOptions.AggressiveInlining)] [Conditional("IMUI_PROFILE")] public static void BeginSample(string name) { } [MethodImpl(MethodImplOptions.AggressiveInlining)] [Conditional("IMUI_PROFILE")] public static void EndSample() { } } public static class ImUnityUtility { public static void Destroy(Object obj) { Object.Destroy(obj); } } } namespace Imui.Rendering { public class ImMeshBuffer { public int VerticesCount; public int IndicesCount; public ImVertex[] Vertices; public int[] Indices; public ImMeshData[] Meshes; public int MeshesCount; public ImMeshBuffer(int meshesCapacity, int verticesCapacity, int indicesCapacity) { Vertices = new ImVertex[verticesCapacity]; Indices = new int[indicesCapacity]; Meshes = new ImMeshData[meshesCapacity]; Clear(); } public void Trim() { if (MeshesCount != 0) { ref ImMeshData reference = ref Meshes[MeshesCount - 1]; while ((reference.VerticesCount == 0 || reference.IndicesCount == 0) && MeshesCount > 1) { reference = ref Meshes[--MeshesCount - 1]; } } } public void Sort() { Span<ImMeshData> span = new Span<ImMeshData>(Meshes, 0, MeshesCount); for (int i = 1; i < span.Length; i++) { ImMeshData imMeshData = span[i]; int num = i - 1; while (num >= 0 && span[num].Order > imMeshData.Order) { span[num + 1] = span[num]; num--; } span[num + 1] = imMeshData; } } public void Clear() { MeshesCount = 0; VerticesCount = 0; IndicesCount = 0; } public void NextMesh() { if (MeshesCount > 0) { ref ImMeshData reference = ref Meshes[MeshesCount - 1]; if (reference.VerticesCount == 0 && reference.IndicesCount == 0) { reference.ClearOptions(); return; } } EnsureMeshesCapacity(MeshesCount + 1); ref ImMeshData reference2 = ref Meshes[MeshesCount++]; reference2.Clear(); reference2.IndicesOffset = IndicesCount; reference2.VerticesOffset = VerticesCount; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void EnsureMeshesCapacity(int size) { if (Meshes.Length < size) { Array.Resize(ref Meshes, Mathf.NextPowerOfTwo(size)); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void EnsureVerticesCapacity(int size) { if (Vertices.Length < size) { Array.Resize(ref Vertices, Mathf.NextPowerOfTwo(size)); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void EnsureIndicesCapacity(int size) { if (Indices.Length < size) { Array.Resize(ref Indices, Mathf.NextPowerOfTwo(size)); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddIndices(int count) { IndicesCount += count; Meshes[MeshesCount - 1].IndicesCount += count; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public void AddVertices(int count) { VerticesCount += count; Meshes[MeshesCount - 1].VerticesCount += count; } } public struct ImMeshClipRect { public bool Enabled; public Rect Rect; } public struct ImMeshMaskRect { public bool Enabled; public Rect Rect; public float Radius; } public struct ImMeshData { public Texture MainTex; public Texture FontTex; public Material Material; public int IndicesOffset; public int VerticesOffset; public int VerticesCount; public int IndicesCount; public MeshTopology Topology; public int Order; public ImMeshClipRect ClipRect; public ImMeshMaskRect MaskRect; public float InvColorMul; public void ClearOptions() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) MainTex = null; FontTex = null; Material = null; Topology = (MeshTopology)0; Order = 0; ClipRect = default(ImMeshClipRect); MaskRect = default(ImMeshMaskRect); InvColorMul = 0f; } public void Clear() { IndicesOffset = 0; VerticesOffset = 0; VerticesCount = 0; IndicesCount = 0; ClearOptions(); } } public class ImMeshDrawer { public const float MAIN_TEX_ID = 0f; public const float FONT_TEX_ID = 1f; private const int SQRT_TABLE_SIZE = 500; private const float SQRT_TABLE_RES = 0.1f; private const float SQRT_TABLE_MAX = 50f; public float Atlas; public Color32 Color; public Vector4 ScaleOffset; internal readonly ImMeshBuffer buffer; private readonly float[] invSqrtLut; public ImMeshDrawer(ImMeshBuffer buffer) { this.buffer = buffer; invSqrtLut = new float[500]; invSqrtLut[0] = 0f; for (int i = 1; i < invSqrtLut.Length; i++) { invSqrtLut[i] = 1f / Mathf.Sqrt((float)i * 0.1f); } } public void Clear() { buffer.Clear(); } public void NextMesh() { buffer.NextMesh(); } public ref ImMeshData GetMesh() { return ref buffer.Meshes[buffer.MeshesCount - 1]; } public void AddLine(ReadOnlySpan<Vector2> path, bool closed, float thickness, float outerScale, float innerScale) { //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_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) //IL_008a: 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_0099: 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_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04a5: Unknown result type (might be due to invalid IL or missing references) //IL_04fa: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_0529: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_05a7: Unknown result type (might be due to invalid IL or missing references) //IL_05c0: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_063d: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_0655: Unknown result type (might be due to invalid IL or missing references) float num = thickness * outerScale; float num2 = thickness * innerScale; int num3 = buffer.IndicesCount; int num4 = buffer.VerticesCount; int num5 = (path.Length - ((!closed) ? 1 : 0)) * 6; int num6 = (path.Length - ((!closed) ? 1 : 0)) * 4; buffer.EnsureIndicesCapacity(num3 + num5); buffer.EnsureVerticesCapacity(num4 + num6); for (int i = 0; i < path.Length - 1; i++) { Vector2 val = path[i]; Vector2 val2 = path[i + 1]; float num7 = val2.x - val.x; float num8 = val2.y - val.y; float num9 = num7 * num7 + num8 * num8; float num10 = ((num9 < 50f) ? invSqrtLut[(int)(num9 / 0.1f)] : (1f / Mathf.Sqrt(num9))); float num11 = (0f - num8) * num10; float num12 = num7 * num10; ref ImVertex reference = ref buffer.Vertices[num4]; reference.Position.x = val.x + num11 * -1f * num; reference.Position.y = val.y + num12 * -1f * num; reference.Color = Color; reference.UV.x = ScaleOffset.z; reference.UV.y = ScaleOffset.w; reference.Atlas = Atlas; ref ImVertex reference2 = ref buffer.Vertices[num4 + 1]; reference2.Position.x = val.x + num11 * num2; reference2.Position.y = val.y + num12 * num2; reference2.Color = Color; reference2.UV.x = ScaleOffset.z; reference2.UV.y = ScaleOffset.w + ScaleOffset.y; reference2.Atlas = Atlas; ref ImVertex reference3 = ref buffer.Vertices[num4 + 2]; reference3.Position.x = val2.x + num11 * -1f * num; reference3.Position.y = val2.y + num12 * -1f * num; reference3.Color = Color; reference3.UV.x = ScaleOffset.z + ScaleOffset.x; reference3.UV.y = ScaleOffset.w; reference3.Atlas = Atlas; ref ImVertex reference4 = ref buffer.Vertices[num4 + 3]; reference4.Position.x = val2.x + num11 * num2; reference4.Position.y = val2.y + num12 * num2; reference4.Color = Color; reference4.UV.x = ScaleOffset.z + ScaleOffset.x; reference4.UV.y = ScaleOffset.w + ScaleOffset.y; reference4.Atlas = Atlas; buffer.Indices[num3] = num4; buffer.Indices[num3 + 1] = num4 + 1; buffer.Indices[num3 + 2] = num4 + 3; buffer.Indices[num3 + 3] = num4 + 3; buffer.Indices[num3 + 4] = num4 + 2; buffer.Indices[num3 + 5] = num4; num3 += 6; num4 += 4; } if (closed) { Vector2 val3 = path[path.Length - 1]; Vector2 val4 = path[0]; float num13 = val4.x - val3.x; float num14 = val4.y - val3.y; float num15 = num13 * num13 + num14 * num14; float num16 = ((num15 < 50f) ? invSqrtLut[(int)(num15 / 0.1f)] : (1f / Mathf.Sqrt(num15))); float num11 = (0f - num14) * num16; float num12 = num13 * num16; ref ImVertex reference5 = ref buffer.Vertices[num4]; reference5.Position.x = val3.x + num11 * -1f * num; reference5.Position.y = val3.y + num12 * -1f * num; reference5.Color = Color; reference5.UV.x = ScaleOffset.z; reference5.UV.y = ScaleOffset.w; reference5.Atlas = Atlas; ref ImVertex reference6 = ref buffer.Vertices[num4 + 1]; reference6.Position.x = val3.x + num11 * num2; reference6.Position.y = val3.y + num12 * num2; reference6.Color = Color; reference6.UV.x = ScaleOffset.z; reference6.UV.y = ScaleOffset.w + ScaleOffset.y; reference6.Atlas = Atlas; ref ImVertex reference7 = ref buffer.Vertices[num4 + 2]; reference7.Position.x = val4.x + num11 * -1f * num; reference7.Position.y = val4.y + num12 * -1f * num; reference7.Color = Color; reference7.UV.x = ScaleOffset.z + ScaleOffset.x; reference7.UV.y = ScaleOffset.w; reference7.Atlas = Atlas; ref ImVertex reference8 = ref buffer.Vertices[num4 + 3]; reference8.Position.x = val4.x + num11 * num2; reference8.Position.y = val4.y + num12 * num2; reference8.Color = Color; reference8.UV.x = ScaleOffset.z + ScaleOffset.x; reference8.UV.y = ScaleOffset.w + ScaleOffset.y; reference8.Atlas = Atlas; buffer.Indices[num3] = num4; buffer.Indices[num3 + 1] = num4 + 1; buffer.Indices[num3 + 2] = num4 + 3; buffer.Indices[num3 + 3] = num4 + 3; buffer.Indices[num3 + 4] = num4 + 2; buffer.Indices[num3 + 5] = num4; } buffer.AddIndices(num5); buffer.AddVertices(num6); } public void AddLineMiter(ReadOnlySpan<Vector2> path, bool closed, float thickness, float outerScale, float innerScale) { //IL_014c: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_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_0081: 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_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: 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_00c1: 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_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0494: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05ba: Unknown result type (might be due to invalid IL or missing references) //IL_05bf: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03e4: Unknown result type (might be due to invalid IL or missing references) if (path.Length < 2) { return; } thickness = Mathf.Max(1f, thickness); float num = thickness * outerScale; float num2 = thickness * innerScale; int num3 = (closed ? path.Length : (path.Length - 1)); float num13; float num14; if (closed) { Vector2 val = path[path.Length - 1]; Vector2 val2 = path[0]; Vector2 val3 = path[1]; float num4 = val2.x - val.x; float num5 = val2.y - val.y; float num6 = Mathf.Sqrt(num4 * num4 + num5 * num5); if (num6 > 0f) { num4 /= num6; num5 /= num6; } float num7 = val3.x - val2.x; float num8 = val3.y - val2.y; float num9 = Mathf.Sqrt(num7 * num7 + num8 * num8); if (num9 > 0f) { num7 /= num9; num8 /= num9; } float num10 = num4 + num7; float num11 = num5 + num8; float num12 = Mathf.Sqrt(num10 * num10 + num11 * num11); if (num12 > 0f) { num10 /= num12; num11 /= num12; } num13 = 0f - num11; num14 = num10; } else { Vector2 val4 = path[0]; Vector2 val5 = path[1]; float num15 = val5.x - val4.x; float num16 = val5.y - val4.y; float num17 = Mathf.Sqrt(num15 * num15 + num16 * num16); num15 /= num17; num16 /= num17; num13 = 0f - num16; num14 = num15; } int num18 = buffer.IndicesCount; int num19 = buffer.VerticesCount; int num20 = num3 * 6; int num21 = num3 * 2 + 2; buffer.EnsureIndicesCapacity(num18 + num20); buffer.EnsureVerticesCapacity(num19 + num21); ref ImVertex reference = ref buffer.Vertices[num19]; reference.Position.x = path[0].x + num13 * -1f * num; reference.Position.y = path[0].y + num14 * -1f * num; reference.Color = Color; reference.UV.x = ScaleOffset.z; reference.UV.y = ScaleOffset.w; reference.Atlas = Atlas; ref ImVertex reference2 = ref buffer.Vertices[num19 + 1]; reference2.Position.x = path[0].x + num13 * num2; reference2.Position.y = path[0].y + num14 * num2; reference2.Color = Color; reference2.UV.x = ScaleOffset.z; reference2.UV.y = ScaleOffset.w + ScaleOffset.y; reference2.Atlas = Atlas; for (int i = 0; i < num3; i++) { Vector2 val6 = path[i]; Vector2 val7 = path[(i + 1) % path.Length]; float num31; float num32; float num33; if (i <= path.Length - 3 || closed) { Vector2 val8 = path[(i + 2) % path.Length]; float num22 = val7.x - val6.x; float num23 = val7.y - val6.y; float num24 = Mathf.Sqrt(num22 * num22 + num23 * num23); if (num24 > 0f) { num22 /= num24; num23 /= num24; } float num25 = val8.x - val7.x; float num26 = val8.y - val7.y; float num27 = Mathf.Sqrt(num25 * num25 + num26 * num26); if (num27 > 0f) { num25 /= num27; num26 /= num27; } float num28 = num22 + num25; float num29 = num23 + num26; float num30 = Mathf.Sqrt(num28 * num28 + num29 * num29); if (num30 > 0f) { num28 /= num30; num29 /= num30; } num31 = 0f - num29; num32 = num28; num33 = num31 * (0f - num23) + num32 * num22; if (Mathf.Abs(num33) < 0.01f) { num31 = 0f - num26; num32 = num25; num33 = 1f; } } else { float num34 = val7.x - val6.x; float num35 = val7.y - val6.y; float num36 = Mathf.Sqrt(num34 * num34 + num35 * num35); float num37 = num34 / num36; num35 /= num36; num31 = 0f - num35; num32 = num37; num33 = 1f; } ref ImVertex reference3 = ref buffer.Vertices[num19 + 2]; reference3.Position.x = val7.x + num31 * -1f * num / num33; reference3.Position.y = val7.y + num32 * -1f * num / num33; reference3.Color = Color; reference3.UV.x = ScaleOffset.z; reference3.UV.y = ScaleOffset.w + ScaleOffset.y; reference3.Atlas = Atlas; ref ImVertex reference4 = ref buffer.Vertices[num19 + 3]; reference4.Position.x = val7.x + num31 * num2 / num33; reference4.Position.y = val7.y + num32 * num2 / num33; reference4.Color = Color; reference4.UV.x = ScaleOffset.z + ScaleOffset.x; reference4.UV.y = ScaleOffset.w + ScaleOffset.y; reference4.Atlas = Atlas; buffer.Indices[num18] = num19; buffer.Indices[num18 + 1] = num19 + 1; buffer.Indices[num18 + 2] = num19 + 3; buffer.Indices[num18 + 3] = num19 + 3; buffer.Indices[num18 + 4] = num19 + 2; buffer.Indices[num18 + 5] = num19; num18 += 6; num19 += 2; } buffer.AddIndices(num20); buffer.AddVertices(num21); } public void AddTriangleFan(Vector2 center, float from, float to, float radius, int segments) { //IL_0051: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) int verticesCount = buffer.VerticesCount; int indicesCount = buffer.IndicesCount; buffer.EnsureVerticesCapacity(verticesCount + 2 + segments); buffer.EnsureIndicesCapacity(indicesCount + 3 * segments); ref ImVertex reference = ref buffer.Vertices[verticesCount]; reference.Position.x = center.x; reference.Position.y = center.y; reference.Color = Color; reference.UV.x = ScaleOffset.z; reference.UV.y = ScaleOffset.w; reference.Atlas = Atlas; ref ImVertex reference2 = ref buffer.Vertices[verticesCount + 1]; reference2.Position.x = center.x + Mathf.Cos(from) * radius; reference2.Position.y = center.y + Mathf.Sin(from) * radius; reference2.Color = Color; reference2.UV.x = ScaleOffset.z; reference2.UV.y = ScaleOffset.w; reference2.Atlas = Atlas; float num = 1f / (float)segments * (to - from); for (int i = 0; i < segments; i++) { float num2 = from + num * (float)(i + 1); int num3 = verticesCount + i + 2; ref ImVertex reference3 = ref buffer.Vertices[num3]; reference3.Position.x = center.x + Mathf.Cos(num2) * radius; reference3.Position.y = center.y + Mathf.Sin(num2) * radius; reference3.Color = Color; reference3.UV.x = ScaleOffset.z; reference3.UV.y = ScaleOffset.w; reference3.Atlas = Atlas; buffer.Indices[indicesCount + i * 3] = verticesCount; buffer.Indices[indicesCount + i * 3 + 1] = num3; buffer.Indices[indicesCount + i * 3 + 2] = num3 - 1; } buffer.AddVertices(2 + segments); buffer.AddIndices(3 * segments); } public void AddTriangleFanTextured(Vector2 center, float from, float to, float radius, int segments) { //IL_0018: 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_0079: 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_0097: 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_00b2: 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_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) int verticesCount = buffer.VerticesCount; int indicesCount = buffer.IndicesCount; float num = center.x - radius; float num2 = center.y - radius; float num3 = radius * 2f; float num4 = radius * 2f; buffer.EnsureVerticesCapacity(verticesCount + 2 + segments); buffer.EnsureIndicesCapacity(indicesCount + 3 * segments); ref ImVertex reference = ref buffer.Vertices[verticesCount]; reference.Position.x = center.x; reference.Position.y = center.y; reference.Color = Color; reference.UV.x = ScaleOffset.z + (center.x - num) / num3 * ScaleOffset.x; reference.UV.y = ScaleOffset.w + (center.y - num2) / num4 * ScaleOffset.y; reference.Atlas = Atlas; ref ImVertex reference2 = ref buffer.Vertices[verticesCount + 1]; reference2.Position.x = center.x + Mathf.Cos(from) * radius; reference2.Position.y = center.y + Mathf.Sin(from) * radius; reference2.Color = Color; reference2.UV.x = ScaleOffset.z + (reference2.Position.x - num) / num3 * ScaleOffset.x; reference2.UV.y = ScaleOffset.w + (reference2.Position.y - num2) / num4 * ScaleOffset.y; reference2.Atlas = Atlas; float num5 = 1f / (float)segments * (to - from); for (int i = 0; i < segments; i++) { float num6 = from + num5 * (float)(i + 1); int num7 = verticesCount + i + 2; ref ImVertex reference3 = ref buffer.Vertices[num7]; reference3.Position.x = center.x + Mathf.Cos(num6) * radius; reference3.Position.y = center.y + Mathf.Sin(num6) * radius; reference3.Color = Color; reference3.UV.x = ScaleOffset.z + (reference3.Position.x - num) / num3 * ScaleOffset.x; reference3.UV.y = ScaleOffset.w + (reference3.Position.y - num2) / num4 * ScaleOffset.y; reference3.Atlas = Atlas; buffer.Indices[indicesCount + i * 3] = verticesCount; buffer.Indices[indicesCount + i * 3 + 1] = num7; buffer.Indices[indicesCount + i * 3 + 2] = num7 - 1; } buffer.AddVertices(2 + segments); buffer.AddIndices(3 * segments); } public void AddQuadTextured(float x0, float y0, float x1, float y1, float x2, float y2, float x3, float y3) { //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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) int verticesCount = buffer.VerticesCount; int indicesCount = buffer.IndicesCount; buffer.EnsureVerticesCapacity(verticesCount + 4); buffer.EnsureIndicesCapacity(indicesCount + 6); ref ImVertex reference = ref buffer.Vertices[verticesCount]; reference.Position.x = x0; reference.Position.y = y0; reference.Color = Color; reference.UV.x = ScaleOffset.z; reference.UV.y = ScaleOffset.w; reference.Atlas = Atlas; ref ImVertex reference2 = ref buffer.Vertices[verticesCount + 1]; reference2.Position.x = x1; reference2.Position.y = y1; reference2.Color = Color; reference2.UV.x = ScaleOffset.z; reference2.UV.y = ScaleOffset.w + ScaleOffset.y; reference2.Atlas = Atlas; ref ImVertex reference3 = ref buffer.Vertices[verticesCount + 2]; reference3.Position.x = x2; reference3.Position.y = y2; reference3.Color = Color; reference3.UV.x = ScaleOffset.z + ScaleOffset.x; reference3.UV.y = ScaleOffset.w + ScaleOffset.y; reference3.Atlas = Atlas; ref ImVertex reference4 = ref buffer.Vertices[verticesCount + 3]; reference4.Position.x = x3; reference4.Position.y = y3; reference4.Color = Color; reference4.UV.x = ScaleOffset.z + ScaleOffset.x; reference4.UV.y = ScaleOffset.w; reference4.Atlas = Atlas; buffer.Indices[indicesCount] = verticesCount; buffer.Indices[indicesCount + 1] = verticesCount + 1; buffer.Indices[indicesCount + 2] = verticesCount + 2; buffer.Indices[indicesCount + 3] = verticesCount + 2; buffer.Indices[indicesCount + 4] = verticesCount + 3; buffer.Indices[indicesCount + 5] = verticesCount; buffer.AddIndices(6); buffer.AddVertices(4); } public void AddQuadTextured(ImVertex v0, ImVertex v1, ImVertex v2, ImVertex v3) { int verticesCount = buffer.VerticesCount; int indicesCount = buffer.IndicesCount; buffer.EnsureVerticesCapacity(verticesCount + 4); buffer.EnsureIndicesCapacity(indicesCount + 6); buffer.Vertices[verticesCount] = v0; buffer.Vertices[verticesCount + 1] = v1; buffer.Vertices[verticesCount + 2] = v2; buffer.Vertices[verticesCount + 3] = v3; buffer.Indices[indicesCount] = verticesCount; buffer.Indices[indicesCount + 1] = verticesCount + 1; buffer.Indices[indicesCount + 2] = verticesCount + 2; buffer.Indices[indicesCount + 3] = verticesCount + 2; buffer.Indices[indicesCount + 4] = verticesCount + 3; buffer.Indices[indicesCount + 5] = verticesCount; buffer.AddIndices(6); buffer.AddVertices(4); } public void AddQuadTextured(float x, float y, float w, float h) { //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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) int verticesCount = buffer.VerticesCount; int indicesCount = buffer.IndicesCount; buffer.EnsureVerticesCapacity(verticesCount + 4); buffer.EnsureIndicesCapacity(indicesCount + 6); ref ImVertex reference = ref buffer.Vertices[verticesCount]; reference.Position.x = x; reference.Position.y = y; reference.Color = Color; reference.UV.x = ScaleOffset.z; reference.UV.y = ScaleOffset.w; reference.Atlas = Atlas; ref ImVertex reference2 = ref buffer.Vertices[verticesCount + 1]; reference2.Position.x = x; reference2.Position.y = y + h; reference2.Color = Color; reference2.UV.x = ScaleOffset.z; reference2.UV.y = ScaleOffset.w + ScaleOffset.y; reference2.Atlas = Atlas; ref ImVertex reference3 = ref buffer.Vertices[verticesCount + 2]; reference3.Position.x = x + w; reference3.Position.y = y + h; reference3.Color = Color; reference3.UV.x = ScaleOffset.z + ScaleOffset.x; reference3.UV.y = ScaleOffset.w + ScaleOffset.y; reference3.Atlas = Atlas; ref ImVertex reference4 = ref buffer.Vertices[verticesCount + 3]; reference4.Position.x = x + w; reference4.Position.y = y; reference4.Color = Color; reference4.UV.x = ScaleOffset.z + ScaleOffset.x; reference4.UV.y = ScaleOffset.w; reference4.Atlas = Atlas; buffer.Indices[indicesCount] = verticesCount; buffer.Indices[indicesCount + 1] = verticesCount + 1; buffer.Indices[indicesCount + 2] = verticesCount + 2; buffer.Indices[indicesCount + 3] = verticesCount + 2; buffer.Indices[indicesCount + 4] = verticesCount + 3; buffer.Indices[indicesCount + 5] = verticesCount; buffer.AddIndices(6); buffer.AddVertices(4); } public void AddFilledConvexMesh(ReadOnlySpan<Vector2> points) { //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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) int verticesCount = buffer.VerticesCount; int num = buffer.IndicesCount; buffer.EnsureVerticesCapacity(verticesCount + points.Length); buffer.EnsureIndicesCapacity(num + (points.Length - 2) * 3); ref readonly Vector2 reference = ref points[0]; ref ImVertex reference2 = ref buffer.Vertices[verticesCount]; reference2.Position.x = reference.x; reference2.Position.y = reference.y; reference2.Color = Color; reference2.UV.x = ScaleOffset.z; reference2.UV.y = ScaleOffset.w; reference2.Atlas = Atlas; ref readonly Vector2 reference3 = ref points[1]; ref ImVertex reference4 = ref buffer.Vertices[verticesCount + 1]; reference4.Position.x = reference3.x; reference4.Position.y = reference3.y; reference4.Color = Color; reference4.UV.x = ScaleOffset.z; reference4.UV.y = ScaleOffset.w; reference4.Atlas = Atlas; for (int i = 2; i < points.Length; i++) { ref readonly Vector2 reference5 = ref points[i]; ref ImVertex reference6 = ref buffer.Vertices[verticesCount + i]; reference6.Position.x = reference5.x; reference6.Position.y = reference5.y; reference6.Color = Color; reference6.UV.x = ScaleOffset.z; reference6.UV.y = ScaleOffset.w; reference6.Atlas = Atlas; buffer.Indices[num] = verticesCount + i; buffer.Indices[num + 1] = verticesCount + i - 1; buffer.Indices[num + 2] = verticesCount; num += 3; } buffer.AddVertices(points.Length); buffer.AddIndices((points.Length - 2) * 3); } public void AddFilledConvexMeshTextured(ReadOnlySpan<Vector2> points, float x, float y, float w, float h) { //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_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_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) int verticesCount = buffer.VerticesCount; int num = buffer.IndicesCount; buffer.EnsureVerticesCapacity(verticesCount + points.Length); buffer.EnsureIndicesCapacity(num + (points.Length - 2) * 3); ref readonly Vector2 reference = ref points[0]; ref ImVertex reference2 = ref buffer.Vertices[verticesCount]; reference2.Position.x = reference.x; reference2.Position.y = reference.y; reference2.Color = Color; reference2.UV.x = ScaleOffset.z + (reference.x - x) / w * ScaleOffset.x; reference2.UV.y = ScaleOffset.w + (reference.y - y) / h * ScaleOffset.y; reference2.Atlas = Atlas; ref readonly Vector2 reference3 = ref points[1]; ref ImVertex reference4 = ref buffer.Vertices[verticesCount + 1]; reference4.Position.x = reference3.x; reference4.Position.y = reference3.y; reference4.Color = Color; reference4.UV.x = ScaleOffset.z + (reference3.x - x) / w * ScaleOffset.x; reference4.UV.y = ScaleOffset.w + (reference3.y - y) / h * ScaleOffset.y; reference4.Atlas = Atlas; for (int i = 2; i < points.Length; i++) { ref readonly Vector2 reference5 = ref points[i]; ref ImVertex reference6 = ref buffer.Vertices[verticesCount + i]; reference6.Position.x = reference5.x; reference6.Position.y = reference5.y; reference6.Color = Color; reference6.UV.x = ScaleOffset.z + (reference5.x - x) / w * ScaleOffset.x; reference6.UV.y = ScaleOffset.w + (reference5.y - y) / h * ScaleOffset.y; reference6.Atlas = Atlas; buffer.Indices[num] = verticesCount + i; buffer.Indices[num + 1] = verticesCount + i - 1; buffer.Indices[num + 2] = verticesCount; num += 3; } buffer.AddVertices(points.Length); buffer.AddIndices((points.Length - 2) * 3); } } public class ImMeshRenderer : IDisposable { private const MeshUpdateFlags MESH_UPDATE_FLAGS = 15; private static readonly int MainTexId = Shader.PropertyToID("_MainTex"); private static readonly int FontTexId = Shader.PropertyToID("_FontTex"); private static readonly int ViewProjectionId = Shader.PropertyToID("_VP"); private static readonly int MaskEnabledId = Shader.PropertyToID("_MaskEnable"); private static readonly int MaskRectId = Shader.PropertyToID("_MaskRect"); private static readonly int MaskCornerRadiusId = Shader.PropertyToID("_MaskCornerRadius"); private static readonly int InvColorMul = Shader.PropertyToID("_InvColorMul"); private readonly MaterialPropertyBlock properties; private Mesh mesh; private bool disposed; private Material wireframeMaterial; private Mesh wireframeMesh; private int[] wireframeIndicesBuffer; public ImMeshRenderer() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown properties = new MaterialPropertyBlock(); mesh = new Mesh(); mesh.MarkDynamic(); } public void Render(CommandBuffer cmd, ImMeshBuffer buffer, Vector2 screenSize, float screenScale, Vector2Int targetSize) { //IL_00a0: 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_00f4: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_034b: Unknown result type (might be due to invalid IL or missing references) //IL_0364: Unknown result type (might be due to invalid IL or missing references) mesh.Clear(true); buffer.Trim(); buffer.Sort(); mesh.SetIndexBufferParams(buffer.IndicesCount, (IndexFormat)1); mesh.SetVertexBufferParams(buffer.VerticesCount, ImVertex.VertexAttributes); mesh.SetVertexBufferData<ImVertex>(buffer.Vertices, 0, 0, buffer.VerticesCount, 0, (MeshUpdateFlags)15); mesh.SetIndexBufferData<int>(buffer.Indices, 0, 0, buffer.IndicesCount, (MeshUpdateFlags)15); NativeArray<SubMeshDescriptor> val = default(NativeArray<SubMeshDescriptor>); val..ctor(buffer.MeshesCount, (Allocator)2, (NativeArrayOptions)0); for (int i = 0; i < buffer.MeshesCount; i++) { ref ImMeshData reference = ref buffer.Meshes[i]; int num = i; SubMeshDescriptor val2 = default(SubMeshDescriptor); ((SubMeshDescriptor)(ref val2)).topology = reference.Topology; ((SubMeshDescriptor)(ref val2)).indexStart = reference.IndicesOffset; ((SubMeshDescriptor)(ref val2)).indexCount = reference.IndicesCount; ((SubMeshDescriptor)(ref val2)).baseVertex = 0; ((SubMeshDescriptor)(ref val2)).firstVertex = reference.VerticesOffset; ((SubMeshDescriptor)(ref val2)).vertexCount = reference.VerticesCount; val[num] = val2; } mesh.SetSubMeshes<SubMeshDescriptor>(val, (MeshUpdateFlags)15); mesh.UploadMeshData(false); Vector2 val3 = screenScale * new Vector2((float)((Vector2Int)(ref targetSize)).x / screenSize.x, (float)((Vector2Int)(ref targetSize)).y / screenSize.y); float num2 = Mathf.Min(val3.x, val3.y); screenSize /= screenScale; Matrix4x4 identity = Matrix4x4.identity; Matrix4x4 gPUProjectionMatrix = GL.GetGPUProjectionMatrix(Matrix4x4.Ortho(0f, screenSize.x, 0f, screenSize.y, -32769f, 32768f), true); cmd.SetGlobalMatrix(ViewProjectionId, identity * gPUProjectionMatrix); Vector4 val4 = default(Vector4); Rect val5 = default(Rect); for (int j = 0; j < buffer.MeshesCount; j++) { ref ImMeshData reference2 = ref buffer.Meshes[j]; properties.SetTexture(MainTexId, reference2.MainTex); properties.SetTexture(FontTexId, reference2.FontTex); properties.SetFloat(InvColorMul, reference2.InvColorMul); if (reference2.MaskRect.Enabled) { float num3 = reference2.MaskRect.Radius * num2; Rect rect = reference2.MaskRect.Rect; float num4 = ((Rect)(ref rect)).width / 2f; float num5 = ((Rect)(ref rect)).height / 2f; ((Vector4)(ref val4))..ctor((((Rect)(ref rect)).x + num4) * val3.x, (((Rect)(ref rect)).y + num5) * val3.y, num4 * val3.x, num5 * val3.y); properties.SetInteger(MaskEnabledId, 1); properties.SetVector(MaskRectId, val4); properties.SetFloat(MaskCornerRadiusId, num3); } else { properties.SetInteger(MaskEnabledId, 0); } if (reference2.ClipRect.Enabled) { float num6 = ((Rect)(ref reference2.ClipRect.Rect)).xMin * val3.x; float num7 = ((Rect)(ref reference2.ClipRect.Rect)).yMin * val3.y; float num8 = ((Rect)(ref reference2.ClipRect.Rect)).width * val3.x; float num9 = ((Rect)(ref reference2.ClipRect.Rect)).height * val3.y; ((Rect)(ref val5))..ctor(num6, num7, num8, num9); cmd.EnableScissorRect(val5); } cmd.DrawMesh(mesh, Matrix4x4.identity, reference2.Material, j, -1, properties); if (reference2.ClipRect.Enabled) { cmd.DisableScissorRect(); } } } public void RenderWireframe(CommandBuffer cmd, ImMeshBuffer buffer, Vector2 screenSize, float screenScale) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Expected O, but got Unknown //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)wireframeMaterial)) { wireframeMaterial = new Material(AssetsManager.LoadAsset<Shader>("assets/imui/imui_wireframe.shader")); } if (!Object.op_Implicit((Object)(object)wireframeMesh)) { wireframeMesh = new Mesh(); wireframeMesh.MarkDynamic(); } wireframeMesh.Clear(true); int num = Mathf.NextPowerOfTwo(buffer.IndicesCount * 2); if (wireframeIndicesBuffer == null) { wireframeIndicesBuffer = new int[num]; } if (wireframeIndicesBuffer.Length < num) { Array.Resize(ref wireframeIndicesBuffer, num); } for (int i = 0; i < buffer.IndicesCount / 3; i++) { int num2 = buffer.Indices[3 * i]; int num3 = buffer.Indices[3 * i + 1]; int num4 = buffer.Indices[3 * i + 2]; wireframeIndicesBuffer[i * 6] = num2; wireframeIndicesBuffer[i * 6 + 1] = num3; wireframeIndicesBuffer[i * 6 + 2] = num3; wireframeIndicesBuffer[i * 6 + 3] = num4; wireframeIndicesBuffer[i * 6 + 4] = num4; wireframeIndicesBuffer[i * 6 + 5] = num2; } wireframeMesh.SetIndexBufferParams(buffer.IndicesCount * 2, (IndexFormat)1); wireframeMesh.SetVertexBufferParams(buffer.VerticesCount, ImVertex.VertexAttributes); wireframeMesh.SetVertexBufferData<ImVertex>(buffer.Vertices, 0, 0, buffer.VerticesCount, 0, (MeshUpdateFlags)15); wireframeMesh.SetIndexBufferData<int>(wireframeIndicesBuffer, 0, 0, buffer.IndicesCount * 2, (MeshUpdateFlags)15); if (wireframeMesh.subMeshCount != 1) { wireframeMesh.subMeshCount = 1; } SubMeshDescriptor val = default(SubMeshDescriptor); ((SubMeshDescriptor)(ref val)).topology = (MeshTopology)3; ((SubMeshDescriptor)(ref val)).indexStart = 0; ((SubMeshDescriptor)(ref val)).indexCount = buffer.IndicesCount * 2; ((SubMeshDescriptor)(ref val)).baseVertex = 0; ((SubMeshDescriptor)(ref val)).firstVertex = 0; ((SubMeshDescriptor)(ref val)).vertexCount = buffer.VerticesCount; SubMeshDescriptor val2 = val; wireframeMesh.SetSubMesh(0, val2, (MeshUpdateFlags)15); wireframeMesh.UploadMeshData(false); screenSize /= screenScale; Matrix4x4 identity = Matrix4x4.identity; Matrix4x4 gPUProjectionMatrix = GL.GetGPUProjectionMatrix(Matrix4x4.Ortho(0f, screenSize.x, 0f, screenSize.y, -32768f, 32767f), true); cmd.SetGlobalMatrix(ViewProjectionId, identity * gPUProjectionMatrix); cmd.DrawMesh(wireframeMesh, Matrix4x4.identity, wireframeMaterial, 0, -1); } public void Dispose() { if (!disposed) { ImUnityUtility.Destroy((Object)(object)mesh); if (Object.op_Implicit((Object)(object)wireframeMesh)) { ImUnityUtility.Destroy((Object)(object)wireframeMesh); } if (Object.op_Implicit((Object)(object)wireframeMaterial)) { ImUnityUtility.Destroy((Object)(object)wireframeMaterial); } mesh = null; wireframeMesh = null; wireframeMaterial = null; wireframeIndicesBuffer = null; disposed = true; } } } public enum ImTextOverflow { Overflow, Ellipsis, Truncate } public enum ImGlyphRenderMode { Smooth, Sdf } public struct ImTextLine { public int Start; public int Count; public float OffsetX; public float Width; } public struct ImTextLayout { public float Size; public float Scale; public float OffsetX; public float OffsetY; public float Width; public float Height; public ImTextLine[] Lines; public int LinesCount; public float LineHeight; public ImTextOverflow Overflow; public float OverflowWidth; } public readonly struct ImTextClipRect { public readonly float Left; public readonly float Right; public readonly float Top; public readonly float Bottom; public ImTextClipRect(float left, float right, float top, float bottom) { Left = left; Right = right; Top = top; Bottom = bottom; } } public class ImTextDrawer : IDisposable { [Flags] public enum GlyphFlag { None = 0, Empty = 1 } public struct GlyphData { public int x; public int y; public int w; public int h; public float bearingX; public float bearingY; public float advance; public GlyphFlag flag; public float uv0x; public float uv0y; public float uv1x; public float uv1y; public GlyphData(Glyph g) { //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_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) GlyphRect glyphRect = g.glyphRect; GlyphMetrics metrics = g.metrics; x = ((GlyphRect)(ref glyphRect)).x; y = ((GlyphRect)(ref glyphRect)).y; w = ((GlyphRect)(ref glyphRect)).width; h = ((GlyphRect)(ref glyphRect)).height; bearingX = ((GlyphMetrics)(ref metrics)).horizontalBearingX; bearingY = ((GlyphMetrics)(ref metrics)).horizontalBearingY; advance = ((GlyphMetrics)(ref metrics)).horizontalAdvance; flag = GlyphFlag.None; uv0x = (float)x / 1024f; uv0y = (float)y / 1024f; uv1x = (float)(x + w) / 1024f; uv1y = (float)(y + h) / 1024f; } } public static class ReflectionUtility { private static MethodInfo removeFontAssetMethod; private static MethodInfo rebuildFontAssetCacheMethod; private static MethodInfo updateAtlasTexturesInQueueMethod; static ReflectionUtility() { Type type = typeof(FontAsset).Assembly.GetType("UnityEngine.TextCore.Text.TextResourceManager"); if (type != null) { removeFontAssetMethod = type.GetMethod("RemoveFontAsset", BindingFlags.Static | BindingFlags.Public); rebuildFontAssetCacheMethod = type.GetMethod("RebuildFontAssetCache", BindingFlags.Static | BindingFlags.NonPublic); } updateAtlasTexturesInQueueMethod = typeof(FontAsset).GetMethod("UpdateAtlasTexturesInQueue", BindingFlags.Static | BindingFlags.NonPublic); } public static void UpdateAtlasTexturesInQueue() { updateAtlasTexturesInQueueMethod?.Invoke(null, null); } public static void RemoveFontAsset(FontAsset asset) { removeFontAssetMethod?.Invoke(null, new object[1] { asset }); } public static void RebuildFontAssetCache() { rebuildFontAssetCacheMethod?.Invoke(null, null); } } private const string ELLIPSIS_FALLBACK = "..."; private const string ELLIPSIS_ONE_CHAR = "…"; private const char NEW_LINE = '\n'; private const char SPACE = ' '; private const char TAB = '\t'; private const int TAB_SPACES = 4; private const int GLYPH_LOOKUP_CAPACITY = 256; private const float FONT_ATLAS_W = 1024f; private const float FONT_ATLAS_H = 1024f; private const int FONT_ATLAS_PADDING = 2; private static ImTextLayout sharedLayout = new ImTextLayout { Lines = new ImTextLine[128] }; public Color32 Color; private FontAsset fontAsset; private ImGlyphRenderMode renderMode; private float lineHeight; private float renderSize; private float descentLine; private GlyphData[] glyphsLookup; private float ellipsisWidth; private GlyphData[] ellipsisGlyphs; private string ellipsisStr; private bool atlasDirty; private readonly ImMeshBuffer buffer; private bool disposed; public Texture2D FontAtlas => fontAsset.atlasTexture; public FontAsset FontAsset => fontAsset; public ImGlyphRenderMode RenderMode => renderMode; public bool IsFontLoaded => Object.op_Implicit((Object)(object)FontAsset); public float FontRenderSize => renderSize; public float FontLineHeight => lineHeight; public ImTextDrawer(ImMeshBuffer buffer) { this.buffer = buffer; glyphsLookup = new GlyphData[256]; ellipsisGlyphs = new GlyphData["...".Length]; } public void LoadFont(Font font) { LoadFont(font, font.fontSize); } public void LoadFont(Font font, int sampleSize, ImGlyphRenderMode renderMode = ImGlyphRenderMode.Smooth) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_005b: 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_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0093: 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) UnloadFont(); GlyphRenderMode val = (GlyphRenderMode)(renderMode switch { ImGlyphRenderMode.Smooth => 4121, ImGlyphRenderMode.Sdf => 4169, _ => throw new NotImplementedException(), }); this.renderMode = renderMode; fontAsset = FontAsset.CreateFontAsset(font, sampleSize, 2, val, 1024, 1024, (AtlasPopulationMode)1, false); fontAsset.ReadFontAssetDefinition(); FaceInfo faceInfo = fontAsset.faceInfo; renderSize = ((FaceInfo)(ref faceInfo)).pointSize; faceInfo = fontAsset.faceInfo; lineHeight = ((FaceInfo)(ref faceInfo)).lineHeight; faceInfo = fontAsset.faceInfo; descentLine = ((FaceInfo)(ref faceInfo)).descentLine; for (uint num = 0u; num < glyphsLookup.Length; num++) { if (!fontAsset.HasCharacter((char)num, false, true)) { glyphsLookup[num] = default(GlyphData); } else { glyphsLookup[num] = new GlyphData(((TextElement)fontAsset.characterLookupTable[num]).glyph); } } glyphsLookup[32].flag |= GlyphFlag.Empty; glyphsLookup[9].flag |= GlyphFlag.Empty; glyphsLookup[9].advance = glyphsLookup[32].advance * 4f; ellipsisWidth = 0f; if (fontAsset.HasCharacter("…"[0], false, true)) { ellipsisGlyphs[0] = new GlyphData(((TextElement)fontAsset.characterLookupTable["…"[0]]).glyph); ellipsisWidth += ellipsisGlyphs[0].advance; ellipsisStr = "…"; } else { for (int i = 0; i < "...".Length; i++) { ellipsisGlyphs[i] = glyphsLookup[(uint)"..."[i]]; ellipsisWidth += ellipsisGlyphs[i].advance; } ellipsisStr = "..."; } ApplyAtlasChanges(force: true); } public void UnloadFont() { if (!((Object)(object)fontAsset == (Object)null)) { ReflectionUtility.UpdateAtlasTexturesInQueue(); ReflectionUtility.RemoveFontAsset(fontAsset); ImUnityUtility.Destroy((Object)(object)fontAsset); fontAsset = null; ReflectionUtility.RebuildFontAssetCache(); } } public void ApplyAtlasChanges(bool force = false) { if (atlasDirty || force) { ReflectionUtility.UpdateAtlasTexturesInQueue(); atlasDirty = false; } } public float GetLineHeightFromFontSize(float size) { return FontLineHeight * (size / FontRenderSize); } public float GetFontSizeFromLineHeight(float height) { return FontRenderSize * (height / FontLineHeight); } public float GetCharacterAdvance(char c, float size) { //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) float num = size / FontRenderSize; if (c < 'Ā') { return glyphsLookup[(uint)c].advance * num; } if (fontAsset.characterLookupTable.TryGetValue(c, out var value)) { GlyphMetrics metrics = ((TextElement)value).glyph.metrics; return ((GlyphMetrics)(ref metrics)).horizontalAdvance * num; } return 0f; } public float GetCharacterAdvance(char c) { //IL_0035: 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) if (c < 'Ā') { return glyphsLookup[(uint)c].advance; } if (fontAsset.characterLookupTable.TryGetValue(c, out var value)) { GlyphMetrics metrics = ((TextElement)value).glyph.metrics; return ((GlyphMetrics)(ref metrics)).horizontalAdvance; } return 0f; } public void AddTextWithLayout(ReadOnlySpan<char> text, in ImTextLayout layout, float x, float y, in ImTextClipRect clipRect) { Dictionary<uint, Character> characterLookupTable = fontAsset.characterLookupTable; float num = lineHeight * layout.Scale; float num2 = x; y -= num; buffer.EnsureVerticesCapacity(buffer.VerticesCount + text.Length * 4); buffer.EnsureIndicesCapacity(buffer.IndicesCount + text.Length * 6); for (int i = 0; i < layout.LinesCount; i++) { ref ImTextLine reference = ref layout.Lines[i]; float num3 = float.MaxValue; if (reference.Width - layout.OverflowWidth > 1f) { num3 = ((layout.Overflow == ImTextOverflow.Ellipsis) ? (num2 + layout.OverflowWidth - ellipsisWidth * layout.Scale) : ((layout.Overflow == ImTextOverflow.Truncate) ? (num2 + layout.OverflowWidth) : num3)); } for (int j = 0; j < reference.Count; j++) { char c = text[reference.Start + j]; if (x > clipRect.Right) { break; } if (c < 'Ā') { ref GlyphData reference2 = ref glyphsLookup[(uint)c]; float num4 = reference2.advance * layout.Scale; if (x + num4 > num3) { if (layout.Overflow == ImTextOverflow.Ellipsis && layout.OverflowWidth > ellipsisWidth * layout.Scale) { for (int k = 0; k < ellipsisStr.Length; k++) { x += AddGlyphQuad(in ellipsisGlyphs[k], x + reference.OffsetX, y + layout.OffsetY, layout.Scale); } } break; } x = (((reference2.flag & GlyphFlag.Empty) == 0) ? (x + AddGlyphQuad(in reference2, x + reference.OffsetX, y + layout.OffsetY, layout.Scale)) : (x + num4)); } else { if (!characterLookupTable.TryGetValue(c, out var value)) { continue; } GlyphData glyph = new GlyphData(((TextElement)value).glyph); float num5 = glyph.advance * layout.Scale; if (x + num5 > num3) { if (layout.Overflow == ImTextOverflow.Ellipsis) { for (int l = 0; l < ellipsisStr.Length; l++) { x += AddGlyphQuad(in ellipsisGlyphs[l], x + reference.OffsetX, y + layout.OffsetY, layout.Scale); } } break; } x += AddGlyphQuad(in glyph, x + reference.OffsetX, y + layout.OffsetY, layout.Scale); } } if (!(y < clipRect.Bottom)) { y -= num; x = num2; continue; } break; } } private void AddControlGlyphQuad(char c, float px, float py, float scale) { //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_0013: 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) //IL_0087: Unknown result type (might be due to invalid IL or missing references) Color32 color = Color; Color.SetAlpha(0.5f * Color.GetAlpha()); ref GlyphData glyph = ref glyphsLookup[92]; switch (c) { case '\n': AddGlyphQuad(in glyphsLookup[110], px + AddGlyphQuad(in glyph, px, py, scale), py, scale); break; case '\t': AddGlyphQuad(in glyphsLookup[116], px + AddGlyphQuad(in glyph, px, py, scale), py, scale); break; } Color = color; } [MethodImpl(MethodImplOptions.AggressiveInlining)] private float AddGlyphQuad(in GlyphData glyph, float px, float py, float scale) { //IL_0097: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) float num = scale * (float)glyph.w; float num2 = scale * (float)glyph.h; float num3 = scale * glyph.bearingX; float num4 = scale * (glyph.bearingY - (float)glyph.h - descentLine); float num5 = px + num3; float num6 = py + num4; float x = num5 + num; float y = num6 + num2; int verticesCount = buffer.VerticesCount; int indicesCount = buffer.IndicesCount; ref ImVertex reference = ref buffer.Vertices[verticesCount]; reference.Position.x = num5; reference.Position.y = num6; reference.Color = Color; reference.UV.x = glyph.uv0x; reference.UV.y = glyph.uv0y; reference.Atlas = 1f; ref ImVertex reference2 = ref buffer.Vertices[verticesCount + 1]; reference2.Position.x = num5; reference2.Position.y = y; reference2.Color = Color; reference2.UV.x = glyph.uv0x; reference2.UV.y = glyph.uv1y; reference2.Atlas = 1f; ref ImVertex reference3 = ref buffer.Vertices[verticesCount + 2]; reference3.Position.x = x; reference3.Position.y = y; reference3.Color = Color; reference3.UV.x = glyph.uv1x; reference3.UV.y = glyph.uv1y; reference3.Atlas = 1f; ref ImVertex reference4 = ref buffer.Vertices[verticesCount + 3]; reference4.Position.x = x; reference4.Position.y = num6; reference4.Color = Color; reference4.UV.x = glyph.uv1x; reference4.UV.y = glyph.uv0y; reference4.Atlas = 1f; buffer.Indices[indicesCount] = verticesCount; buffer.Indices[indicesCount + 1] = verticesCount + 1; buffer.Indices[indicesCount + 2] = verticesCount + 2; buffer.Indices[indicesCount + 3] = verticesCount + 2; buffer.Indices[indicesCount + 4] = verticesCount + 3; buffer.Indices[indicesCount + 5] = verticesCount; buffer.AddVertices(4); buffer.AddIndices(6); return glyph.advance * scale; } public ref readonly ImTextLayout BuildTempLayout(ReadOnlySpan<char> text, float boundsWidth, float boundsHeight, float alignX, float alignY, float size, bool wrap, ImTextOverflow overflow) { FillLayout(text, boundsWidth, boundsHeight, alignX, alignY, size, wrap, overflow, ref sharedLayout); return ref sharedLayout; } public void FillLayout(ReadOnlySpan<char> text, float boundsWidth, float boundsHeight, float alignX, float alignY, float size, bool wrap, ImTextOverflow overflow, ref ImTextLayout layout) { //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) layout.LinesCount = 0; layout.Scale = size / FontRenderSize; layout.OffsetX = boundsWidth * alignX; layout.OffsetY = 0f; layout.Width = 0f; layout.Height = 0f; layout.Size = size; layout.LineHeight = lineHeight * layout.Scale; layout.OverflowWidth = boundsWidth; layout.Overflow = overflow; if (text.IsEmpty) { return; } wrap = wrap && boundsWidth > 0f; float num = ((overflow == ImTextOverflow.Overflow) ? float.MinValue : 0f); float num2 = 0f; float num3 = 0f; int num4 = 0; int length = text.Length; Dictionary<uint, Character> characterLookupTable = fontAsset.characterLookupTable; int num5 = ((overflow == ImTextOverflow.Overflow || boundsHeight <= 0f) ? int.MaxValue : ((int)((boundsHeight + 0.001f) / layout.LineHeight))); int num6 = -1; float num7 = 0f; bool flag = false; for (int i = 0; i < length; i++) { char c = text[i]; float num8; Character value; GlyphMetrics metrics; if (c < 'Ā') { num8 = glyphsLookup[(uint)c].advance; } else if (characterLookupTable.TryGetValue(c, out value)) { metrics = ((TextElement)value).glyph.metrics; num8 = ((GlyphMetrics)(ref metrics)).horizontalAdvance; } else { if (!fontAsset.HasCharacter(c, false, true)) { continue; } atlasDirty = true; metrics = ((TextElement)characterLookupTable[c]).glyph.metrics; num8 = ((GlyphMetrics)(ref metrics)).horizontalAdvance; } if (flag && c != ' ') { num6 = i; num7 = num3; } flag = c == ' '; float num9 = num8 * layout.Scale; bool flag2 = c == '\n'; bool flag3 = flag2; if (!flag3 && wrap && num3 > 0f && num3 + num9 > boundsWidth + 0.0001f) { if (num6 != -1) { num3 = num7; i = num6; } flag3 = true; } if (flag3) { ref ImTextLine reference = ref layout.Lines[layout.LinesCount]; reference.Width = num3; reference.Start = num4; reference.Count = i - num4 + (flag2 ? 1 : 0); reference.OffsetX = Mathf.Max(boundsWidth - num3, num) * alignX; if (reference.Width > num2) { num2 = reference.Width; } layout.LinesCount++; if (layout.LinesCount >= num5) { break; } layout.OffsetX = Mathf.Min(reference.OffsetX, layout.OffsetX); num3 = num9; num4 = i + (flag2 ? 1 : 0); if (layout.LinesCount >= layout.Lines.Length) { Array.Resize(ref layout.Lines, layout.Lines.Length * 2); } num6 = -1; } else { num3 += num9; } } if (layout.LinesCount < num5 && (text.Length > num4 || text[num4 - 1] == '\n')) { ref ImTextLine reference2 = ref layout.Lines[layout.LinesCount]; reference2.Width = num3; reference2.Start = num4; reference2.Count = length - num4; reference2.OffsetX = Mathf.Max(boundsWidth - num3, num) * alignX; if (reference2.Width > num2) { num2 = reference2.Width; } layout.OffsetX = Mathf.Min(reference2.OffsetX, layout.OffsetX); layout.LinesCount++; } layout.Width = num2; layout.Height = layout.LineHeight * (float)layout.LinesCount; layout.OffsetY = (0f - (boundsHeight - (float)layout.LinesCount * layout.LineHeight)) * alignY; } public void Dispose() { if (!disposed) { UnloadFont(); disposed = true; } } } [StructLayout(LayoutKind.Sequential, Pack = 1)] public struct ImVertex { public static readonly VertexAttributeDescriptor[] VertexAttributes = (VertexAttributeDescriptor[])(object)new VertexAttributeDescriptor[4] { new VertexAttributeDescriptor((VertexAttribute)0, (VertexAttributeFormat)0, 2, 0), new VertexAttributeDescriptor((VertexAttribute)3, (VertexAttributeFormat)2, 4, 0), new VertexAttributeDescriptor((VertexAttribute)4, (VertexAttributeFormat)0, 2, 0), new VertexAttributeDescriptor((VertexAttribute)5, (VertexAttributeFormat)0, 1, 0) }; public Vector2 Position; public Color32 Color; public Vector2 UV; public float Atlas; public ImVertex(Vector2 position, Color32 color, Vector2 uv, float atlas) { //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_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_000f: 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) Position = position; Color = color; UV = uv; Atlas = atlas; } public ImVertex(ImVertex vertex) { //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_000e: 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_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) Position = vertex.Position; Color = vertex.Color; UV = vertex.UV; Atlas = vertex.Atlas; } } } namespace Imui.IO { public interface IImuiInput { public delegate bool RaycasterDelegate(float x, float y); string Clipboard { get { return GUIUtility.systemCopyBuffer ?? string.Empty; } set { GUIUtility.systemCopyBuffer = value; } } Vector2 MousePosition { get; } double Time { get; } bool WasMouseDownThisFrame { get; } ref readonly ImMouseEvent MouseEvent { get; } ref readonly ImTextEvent TextEvent { get; } int KeyboardEventsCount { get; } void UseMouseEvent(); void UseTextEvent(); ref readonly ImKeyboardEvent GetKeyboardEvent(int index); void UseKeyboardEvent(int index); void RequestTouchKeyboard(uint owner, ReadOnlySpan<char> text, ImTouchKeyboardSettings settings); void UseRaycaster(RaycasterDelegate raycaster); void Pull(); } public interface IImuiRenderer { Vector2 GetScreenSize(); float GetScale(); Vector2Int SetupRenderTarget(CommandBuffer cmd); void Schedule(IImuiRenderDelegate renderDelegate); } public interface IImuiRenderDelegate { void Render(IImuiRenderingContext context); } public interface IImuiRenderingScheduler : IDisposable { void Schedule(IImuiRenderDelegate renderDelegate); } public interface IImuiRenderingContext : IDisposable { CommandBuffer CreateCommandBuffer(); void ReleaseCommandBuffer(CommandBuffer cmd); void ExecuteCommandBuffer(CommandBuffer cmd); } } namespace Imui.IO.Utility { public class ImDynamicRenderTexture : IDisposable { private const int RES_MIN = 32; private const int RES_MAX = 4096; private RenderTexture prevTexture; private bool disposed; public RenderTexture Texture { get; private set; } public Vector2Int SetupRenderTarget(CommandBuffer cmd, Vector2Int requestedSize, out bool textureChanged) { //IL_0008: 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_0030: 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) AssertDisposed(); textureChanged = SetupTexture(requestedSize, 1f, out var targetSize); cmd.Clear(); cmd.SetRenderTarget(RenderTargetIdentifier.op_Implicit((Texture)(object)Texture)); cmd.ClearRenderTarget(true, true, Color.clear); return targetSize; } private bool SetupTexture(Vector2Int size, float scale, out Vector2Int targetSize) { //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_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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Expected O, but got Unknown AssertDisposed(); ReleasePrevTexture(); int num = Mathf.Clamp((int)((float)((Vector2Int)(ref size)).x * scale), 32, 4096); int num2 = Mathf.Clamp((int)((float)((Vector2Int)(ref size)).y * scale), 32, 4096); targetSize = new Vector2Int(num, num2); if (num == 0 || num2 == 0) { return false; } if (Object.op_Implicit((Object)(object)Texture) && Texture.IsCreated() && ((Texture)Texture).width == num && ((Texture)Texture).height == num2) { return false; } if (Object.op_Implicit((Object)(object)Texture)) { if (!Object.op_Implicit((Object)(object)prevTexture)) { prevTexture = Texture; Texture = null; } else { ReleaseActiveTexture(); } } RenderTextureDescriptor val = default(RenderTextureDescriptor); ((RenderTextureDescriptor)(ref val))..ctor(num, num2, (RenderTextureFormat)0, 0, 0, (RenderTextureReadWrite)1); Texture = new RenderTexture(val) { name = "ImuiRenderBuffer" }; return Texture.Create(); } private void ReleasePrevTexture() { if (Object.op_Implicit((Object)(object)prevTexture)) { prevTexture.Release(); prevTexture = null; } } private void ReleaseActiveTexture() { if (Object.op_Implicit((Object)(object)Texture)) { Texture.Release(); Texture = null; } } [HideInCallstack] private void AssertDisposed() { if (disposed) { throw new ObjectDisposedException("ImDynamicRenderTexture"); } } public void Dispose() { if (!disposed) { ReleasePrevTexture(); ReleaseActiveTexture(); disposed = true; } } } [Flags] public enum ImKeyboardCommandFlag : uint { None = 0u, Select = 1u, JumpWord = 2u, SelectAll = 4u, Copy = 8u, Paste = 0x10u, Cut = 0x20u, JumpEnd = 0x40u } public static class ImKeyboardCommandsHelper { public static bool TryGetCommand(ImKeyboardEvent evt, out ImKeyboardCommandFlag command) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 if ((int)SystemInfo.operatingSystemFamily != 1) { return TryGetCommandGeneric(evt, out command); } return TryGetCommandMacOS(evt, out command); } public static bool TryGetCommandMacOS(ImKeyboardEvent evt, out ImKeyboardCommandFlag result) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0025: 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_0053: 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: Invalid comparison between Unknown and I4 //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Invalid comparison between Unknown and I4 //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Invalid comparison between Unknown and I4 //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Invalid comparison between Unknown and I4 result = ImKeyboardCommandFlag.None; bool flag = (int)evt.Key >= 273 && (int)evt.Key <= 276; bool flag2 = ((Enum)evt.Modifiers).HasFlag((Enum)(object)(EventModifiers)4); bool flag3 = ((Enum)evt.Modifiers).HasFlag((Enum)(object)(EventModifiers)8); bool flag4 = ((Enum)evt.Modifiers).HasFlag((Enum)(object)(EventModifiers)1); if (flag && flag3 && !flag2) { result |= ImKeyboardCommandFlag.JumpEnd; } else if (flag && !flag3 && flag2) { result |= ImKeyboardCommandFlag.JumpWord; } if (flag && flag4) { result |= ImKeyboardCommandFlag.Select; } if (flag3 && (int)evt.Key == 97) { result |= ImKeyboardCommandFlag.SelectAll; } if (flag3 && (int)evt.Key == 99) { result |= ImKeyboardCommandFlag.Copy; } if (flag3 && (int)evt.Key == 118) { result |= ImKeyboardCommandFlag.Paste; } if (flag3 && (int)evt.Key == 120) { result |= ImKeyboardCommandFlag.Cut; } return result != ImKeyboardCommandFlag.None; } public static bool TryGetCommandGeneric(ImKeyboardEvent evt, out ImKeyboardCommandFlag command) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Invalid comparison between Unknown and I4 //IL_0024: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Invalid comparison between Unknown and I4 //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Invalid comparison between Unknown and I4 //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Invalid comparison between Unknown and I4 command = ImKeyboardCommandFlag.None; bool num = (int)evt.Key >= 273 && (int)evt.Key <= 276; bool flag = ((Enum)evt.Modifiers).HasFlag((Enum)(object)(EventModifiers)2); if (num && ((Enum)evt.Modifiers).HasFlag((Enum)(object)(EventModifiers)1)) { command |= ImKeyboardCommandFlag.Select; } if (num && flag) { command |= ImKeyboardCommandFlag.JumpWord; } if (flag && (int)evt.Key == 97) { command |= ImKeyboardCommandFlag.SelectAll; } if (flag && (int)evt.Key == 99) { command |= ImKeyboardCommandFlag.Copy; } if (flag && (int)evt.Key == 118) { command |= ImKeyboardCommandFlag.Paste; } if (flag && (int)evt.Key == 120) { command |= ImKeyboardCommandFlag.Cut; } return command != ImKeyboardCommandFlag.None; } } public static class ImUnityInputWrapper { public unsafe static Vector2 MousePosition { get { //IL_002d: 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_006e: 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) Mouse current = Mouse.current; Vector2? obj; if (current == null) { obj = null; } else { Vector2Control position = ((Pointer)current).position; obj = ((position != null) ? new Vector2?(Unsafe.Read<Vector2>((void*)((InputControl<Vector2>)(object)position).value)) : null); } Vector2? val = obj; if (!val.HasValue) { Touchscreen current2 = Touchscreen.current; Vector2? obj2; if (current2 == null) { obj2 = null; } else { Vector2Control position2 = ((Pointer)current2).position; obj2 = ((position2 != null) ? new Vector2?(Unsafe.Read<Vector2>((void*)((InputControl<Vector2>)(object)position2).value)) : null); } Vector2? val2 = obj2; return val2.GetValueOrDefault(); } return val.GetValueOrDefault(); } } public static bool TouchScreenSupported { get { Touchscreen current = Touchscreen.current; if (current == null) { return false; } return ((InputDevice)current).enabled; } } public static bool IsControlPressed { get { Keyboard current = Keyboard.current; if (current == null) { return false; } return current.ctrlKey.isPressed; } } public unsafe static bool IsTouchBeganThisFrame() { //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) Touchscreen current = Touchscreen.current; if (current == null) { return false; } ReadOnlyArray<TouchControl> touches = current.touches; for (int i = 0; i < touches.Count; i++) { if (*(int*)((InputControl<TouchPhase>)(object)touches[i].phase).value == 1) { return true; } } return false; } } public static class ImUnityScrollUtility { public static Vector2 ProcessScrollDelta(float dx, float dy) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return new Vector2(dx, dy); } } } namespace Imui.IO.UGUI { [RequireComponent(typeof(CanvasRenderer))] [ExecuteAlways] public class ImuiUnityGUIBackend : Graphic, IImuiRenderer, IImuiInput, IPointerDownHandler, IEventSystemHandler, IPointerUpHandler, IDragHandler, IBeginDragHandler, IScrollHandler { public enum ScalingMode { Inherited, Custom } private const float CUSTOM_SCALE_MIN = 0.05f; private const float CUSTOM_SCALE_MAX = 16f; private const int MOUSE_EVENTS_QUEUE_SIZE = 4; private const int KEYBOARD_EVENTS_QUEUE_SIZE = 16; private const float HELD_DOWN_DELAY = 0.2f; private const float MULTI_CLICK_TIME_THRESHOLD = 0.2f; private const float MULTI_CLICK_POS_THRESHOLD = 20f; private const float CLICK_POS_THRESHOLD = 8f; private const int MAX_MOUSE_BUTTONS = 3; private static Texture2D ClearTexture; private static readonly Vector3[] TempBuffer = (Vector3[])(object)new Vector3[4]; private static Material DefaultMaterial; [SerializeField] private ScalingMode scalingMode; [SerializeField] private float customScale = 1f; private IImuiInput.RaycasterDelegate raycaster; private ImDynamicRenderTexture texture; private ImCircularBuffer<ImMouseEvent> mouseEventsQueue; private ImCircularBuffer<ImKeyboardEvent> nextKeyboardEvents; private ImCircularBuffer<ImKeyboardEvent> keyboardEvents; private IImuiRenderingScheduler scheduler; private Vector2 mousePosition; private ImMouseEvent mouseEvent; private ImTextEvent textEvent; private ImTouchKeyboard touchKeyboardHandler; private bool elementHovered; private double time; private bool mouseHeldDown; private ImMouseDevice mouseDownDevice; private float[] mouseDownTime = new float[3]; private int[] mouseDownCount = new int[3]; private Vector2[] mouseDownPos = (Vector2[])(object)new Vector2[3]; private bool[] possibleClick = new bool[3]; public bool WasMouseDownThisFrame { get; private set; } public Vector2 MousePosition => mousePosition; public double Time => time; public ref readonly ImMouseEvent MouseEvent => ref mouseEvent; public ref readonly ImTextEvent TextEvent => ref textEvent; public int KeyboardEventsCount => keyboardEvents.Count; public override Texture mainTexture { get { if (!((Object)(object)texture?.Texture == (Object)null)) { return (Texture)(object)texture.Texture; } return (Texture)(object)ClearTexture; } } public override Material defaultMaterial { get { if (!Object.op_Implicit((Object)(object)DefaultMaterial)) { return ((Graphic)this).defaultMaterial; } return DefaultMaterial; } } public float CustomScale { get { return customScale; } set { customScale = Mathf.Clamp(value, 0.05f, 16f); } } public ScalingMode Scaling { get { return scalingMode; } set { scalingMode = value; } } protected override void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown ((UIBehaviour)this).Awake(); if (!Object.op_Implicit((Object)(object)DefaultMaterial)) { Shader val = AssetsManager.LoadAsset<Sh
BepInEx/plugins/WhiteKnuckleTrainer.dll
Decompiled 3 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("WhiteKnuckleTrainer")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("WhiteKnuckleTrainer")] [assembly: AssemblyTitle("WhiteKnuckleTrainer")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 WhiteKnuckleTrainer { internal sealed class EspOverlay : MonoBehaviour { private readonly List<Item_Object> _targets = new List<Item_Object>(); private float _nextRefresh; private GUIStyle? _style; private void Update() { if (!(Time.unscaledTime < _nextRefresh)) { _nextRefresh = Time.unscaledTime + 1f; _targets.Clear(); _targets.AddRange(from item in Object.FindObjectsOfType<Item_Object>() where (Object)(object)item != (Object)null && item.itemData != null select item); } } private void OnGUI() { //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_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_0096: Expected O, but got Unknown //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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) WhiteKnuckleTrainerPlugin instance = WhiteKnuckleTrainerPlugin.Instance; if (instance == null || !instance.Features.EspEnabled || NativePauseMenuPatch.IsOpen) { return; } ENT_Player player = ENT_Player.GetPlayer(); Camera main = Camera.main; if ((Object)(object)player == (Object)null || (Object)(object)main == (Object)null) { return; } if (_style == null) { GUIStyle val = new GUIStyle(GUI.skin.label) { alignment = (TextAnchor)4, fontSize = 12, fontStyle = (FontStyle)1 }; val.normal.textColor = Color.white; _style = val; } TrainerFeatures features = instance.Features; int num = 0; RaycastHit val2 = default(RaycastHit); foreach (Item_Object item in from target in _targets where (Object)(object)target != (Object)null orderby Vector3.SqrMagnitude(((Component)target).transform.position - ((Component)player).transform.position) select target) { if (num >= features.EspMaximumLabels) { break; } Vector3 position = ((Component)item).transform.position; float num2 = Vector3.Distance(((Component)player).transform.position, position); if (!(num2 > features.EspMaximumDistance) && (!features.EspOcclusionCheck || !Physics.Linecast(((Component)main).transform.position, position, ref val2) || !((Object)(object)((RaycastHit)(ref val2)).transform != (Object)(object)((Component)item).transform) || ((RaycastHit)(ref val2)).transform.IsChildOf(((Component)item).transform))) { Vector3 val3 = main.WorldToScreenPoint(position); bool flag = val3.z > 0f && val3.x >= 0f && val3.x <= (float)Screen.width && val3.y >= 0f && val3.y <= (float)Screen.height; if ((!features.EspOnlyOnScreen || flag) && flag) { string text = (string.IsNullOrWhiteSpace(item.itemData.itemName) ? ((Object)item).name : item.itemData.itemName); GUI.Label(new Rect(val3.x - 90f, (float)Screen.height - val3.y - 15f, 180f, 30f), "[" + text + "]\n" + num2.ToString("0") + " m", _style); num++; } } } } } [HarmonyPatch(typeof(CL_GameManager), "Pause")] internal static class NativePauseMenuPatch { private const string ModMenuButtonName = "WhiteKnuckleTrainer_ModMenu"; private const string ModMenuGapName = "WhiteKnuckleTrainer_ModMenuGap"; private const string GeneratedPrefix = "WhiteKnuckleTrainer_Generated_"; private const int PageSize = 6; private static bool _reportedMissingTemplate; private static Transform? _layout; private static Transform? _settingsTemplate; private static readonly List<(GameObject Object, bool WasActive)> OriginalEntries = new List<(GameObject, bool)>(); private static readonly List<GameObject> GeneratedEntries = new List<GameObject>(); internal static bool IsOpen { get; private set; } private static void Postfix(CL_GameManager __instance) { try { EnsureInjected(__instance); } catch (Exception arg) { WhiteKnuckleTrainerPlugin.Instance?.LogNativeError($"[Trainer] Native pause-menu injection failed: {arg}"); } } internal static void ResetSceneState() { Close(); _reportedMissingTemplate = false; _layout = null; _settingsTemplate = null; } internal static bool TryOpen(CL_GameManager gameManager) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown WhiteKnuckleTrainerPlugin instance = WhiteKnuckleTrainerPlugin.Instance; if ((Object)(object)instance == (Object)null || !EnsureInjected(gameManager) || (Object)(object)_layout == (Object)null || (Object)(object)_settingsTemplate == (Object)null) { return false; } if (IsOpen) { return true; } OriginalEntries.Clear(); foreach (Transform item in _layout) { Transform val = item; OriginalEntries.Add((((Component)val).gameObject, ((Component)val).gameObject.activeSelf)); ((Component)val).gameObject.SetActive(false); } IsOpen = true; ShowHome(instance); instance.LogNativeInfo("[Trainer] Native trainer menu opened."); return true; } internal static void Close() { if (!IsOpen) { return; } ClearGeneratedEntries(); foreach (var (val, active) in OriginalEntries) { if ((Object)(object)val != (Object)null) { val.SetActive(active); } } OriginalEntries.Clear(); IsOpen = false; RebuildLayout(); WhiteKnuckleTrainerPlugin.Instance?.LogNativeInfo("[Trainer] Returned to the native pause menu."); } private static bool EnsureInjected(CL_GameManager gameManager) { WhiteKnuckleTrainerPlugin instance = WhiteKnuckleTrainerPlugin.Instance; if ((Object)(object)instance == (Object)null || (Object)(object)gameManager.pauseMenu == (Object)null) { return false; } Transform val = FindPauseLayout(gameManager.pauseMenu.transform); if ((Object)(object)val == (Object)null) { ReportMissingTemplate(instance, "Pause Layout"); return false; } _layout = val; _settingsTemplate = val.Find("Settings"); Transform val2 = val.Find("Gap.01"); if ((Object)(object)_settingsTemplate == (Object)null || (Object)(object)val2 == (Object)null) { ReportMissingTemplate(instance, "Settings button or Gap.01 layout entry"); return false; } if ((Object)(object)val.Find("WhiteKnuckleTrainer_ModMenu") != (Object)null) { return true; } GameObject obj = Object.Instantiate<GameObject>(((Component)val2).gameObject, val); ((Object)obj).name = "WhiteKnuckleTrainer_ModMenuGap"; obj.SetActive(true); obj.transform.SetSiblingIndex(val.childCount - 1); GameObject obj2 = Object.Instantiate<GameObject>(((Component)_settingsTemplate).gameObject, val); ((Object)obj2).name = "WhiteKnuckleTrainer_ModMenu"; obj2.SetActive(true); obj2.transform.SetSiblingIndex(val.childCount - 1); ConfigureNativeButton(obj2, "MOD MENU", delegate { TryOpen(gameManager); }, enabled: true); RebuildLayout(); instance.LogNativeInfo("[Trainer] Native MOD MENU button injected successfully."); return true; } private static void ShowHome(WhiteKnuckleTrainerPlugin plugin) { BeginPage(); AddButton("WHITE KNUCKLE TRAINER", null, enabled: false); if (CommandConsole.hasCheated) { AddButton("CHEAT MODE ACTIVE — LEADERBOARDS DISABLED", null, enabled: false); } AddButton("PLAYER", delegate { ShowPlayer(plugin); }); AddButton("MOVEMENT", delegate { ShowMovement(plugin); }); AddButton("ITEMS", delegate { ShowItemCategories(plugin, 0); }); AddButton("PERKS", delegate { ShowPerks(plugin, 0); }); AddButton("ESP / ITEM RADAR", delegate { ShowEsp(plugin); }); AddButton("COSMETICS", delegate { ShowCosmetics(plugin); }); AddButton("TOOLS", delegate { ShowTools(plugin); }); AddButton("BACK TO PAUSE MENU", Close); FinishPage(); } private static void ShowPlayer(WhiteKnuckleTrainerPlugin plugin) { BeginPage(); AddButton("PLAYER", null, enabled: false); AddButton("GOD MODE: " + OnOff(plugin.Features.GodMode), delegate { plugin.Features.ToggleGodMode(); ShowPlayer(plugin); }); AddButton("NO FALL DAMAGE: " + OnOff(plugin.Features.NoFallDamage), delegate { plugin.Features.ToggleNoFallDamage(); ShowPlayer(plugin); }); AddButton("INFINITE STAMINA: " + OnOff(plugin.InfiniteStamina), delegate { plugin.ToggleInfiniteStamina(); ShowPlayer(plugin); }); AddButton("INFINITE AMMO / PITONS: " + OnOff(plugin.InfiniteAmmoAndThrowables), delegate { plugin.ToggleInfiniteAmmoAndThrowables(); ShowPlayer(plugin); }); AddButton("NO ENCUMBRANCE: " + OnOff(plugin.Features.NoEncumbrance), delegate { plugin.Features.ToggleNoEncumbrance(); ShowPlayer(plugin); }); AddButton("BACK", delegate { ShowHome(plugin); }); FinishPage(); } private static void ShowMovement(WhiteKnuckleTrainerPlugin plugin) { BeginPage(); AddButton("MOVEMENT", null, enabled: false); AddButton("INFINITE JUMPS: " + OnOff(plugin.InfiniteJumps), delegate { plugin.ToggleInfiniteJumps(); ShowMovement(plugin); }); AddButton("MULTI-JUMP COUNT: " + plugin.Features.MultiJumpCount, delegate { ShowMultiJump(plugin); }); AddButton("MOVEMENT SPEED: " + plugin.Features.MovementMultiplier.ToString("0.00") + "x", delegate { ShowMovementTuning(plugin); }); AddButton("JUMP HEIGHT: " + plugin.Features.JumpHeightMultiplier.ToString("0.00") + "x", delegate { ShowMovementTuning(plugin); }); AddButton("GRAVITY: " + plugin.Features.GravityMultiplier.ToString("0.00") + "x", delegate { ShowMovementTuning(plugin); }); AddButton("TIME SCALE: " + plugin.Features.TimeScaleMultiplier.ToString("0.00") + "x", delegate { ShowTime(plugin); }); AddButton("MODE CONTROLS", delegate { ShowMovementModes(plugin); }); AddButton("BACK", delegate { ShowHome(plugin); }); FinishPage(); } private static void ShowMultiJump(WhiteKnuckleTrainerPlugin plugin) { BeginPage(); AddButton("MULTI-JUMP COUNT: " + plugin.Features.MultiJumpCount, null, enabled: false); AddButton("DECREASE", delegate { plugin.Features.AdjustMultiJump(-1); ShowMultiJump(plugin); }); AddButton("INCREASE", delegate { plugin.Features.AdjustMultiJump(1); ShowMultiJump(plugin); }); AddButton("1 = VANILLA AIR JUMP ALLOWANCE", null, enabled: false); AddButton("INFINITE JUMPS OVERRIDES THIS VALUE", null, enabled: false); AddButton("BACK", delegate { ShowMovement(plugin); }); FinishPage(); } private static void ShowMovementTuning(WhiteKnuckleTrainerPlugin plugin) { BeginPage(); AddButton("MOVEMENT SPEED: " + plugin.Features.MovementMultiplier.ToString("0.00") + "x", delegate { plugin.Features.AdjustMovement(0.25f); ShowMovementTuning(plugin); }); AddButton("JUMP HEIGHT: " + plugin.Features.JumpHeightMultiplier.ToString("0.00") + "x", delegate { plugin.Features.AdjustJumpHeight(0.25f); ShowMovementTuning(plugin); }); AddButton("GRAVITY: " + plugin.Features.GravityMultiplier.ToString("0.00") + "x", delegate { plugin.Features.AdjustGravity(-0.25f); ShowMovementTuning(plugin); }); AddButton("RESET MOVEMENT SPEED", delegate { plugin.Features.AdjustMovement(1f - plugin.Features.MovementMultiplier); ShowMovementTuning(plugin); }); AddButton("RESET JUMP HEIGHT", delegate { plugin.Features.AdjustJumpHeight(1f - plugin.Features.JumpHeightMultiplier); ShowMovementTuning(plugin); }); AddButton("RESET GRAVITY", delegate { plugin.Features.AdjustGravity(1f - plugin.Features.GravityMultiplier); ShowMovementTuning(plugin); }); AddButton("BACK", delegate { ShowMovement(plugin); }); FinishPage(); } private static void ShowTime(WhiteKnuckleTrainerPlugin plugin) { BeginPage(); AddButton("TIME SCALE: " + plugin.Features.TimeScaleMultiplier.ToString("0.00") + "x", null, enabled: false); AddButton("SLOWER", delegate { plugin.Features.AdjustTimeScale(-0.1f); ShowTime(plugin); }); AddButton("FASTER", delegate { plugin.Features.AdjustTimeScale(0.1f); ShowTime(plugin); }); AddButton("RESET TO 1.00x", delegate { plugin.Features.AdjustTimeScale(1f - plugin.Features.TimeScaleMultiplier); ShowTime(plugin); }); AddButton("BACK", delegate { ShowMovement(plugin); }); FinishPage(); } private static void ShowMovementModes(WhiteKnuckleTrainerPlugin plugin) { BeginPage(); AddButton("FLY MODE: " + OnOff(plugin.Features.Fly), delegate { plugin.Features.ToggleFly(); ShowMovementModes(plugin); }); AddButton("NOCLIP: " + OnOff(plugin.Features.Noclip), delegate { plugin.Features.ToggleNoclip(); ShowMovementModes(plugin); }); AddButton("CLIMB ANYWHERE: " + OnOff(plugin.Features.ClimbAnywhere), delegate { plugin.Features.ToggleClimbAnywhere(); ShowMovementModes(plugin); }); AddButton("FLY: JUMP ASCENDS, CROUCH DESCENDS", null, enabled: false); AddButton("BACK", delegate { ShowMovement(plugin); }); FinishPage(); } private static void ShowItemCategories(WhiteKnuckleTrainerPlugin plugin, int page) { ShowPagedButtons(new List<string> { "Consumables", "Tools & weapons", "Miscellaneous", "Artifacts", "Trinkets", "Cheats / unused", "All discovered" }, page, (string category) => "SPAWN — " + category.ToUpperInvariant(), delegate(string category) { ShowItems(plugin, category, 0); }, delegate(int previous) { ShowItemCategories(plugin, previous); }, delegate { ShowHome(plugin); }); } private static void ShowItems(WhiteKnuckleTrainerPlugin plugin, string category, int page) { List<WhiteKnuckleTrainerPlugin.ItemEntry> list = (from item in plugin.GetItemsForNativeMenu().Where(WhiteKnuckleTrainerPlugin.ShouldListNativeItem) where category == "All discovered" || item.Category == category orderby item.DisplayName select item).ToList(); if (list.Count == 0) { BeginPage(); AddButton("NO ITEMS AVAILABLE YET", null, enabled: false); AddButton("ENTER A RUN, THEN OPEN THIS MENU", null, enabled: false); AddButton("BACK", delegate { ShowItemCategories(plugin, 0); }); FinishPage(); return; } ShowPagedButtons(list, page, (WhiteKnuckleTrainerPlugin.ItemEntry item) => "SPAWN: " + item.DisplayName.ToUpperInvariant(), delegate(WhiteKnuckleTrainerPlugin.ItemEntry item) { plugin.Spawn(item); ShowItems(plugin, category, page); }, delegate(int previous) { ShowItems(plugin, category, previous); }, delegate { ShowItemCategories(plugin, 0); }); } private static void ShowCosmetics(WhiteKnuckleTrainerPlugin plugin) { BeginPage(); AddButton("COSMETICS", null, enabled: false); AddButton("HANDS", delegate { ShowCosmeticList(plugin, hands: true, 0); }); AddButton("HAMMERS", delegate { ShowCosmeticList(plugin, hands: false, 0); }); AddButton("BACK", delegate { ShowHome(plugin); }); FinishPage(); } private static void ShowPerks(WhiteKnuckleTrainerPlugin plugin, int page) { List<Perk> list = plugin.GetPerksForNativeMenu().ToList(); if (list.Count == 0) { BeginPage(); AddButton("NO PERKS AVAILABLE YET", null, enabled: false); AddButton("ENTER A RUN, THEN OPEN THIS MENU", null, enabled: false); AddButton("BACK", delegate { ShowHome(plugin); }); FinishPage(); return; } ShowPagedButtons(list, page, (Perk perk) => (plugin.IsPerkActive(perk) ? "REMOVE: " : "ADD: ") + PerkLabel(perk).ToUpperInvariant(), delegate(Perk perk) { if (plugin.IsPerkActive(perk)) { plugin.RemovePerkFromNativeMenu(perk); } else { plugin.AddPerkFromNativeMenu(perk); } ShowPerks(plugin, page); }, delegate(int previous) { ShowPerks(plugin, previous); }, delegate { ShowHome(plugin); }); } private static void ShowTools(WhiteKnuckleTrainerPlugin plugin) { BeginPage(); AddButton("TOOLS", null, enabled: false); AddButton("EXPORT DIAGNOSTICS", delegate { TrainerTools.ExportDiagnostics(plugin); }); AddButton("EXPORT LEVEL DATA", delegate { TrainerTools.ExportLevelData(plugin); }); AddButton("EXPORTS: BEPINEX/CONFIG/WHITEKNUCKLETRAINER", null, enabled: false); AddButton("LEVEL EXPORT ENABLES NATIVE CHEAT MODE", null, enabled: false); AddButton("BACK", delegate { ShowHome(plugin); }); FinishPage(); } private static void ShowEsp(WhiteKnuckleTrainerPlugin plugin) { TrainerFeatures features = plugin.Features; BeginPage(); AddButton("ESP / ITEM RADAR", null, enabled: false); AddButton("ENABLE ESP: " + OnOff(features.EspEnabled), delegate { features.ToggleEsp(); ShowEsp(plugin); }); AddButton("MAX DISTANCE: " + features.EspMaximumDistance.ToString("0") + "m", delegate { ShowEspDistance(plugin); }); AddButton("MAX LABELS: " + features.EspMaximumLabels, delegate { ShowEspLabels(plugin); }); AddButton("ONLY ON SCREEN: " + OnOff(features.EspOnlyOnScreen), delegate { features.ToggleEspOnlyOnScreen(); ShowEsp(plugin); }); AddButton("OCCLUSION CHECK: " + OnOff(features.EspOcclusionCheck), delegate { features.ToggleEspOcclusionCheck(); ShowEsp(plugin); }); AddButton("NEAREST DISCOVERED ITEMS — 1s REFRESH", null, enabled: false); AddButton("BACK", delegate { ShowHome(plugin); }); FinishPage(); } private static void ShowEspDistance(WhiteKnuckleTrainerPlugin plugin) { BeginPage(); AddButton("MAX ESP DISTANCE: " + plugin.Features.EspMaximumDistance.ToString("0") + "m", null, enabled: false); AddButton("DECREASE BY 15m", delegate { plugin.Features.AdjustEspDistance(-15f); ShowEspDistance(plugin); }); AddButton("INCREASE BY 15m", delegate { plugin.Features.AdjustEspDistance(15f); ShowEspDistance(plugin); }); AddButton("BACK", delegate { ShowEsp(plugin); }); FinishPage(); } private static void ShowEspLabels(WhiteKnuckleTrainerPlugin plugin) { BeginPage(); AddButton("MAX ESP LABELS: " + plugin.Features.EspMaximumLabels, null, enabled: false); AddButton("DECREASE", delegate { plugin.Features.AdjustEspLabels(-3); ShowEspLabels(plugin); }); AddButton("INCREASE", delegate { plugin.Features.AdjustEspLabels(3); ShowEspLabels(plugin); }); AddButton("BACK", delegate { ShowEsp(plugin); }); FinishPage(); } private static void ShowCosmeticList(WhiteKnuckleTrainerPlugin plugin, bool hands, int page) { List<Cosmetic_Base> list = (hands ? plugin.GetHandCosmeticsForNativeMenu() : plugin.GetHammerCosmeticsForNativeMenu()).OrderBy(WhiteKnuckleTrainerPlugin.GetNativeCosmeticName).ToList(); if (list.Count == 0) { BeginPage(); AddButton("NO " + (hands ? "HAND" : "HAMMER") + " COSMETICS FOUND", null, enabled: false); AddButton("BACK", delegate { ShowCosmetics(plugin); }); FinishPage(); return; } ShowPagedButtons(list, page, (Cosmetic_Base cosmetic) => "EQUIP: " + WhiteKnuckleTrainerPlugin.GetNativeCosmeticName(cosmetic).ToUpperInvariant(), delegate(Cosmetic_Base cosmetic) { plugin.EquipCosmeticFromNativeMenu(cosmetic, hands); plugin.LogNativeInfo("[Trainer] Equipped cosmetic: " + WhiteKnuckleTrainerPlugin.GetNativeCosmeticName(cosmetic)); ShowCosmeticList(plugin, hands, page); }, delegate(int previous) { ShowCosmeticList(plugin, hands, previous); }, delegate { ShowCosmetics(plugin); }); } private static void ShowPagedButtons<T>(IReadOnlyList<T> entries, int requestedPage, Func<T, string> label, Action<T> selected, Action<int> showPage, Action back) { int num = Mathf.Max(1, Mathf.CeilToInt((float)entries.Count / 6f)); int page = Mathf.Clamp(requestedPage, 0, num - 1); int num2 = page * 6; int num3 = Mathf.Min(num2 + 6, entries.Count); BeginPage(); for (int i = num2; i < num3; i++) { T entry = entries[i]; AddButton(label(entry), delegate { selected(entry); }); } if (page > 0) { AddButton("PREVIOUS PAGE (" + page + "/" + num + ")", delegate { showPage(page - 1); }); } if (page + 1 < num) { AddButton("NEXT PAGE (" + (page + 2) + "/" + num + ")", delegate { showPage(page + 1); }); } AddButton("BACK", back); FinishPage(); } private static void BeginPage() { ClearGeneratedEntries(); } private static void FinishPage() { ConfigureGeneratedNavigation(); RebuildLayout(); } private static void AddButton(string label, Action? action, bool enabled = true) { if (!((Object)(object)_layout == (Object)null) && !((Object)(object)_settingsTemplate == (Object)null)) { GameObject val = Object.Instantiate<GameObject>(((Component)_settingsTemplate).gameObject, _layout); ((Object)val).name = "WhiteKnuckleTrainer_Generated_" + GeneratedEntries.Count; val.SetActive(true); ConfigureNativeButton(val, label, action, enabled); GeneratedEntries.Add(val); } } private static void ConfigureNativeButton(GameObject buttonObject, string label, Action? action, bool enabled) { //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Expected O, but got Unknown UI_MenuButton component = buttonObject.GetComponent<UI_MenuButton>(); if ((Object)(object)component != (Object)null) { Object.Destroy((Object)(object)component); } Button component2 = buttonObject.GetComponent<Button>(); TMP_Text componentInChildren = buttonObject.GetComponentInChildren<TMP_Text>(true); if ((Object)(object)component2 == (Object)null || (Object)(object)componentInChildren == (Object)null) { throw new InvalidOperationException("The verified Settings template no longer contains a Button and TMP label."); } componentInChildren.text = label; bool flag = label.Length > 24; LayoutElement val = buttonObject.GetComponent<LayoutElement>(); if ((Object)(object)val == (Object)null) { val = buttonObject.AddComponent<LayoutElement>(); } val.minHeight = (flag ? 72f : 0f); val.preferredHeight = (flag ? 72f : (-1f)); componentInChildren.enableWordWrapping = flag; componentInChildren.overflowMode = (TextOverflowModes)((!flag) ? 1 : 3); componentInChildren.enableAutoSizing = true; componentInChildren.fontSizeMin = (flag ? 15f : 18f); componentInChildren.fontSizeMax = (flag ? 24f : 32f); ((UnityEventBase)component2.onClick).RemoveAllListeners(); ((Selectable)component2).interactable = enabled && action != null; if (enabled && action != null) { ((UnityEvent)component2.onClick).AddListener((UnityAction)delegate { action(); }); } } private static void ConfigureGeneratedNavigation() { //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_00dd: Unknown result type (might be due to invalid IL or missing references) List<Button> list = (from entry in GeneratedEntries where (Object)(object)entry != (Object)null && entry.activeInHierarchy select entry.GetComponent<Button>() into button where (Object)(object)button != (Object)null && ((Selectable)button).interactable select button).Cast<Button>().ToList(); for (int num = 0; num < list.Count; num++) { Navigation navigation = ((Selectable)list[num]).navigation; ((Navigation)(ref navigation)).mode = (Mode)4; ((Navigation)(ref navigation)).selectOnUp = (Selectable)(object)((num > 0) ? list[num - 1] : list[num]); ((Navigation)(ref navigation)).selectOnDown = (Selectable)(object)((num + 1 < list.Count) ? list[num + 1] : list[num]); ((Selectable)list[num]).navigation = navigation; } if (list.Count > 0) { ((Selectable)list[0]).Select(); } } private static void ClearGeneratedEntries() { foreach (GameObject generatedEntry in GeneratedEntries) { if ((Object)(object)generatedEntry != (Object)null) { generatedEntry.SetActive(false); Object.Destroy((Object)(object)generatedEntry); } } GeneratedEntries.Clear(); } private static void RebuildLayout() { Transform? layout = _layout; RectTransform val = (RectTransform)(object)((layout is RectTransform) ? layout : null); if (val != null) { LayoutRebuilder.ForceRebuildLayoutImmediate(val); } } private static Transform? FindPauseLayout(Transform pauseMenu) { Transform[] componentsInChildren = ((Component)pauseMenu).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (((Object)val).name == "Pause Layout") { return val; } } return null; } private static void ReportMissingTemplate(WhiteKnuckleTrainerPlugin plugin, string missing) { if (!_reportedMissingTemplate) { _reportedMissingTemplate = true; plugin.LogNativeWarning("[Trainer] Pause menu discovered, but native template was not found: " + missing + "."); } } private static string OnOff(bool enabled) { if (!enabled) { return "OFF"; } return "ON"; } private static string PerkLabel(Perk perk) { if (!string.IsNullOrWhiteSpace(perk.title)) { return perk.title; } return perk.id; } } [HarmonyPatch(typeof(CL_GameManager), "UnPause")] internal static class NativePauseMenuUnpausePatch { private static void Postfix() { NativePauseMenuPatch.Close(); } } internal sealed class TrainerFeatures { private readonly struct PlayerDefaults { internal readonly bool Initialized; internal readonly float Speed; internal readonly float SprintSpeed; internal readonly float CrouchSpeed; internal readonly float SwimSpeed; internal readonly float JumpHeight; internal readonly float Gravity; internal readonly int ExtraJumps; internal PlayerDefaults(ENT_Player player) { Initialized = true; Speed = player.speed; SprintSpeed = player.sprintSpeed; CrouchSpeed = player.crouchSpeed; SwimSpeed = player.swimSpeed; JumpHeight = player.jumpHeight; Gravity = player.gravity; ExtraJumps = player.extraJumps; } } private readonly WhiteKnuckleTrainerPlugin _plugin; private ENT_Player? _player; private PlayerDefaults _defaults; internal bool GodMode { get; private set; } internal bool NoFallDamage { get; private set; } internal bool NoEncumbrance { get; private set; } internal bool Fly { get; private set; } internal bool Noclip { get; private set; } internal bool ClimbAnywhere { get; private set; } internal bool EspEnabled { get; private set; } internal bool EspOnlyOnScreen { get; private set; } = true; internal bool EspOcclusionCheck { get; private set; } internal float EspMaximumDistance { get; private set; } = 75f; internal int EspMaximumLabels { get; private set; } = 15; internal int MultiJumpCount { get; private set; } = 1; internal float MovementMultiplier { get; private set; } = 1f; internal float JumpHeightMultiplier { get; private set; } = 1f; internal float GravityMultiplier { get; private set; } = 1f; internal float TimeScaleMultiplier { get; private set; } = 1f; internal TrainerFeatures(WhiteKnuckleTrainerPlugin plugin) { _plugin = plugin; } internal void ResetScene() { _player = null; _defaults = default(PlayerDefaults); } internal void Update(ENT_Player player) { if ((Object)(object)_player != (Object)(object)player) { RestorePreviousPlayer(); _player = player; _defaults = new PlayerDefaults(player); ApplyNativeToggles(player); } if (!HasActiveGameplayModification() || _plugin.EnsureNativeCheatMode()) { ApplyPlayerValues(player); } } internal void ToggleGodMode() { GodMode = ToggleGameplay(GodMode); ApplyNativeTogglesIfReady(); } internal void ToggleNoFallDamage() { NoFallDamage = ToggleGameplay(NoFallDamage); } internal void ToggleNoEncumbrance() { NoEncumbrance = ToggleGameplay(NoEncumbrance); } internal void ToggleFly() { Fly = ToggleGameplay(Fly); ApplyNativeTogglesIfReady(); } internal void ToggleNoclip() { Noclip = ToggleGameplay(Noclip); ApplyNativeTogglesIfReady(); } internal void ToggleClimbAnywhere() { ClimbAnywhere = ToggleGameplay(ClimbAnywhere); ApplyNativeTogglesIfReady(); } internal void ToggleEsp() { EspEnabled = ToggleGameplay(EspEnabled); } internal void ToggleEspOnlyOnScreen() { EspOnlyOnScreen = !EspOnlyOnScreen; } internal void ToggleEspOcclusionCheck() { EspOcclusionCheck = !EspOcclusionCheck; } internal void AdjustEspDistance(float delta) { float espMaximumDistance = Mathf.Clamp(EspMaximumDistance + delta, 15f, 200f); if (_plugin.EnsureNativeCheatMode()) { EspMaximumDistance = espMaximumDistance; } } internal void AdjustEspLabels(int delta) { int espMaximumLabels = Mathf.Clamp(EspMaximumLabels + delta, 3, 30); if (_plugin.EnsureNativeCheatMode()) { EspMaximumLabels = espMaximumLabels; } } internal void AdjustMultiJump(int delta) { SetMultiJump(Mathf.Clamp(MultiJumpCount + delta, 1, 20)); } internal void AdjustMovement(float delta) { SetMovement(Mathf.Clamp(MovementMultiplier + delta, 0.5f, 3f)); } internal void AdjustJumpHeight(float delta) { SetJumpHeight(Mathf.Clamp(JumpHeightMultiplier + delta, 0.5f, 3f)); } internal void AdjustGravity(float delta) { SetGravity(Mathf.Clamp(GravityMultiplier + delta, 0.25f, 2f)); } internal void AdjustTimeScale(float delta) { SetTimeScale(Mathf.Clamp(TimeScaleMultiplier + delta, 0.1f, 1f)); } private void SetMultiJump(int value) { if (value <= 1 || _plugin.EnsureNativeCheatMode()) { MultiJumpCount = value; } } private void SetMovement(float value) { if (Mathf.Approximately(value, 1f) || _plugin.EnsureNativeCheatMode()) { MovementMultiplier = value; } } private void SetJumpHeight(float value) { if (Mathf.Approximately(value, 1f) || _plugin.EnsureNativeCheatMode()) { JumpHeightMultiplier = value; } } private void SetGravity(float value) { if (Mathf.Approximately(value, 1f) || _plugin.EnsureNativeCheatMode()) { GravityMultiplier = value; } } private void SetTimeScale(float value) { if (Mathf.Approximately(value, 1f) || _plugin.EnsureNativeCheatMode()) { TimeScaleMultiplier = value; CL_GameManager.SetTimescaleMult(TimeScaleMultiplier); } } private bool ToggleGameplay(bool current) { bool flag = !current; if (flag && !_plugin.EnsureNativeCheatMode()) { return current; } return flag; } private void ApplyNativeTogglesIfReady() { if ((Object)(object)_player != (Object)null) { ApplyNativeToggles(_player); } } private void ApplyPlayerValues(ENT_Player player) { if (_defaults.Initialized) { player.speed = _defaults.Speed * MovementMultiplier; player.sprintSpeed = _defaults.SprintSpeed * MovementMultiplier; player.crouchSpeed = _defaults.CrouchSpeed * MovementMultiplier; player.swimSpeed = _defaults.SwimSpeed * MovementMultiplier; player.jumpHeight = _defaults.JumpHeight * JumpHeightMultiplier; player.gravity = _defaults.Gravity * GravityMultiplier; player.extraJumps = MultiJumpCount - 1; } CL_GameManager.SetTimescaleMult(TimeScaleMultiplier); } private void ApplyNativeToggles(ENT_Player player) { player.GodMode(new string[1] { GodMode.ToString() }); player.FlyCommand(new string[1] { Fly.ToString() }); player.Noclip(new string[1] { Noclip.ToString() }); player.ClimbAnywhereCommand(new string[1] { ClimbAnywhere.ToString() }); CL_GameManager.SetTimescaleMult(TimeScaleMultiplier); } private bool HasActiveGameplayModification() { if (!GodMode && !NoFallDamage && !NoEncumbrance && !Fly && !Noclip && !ClimbAnywhere && !EspEnabled && MultiJumpCount <= 1 && Mathf.Approximately(MovementMultiplier, 1f) && Mathf.Approximately(JumpHeightMultiplier, 1f) && Mathf.Approximately(GravityMultiplier, 1f)) { return !Mathf.Approximately(TimeScaleMultiplier, 1f); } return true; } private void RestorePreviousPlayer() { if (!((Object)(object)_player == (Object)null) && _defaults.Initialized) { _player.speed = _defaults.Speed; _player.sprintSpeed = _defaults.SprintSpeed; _player.crouchSpeed = _defaults.CrouchSpeed; _player.swimSpeed = _defaults.SwimSpeed; _player.jumpHeight = _defaults.JumpHeight; _player.gravity = _defaults.Gravity; _player.extraJumps = _defaults.ExtraJumps; } } } [HarmonyPatch(typeof(Inventory), "GetEncumberance")] internal static class NoEncumbrancePatch { private static bool Prefix(ref float __result) { WhiteKnuckleTrainerPlugin? instance = WhiteKnuckleTrainerPlugin.Instance; if (instance == null || !instance.Features.NoEncumbrance) { return true; } __result = 1f; return false; } } [HarmonyPatch(typeof(ENT_Player), "Damage")] internal static class NoFallDamagePatch { private static bool Prefix(DamageInfo info) { WhiteKnuckleTrainerPlugin? instance = WhiteKnuckleTrainerPlugin.Instance; if (instance != null && instance.Features.NoFallDamage) { return !string.Equals(info.type, "falling", StringComparison.OrdinalIgnoreCase); } return true; } } [HarmonyPatch(typeof(ENT_Player), "Kill")] internal static class NoFallDeathPatch { private static bool Prefix(string type) { WhiteKnuckleTrainerPlugin? instance = WhiteKnuckleTrainerPlugin.Instance; if (instance != null && instance.Features.NoFallDamage) { return !string.Equals(type, "falling", StringComparison.OrdinalIgnoreCase); } return true; } } internal static class TrainerTools { [Serializable] private sealed class LevelDump { public string scene = ""; public Vector3 playerPosition; public List<LevelItem> items = new List<LevelItem>(); } [Serializable] private sealed class LevelItem { public string name = ""; public string prefabId = ""; public string category = ""; public Vector3 position; } private static string ExportDirectory => Path.Combine(Paths.ConfigPath, "WhiteKnuckleTrainer"); internal static string ExportDiagnostics(WhiteKnuckleTrainerPlugin plugin) { //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) Directory.CreateDirectory(ExportDirectory); TrainerFeatures features = plugin.Features; string text = Path.Combine(ExportDirectory, "diagnostics.txt"); string[] obj = new string[23] { "White Knuckle Trainer diagnostics", "Version: 1.0.0", "BepInEx assembly: " + typeof(BaseUnityPlugin).Assembly.GetName().Version, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null }; Scene activeScene = SceneManager.GetActiveScene(); obj[3] = "Scene: " + ((Scene)(ref activeScene)).name; obj[4] = "Native cheat mode: " + CommandConsole.hasCheated; obj[5] = "God mode: " + features.GodMode; obj[6] = "No fall damage: " + features.NoFallDamage; obj[7] = "No encumbrance: " + features.NoEncumbrance; obj[8] = "Infinite jumps: " + plugin.InfiniteJumps; obj[9] = "Infinite stamina: " + plugin.InfiniteStamina; obj[10] = "Infinite ammo: " + plugin.InfiniteAmmoAndThrowables; obj[11] = "Multi-jump count: " + features.MultiJumpCount; obj[12] = "Movement multiplier: " + features.MovementMultiplier.ToString("0.00"); obj[13] = "Jump-height multiplier: " + features.JumpHeightMultiplier.ToString("0.00"); obj[14] = "Gravity multiplier: " + features.GravityMultiplier.ToString("0.00"); obj[15] = "Time scale: " + features.TimeScaleMultiplier.ToString("0.00"); obj[16] = "Fly: " + features.Fly; obj[17] = "Noclip: " + features.Noclip; obj[18] = "Climb anywhere: " + features.ClimbAnywhere; obj[19] = "Spawnable items discovered: " + plugin.GetItemsForNativeMenu().Count; obj[20] = "Perks discovered: " + plugin.GetPerksForNativeMenu().Count; obj[21] = "Hand cosmetics: " + plugin.GetHandCosmeticsForNativeMenu().Count; obj[22] = "Hammer cosmetics: " + plugin.GetHammerCosmeticsForNativeMenu().Count; string[] contents = obj; File.WriteAllLines(text, contents); plugin.LogNativeInfo("[Trainer] Diagnostics exported: " + text); return text; } internal static string? ExportLevelData(WhiteKnuckleTrainerPlugin plugin) { //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_004a: 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_004f: Unknown result type (might be due to invalid IL or missing references) if (!plugin.EnsureNativeCheatMode()) { return null; } Directory.CreateDirectory(ExportDirectory); ENT_Player player = ENT_Player.GetPlayer(); LevelDump levelDump = new LevelDump(); Scene activeScene = SceneManager.GetActiveScene(); levelDump.scene = ((Scene)(ref activeScene)).name; levelDump.playerPosition = (((Object)(object)player == (Object)null) ? Vector3.zero : ((Component)player).transform.position); levelDump.items = (from item in Object.FindObjectsOfType<Item_Object>() where (Object)(object)item != (Object)null && item.itemData != null select new LevelItem { name = item.itemData.itemName, prefabId = item.itemData.prefabName, category = WhiteKnuckleTrainerPlugin.Categorize(item.itemData.itemName, item.itemData.prefabName), position = ((Component)item).transform.position }).ToList(); LevelDump levelDump2 = levelDump; string text = Path.Combine(ExportDirectory, "level-" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + ".json"); File.WriteAllText(text, JsonUtility.ToJson((object)levelDump2, true)); plugin.LogNativeInfo("[Trainer] Metadata-only level export written: " + text); return text; } } [BepInPlugin("drake.whiteknuckle.trainer", "White Knuckle Trainer", "1.0.0")] public sealed class WhiteKnuckleTrainerPlugin : BaseUnityPlugin { internal sealed class ItemEntry { public string DisplayName { get; } public string PrefabId { get; } public string Category { get; } public Sprite? Icon { get; } public ItemEntry(string displayName, string prefabId, string category, Sprite? icon) { DisplayName = displayName; PrefabId = prefabId; Category = category; Icon = icon; } } public const string PluginGuid = "drake.whiteknuckle.trainer"; public const string PluginName = "White Knuckle Trainer"; public const string PluginVersion = "1.0.0"; private readonly List<ItemEntry> _items = new List<ItemEntry>(); private readonly List<Cosmetic_Base> _handCosmetics = new List<Cosmetic_Base>(); private readonly List<Cosmetic_Base> _hammerCosmetics = new List<Cosmetic_Base>(); private readonly Dictionary<Cosmetic_Base, Sprite?> _cosmeticPreviewCache = new Dictionary<Cosmetic_Base, Sprite>(); private Vector2 _scroll; private Vector2 _handCosmeticScroll; private Vector2 _hammerCosmeticScroll; private Rect _windowRect = new Rect(25f, 60f, 900f, 650f); private string _category = "Consumables"; private string _search = string.Empty; private bool _menuOpen; private bool _pausedByTrainer; private bool _cursorStateCaptured; private CursorLockMode _savedCursorLockState; private bool _savedCursorVisible; private bool _lastInfiniteAmmo; private bool _itemsScanned; private string _mainTab = "Trainer"; private string _cosmeticTab = "Hands"; private bool _cosmeticsCached; private string? _cosmeticDiscoveryError; private GUIStyle? _windowStyle; private GUIStyle? _buttonStyle; private GUIStyle? _labelStyle; private GUIStyle? _textFieldStyle; private GUIStyle? _toggleStyle; private GUIStyle? _cosmeticCardStyle; private GUIStyle? _cosmeticNameStyle; private GUIStyle? _sectionHeaderStyle; private GUIStyle? _closeButtonStyle; private Texture2D? _opaqueBackground; private Texture2D? _checkboxOff; private Texture2D? _checkboxOn; private Texture2D? _buttonNormalTexture; private Texture2D? _buttonHoverTexture; private Texture2D? _buttonSelectedTexture; private GUIStyle? _buttonTextStyle; private static readonly string[] Categories = new string[7] { "Consumables", "Tools & weapons", "Miscellaneous", "Artifacts", "Trinkets", "Cheats / unused", "All discovered" }; internal static WhiteKnuckleTrainerPlugin? Instance { get; private set; } internal TrainerFeatures Features { get; private set; } internal bool InfiniteJumps { get; private set; } internal bool InfiniteStamina { get; private set; } internal bool InfiniteAmmoAndThrowables { get; private set; } internal void LogNativeInfo(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } internal void LogNativeWarning(string message) { ((BaseUnityPlugin)this).Logger.LogWarning((object)message); } internal void LogNativeError(string message) { ((BaseUnityPlugin)this).Logger.LogError((object)message); } internal void ToggleInfiniteJumps() { if (InfiniteJumps || EnsureNativeCheatMode()) { InfiniteJumps = !InfiniteJumps; } } internal void ToggleInfiniteStamina() { if (InfiniteStamina || EnsureNativeCheatMode()) { InfiniteStamina = !InfiniteStamina; } } internal void ToggleInfiniteAmmoAndThrowables() { if (InfiniteAmmoAndThrowables || EnsureNativeCheatMode()) { InfiniteAmmoAndThrowables = !InfiniteAmmoAndThrowables; } } internal IReadOnlyList<ItemEntry> GetItemsForNativeMenu() { if (!_itemsScanned) { ScanInstalledItems(); } return _items; } internal IReadOnlyList<Perk> GetPerksForNativeMenu() { try { return (from perk in CL_AssetManager.GetFullCombinedAssetDatabase().perkAssets where (Object)(object)perk != (Object)null && !string.IsNullOrWhiteSpace(perk.id) orderby (!string.IsNullOrWhiteSpace(perk.title)) ? perk.title : perk.id select perk).ToList(); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogDebug((object)("Perk database is not ready: " + ex.Message)); return Array.Empty<Perk>(); } } internal bool AddPerkFromNativeMenu(Perk perk) { ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)player == (Object)null || !EnsureNativeCheatMode()) { return false; } if (player.HasPerk(perk.id) && !perk.canStack) { return false; } player.AddPerk(perk, 1, true); return true; } internal bool RemovePerkFromNativeMenu(Perk perk) { ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)player == (Object)null || !EnsureNativeCheatMode() || !player.HasPerk(perk.id)) { return false; } player.RemovePerk(perk.id, false); return true; } internal bool IsPerkActive(Perk perk) { ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)player != (Object)null) { return player.HasPerk(perk.id); } return false; } internal IReadOnlyList<Cosmetic_Base> GetHandCosmeticsForNativeMenu() { EnsureCosmeticCache(); return _handCosmetics; } internal IReadOnlyList<Cosmetic_Base> GetHammerCosmeticsForNativeMenu() { EnsureCosmeticCache(); return _hammerCosmetics; } internal void EquipCosmeticFromNativeMenu(Cosmetic_Base cosmetic, bool hands) { if (hands) { Cosmetic_HandItem val = (Cosmetic_HandItem)(object)((cosmetic is Cosmetic_HandItem) ? cosmetic : null); if (val != null) { EquipHandCosmetic(val); return; } } if (!hands) { EquipHammerCosmetic(cosmetic); } } internal static string GetNativeCosmeticName(Cosmetic_Base cosmetic) { return GetDisplayName(cosmetic); } internal static bool ShouldListNativeItem(ItemEntry item) { if (!(item.Category != "Consumables")) { return IsUsefulConsumable(item); } return true; } private void Awake() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) Instance = this; Features = new TrainerFeatures(this); Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); ((Component)this).gameObject.AddComponent<EspOverlay>(); new Harmony("drake.whiteknuckle.trainer").PatchAll(); SceneManager.sceneLoaded += OnSceneLoaded; ((BaseUnityPlugin)this).Logger.LogInfo((object)"White Knuckle Trainer 1.0.0 loaded. Press Shift + Insert to open the menu."); } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; NativePauseMenuPatch.Close(); SetGameInfiniteAmmo(enabled: false); Instance = null; } private void OnSceneLoaded(Scene _, LoadSceneMode __) { NativePauseMenuPatch.ResetSceneState(); Features.ResetScene(); _itemsScanned = false; _items.Clear(); _cosmeticsCached = false; _handCosmetics.Clear(); _hammerCosmetics.Clear(); _cosmeticPreviewCache.Clear(); } private void Update() { if (Input.GetKeyDown((KeyCode)277) && (Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303))) { ToggleNativeTrainerMenu(); } if (NativePauseMenuPatch.IsOpen && Input.GetKeyDown((KeyCode)27)) { NativePauseMenuPatch.Close(); } if (_menuOpen) { Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; } ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)player == (Object)null) { return; } if (InfiniteJumps || InfiniteStamina || InfiniteAmmoAndThrowables) { EnsureNativeCheatMode(); } if (InfiniteStamina) { Hand[] hands = player.hands; foreach (Hand obj in hands) { obj.SetGripStrength(obj.GetGripStrengthMax()); } } if (InfiniteJumps) { SetJumpCounters(player, 99, 99); } Features.Update(player); if (_lastInfiniteAmmo != InfiniteAmmoAndThrowables) { SetGameInfiniteAmmo(InfiniteAmmoAndThrowables); _lastInfiniteAmmo = InfiniteAmmoAndThrowables; } if (!_itemsScanned) { ScanInstalledItems(); } } private void OnGUI() { } private void DrawWindow(int _) { //IL_0020: 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) if (GUI.Button(new Rect(((Rect)(ref _windowRect)).width - 27f, 2f, 23f, 18f), "X")) { SetMenuOpen(open: false); return; } GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Space(12f); DrawHeaderTabs(); if (_mainTab == "Cosmetic editor") { DrawCosmeticEditor(); } else { DrawTrainerTab(); } GUILayout.EndVertical(); GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width - 32f, 22f)); } private void DrawHeaderTabs() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); if (DrawButton("TRAINER", 180f, 30f, _mainTab == "Trainer")) { _mainTab = "Trainer"; } if (DrawButton("COSMETIC EDITOR", 210f, 30f, _mainTab == "Cosmetic editor")) { _mainTab = "Cosmetic editor"; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); GUILayout.Space(8f); } private void DrawTrainerTab() { GUILayout.Label("TRAINER OPTIONS", _sectionHeaderStyle, Array.Empty<GUILayoutOption>()); DrawTrainerOptions(); GUILayout.Space(8f); GUILayout.Label("ITEM SPAWNER", _sectionHeaderStyle, Array.Empty<GUILayoutOption>()); DrawItemSpawner(); } private void DrawTrainerOptions() { InfiniteJumps = DrawCheckbox("Infinite Jumps", InfiniteJumps); InfiniteStamina = DrawCheckbox("Infinite Stamina", InfiniteStamina); InfiniteAmmoAndThrowables = DrawCheckbox("Infinite Ammo / Throwables / Pitons", InfiniteAmmoAndThrowables); } private void DrawItemSpawner() { GUILayout.Label("Spawn items directly into the inventory", _labelStyle, Array.Empty<GUILayoutOption>()); DrawItemCategoryFilters(); DrawItemSearch(); DrawItemResults(); } private void DrawItemCategoryFilters() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); string[] categories = Categories; foreach (string text in categories) { if (DrawButton(text.ToUpperInvariant(), 0f, 27f, _category == text)) { _category = text; } } GUILayout.EndHorizontal(); } private void DrawItemSearch() { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label("Search", _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(48f) }); _search = GUILayout.TextField(_search, _textFieldStyle, Array.Empty<GUILayoutOption>()); if (DrawButton("CLEAR", 65f, 25f)) { _search = string.Empty; } GUILayout.EndHorizontal(); } private void DrawItemResults() { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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) if (!_itemsScanned) { GUILayout.Label("Waiting for a gameplay scene so the game's item database is available...", _labelStyle, Array.Empty<GUILayoutOption>()); } else { IEnumerable<ItemEntry> source = _items.Where((ItemEntry item) => _category == "All discovered" || item.Category == _category); if (_category == "Consumables") { source = source.Where(IsUsefulConsumable); } if (!string.IsNullOrWhiteSpace(_search)) { source = source.Where((ItemEntry item) => item.DisplayName.IndexOf(_search, StringComparison.OrdinalIgnoreCase) >= 0 || item.PrefabId.IndexOf(_search, StringComparison.OrdinalIgnoreCase) >= 0); } bool flag = _category == "Consumables" || _category == "All discovered"; if (flag) { _scroll = GUILayout.BeginScrollView(_scroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(440f) }); } foreach (ItemEntry item in source.OrderBy((ItemEntry item) => item.DisplayName)) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); DrawItemPreview(item); GUILayout.Label(item.DisplayName, _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(250f) }); GUILayout.Label(item.PrefabId, _labelStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(300f) }); if (DrawButton("SPAWN", 90f, 25f)) { Spawn(item); } GUILayout.EndHorizontal(); } if (flag) { GUILayout.EndScrollView(); } } GUILayout.Label("Shift + Insert or X closes this menu. The list is read from this installed game's runtime database.", _labelStyle, Array.Empty<GUILayoutOption>()); } private bool DrawCheckbox(string label, bool value) { //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) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_00a3: 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_00b1: 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) GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); Rect rect = GUILayoutUtility.GetRect(24f, 24f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(24f), GUILayout.Height(24f) }); GUI.DrawTexture(rect, (Texture)(object)(value ? _checkboxOn : _checkboxOff)); if (value) { GUI.Label(rect, "✓", _buttonStyle); } Rect rect2 = GUILayoutUtility.GetRect(420f, 24f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(24f) }); GUI.Label(rect2, label, _labelStyle); if ((int)Event.current.type == 0 && (((Rect)(ref rect)).Contains(Event.current.mousePosition) || ((Rect)(ref rect2)).Contains(Event.current.mousePosition))) { Event.current.Use(); value = !value; } GUILayout.EndHorizontal(); return value; } private bool DrawButton(string label, float width, float height, bool selected = false) { //IL_0047: 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_004c: 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_005f: 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_00bb: 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_0096: 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) Rect val = ((width > 0f) ? GUILayoutUtility.GetRect(width, height, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(width), GUILayout.Height(height) }) : GUILayoutUtility.GetRect(0f, height, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.ExpandWidth(true), GUILayout.Height(height) })); bool flag = ((Rect)(ref val)).Contains(Event.current.mousePosition); DrawOutlinedPanel(val, selected ? new Color(0.48f, 0.51f, 0.55f, 1f) : (flag ? new Color(0.4f, 0.43f, 0.47f, 1f) : new Color(0.3f, 0.32f, 0.35f, 1f))); GUI.Label(val, label, _buttonTextStyle); return GUI.Button(val, GUIContent.none, GUIStyle.none); } private static void DrawOutlinedPanel(Rect rect, Color fill) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_008d: 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) Color color = GUI.color; GUI.color = fill; GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture); GUI.color = color; GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1f), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax - 1f, ((Rect)(ref rect)).width, 1f), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)Texture2D.whiteTexture); GUI.DrawTexture(new Rect(((Rect)(ref rect)).xMax - 1f, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)Texture2D.whiteTexture); } private void DrawCosmeticEditor() { //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0121: 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_012f: 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_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label("COSMETIC EDITOR", _sectionHeaderStyle, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.FlexibleSpace(); if (DrawButton("HANDS", 150f, 30f, _cosmeticTab == "Hands")) { _cosmeticTab = "Hands"; } if (DrawButton("HAMMERS", 150f, 30f, _cosmeticTab == "Hammers")) { _cosmeticTab = "Hammers"; } GUILayout.FlexibleSpace(); GUILayout.EndHorizontal(); EnsureCosmeticCache(); if (_cosmeticDiscoveryError != null) { GUILayout.Label("Cosmetic discovery failed. Check the BepInEx log.", _labelStyle, Array.Empty<GUILayoutOption>()); return; } List<Cosmetic_Base> list = ((_cosmeticTab == "Hands") ? _handCosmetics : _hammerCosmetics); if (list.Count == 0) { GUILayout.Label((_cosmeticTab == "Hands") ? "No hand cosmetics were discovered." : "No hammer cosmetics were discovered.", _labelStyle, Array.Empty<GUILayoutOption>()); return; } Vector2 val = ((_cosmeticTab == "Hands") ? _handCosmeticScroll : _hammerCosmeticScroll); val = GUILayout.BeginScrollView(val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(500f) }); foreach (Cosmetic_Base item in list.OrderBy(GetDisplayName)) { DrawCosmeticRow(item, _cosmeticTab == "Hands"); } GUILayout.EndScrollView(); if (_cosmeticTab == "Hands") { _handCosmeticScroll = val; } else { _hammerCosmeticScroll = val; } GUILayout.Label("Hands apply immediately. Hammer cosmetics apply when a hammer is equipped again.", _labelStyle, Array.Empty<GUILayoutOption>()); } private void DrawCosmeticRow(Cosmetic_Base cosmetic, bool hands) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginHorizontal(_cosmeticCardStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(54f) }); Rect rect = GUILayoutUtility.GetRect(44f, 44f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(44f), GUILayout.Height(44f) }); DrawCosmeticPreview(rect, cosmetic); if (DrawButton(GetDisplayName(cosmetic), 0f, 44f)) { if (hands) { Cosmetic_HandItem val = (Cosmetic_HandItem)(object)((cosmetic is Cosmetic_HandItem) ? cosmetic : null); if (val != null) { EquipHandCosmetic(val); goto IL_008a; } } EquipHammerCosmetic(cosmetic); } goto IL_008a; IL_008a: GUILayout.EndHorizontal(); } private void DrawCosmeticPreview(Rect destination, Cosmetic_Base cosmetic) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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) if (!_cosmeticPreviewCache.TryGetValue(cosmetic, out Sprite value)) { value = cosmetic.GetInfoSprite() ?? cosmetic.cosmeticInfo.cardForeground ?? cosmetic.cosmeticInfo.cardBackground; if ((Object)(object)value == (Object)null) { Cosmetic_HandItem val = (Cosmetic_HandItem)(object)((cosmetic is Cosmetic_HandItem) ? cosmetic : null); if (val != null && val.cosmeticData?.swapSprites != null) { value = val.cosmeticData.swapSprites.SelectMany(delegate(SwapSprite swap) { IEnumerable<Sprite> replacementSprites = swap.replacementSprites; return replacementSprites ?? Enumerable.Empty<Sprite>(); }).FirstOrDefault(); } } _cosmeticPreviewCache[cosmetic] = value; if ((Object)(object)value == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[Trainer] Failed to load icon for cosmetic: " + GetDisplayName(cosmetic))); } } if ((Object)(object)value == (Object)null) { GUI.DrawTexture(destination, (Texture)(object)_opaqueBackground); return; } Rect rect = value.rect; Texture texture = (Texture)(object)value.texture; GUI.DrawTextureWithTexCoords(destination, texture, new Rect(((Rect)(ref rect)).x / (float)texture.width, ((Rect)(ref rect)).y / (float)texture.height, ((Rect)(ref rect)).width / (float)texture.width, ((Rect)(ref rect)).height / (float)texture.height)); } private void EnsureCosmeticCache() { if (_cosmeticsCached) { return; } try { ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Trainer] Discovering hand and hammer cosmetics..."); foreach (Cosmetic_Base allLoadedCosmetic in CL_CosmeticManager.GetAllLoadedCosmetics()) { if (allLoadedCosmetic?.cosmeticInfo != null) { if (IsHammerCosmetic(allLoadedCosmetic) && !GetDisplayName(allLoadedCosmetic).Replace(" ", string.Empty).EndsWith("handitem", StringComparison.OrdinalIgnoreCase)) { _hammerCosmetics.Add(allLoadedCosmetic); } else if (allLoadedCosmetic is Cosmetic_HandItem && !IsHammerCosmetic(allLoadedCosmetic)) { _handCosmetics.Add(allLoadedCosmetic); } } } foreach (Cosmetic_Base handCosmetic in _handCosmetics) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Trainer] Hand cosmetic discovered: " + GetDisplayName(handCosmetic))); } foreach (Cosmetic_Base hammerCosmetic in _hammerCosmetics) { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Trainer] Hammer cosmetic discovered: " + GetDisplayName(hammerCosmetic))); } ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Trainer] {_handCosmetics.Count} hand cosmetics and {_hammerCosmetics.Count} hammer cosmetics discovered."); _cosmeticsCached = true; } catch (Exception ex) { _cosmeticDiscoveryError = ex.Message; ((BaseUnityPlugin)this).Logger.LogError((object)$"[Trainer] Cosmetic discovery failed: {ex}"); } } private static string GetDisplayName(Cosmetic_Base cosmetic) { string cosmeticName = cosmetic.cosmeticInfo.cosmeticName; if (!string.IsNullOrWhiteSpace(cosmeticName) && !string.Equals(cosmeticName, "default", StringComparison.OrdinalIgnoreCase) && !string.Equals(cosmeticName, "template", StringComparison.OrdinalIgnoreCase)) { return cosmeticName; } string[] source = (cosmetic.cosmeticInfo.id ?? "Unnamed cosmetic").Replace("_", " ").Replace("-", " ").Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries); return string.Join(" ", from word in source where !string.Equals(word, "item", StringComparison.OrdinalIgnoreCase) select char.ToUpperInvariant(word[0]) + word.Substring(1)); } private static bool IsHammerCosmetic(Cosmetic_Base cosmetic) { if (string.Equals(cosmetic.cosmeticInfo.tag, "hammer", StringComparison.OrdinalIgnoreCase)) { return true; } string text = cosmetic.cosmeticInfo.id ?? string.Empty; Cosmetic_Item val = (Cosmetic_Item)(object)((cosmetic is Cosmetic_Item) ? cosmetic : null); if (val != null && val.cosmeticData != null) { text = text + " " + val.cosmeticData.itemName; } if (text.IndexOf("hammer", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("wrench", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("mallet", StringComparison.OrdinalIgnoreCase) < 0) { return text.IndexOf("crowbar", StringComparison.OrdinalIgnoreCase) >= 0; } return true; } private static void EquipHandCosmetic(Cosmetic_HandItem cosmetic) { CosmeticSaveData cosmeticSaveData = SettingsManager.settings.cosmeticSaveData; cosmeticSaveData.ActivateHandCosmetic(cosmetic, 0, true); cosmeticSaveData.ActivateHandCosmetic(cosmetic, 1, true); ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)player != (Object)null) { Hand[] hands = player.hands; foreach (Hand obj in hands) { obj.RemoveAllCosmetics(); obj.currentCosmetics.Add(cosmetic); } } SettingsManager.instance.SaveSettings(); } private static void EquipHammerCosmetic(Cosmetic_Base cosmetic) { SettingsManager.settings.cosmeticSaveData.ActivateCosmetic(cosmetic, true); SettingsManager.instance.SaveSettings(); } private void EnsureTheme() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_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_0094: 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_00a9: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Expected O, but got Unknown //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Expected O, but got Unknown //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Expected O, but got Unknown //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03e8: Unknown result type (might be due to invalid IL or missing references) //IL_0404: Unknown result type (might be due to invalid IL or missing references) //IL_040e: Expected O, but got Unknown //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_0428: Unknown result type (might be due to invalid IL or missing references) //IL_0445: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Expected O, but got Unknown //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) if (_windowStyle == null) { _opaqueBackground = MakeTexture(new Color(0.005f, 0.006f, 0.008f, 1f)); _buttonNormalTexture = MakeBorderTexture(new Color(0.22f, 0.24f, 0.27f, 1f), Color.white); _buttonHoverTexture = MakeBorderTexture(new Color(0.34f, 0.37f, 0.41f, 1f), Color.white); _buttonSelectedTexture = MakeBorderTexture(new Color(0.45f, 0.48f, 0.52f, 1f), Color.white); GUIStyle val = new GUIStyle { alignment = (TextAnchor)4, fontSize = 13, fontStyle = (FontStyle)1 }; val.normal.textColor = Color.white; _buttonTextStyle = val; _checkboxOff = MakeBorderTexture(new Color(0.02f, 0.025f, 0.03f, 1f), Color.white); _checkboxOn = MakeBorderTexture(new Color(0.18f, 0.3f, 0.22f, 1f), Color.white); _windowStyle = CreateStyle(new Color(0.035f, 0.04f, 0.05f, 0.98f), Color.white, (TextAnchor)1, 14); _windowStyle.padding = new RectOffset(12, 12, 28, 10); _buttonStyle = CreateStyle(new Color(0.1f, 0.12f, 0.15f, 1f), Color.white, (TextAnchor)4, 13); _buttonStyle.hover.background = MakeBorderTexture(new Color(0.18f, 0.21f, 0.25f, 1f), Color.white); _buttonStyle.active.background = MakeBorderTexture(new Color(0.25f, 0.29f, 0.34f, 1f), Color.white); _buttonStyle.onNormal.background = MakeBorderTexture(new Color(0.24f, 0.3f, 0.36f, 1f), Color.white); _buttonStyle.onHover.background = MakeBorderTexture(new Color(0.32f, 0.39f, 0.46f, 1f), Color.white); _labelStyle = CreateStyle(Color.clear, Color.white, (TextAnchor)3, 13); _textFieldStyle = CreateStyle(new Color(0.015f, 0.018f, 0.022f, 1f), Color.white, (TextAnchor)3, 13); _textFieldStyle.padding = new RectOffset(7, 7, 4, 4); _toggleStyle = CreateStyle(Color.clear, Color.white, (TextAnchor)3, 13); _toggleStyle.normal.background = MakeTexture(new Color(0.08f, 0.09f, 0.11f, 1f)); _toggleStyle.onNormal.background = MakeTexture(new Color(0.22f, 0.31f, 0.39f, 1f)); _toggleStyle.padding = new RectOffset(22, 6, 3, 3); _sectionHeaderStyle = CreateStyle(new Color(0.025f, 0.03f, 0.04f, 1f), Color.white, (TextAnchor)3, 16); _sectionHeaderStyle.fontStyle = (FontStyle)1; _sectionHeaderStyle.padding = new RectOffset(10, 10, 6, 6); _closeButtonStyle = CreateStyle(new Color(0.12f, 0.03f, 0.03f, 1f), Color.white, (TextAnchor)4, 13); _closeButtonStyle.fontStyle = (FontStyle)1; _cosmeticCardStyle = CreateStyle(new Color(0.06f, 0.07f, 0.085f, 1f), Color.white, (TextAnchor)3, 13); _cosmeticCardStyle.padding = new RectOffset(4, 4, 4, 4); _cosmeticNameStyle = CreateStyle(new Color(0.09f, 0.11f, 0.13f, 1f), Color.white, (TextAnchor)3, 14); _cosmeticNameStyle.padding = new RectOffset(10, 8, 3, 3); _cosmeticNameStyle.hover.background = MakeBorderTexture(new Color(0.19f, 0.23f, 0.27f, 1f), Color.white); } } private static GUIStyle CreateStyle(Color background, Color text, TextAnchor alignment, int fontSize) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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_0013: 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_001f: 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_0026: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0054: Expected O, but got Unknown GUIStyle val = new GUIStyle { alignment = alignment, fontSize = fontSize }; val.normal.textColor = text; val.normal.background = MakeBorderTexture(background, Color.white); val.border = new RectOffset(1, 1, 1, 1); val.margin = new RectOffset(2, 2, 2, 2); return val; } private static Texture2D MakeTexture(Color color) { //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_000a: 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_0017: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1); val.SetPixel(0, 0, color); val.Apply(); return val; } private static Texture2D MakeBorderTexture(Color interior, Color border) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0024: 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) Texture2D val = new Texture2D(4, 4); for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { val.SetPixel(j, i, (j == 0 || i == 0 || j == 3 || i == 3) ? border : interior); } } val.Apply(); return val; } private void ScanInstalledItems() { try { List<GameObject> itemPrefabs = CL_AssetManager.GetFullCombinedAssetDatabase().itemPrefabs; if (itemPrefabs == null || itemPrefabs.Count == 0) { return; } _items.Clear(); foreach (GameObject item in itemPrefabs) { if ((Object)(object)item == (Object)null) { continue; } Item_Object component = item.GetComponent<Item_Object>(); if (component?.itemData != null) { string text = component.itemData.prefabName; if (string.IsNullOrWhiteSpace(text)) { text = ((Object)item).name; } string text2 = (string.IsNullOrWhiteSpace(component.itemData.itemName) ? ((Object)item).name : component.itemData.itemName); _items.Add(new ItemEntry(text2, text, Categorize(text2, text), component.itemData.normalSprite)); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Item database: " + text2 + " => " + text)); } } _itemsScanned = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Read {_items.Count} item prefabs from the current White Knuckle database."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogDebug((object)("Item database is not ready: " + ex.Message)); } } internal void Spawn(ItemEntry entry) { Item_Object itemObjectPrefab = CL_AssetManager.GetItemObjectPrefab(entry.PrefabId, ""); if ((Object)(object)itemObjectPrefab == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Spawn failed: " + entry.PrefabId + " is not in the current item database.")); return; } if (!EnsureNativeCheatMode()) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"Spawn cancelled because White Knuckle cheat mode is not ready."); return; } Inventory.instance.AddItemToInventoryCenter(itemObjectPrefab.itemData.GetClone((Item)null, false)); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Added " + entry.DisplayName + " (" + entry.PrefabId + ") to the inventory.")); } private void SetMenuOpen(bool open) { //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_0065: Unknown result type (might be due to invalid IL or missing references) if (_menuOpen == open) { return; } _menuOpen = open; if (open) { _savedCursorLockState = Cursor.lockState; _savedCursorVisible = Cursor.visible; _cursorStateCaptured = true; Cursor.lockState = (CursorLockMode)0; Cursor.visible = true; if ((Object)(object)CL_GameManager.gMan != (Object)null) { CL_GameManager.gMan.Pause(); _pausedByTrainer = true; } } else if (_cursorStateCaptured) { Cursor.lockState = _savedCursorLockState; Cursor.visible = _savedCursorVisible; _cursorStateCaptured = false; if (_pausedByTrainer && (Object)(object)CL_GameManager.gMan != (Object)null) { CL_GameManager.gMan.UnPause(); _pausedByTrainer = false; } } } private void ToggleNativeTrainerMenu() { CL_GameManager gMan = CL_GameManager.gMan; if ((Object)(object)gMan == (Object)null) { return; } if (NativePauseMenuPatch.IsOpen) { NativePauseMenuPatch.Close(); return; } if (!gMan.isPaused) { gMan.Pause(); } NativePauseMenuPatch.TryOpen(gMan); } internal bool EnsureNativeCheatMode() { if (CommandConsole.hasCheated) { return true; } if ((Object)(object)CommandConsole.instance == (Object)null) { return false; } CommandConsole.instance.ExecuteCommand("cheats true", false); if (CommandConsole.hasCheated) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Trainer] Enabled White Knuckle cheats for the active trainer run."); } return CommandConsole.hasCheated; } internal static string Categorize(string displayName, string prefabId) { string value = (displayName + " " + prefabId).ToLowerInvariant(); if (Contains(value, "banhammer", "fruit", "rope")) { return "Cheats / unused"; } if (Contains(value, "glove", "remote", "spear", "timepiece", "translocator", "rapier", "blink", "cleaver", "rho", "barnacle", "p-beans", "p_beans", "p beans")) { return "Artifacts"; } if (Contains(value, "beta", "buddy", "carabiner", "chalk", "climbing shoes", "employee id", "gold nugget", "head lamp", "helmet", "mass damper", "moon rocks", "yearning photo")) { return "Trinkets"; } if (Contains(value, "hammer", "cryo", "flare gun", "handgun", "flashlight", "wrench", "scanner", "auto piton", "brick", "piton", "rebar")) { return "Tools & weapons"; } if (Contains(value, "gold roach", "platinum roach", "ruby roach", "flare", "ammo", "floppy", "fuel cell")) { return "Miscellaneous"; } if (Contains(value, "bean", "food bar", "grub", "inject", "inocul", "roach", "milk", "pill", "wine", "cocoa", "cookie", "meat", "candy cauldron")) { return "Consumables"; } return "Uncategorized"; } private static bool Contains(string value, params string[] words) { return words.Any(value.Contains); } private static bool IsUsefulConsumable(ItemEntry item) { string text = item.PrefabId.ToLowerInvariant(); if (!text.Contains("_empty") && !text.Contains("_eaten")) { return !text.Contains("_navmesh"); } return false; } private static void DrawItemPreview(ItemEntry item) { //IL_002a: 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) //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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) Rect rect = GUILayoutUtility.GetRect(24f, 24f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(24f), GUILayout.Height(24f) }); if (!((Object)(object)item.Icon == (Object)null)) { Rect rect2 = item.Icon.rect; Texture texture = (Texture)(object)item.Icon.texture; GUI.DrawTextureWithTexCoords(rect, texture, new Rect(((Rect)(ref rect2)).x / (float)texture.width, ((Rect)(ref rect2)).y / (float)texture.height, ((Rect)(ref rect2)).width / (float)texture.width, ((Rect)(ref rect2)).height / (float)texture.height)); } } private static void SetJumpCounters(ENT_Player player, int normal, int temporary) { Traverse obj = Traverse.Create((object)player); obj.Field("extraJumpsRemaining").SetValue((object)normal); obj.Field("temporaryExtraJumpsRemaining").SetValue((object)temporary); } private static void SetGameInfiniteAmmo(bool enabled) { ENT_Player player = ENT_Player.GetPlayer(); if ((Object)(object)player != (Object)null) { player.InfiniteAmmoCommand(new string[1] { enabled.ToString() }); } } } [HarmonyPatch(typeof(ENT_Player), "Jump")] internal static class InfiniteJumpPatch { private static void Prefix(ENT_Player __instance) { WhiteKnuckleTrainerPlugin? instance = WhiteKnuckleTrainerPlugin.Instance; if (instance != null && instance.InfiniteJumps) { Traverse obj = Traverse.Create((object)__instance); obj.Field("extraJumpsRemaining").SetValue((object)99); obj.Field("temporaryExtraJumpsRemaining").SetValue((object)99); } } } [HarmonyPatch(typeof(HandItem), "RemoveItem")] internal static class InfiniteThrowablePatch { private static bool Prefix(HandItem __instance) { WhiteKnuckleTrainerPlugin? instance = WhiteKnuckleTrainerPlugin.Instance; if (instance == null || !instance.InfiniteAmmoAndThrowables) { return true; } __instance.item.SetUsed(false); __instance.used = false; return false; } } }
BepInEx/plugins/WKLib.dll
Decompiled 3 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Imui.Controls; using Imui.Core; using Imui.IO; using Imui.IO.Touch; using Imui.IO.UGUI; using Imui.Rendering; using Imui.Style; using ImuiBepInEx.API; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Audio; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; using WKLib.API; using WKLib.API.Assets; using WKLib.API.Input; using WKLib.API.UI; using WKLib.Core.Attributes; using WKLib.Core.Classes; using WKLib.Core.Config; using WKLib.Core.Reflection; using WKLib.Core.UI; using WKLib.Core.UI.Windows; using WKLib.Examples.UI; using WKLib.Utilities; [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-CSharp")] [assembly: AssemblyCompany("WKLib")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("0.3.0.0")] [assembly: AssemblyInformationalVersion("0.3.0+783600fdf7a4da27907d61242ace9cff4b43419f")] [assembly: AssemblyProduct("WKLib")] [assembly: AssemblyTitle("WKLib")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.3.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 WKLib { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.monksilly.WKLib", "WKLib", "0.3.0")] public class WKLibPlugin : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__5_0; public static UnityAction <>9__5_1; internal void <OnSceneLoaded>b__5_0() { MonoSingleton<RootPanel>.Instance.IsOpen = !MonoSingleton<RootPanel>.Instance.IsOpen; EventSystem.current.SetSelectedGameObject((GameObject)null); } internal void <OnSceneLoaded>b__5_1() { MonoSingleton<RootPanel>.Instance.IsOpen = !MonoSingleton<RootPanel>.Instance.IsOpen; EventSystem.current.SetSelectedGameObject((GameObject)null); } } public const string GUID = "com.monksilly.WKLib"; public const string NAME = "WKLib"; public const string VERSION = "0.3.0"; private static Harmony harmony; private void Awake() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown WKLog.Initialize(((BaseUnityPlugin)this).Logger); WKLog.Debug("Initalizing reflection..."); ReflectionUtility.Initialize(); WKLog.Debug("Initalizing input utility..."); InputUtility.Initialize(); ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; harmony = new Harmony("com.monksilly.WKLib"); Type[] types = typeof(WKLibPlugin).Assembly.GetTypes(); foreach (Type type in types) { if (type.GetCustomAttribute<PatchOnEntryAttribute>() != null) { harmony.PatchAll(type); } } ConfigManager.CreateEntries(((BaseUnityPlugin)this).Config); WKLog.Info("Plugin WKLib v0.3.0 is loaded!"); SceneManager.sceneLoaded -= OnSceneLoaded; SceneManager.sceneLoaded += OnSceneLoaded; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Expected O, but got Unknown //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown bool flag = false; if (((Scene)(ref scene)).name == "Main-Menu") { GameObject obj = GameObject.Find("Canvas - Main Menu/Main Menu/Version Text"); TextMeshProUGUI val = ((obj != null) ? obj.GetComponent<TextMeshProUGUI>() : null); if (val != null) { ((TMP_Text)val).text = ((TMP_Text)val).text + string.Format(" (wklib-{0}) ({1} Mods)", "0.3.0", Chainloader.PluginInfos.Count); } GameObject val2 = GameObject.Find("Canvas - Main Menu/Main Menu/Support Menu/Update Info"); if (!((Object)(object)val2 != (Object)null)) { return; } GameObject val3 = Object.Instantiate<GameObject>(val2, val2.transform.parent); val3.transform.SetSiblingIndex(0); ((Object)val3).name = "Toggle Overlay"; UI_MenuButton component = val3.GetComponent<UI_MenuButton>(); if (component != null) { Object.DestroyImmediate((Object)(object)component); } TextMeshProUGUI componentInChildren = val3.GetComponentInChildren<TextMeshProUGUI>(); if ((Object)(object)componentInChildren != (Object)null) { ((TMP_Text)componentInChildren).text = "Toggle Overlay"; } Button component2 = val3.GetComponent<Button>(); if (!((Object)(object)component2 != (Object)null)) { return; } ((UnityEventBase)component2.onClick).RemoveAllListeners(); ButtonClickedEvent onClick = component2.onClick; object obj2 = <>c.<>9__5_0; if (obj2 == null) { UnityAction val4 = delegate { MonoSingleton<RootPanel>.Instance.IsOpen = !MonoSingleton<RootPanel>.Instance.IsOpen; EventSystem.current.SetSelectedGameObject((GameObject)null); }; <>c.<>9__5_0 = val4; obj2 = (object)val4; } ((UnityEvent)onClick).AddListener((UnityAction)obj2); return; } GameObject val5 = GameObject.Find("GameManager/Canvas/Pause/Pause Menu/Pause Buttons/Pause Layout"); if (!((Object)(object)val5 != (Object)null)) { return; } Transform val6 = val5.transform.Find("Gap.01"); Transform val7 = val5.transform.Find("Settings"); if (!((Object)(object)val6 != (Object)null) || !((Object)(object)val7 != (Object)null)) { return; } GameObject val8 = Object.Instantiate<GameObject>(((Component)val6).gameObject, ((Component)val6).transform.parent); val8.transform.SetSiblingIndex(val6.parent.childCount - 1); ((Object)val8).name = "Gap.03"; GameObject val9 = Object.Instantiate<GameObject>(((Component)val7).gameObject, ((Component)val7).transform.parent); val9.transform.SetSiblingIndex(val7.parent.childCount - 1); ((Object)val9).name = "Toggle Overlay"; UI_MenuButton component3 = val9.GetComponent<UI_MenuButton>(); if (component3 != null) { Object.DestroyImmediate((Object)(object)component3); } TextMeshProUGUI componentInChildren2 = val9.GetComponentInChildren<TextMeshProUGUI>(); if ((Object)(object)componentInChildren2 != (Object)null) { ((TMP_Text)componentInChildren2).text = "TOGGLE OVERLAY"; } Button component4 = val9.GetComponent<Button>(); if (!((Object)(object)component4 != (Object)null)) { return; } ((UnityEventBase)component4.onClick).RemoveAllListeners(); ButtonClickedEvent onClick2 = component4.onClick; object obj3 = <>c.<>9__5_1; if (obj3 == null) { UnityAction val10 = delegate { MonoSingleton<RootPanel>.Instance.IsOpen = !MonoSingleton<RootPanel>.Instance.IsOpen; EventSystem.current.SetSelectedGameObject((GameObject)null); }; <>c.<>9__5_1 = val10; obj3 = (object)val10; } ((UnityEvent)onClick2).AddListener((UnityAction)obj3); } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } Object.Destroy((Object)(object)MonoSingleton<RootPanel>.Instance.ImuiPanel.Canvas); SceneManager.sceneLoaded -= OnSceneLoaded; WKLog.Info("Plugin WKLib unloaded!"); } } } namespace WKLib.Utilities { internal static class WKLog { private static ManualLogSource _log; internal static void Initialize(ManualLogSource logSource) { _log = logSource; } public static void Info(object msg) { ManualLogSource log = _log; if (log != null) { log.LogInfo((object)$"[WKLib] {msg}"); } } public static void Warn(object msg) { ManualLogSource log = _log; if (log != null) { log.LogWarning((object)$"[WKLib] {msg}"); } } public static void Error(object msg) { ManualLogSource log = _log; if (log != null) { log.LogError((object)$"[WKLib] {msg}"); } } public static void Debug(object msg) { ManualLogSource log = _log; if (log != null) { log.LogDebug((object)$"[WKLib] {msg}"); } } } } namespace WKLib.Examples.UI { [Flags] internal enum DemoEnumFlags { None = 0, Flag1 = 1, Flag2 = 2, Flag3 = 4, Flag1And3 = 5 } internal struct DemoTreeNode { public string Name; public DemoTreeNode[] Childrens; public DemoTreeNode(string name, params DemoTreeNode[] childrens) { Name = name; Childrens = childrens; } } public static class DemoWindow { private static char[] formatBuffer = new char[256]; private static bool checkboxValue; private static int selectedValue = -1; private static float bouncingBallSize = 22f; private static float bouncingBallSpeed = 1f; private static int bouncingBallTrail = 32; private static float bouncingBallTime; private static string[] values = new string[12] { "Value 1", "Value 2", "Value 3", "Value 4", "Value 5", "Value 6", "Value 7", "Value 8", "Value 9", "Value 10", "Value 11", "Value 12" }; private static string textWithHint = string.Empty; private static string singleLineText = "Single line text edit"; private static string multiLineText = "Multiline text\nedit"; private static float floatValue = 10.5f; private static int intValue = 105; private static bool isReadOnly; private static bool customDropdownOpen; private static ImDropdownPreviewType dropdownPreview; private static bool[] checkboxes = new bool[4]; private static int clicks; private static int nestedFoldouts; private static bool showPlusMinusButtons = true; private static bool useNumericSlider = false; private static DemoEnumFlags demoFlags; private static int largeTableRows = 131072; private static int largeTableColumns = 512; private static float largeTableColumnSize = 150f; private static bool largeTableScrollable = true; private static bool largeTableResizable = true; private static Vector2 vec2 = new Vector2(1f, 2f); private static Vector3 vec3 = new Vector3(1f, 2f, 3f); private static Vector4 vec4 = new Vector4(1f, 2f, 3f, 4f); private static Vector2Int vec2int = new Vector2Int(1, 2); private static Vector3Int vec3int = new Vector3Int(1, 2, 3); private static bool textEditWrap; private static bool selectMultipleValues = false; private static HashSet<string> selectedNodes = new HashSet<string>(8); private static readonly DemoTreeNode[] treeNodes = new DemoTreeNode[3] { new DemoTreeNode("Node 0", new DemoTreeNode("Node 1"), new DemoTreeNode("Node 2")), new DemoTreeNode("Node 3"), new DemoTreeNode("Node 4", new DemoTreeNode("Node 5", new DemoTreeNode("Node 6"), new DemoTreeNode("Node 7"))) }; private static HashSet<int> selectedValues = new HashSet<int>(values.Length); public static void Draw(ImGui gui, ref bool open) { //IL_0017: 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_009d: 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_00d9: 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) if (ImWindow.BeginWindow(gui, "Demo", ref open, ImSize.op_Implicit((700f, 700f)), (ImWindowFlag)16)) { ImMenuBar.BeginMenuBar(gui); DrawMenuBarItems(gui, ref open); ImMenuBar.EndMenuBar(gui); if (ImFoldout.BeginFoldout(gui, "Controls".AsSpan(), default(ImSize), false)) { ImLayoutUtility.BeginIndent(gui); DrawControlsPage(gui, ref open); ImLayoutUtility.EndIndent(gui); ImFoldout.EndFoldout(gui); } gui.BeginReadOnly(isReadOnly); if (ImFoldout.BeginFoldout(gui, "Layout".AsSpan(), default(ImSize), false)) { ImLayoutUtility.BeginIndent(gui); DrawLayoutPage(gui); ImLayoutUtility.EndIndent(gui); ImFoldout.EndFoldout(gui); } if (ImFoldout.BeginFoldout(gui, "Tables".AsSpan(), default(ImSize), false)) { ImLayoutUtility.BeginIndent(gui); DrawTablesPage(gui); ImLayoutUtility.EndIndent(gui); ImFoldout.EndFoldout(gui); } gui.EndReadOnly(); ImWindow.EndWindow(gui); } } private static void DrawControlsPage(ImGui gui, ref bool open) { //IL_0013: 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_0065: 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_00c0: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_0137: 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_014d: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fd: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0446: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_04a0: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0511: Unknown result type (might be due to invalid IL or missing references) //IL_056d: Unknown result type (might be due to invalid IL or missing references) //IL_0572: Unknown result type (might be due to invalid IL or missing references) //IL_0574: Unknown result type (might be due to invalid IL or missing references) //IL_05b1: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_0675: Unknown result type (might be due to invalid IL or missing references) //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_069d: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Unknown result type (might be due to invalid IL or missing references) //IL_06d6: Unknown result type (might be due to invalid IL or missing references) //IL_06dc: Unknown result type (might be due to invalid IL or missing references) //IL_06fe: Unknown result type (might be due to invalid IL or missing references) //IL_0704: Unknown result type (might be due to invalid IL or missing references) ImCheckbox.Checkbox(gui, ref isReadOnly, "Read Only".AsSpan(), default(ImSize)); gui.BeginReadOnly(isReadOnly); ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui); ImLayoutUtility.BeginHorizontal(gui, 0f, 0f); if (ImButton.Button(gui, Format("Clicks ".AsSpan(), clicks, "0".AsSpan()), ImSize.op_Implicit((ImSizeMode)2), (ImButtonFlag)0)) { clicks++; } if (ImButton.Button(gui, "Reset Clicks".AsSpan(), ImSize.op_Implicit((ImSizeMode)0), (ImButtonFlag)0)) { clicks = 0; } ImLayoutUtility.EndHorizontal(gui); ImCheckbox.Checkbox(gui, ref checkboxValue, "Checkbox".AsSpan(), default(ImSize)); ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui); ImLayoutUtility.BeginHorizontal(gui, 0f, 0f); ImText.Text(gui, "Dropdown preview mode: ".AsSpan(), false, (ImTextOverflow)0); ImRadio.Radio<ImDropdownPreviewType>(gui, ref dropdownPreview, true); ImLayoutUtility.EndHorizontal(gui); ReadOnlySpan<string> readOnlySpan = values; ReadOnlySpan<char> readOnlySpan2 = "Dropdown without value selected".AsSpan(); ImDropdownPreviewType val = dropdownPreview; ImDropdown.Dropdown(gui, ref selectedValue, readOnlySpan, default(ImSize), val, readOnlySpan2); ReadOnlySpan<char> readOnlySpan3 = "Custom Dropdown".AsSpan(); val = dropdownPreview; if (ImDropdown.BeginDropdown(gui, readOnlySpan3, default(ImSize), val)) { if (ImMenu.Menu(gui, "Menu Item".AsSpan())) { ImDropdown.CloseDropdown(gui); } ImTooltip.TooltipAtLastControl(gui, "Will close dropdown on click".AsSpan(), (ImTooltipShow)1); if (ImMenu.BeginMenu(gui, "Sub Menu Inside Dropdown".AsSpan())) { ImText.Text(gui, "Hello there".AsSpan(), false, (ImTextOverflow)0); ImMenu.EndMenu(gui); } ImCheckbox.Checkbox(gui, ref checkboxValue, "Checkbox".AsSpan(), default(ImSize)); ImSeparator.Separator(gui, "Nested dropdown, if that's want you really want".AsSpan()); ReadOnlySpan<string> readOnlySpan4 = values; readOnlySpan2 = "Nothing".AsSpan(); val = dropdownPreview; ImDropdown.Dropdown(gui, ref selectedValue, readOnlySpan4, default(ImSize), val, readOnlySpan2); ImDropdown.EndDropdown(gui); } ImSeparator.Separator(gui, "Text editors".AsSpan()); readOnlySpan2 = "Write something here".AsSpan(); ImTextEdit.TextEdit(gui, ref textWithHint, default(ImSize), (bool?)null, 0, (ImTouchKeyboardType)0, readOnlySpan2); bool? flag = false; ImTextEdit.TextEdit(gui, ref singleLineText, default(ImSize), flag, 0, (ImTouchKeyboardType)0, default(ReadOnlySpan<char>)); ImCheckbox.Checkbox(gui, ref textEditWrap, "Wrap Text".AsSpan(), default(ImSize)); ImStyleScope<bool> val2 = ImControlStyleExtensions.StyleScope<bool>(gui, ref gui.Style.TextEdit.TextWrap, ref textEditWrap); try { flag = true; ImTextEdit.TextEdit(gui, ref multiLineText, default(ImSize), flag, 0, (ImTouchKeyboardType)0, default(ReadOnlySpan<char>)); } finally { val2.Dispose(); } ImSeparator.Separator(gui, "Sliders (with tooltips)".AsSpan()); DrawSlidersDemo(gui); ImSeparator.Separator(gui, "Selection list (you can select multiple values)".AsSpan()); ImList.BeginList(gui, ImSize.op_Implicit((ImLayoutUtility.GetLayoutWidth(gui), ImList.GetEnclosingHeight(gui, ImLayoutUtility.GetRowsHeightWithSpacing(gui, 3))))); for (int i = 0; i < values.Length; i++) { bool flag2 = selectedValues.Contains(i); if (ImList.ListItem(gui, flag2, values[i].AsSpan())) { if (flag2) { selectedValues.Remove(i); } else { selectedValues.Add(i); } } } ImList.EndList(gui); ImSeparator.Separator(gui, "Numeric editors".AsSpan()); gui.BeginReadOnly(useNumericSlider); ImCheckbox.Checkbox(gui, ref showPlusMinusButtons, "Enable Plus/Minus buttons".AsSpan(), default(ImSize)); gui.EndReadOnly(); ImCheckbox.Checkbox(gui, ref useNumericSlider, "Enable Slider".AsSpan(), default(ImSize)); ImNumericEditFlag val3 = (ImNumericEditFlag)0; val3 = (ImNumericEditFlag)(val3 | (showPlusMinusButtons ? 1 : 0)); val3 = (ImNumericEditFlag)(val3 | (useNumericSlider ? 2 : 0)); ImNumericEditFlag val4 = val3; readOnlySpan2 = "0.0### kg".AsSpan(); ImNumericEdit.NumericEdit(gui, ref floatValue, default(ImSize), readOnlySpan2, 0.05f, float.MinValue, float.MaxValue, val4); val4 = val3; readOnlySpan2 = "0 miles".AsSpan(); ImNumericEdit.NumericEdit(gui, ref intValue, default(ImSize), readOnlySpan2, 1, int.MinValue, int.MaxValue, val4); ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui); ImSeparator.Separator(gui, "Radio buttons (enum flags)".AsSpan()); ImRadio.Radio<DemoEnumFlags>(gui, ref demoFlags, true); ImSeparator.Separator(gui, "Dropdown (enum flags)".AsSpan()); ImDropdown.Dropdown<DemoEnumFlags>(gui, ref demoFlags, default(ImSize), (ImDropdownPreviewType)0); ImSeparator.Separator(gui, "Trees".AsSpan()); DrawTreeDemo(gui); ImSeparator.Separator(gui, "Nested Foldout".AsSpan()); NestedFoldout(gui, 0, ref nestedFoldouts); ImSeparator.Separator(gui, "Floating menu".AsSpan()); ImRect val5 = ImLayoutUtility.AddLayoutRect(gui, ImLayoutUtility.GetLayoutWidth(gui), ImLayoutUtility.GetRowHeight(gui)); ImMenuBar.BeginMenuBar(gui, val5); DrawMenuBarItems(gui, ref open); ImMenuBar.EndMenuBar(gui); ImSeparator.Separator(gui, "Tabs".AsSpan()); ImLayoutUtility.AddSpacing(gui); ImTabsPane.BeginTabsPane(gui, ImLayoutUtility.AddLayoutRect(gui, ImLayoutUtility.GetLayoutWidth(gui), ImLayoutUtility.GetRowsHeightWithSpacing(gui, 2)), (ImTabsPaneFlags)0); for (int j = 0; j < 4; j++) { Span<char> span = gui.Formatter.Concat("Tab ".AsSpan(), j); if (ImTabsPane.BeginTab(gui, (ReadOnlySpan<char>)span)) { ImText.Text(gui, (ReadOnlySpan<char>)span, false, (ImTextOverflow)0); ImTabsPane.EndTab(gui); } } ImTabsPane.EndTabsPane(gui); ImSeparator.Separator(gui, "Vectors (float)".AsSpan()); ImText.Text(gui, "Two component vector".AsSpan(), false, (ImTextOverflow)0); ImVector.Vector(gui, ref vec2, default(ImSize)); ImText.Text(gui, "Three component vector".AsSpan(), false, (ImTextOverflow)0); ImVector.Vector(gui, ref vec3, default(ImSize)); ImText.Text(gui, "Four component vector".AsSpan(), false, (ImTextOverflow)0); ImVector.Vector(gui, ref vec4, default(ImSize)); ImSeparator.Separator(gui, "Vectors (int)".AsSpan()); ImText.Text(gui, "Two component vector".AsSpan(), false, (ImTextOverflow)0); ImVector.Vector(gui, ref vec2int, default(ImSize)); ImText.Text(gui, "Three component vector".AsSpan(), false, (ImTextOverflow)0); ImVector.Vector(gui, ref vec3int, default(ImSize)); gui.EndReadOnly(); } private static void DrawSelectableTreeDemo(ImGui gui) { //IL_0020: 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) ImCheckbox.Checkbox(gui, ref selectMultipleValues, "Select multiple values".AsSpan(), default(ImSize)); ImLayoutUtility.BeginHorizontal(gui, 0f, 0f); ImText.Text(gui, "Selected nodes: ".AsSpan(), false, (ImTextOverflow)0); foreach (string selectedNode in selectedNodes) { ImText.Text(gui, selectedNode.AsSpan(), false, (ImTextOverflow)0); ImLayoutUtility.AddSpacing(gui); } ImLayoutUtility.EndHorizontal(gui); for (int i = 0; i < treeNodes.Length; i++) { Node(ref treeNodes[i]); } void Node(ref DemoTreeNode node) { //IL_001a: 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_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) ImTreeNodeFlags val = (ImTreeNodeFlags)((selectMultipleValues ? 1 : 0) | ((node.Childrens.Length == 0) ? 4 : 0)); bool selected2 = selectedNodes.Contains(node.Name); ImGui obj = gui; ReadOnlySpan<char> readOnlySpan = node.Name.AsSpan(); ImTreeNodeFlags val2 = val; bool flag = ImTree.BeginTreeNode(obj, ref selected2, readOnlySpan, default(ImSize), val2); SetSelected(node.Name, selected2); if (flag) { for (int j = 0; j < node.Childrens.Length; j++) { Node(ref node.Childrens[j]); } ImTree.EndTreeNode(gui); } } static void SetSelected(string name, bool selected) { if (selected) { if (!selectMultipleValues) { selectedNodes.Clear(); } selectedNodes.Add(name); } else { selectedNodes.Remove(name); } } } private static void DrawTreeDemo(ImGui gui) { //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_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) //IL_00ad: 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_00c8: 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_0048: 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_0063: 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_0082: 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) ImTree.TreeNode(gui, "Node 0".AsSpan(), default(ImSize), (ImTreeNodeFlags)0); if (ImTree.BeginTreeNode(gui, "Node 1".AsSpan(), default(ImSize), (ImTreeNodeFlags)0)) { ImTree.TreeNode(gui, "Node 3".AsSpan(), default(ImSize), (ImTreeNodeFlags)0); if (ImTree.BeginTreeNode(gui, "Node 4".AsSpan(), default(ImSize), (ImTreeNodeFlags)0)) { ImTree.TreeNode(gui, "Node 5".AsSpan(), default(ImSize), (ImTreeNodeFlags)0); ImTree.EndTreeNode(gui); } ImTree.EndTreeNode(gui); } ImTree.TreeNode(gui, "Node 5".AsSpan(), default(ImSize), (ImTreeNodeFlags)0); if (ImTree.BeginTreeNode(gui, "Selectable nodes demo".AsSpan(), default(ImSize), (ImTreeNodeFlags)0)) { DrawSelectableTreeDemo(gui); ImTree.EndTreeNode(gui); } } private static void DrawSlidersDemo(ImGui gui) { //IL_003b: 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_0092: 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_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) DrawBouncingBall(gui); ImSlider.SliderHeader(gui, "Size".AsSpan(), bouncingBallSize, "0.00 px".AsSpan()); ImSlider.Slider(gui, ref bouncingBallSize, 1f, ImLayoutUtility.GetRowHeight(gui), default(ImSize), 0f, (ImSliderFlag)0); ImTooltip.TooltipAtLastControl(gui, "Size of the circles in pixels".AsSpan(), (ImTooltipShow)1); ImSlider.SliderHeader(gui, "Speed".AsSpan(), bouncingBallSpeed, "0.##".AsSpan()); ImSlider.Slider(gui, ref bouncingBallSpeed, -2f, 2f, default(ImSize), 0f, (ImSliderFlag)0); ImTooltip.TooltipAtLastControl(gui, "Speed of moving circles".AsSpan(), (ImTooltipShow)1); ImSlider.SliderHeader(gui, "Trail Length".AsSpan(), (float)bouncingBallTrail, default(ReadOnlySpan<char>)); ImSlider.Slider(gui, ref bouncingBallTrail, 1, 256, default(ImSize), 32, (ImSliderFlag)1); ImTooltip.TooltipAtLastControl(gui, "Number of circles drawn".AsSpan(), (ImTooltipShow)1); } private static void DrawMenuBarItems(ImGui gui, ref bool windowOpen) { if (!ImMenu.BeginMenu(gui, "Demo".AsSpan())) { return; } if (ImMenu.BeginMenu(gui, "Custom Menus".AsSpan())) { ImLayoutUtility.BeginVertical(gui, 300f, 0f); DrawSlidersDemo(gui); ImLayoutUtility.EndVertical(gui); ImMenu.EndMenu(gui); } if (ImMenu.BeginMenu(gui, "Recursive".AsSpan())) { DrawMenuBarItems(gui, ref windowOpen); ImMenu.EndMenu(gui); } ImSeparator.Separator(gui); if (ImMenu.BeginMenu(gui, "Test".AsSpan())) { if (ImMenu.BeginMenu(gui, "Same name submenu".AsSpan())) { ImMenu.Menu(gui, "Item".AsSpan()); ImMenu.EndMenu(gui); } gui.PushId("Next Menu".AsSpan()); if (ImMenu.BeginMenu(gui, "Same name submenu".AsSpan())) { ImMenu.Menu(gui, "Item".AsSpan()); ImMenu.EndMenu(gui); } gui.PopId(); ImMenu.EndMenu(gui); } ImSeparator.Separator(gui); if (ImMenu.Menu(gui, "Close".AsSpan())) { windowOpen = false; } ImMenu.EndMenu(gui); } private static void DrawLayoutPage(ImGui gui) { //IL_002a: 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_00a4: 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_00d0: Unknown result type (might be due to invalid IL or missing references) ImLayoutUtility.AddSpacing(gui); ImLayoutUtility.BeginHorizontal(gui, 0f, 0f); for (int i = 0; i < 3; i++) { ImButton.Button(gui, "Horizontal".AsSpan(), ImSize.op_Implicit((ImSizeMode)2), (ImButtonFlag)0); } ImLayoutUtility.EndHorizontal(gui); ImLayoutUtility.AddSpacing(gui); ImLayoutUtility.BeginVertical(gui, 0f, 0f); for (int j = 0; j < 3; j++) { ImButton.Button(gui, "Vertical".AsSpan(), ImSize.op_Implicit((ImSizeMode)2), (ImButtonFlag)0); } ImLayoutUtility.EndVertical(gui); ImLayoutUtility.AddSpacing(gui); ImGridState val = ImGrid.BeginGrid(gui, 5, ImLayoutUtility.GetRowHeight(gui)); for (int k = 0; k < 12; k++) { ImText.TextAutoSize(gui, Format("Grid cell ".AsSpan(), k, "0".AsSpan()), ImGrid.GridNextCell(gui, ref val), false); } ImGrid.EndGrid(gui, ref val); } private static void DrawTablesPage(ImGui gui) { //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_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_02a6: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_037f: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041a: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_0436: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) if (ImTree.BeginTreeNode(gui, "Simple".AsSpan(), default(ImSize), (ImTreeNodeFlags)0)) { _ = ref ImTable.BeginTable(gui, 4, default(ImSize), (ImTableFlag)0); for (int i = 0; i < 5; i++) { ImTable.TableNextRow(gui); for (int j = 0; j < 4; j++) { ImTable.TableNextColumn(gui); ImText.Text(gui, (ReadOnlySpan<char>)gui.Formatter.Concat("Hello At ".AsSpan(), gui.Formatter.Format((long)j, default(ReadOnlySpan<char>)), ":".AsSpan(), gui.Formatter.Format((long)i, default(ReadOnlySpan<char>))), false, (ImTextOverflow)0); } } ImTable.EndTable(gui); ImSeparator.Separator(gui, "Resizable Columns".AsSpan()); _ = ref ImTable.BeginTable(gui, 4, default(ImSize), (ImTableFlag)1); for (int k = 0; k < 5; k++) { ImTable.TableNextRow(gui); for (int l = 0; l < 4; l++) { ImTable.TableNextColumn(gui); ImText.Text(gui, (ReadOnlySpan<char>)gui.Formatter.Concat("Hello At ".AsSpan(), gui.Formatter.Format((long)l, default(ReadOnlySpan<char>)), ":".AsSpan(), gui.Formatter.Format((long)k, default(ReadOnlySpan<char>))), true, (ImTextOverflow)0); } } ImTable.EndTable(gui); ImTree.EndTreeNode(gui); } if (ImTree.BeginTreeNode(gui, "With Scroll Bars".AsSpan(), default(ImSize), (ImTreeNodeFlags)0)) { _ = ref ImTable.BeginTable(gui, 4, ImSize.op_Implicit((ImLayoutUtility.GetLayoutWidth(gui), 200f)), (ImTableFlag)0); for (int m = 0; m < 12; m++) { ImTable.TableNextRow(gui); for (int n = 0; n < 4; n++) { ImTable.TableNextColumn(gui); ImText.Text(gui, (ReadOnlySpan<char>)gui.Formatter.Concat("Hello At ".AsSpan(), gui.Formatter.Format((long)n, default(ReadOnlySpan<char>)), ":".AsSpan(), gui.Formatter.Format((long)m, default(ReadOnlySpan<char>))), true, (ImTextOverflow)0); } } ImTable.EndTable(gui); ImTree.EndTreeNode(gui); } if (!ImTree.BeginTreeNode(gui, "Large Tables".AsSpan(), default(ImSize), (ImTreeNodeFlags)0)) { return; } NumEditWithLabel(gui, ref largeTableRows, "Rows".AsSpan(), 1, 4194304); NumEditWithLabel(gui, ref largeTableColumns, "Columns".AsSpan(), 1, 4096); NumEditWithLabel(gui, ref largeTableColumnSize, "Col. Size".AsSpan(), 50f, 300f); ImCheckbox.Checkbox(gui, ref largeTableResizable, "Resizable Columns".AsSpan(), default(ImSize)); ImCheckbox.Checkbox(gui, ref largeTableScrollable, "Scrollable".AsSpan(), default(ImSize)); ImSize val = (largeTableScrollable ? new ImSize(ImLayoutUtility.GetLayoutWidth(gui), 300f) : new ImSize((ImSizeMode)0)); ImTableFlag val2 = (ImTableFlag)(largeTableResizable ? 1 : 0); ref ImTableState reference = ref ImTable.BeginTable(gui, largeTableColumns, val, val2); ImTable.TableSetRowsHeight(gui, ImLayoutUtility.GetTextLineHeight(gui) + ((ImPadding)(ref gui.Style.Table.CellPadding)).Vertical); for (int num = 0; num < largeTableColumns; num++) { ImTable.TableSetColumnWidth(gui, num, largeTableColumnSize); } ImTextSettings val3 = default(ImTextSettings); ((ImTextSettings)(ref val3))..ctor(gui.Style.Layout.TextSize, new ImAlignment(0.5f, 0.5f), false, (ImTextOverflow)1); ImTableRowsRange val4 = ImTable.TableGetVisibleRows(gui, largeTableRows); ImTableColumnsRange val5 = ImTable.TableGetVisibleColumns(gui); for (int num2 = val4.Min; num2 < val4.Max; num2++) { ImTable.TableSetRow(gui, num2, ref reference); for (int num3 = val5.Min; num3 < val5.Max; num3++) { ImTable.TableSetColumn(gui, num3, ref reference); ImText.Text(gui, (ReadOnlySpan<char>)gui.Formatter.Concat(gui.Formatter.Format((long)num3, default(ReadOnlySpan<char>)), "x".AsSpan(), gui.Formatter.Format((long)num2, default(ReadOnlySpan<char>))), ref val3); } } ImTable.EndTable(gui); ImTree.EndTreeNode(gui); } private static void NumEditWithLabel(ImGui gui, ref int value, ReadOnlySpan<char> label, int min, int max) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui); ImLayoutUtility.BeginHorizontal(gui, 0f, 0f); ImText.Text(gui, label, gui.Layout.AddRect(150f, ImLayoutUtility.GetRowHeight(gui)), false, (ImTextOverflow)0); ImNumericEdit.NumericEdit(gui, ref value, default(ImSize), default(ReadOnlySpan<char>), 1, min, max, (ImNumericEditFlag)1); ImLayoutUtility.EndHorizontal(gui); } private static void NumEditWithLabel(ImGui gui, ref float value, ReadOnlySpan<char> label, float min, float max) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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) ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui); ImLayoutUtility.BeginHorizontal(gui, 0f, 0f); ImText.Text(gui, label, gui.Layout.AddRect(150f, ImLayoutUtility.GetRowHeight(gui)), false, (ImTextOverflow)0); ImNumericEdit.NumericEdit(gui, ref value, default(ImSize), default(ReadOnlySpan<char>), 0.1f, min, max, (ImNumericEditFlag)1); ImLayoutUtility.EndHorizontal(gui); } public static void DrawBouncingBall(ImGui gui) { //IL_0015: 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_00d2: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: 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_0118: Unknown result type (might be due to invalid IL or missing references) ImRect val = ImRectUtility.WithPadding(ImLayoutUtility.AddLayoutRectWithSpacing(gui, ImLayoutUtility.GetLayoutWidth(gui), ImLayoutUtility.GetRowHeight(gui) * 1.25f), bouncingBallSize / 2f, bouncingBallSize / 2f, 0f, 0f); float num = Time.unscaledDeltaTime * bouncingBallSpeed; bouncingBallTime += num; for (int i = 0; i < bouncingBallTrail; i++) { float num2 = mod(bouncingBallTime + (float)i * 0.01f * bouncingBallSpeed, 2f); float num3 = ((num2 <= 1f) ? num2 : (1f - (num2 - 1f))); float num4 = 0.5f + Mathf.Sin((bouncingBallTime + (float)i * 0.01f * bouncingBallSpeed) * MathF.PI * 2f) * 0.25f; Vector2 pointAtNormalPosition = ((ImRect)(ref val)).GetPointAtNormalPosition(num3, num4); Color32 val2 = ImColorUtility.WithAlpha(gui.Style.Text.Color, Mathf.Pow((float)(i + 1) / (float)bouncingBallTrail, 6f)); gui.Canvas.Circle(pointAtNormalPosition, bouncingBallSize * 0.5f, val2); } static float mod(float x, float y) { return (x % y + y) % y; } } public static void NestedFoldout(ImGui gui, int current, ref int total) { //IL_0030: 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_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00a7: Unknown result type (might be due to invalid IL or missing references) ReadOnlySpan<char> readOnlySpan = ((current == 0) ? "Nested Foldout".AsSpan() : Format("Nested Foldout ".AsSpan(), current, "0".AsSpan())); if (!ImFoldout.BeginFoldout(gui, readOnlySpan, default(ImSize), false)) { return; } ImLayoutUtility.BeginIndent(gui); if (current < total) { NestedFoldout(gui, current + 1, ref total); } else if (current == total) { if (total == 8) { ImText.Text(gui, "Let's just stop here".AsSpan(), false, (ImTextOverflow)0); if (ImButton.Button(gui, "Reset".AsSpan(), default(ImSize), (ImButtonFlag)0)) { total = 0; } } else if (ImButton.Button(gui, "Add one more".AsSpan(), default(ImSize), (ImButtonFlag)0)) { total++; } } ImLayoutUtility.EndIndent(gui); ImFoldout.EndFoldout(gui); } private static ReadOnlySpan<char> Format(ReadOnlySpan<char> prefix, float value, ReadOnlySpan<char> format = default(ReadOnlySpan<char>)) { Span<char> destination = new Span<char>(formatBuffer); prefix.CopyTo(destination); int length = prefix.Length; value.TryFormat(destination.Slice(length, destination.Length - length), out var charsWritten, format); return destination.Slice(0, prefix.Length + charsWritten); } } } namespace WKLib.Core.UI { internal class OverlayState : MonoBehaviour { public static List<PopupSettings> Popups = new List<PopupSettings>(); private Dictionary<GraphicRaycaster, bool> _originalState = new Dictionary<GraphicRaycaster, bool>(); private CL_GameManager gameManager = null; private GraphicRaycaster mainGraphicRaycaster = null; private bool isOpen = false; public bool IsOpen { get { return isOpen; } set { if ((Object)(object)gameManager == (Object)null) { GameObject obj = GameObject.Find("GameManager"); gameManager = ((obj != null) ? obj.GetComponent<CL_GameManager>() : null); } bool flag = (Object)(object)gameManager != (Object)null && gameManager.loading; bool flag2 = (Object)(object)gameManager != (Object)null && gameManager.reviving; if (!flag && !flag2) { if (isOpen == value) { return; } } else { value = false; } isOpen = value; bool flag3 = (Object)(object)gameManager != (Object)null && gameManager.isPaused; bool inUse = OS_Manager.inUse; bool flag4 = (Object)(object)gameManager != (Object)null && Object.op_Implicit((Object)(object)gameManager.pauseMenu); bool flag5 = (Object)(object)gameManager != (Object)null && gameManager.canPause; if (isOpen) { _originalState.Clear(); if (flag4) { if (flag3) { return; } if (!inUse && flag5 && !flag && !flag2) { CL_GameManager obj2 = gameManager; if (obj2 != null) { obj2.Pause(); } return; } isOpen = false; PopupSettings popupSettings = new PopupSettings(); if (inUse) { popupSettings.PopupText = "Cannot open overlay in terminal."; } else if (!flag5) { popupSettings.PopupText = "Cannot open because game cannot be paused."; } else if (flag) { popupSettings.PopupText = "Cannot open overlay because the game is loading."; } else if (flag2) { popupSettings.PopupText = "Cannot open overlay because the player is reviving."; } popupSettings.TimeTillClose = Time.realtimeSinceStartup + popupSettings.PopupTime; Popups.Add(popupSettings); } else { if (!((Object)(object)mainGraphicRaycaster != (Object)null)) { return; } GraphicRaycaster[] array = Object.FindObjectsOfType<GraphicRaycaster>(); GraphicRaycaster[] array2 = array; foreach (GraphicRaycaster val in array2) { if (!((Object)(object)val == (Object)null)) { _originalState[val] = ((UIBehaviour)val).IsActive(); ((Behaviour)val).enabled = false; } } ((Behaviour)mainGraphicRaycaster).enabled = true; } return; } if (flag4) { if (flag3 && !inUse && flag5 && !flag && !flag2) { CL_GameManager obj3 = gameManager; if (obj3 != null) { obj3.UnPause(); } } return; } foreach (KeyValuePair<GraphicRaycaster, bool> item in _originalState) { if (!((Object)(object)item.Key == (Object)null)) { ((Behaviour)item.Key).enabled = true; } } } } private void OnEnable() { mainGraphicRaycaster = ((Component)this).gameObject.GetComponent<GraphicRaycaster>(); } public void Draw(ImGui gui) { foreach (PopupSettings popup in Popups) { if (Time.realtimeSinceStartup < popup.TimeTillClose) { QuickPopupWindow.Draw(gui, popup.PopupText); } } } } [DefaultExecutionOrder(-999)] internal class RootPanel : MonoSingleton<RootPanel> { public ImGui gui = null; public ImuiPanel ImuiPanel = null; public ThemeController ThemeController = null; public OverlayState OverlayState = null; private bool isDemoOpen = false; public bool IsOpen { get { return OverlayState.IsOpen; } set { OverlayState.IsOpen = value; } } public override void OnEnable() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown base.OnEnable(); SceneManager.sceneLoaded -= OnSceneChange; SceneManager.sceneLoaded += OnSceneChange; ((Object)ImuiPanel.Canvas).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)ImuiPanel.Canvas); ImuiUnityGUIBackend component = ((Component)((Component)this).transform).GetComponent<ImuiUnityGUIBackend>(); if (gui == null) { gui = new ImGui((IImuiRenderer)(object)component, (IImuiInput)(object)component); } OverlayState = ((Component)this).gameObject.GetComponent<OverlayState>(); if ((Object)(object)OverlayState == (Object)null) { OverlayState = ((Component)this).gameObject.AddComponent<OverlayState>(); } ThemeController = ((Component)this).gameObject.GetComponent<ThemeController>(); if ((Object)(object)ThemeController == (Object)null) { ThemeController = ((Component)this).gameObject.AddComponent<ThemeController>(); } ThemeController.SetTheme(gui); ModListWindow.Initialize(); void OnSceneChange(Scene scene, LoadSceneMode loadSceneMode) { if (ConfigManager.AutoCloseOverlay.Value) { IsOpen = false; } } } private void Update() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) ThemeController.DetectChanges(gui); gui.BeginFrame(); if (InputUtility.GetKeyDown(ConfigManager.OverlayKey.Value)) { IsOpen = !IsOpen; } HandleAPIInput(); OverlayState.Draw(gui); if (IsOpen) { DrawRootMenuBar(); } ChangeLogWindow.Draw(gui, IsOpen); if (ConfigManager.EnableDemoWindow.Value) { DemoWindow.Draw(gui, ref isDemoOpen); } ModListWindow.Draw(gui, IsOpen); DrawAPIWindows(); if (InputUtility.GetKeyDown((KeyCode)13)) { gui.ResetActiveControl(); } gui.EndFrame(); gui.Render(); } private void DrawRootMenuBar() { ImMenuBar.BeginMenuBar(gui); if (ImMenu.BeginMenu(gui, "General".AsSpan())) { ImMenu.Menu(gui, "Open mod list".AsSpan(), ref ModListWindow.isOpen); if (ConfigManager.EnableDemoWindow.Value) { ImMenu.Menu(gui, "Open demo menu".AsSpan(), ref isDemoOpen); } ImSeparator.Separator(gui); ImMenu.Menu(gui, "Open changelog".AsSpan(), ref ChangeLogWindow.isOpen); ImSeparator.Separator(gui); if (ImMenu.Menu(gui, "Close menu".AsSpan())) { IsOpen = false; } ImMenu.EndMenu(gui); } if (ImMenu.BeginMenu(gui, "Windows".AsSpan())) { if (ImMenu.Menu(gui, "Close all windows".AsSpan())) { ModListWindow.isOpen = false; ModListWindow.CloseConfigWindows(); CloseAPIWindows(); } ImMenu.EndMenu(gui); } ImMenuBar.EndMenuBar(gui); } private void DrawAPIWindows() { foreach (WKLibAPI internalAPI in WKLibAPI.internalAPIs) { if (internalAPI == null) { continue; } foreach (WKLibWindow window in internalAPI.Windows) { window?.Draw(gui, IsOpen); } } } private void HandleAPIInput() { foreach (WKLibAPI internalAPI in WKLibAPI.internalAPIs) { if (internalAPI == null) { continue; } foreach (WKLibWindow window in internalAPI.Windows) { window?.HandleInput(gui); } } } private void CloseAPIWindows() { foreach (WKLibAPI internalAPI in WKLibAPI.internalAPIs) { if (internalAPI == null) { continue; } foreach (WKLibWindow window in internalAPI.Windows) { if (window != null) { window.isOpen = false; } } } } } internal class ThemeController : MonoBehaviour { public ImTheme BaseTheme = SetBaseTheme(ImThemeBuiltin.Dark()); private bool changesDetected = false; public static ImTheme SetBaseTheme(ImTheme theme) { //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_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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) theme.Background = new Color(0f, 0f, 0f, 1f); theme.Foreground = new Color(1f, 1f, 1f, 1f); theme.Accent = ConfigManager.AccentColor.Value; theme.Control = new Color(0.15f, 0.15f, 0.15f, 1f); theme.Contrast = (ConfigManager.HighContrast.Value ? 1f : 0f); theme.BorderContrast = 1f; theme.TextSize = 16f; theme.BorderRadius = 1f; theme.ReadOnlyColorMultiplier = 0.25f; return theme; } public void RegisterChanges() { //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) changesDetected = true; BaseTheme.Contrast = (ConfigManager.HighContrast.Value ? 1f : 0f); BaseTheme.Accent = ConfigManager.AccentColor.Value; } public void DetectChanges(ImGui gui) { if (changesDetected) { changesDetected = false; SetTheme(gui); } } public void DrawAppearanceEditor(ImGui gui) { //IL_001b: 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_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_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_009e: 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) bool value = ConfigManager.HighContrast.Value; if (ImCheckbox.Checkbox(gui, ref value, "High contrast".AsSpan(), default(ImSize))) { ConfigManager.HighContrast.Value = value; BaseTheme.Contrast = (ConfigManager.HighContrast.Value ? 1f : 0f); SetTheme(gui); } Color value2 = ConfigManager.AccentColor.Value; if (ImColorEdit.ColorEdit(gui, ref value2, default(ImSize))) { ConfigManager.AccentColor.Value = value2; BaseTheme.Accent = ConfigManager.AccentColor.Value; SetTheme(gui); } } public static bool DrawThemeEditor(ImGui gui, ref ImTheme theme) { //IL_0035: 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_0075: 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_00b5: 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_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: 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_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_0308: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_03bc: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0470: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04d0: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_057e: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) bool flag = false; ImSeparator.Separator(gui, "Colors".AsSpan()); using (new UIUtility.LabeledScope(gui, "Foreground".AsSpan())) { flag |= ImColorEdit.ColorEdit(gui, ref theme.Foreground, default(ImSize)); } using (new UIUtility.LabeledScope(gui, "Background".AsSpan())) { flag |= ImColorEdit.ColorEdit(gui, ref theme.Background, default(ImSize)); } using (new UIUtility.LabeledScope(gui, "Accent".AsSpan())) { flag |= ImColorEdit.ColorEdit(gui, ref theme.Accent, default(ImSize)); } using (new UIUtility.LabeledScope(gui, "Control".AsSpan())) { flag |= ImColorEdit.ColorEdit(gui, ref theme.Control, default(ImSize)); } using (new UIUtility.LabeledScope(gui, "Contrast".AsSpan())) { flag |= ImNumericEdit.NumericEdit(gui, ref theme.Contrast, default(ImSize), default(ReadOnlySpan<char>), 0.1f, -1f, 1f, (ImNumericEditFlag)2); } using (new UIUtility.LabeledScope(gui, "BorderContrast".AsSpan())) { flag |= ImNumericEdit.NumericEdit(gui, ref theme.BorderContrast, default(ImSize), default(ReadOnlySpan<char>), 0.1f, -1f, 2f, (ImNumericEditFlag)2); } ImSeparator.Separator(gui, "Values".AsSpan()); using (new UIUtility.LabeledScope(gui, "TextSize".AsSpan())) { flag |= ImNumericEdit.NumericEdit(gui, ref theme.TextSize, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 4f, 128f, (ImNumericEditFlag)2); } using (new UIUtility.LabeledScope(gui, "Spacing".AsSpan())) { flag |= ImNumericEdit.NumericEdit(gui, ref theme.Spacing, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 32f, (ImNumericEditFlag)2); } using (new UIUtility.LabeledScope(gui, "InnerSpacing".AsSpan())) { flag |= ImNumericEdit.NumericEdit(gui, ref theme.InnerSpacing, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 32f, (ImNumericEditFlag)2); } using (new UIUtility.LabeledScope(gui, "Indent".AsSpan())) { flag |= ImNumericEdit.NumericEdit(gui, ref theme.Indent, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 128f, (ImNumericEditFlag)2); } using (new UIUtility.LabeledScope(gui, "ExtraRowHeight".AsSpan())) { flag |= ImNumericEdit.NumericEdit(gui, ref theme.ExtraRowHeight, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 128f, (ImNumericEditFlag)2); } using (new UIUtility.LabeledScope(gui, "ScrollBarSize".AsSpan())) { flag |= ImNumericEdit.NumericEdit(gui, ref theme.ScrollBarSize, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 2f, 128f, (ImNumericEditFlag)2); } using (new UIUtility.LabeledScope(gui, "WindowBorderRadius".AsSpan())) { flag |= ImNumericEdit.NumericEdit(gui, ref theme.WindowBorderRadius, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 32f, (ImNumericEditFlag)2); } using (new UIUtility.LabeledScope(gui, "WindowBorderThickness".AsSpan())) { flag |= ImNumericEdit.NumericEdit(gui, ref theme.WindowBorderThickness, default(ImSize), default(ReadOnlySpan<char>), 0.5f, 0f, 8f, (ImNumericEditFlag)2); } using (new UIUtility.LabeledScope(gui, "BorderRadius".AsSpan())) { flag |= ImNumericEdit.NumericEdit(gui, ref theme.BorderRadius, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 16f, (ImNumericEditFlag)2); } using (new UIUtility.LabeledScope(gui, "BorderThickness".AsSpan())) { flag |= ImNumericEdit.NumericEdit(gui, ref theme.BorderThickness, default(ImSize), default(ReadOnlySpan<char>), 0.5f, 0f, 8f, (ImNumericEditFlag)2); } using (new UIUtility.LabeledScope(gui, "ReadOnlyColorMultiplier".AsSpan())) { flag |= ImNumericEdit.NumericEdit(gui, ref theme.ReadOnlyColorMultiplier, default(ImSize), default(ReadOnlySpan<char>), 0.1f, 0f, 8f, (ImNumericEditFlag)2); } return flag; } public void SetTheme(ImGui gui) { gui.SetTheme(ref BaseTheme); } } } namespace WKLib.Core.UI.Windows { internal class ChangeLogWindow { public static bool isOpen; public static void Draw(ImGui gui, bool isRootPanelOpen) { //IL_0023: 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_005f: 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_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: 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) if (isRootPanelOpen && ImWindow.BeginWindow(gui, "WKLib changelog", ref isOpen, new ImSize(500f, 400f), (ImWindowFlag)0)) { ImSeparator.Separator(gui, "Versions".AsSpan()); if (ImTree.BeginTreeNode(gui, "Version 0.3.0".AsSpan(), default(ImSize), (ImTreeNodeFlags)0)) { ImText.Text(gui, "+ Rework Input system to work with more keys".AsSpan(), false, (ImTextOverflow)0); ImText.Text(gui, "- Remove old config system and adapted BepInEx config system".AsSpan(), false, (ImTextOverflow)0); ImText.Text(gui, "- Remove config window, now found in Mod List".AsSpan(), false, (ImTextOverflow)0); ImTree.EndTreeNode(gui); } if (ImTree.BeginTreeNode(gui, "Version 0.2.3".AsSpan(), default(ImSize), (ImTreeNodeFlags)0)) { ImText.Text(gui, "+ Change config system default saving folder location, dont use WKLib as the default".AsSpan(), false, (ImTextOverflow)0); ImText.Text(gui, "+ Fix configs not saving as jsons".AsSpan(), false, (ImTextOverflow)0); ImTree.EndTreeNode(gui); } if (ImTree.BeginTreeNode(gui, "Version 0.2.2".AsSpan(), default(ImSize), (ImTreeNodeFlags)0)) { ImText.Text(gui, "+ Fix plugin object being deleted".AsSpan(), false, (ImTextOverflow)0); ImText.Text(gui, "+ Fix error on scene loaded".AsSpan(), false, (ImTextOverflow)0); ImTree.EndTreeNode(gui); } if (ImTree.BeginTreeNode(gui, "Version 0.2.1".AsSpan(), default(ImSize), (ImTreeNodeFlags)0)) { ImText.Text(gui, "+ Change config system saving and loading".AsSpan(), false, (ImTextOverflow)0); ImTree.EndTreeNode(gui); } if (ImTree.BeginTreeNode(gui, "Version 0.2.0".AsSpan(), default(ImSize), (ImTreeNodeFlags)0)) { ImText.Text(gui, "+ Added ChangeLog window".AsSpan(), false, (ImTextOverflow)0); ImText.Text(gui, "+ Updated AssetService".AsSpan(), false, (ImTextOverflow)0); ImText.Text(gui, "+ Added Overlay button on main menu and pause menu".AsSpan(), false, (ImTextOverflow)0); ImTree.EndTreeNode(gui); } if (ImTree.BeginTreeNode(gui, "Version 0.1.0".AsSpan(), default(ImSize), (ImTreeNodeFlags)0)) { ImText.Text(gui, "+ Reworked UI and Config API".AsSpan(), false, (ImTextOverflow)0); ImTree.EndTreeNode(gui); } ImWindow.EndWindow(gui); } } } internal static class ModListWindow { public static bool isOpen = true; private static PluginContainer[] pluginContainers = Array.Empty<PluginContainer>(); private static string searchString = ""; public static void Initialize() { List<PluginContainer> pluginSettings = PluginConfigSearcher.GetPluginSettings(); foreach (PluginContainer item in pluginSettings) { item.PluginName = PrettifyName(item.PluginInfo.Metadata.Name); } pluginContainers = pluginSettings.OrderBy<PluginContainer, string>((PluginContainer x) => x.PluginName, StringComparer.OrdinalIgnoreCase).ToArray(); static string PrettifyName(string input) { input = Regex.Replace(input, "([a-z])([A-Z])", "$1 $2"); input = Regex.Replace(input, "([A-Z])([A-Z][a-z])", "$1 $2"); input = Regex.Replace(input, "\\s+", " "); input = Regex.Replace(input, "([A-Z]\\.)\\s([A-Z]\\.)", "$1$2"); return input.Trim(); } } public static void Draw(ImGui gui, bool open) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) if (!open || !ImWindow.BeginWindow(gui, "Mod list", ref isOpen, new ImSize(250f, 500f), (ImWindowFlag)0)) { return; } ImLayoutUtility.BeginVertical(gui, 0f, 0f); ImSeparator.Separator(gui, "Mods".AsSpan()); ReadOnlySpan<char> readOnlySpan = "Search for mod".AsSpan(); ImTextEdit.TextEdit(gui, ref searchString, default(ImSize), (bool?)null, 0, (ImTouchKeyboardType)0, readOnlySpan); ImLayoutUtility.AddSpacing(gui); for (int i = 0; i < pluginContainers.Length; i++) { ref PluginContainer reference = ref pluginContainers[i]; if (reference == null || reference.PluginInfo == null) { continue; } WKLibAPI aPIReference = reference.APIReference; if (aPIReference == null || (aPIReference != null && aPIReference.ModTab == null)) { string name = reference.PluginInfo.Metadata.Name; if (!Utility.IsNullOrWhiteSpace(name) && (!(searchString.Trim() != string.Empty) || name.Contains(searchString, StringComparison.OrdinalIgnoreCase))) { gui.PushId(reference.PluginInfo.Metadata.GUID.AsSpan()); if (ImButton.Button(gui, name.AsSpan(), default(ImSize), (ImButtonFlag)0)) { reference.IsWindowOpen = !reference.IsWindowOpen; } gui.PopId(); } } else if (aPIReference.ModTab != null && (!(searchString.Trim() != string.Empty) || aPIReference.ModTab.DisplayName.Contains(searchString, StringComparison.OrdinalIgnoreCase)) && ImTree.BeginTreeNode(gui, aPIReference.ModTab.DisplayName.AsSpan(), default(ImSize), (ImTreeNodeFlags)0)) { aPIReference.ModTab.DrawSubMenu(gui); ImTree.EndTreeNode(gui); } } ImLayoutUtility.EndVertical(gui); ImWindow.EndWindow(gui); DrawConfigWindows(gui); } public static void CloseConfigWindows() { for (int i = 0; i < pluginContainers.Length; i++) { ref PluginContainer reference = ref pluginContainers[i]; if (reference != null) { reference.IsWindowOpen = false; } } } private static void DrawConfigWindows(ImGui gui) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < pluginContainers.Length; i++) { ref PluginContainer reference = ref pluginContainers[i]; if (reference == null || reference.PluginInfo == null || !reference.IsWindowOpen) { continue; } string name = reference.PluginInfo.Metadata.Name; if (Utility.IsNullOrWhiteSpace(name) || !ImWindow.BeginWindow(gui, name + " " + reference.PluginInfo.Metadata.Version, ref reference.IsWindowOpen, new ImSize(500f, 500f), (ImWindowFlag)0)) { continue; } PluginContainer.ConfigEntrySection[] configSection = reference.ConfigSection; foreach (PluginContainer.ConfigEntrySection configEntrySection in configSection) { if (!Utility.IsNullOrWhiteSpace(configEntrySection.Section)) { ImLayoutUtility.AddSpacing(gui); ImSeparator.Separator(gui, configEntrySection.Section.AsSpan()); } ConfigEntryBase[] configEntries = configEntrySection.ConfigEntries; foreach (ConfigEntryBase configEntry in configEntries) { UIUtility.DrawConfigEntry(gui, configEntry); } } ImWindow.EndWindow(gui); } } public static void HandleInput(ImGui gui, bool open) { } } internal static class QuickPopupWindow { public static void Draw(ImGui gui, string text) { //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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (!(text.Trim() == string.Empty)) { Vector2 val = ImText.MeasureTextSize(gui, text.AsSpan()); ImWindow.BeginWindow(gui, "Popup", new ImSize(val.x * 1.5f, ImLayoutUtility.GetRowHeight(gui) * 5f), (ImWindowFlag)0); ImText.Text(gui, text.AsSpan(), false, (ImTextOverflow)0); ImWindow.EndWindow(gui); } } } } namespace WKLib.Core.Reflection { internal class ReflectionUtility { private static readonly SortedDictionary<string, Type> AllTypes = new SortedDictionary<string, Type>(StringComparer.OrdinalIgnoreCase); internal static void Initialize() { SetupTypeCache(); } internal static Type GetTypeByName(string fullName) { AllTypes.TryGetValue(fullName, out var value); if (value == null) { return Type.GetType(fullName); } return value; } private static void SetupTypeCache() { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly asm in assemblies) { CacheTypes(asm); } } private static void CacheTypes(Assembly asm) { Type[] array = null; try { array = asm.GetTypes(); } catch { return; } if (array != null) { Type[] array2 = array; foreach (Type type in array2) { AllTypes[type.FullName] = type; } } } } } namespace WKLib.Core.Patches { [PatchOnEntry] [HarmonyPatch] internal static class CL_GameManagerPatch { [HarmonyPatch(typeof(CL_GameManager), "UnPause")] [HarmonyPostfix] private static void CL_GameManager_UnPause(CL_GameManager __instance) { if (!((Object)(object)MonoSingleton<RootPanel>.Instance == (Object)null) && ConfigManager.AutoCloseOverlay.Value && MonoSingleton<RootPanel>.Instance.IsOpen && !__instance.isPaused) { MonoSingleton<RootPanel>.Instance.IsOpen = false; } } } [PatchOnEntry] [HarmonyPatch] internal static class InputManagerPatch { [HarmonyPatch(typeof(InputManager), "Start")] [HarmonyPostfix] private static void InputManager_Start(InputManager __instance) { if (!((Object)(object)MonoSingleton<RootPanel>.Instance != (Object)null)) { ImuiPanel val = ImuiBepInExAPI.CreateImuiPanel(); ((Component)val.Backend).gameObject.SetActive(false); RootPanel rootPanel = ((Component)val.Backend).gameObject.AddComponent<RootPanel>(); rootPanel.ImuiPanel = val; ((Component)val.Backend).gameObject.SetActive(true); } } } } namespace WKLib.Core.Config { public static class ConfigManager { public static ConfigEntry<KeyCode> OverlayKey; public static ConfigEntry<bool> AutoCloseOverlay; public static ConfigEntry<bool> EnableDemoWindow; public static ConfigEntry<bool> HighContrast; public static ConfigEntry<Color> AccentColor; public static void CreateEntries(ConfigFile Config) { //IL_0090: Unknown result type (might be due to invalid IL or missing references) OverlayKey = Config.Bind<KeyCode>("General", "Overlay Key", (KeyCode)287, "Keybind for opening and closing the overlay menu"); AutoCloseOverlay = Config.Bind<bool>("General", "Auto Close Overlay", true, "Automatically close overlay on scene change"); EnableDemoWindow = Config.Bind<bool>("General", "Enable Demo Window", false, "Enable demo window, used to showcase the WKLib UI"); HighContrast = Config.Bind<bool>("Theme", "High Contrast", false, "Apply high contrast to the UI"); AccentColor = Config.Bind<Color>("Theme", "Accent color", new Color(0.05f, 0.45f, 0.75f, 1f), "Change accent color of the UI"); HighContrast.SettingChanged += delegate { MonoSingleton<RootPanel>.Instance?.ThemeController?.RegisterChanges(); }; AccentColor.SettingChanged += delegate { MonoSingleton<RootPanel>.Instance?.ThemeController?.RegisterChanges(); }; } } internal static class PluginConfigSearcher { public static BaseUnityPlugin[] FindPlugins() { return (from x in Chainloader.PluginInfos.Values select x.Instance into plugin where (Object)(object)plugin != (Object)null select plugin).Union(Object.FindObjectsOfType(typeof(BaseUnityPlugin)).Cast<BaseUnityPlugin>()).ToArray(); } public static List<PluginContainer> GetPluginSettings() { List<PluginContainer> list = new List<PluginContainer>(); BaseUnityPlugin[] array = FindPlugins(); foreach (BaseUnityPlugin val in array) { string GUID = val.Info.Metadata.GUID; WKLibAPI wKLibAPI = WKLibAPI.internalAPIs.Find((WKLibAPI api) => string.Equals(api.GUID, GUID, StringComparison.Ordinal)); Type type = ((object)val).GetType(); if (type.GetCustomAttributes(typeof(BrowsableAttribute), inherit: false).Cast<BrowsableAttribute>().Any((BrowsableAttribute x) => !x.Browsable) && wKLibAPI == null) { continue; } PluginContainer pluginContainer = new PluginContainer { PluginName = val.Info.Metadata.Name, PluginInfo = val.Info, APIReference = wKLibAPI }; if (wKLibAPI == null || (wKLibAPI != null && wKLibAPI.ModTab == null)) { Dictionary<string, List<ConfigEntryBase>> dictionary = new Dictionary<string, List<ConfigEntryBase>>(); foreach (ConfigEntryBase item in ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)val.Config).Select((KeyValuePair<ConfigDefinition, ConfigEntryBase> configEntry) => configEntry.Value)) { ConfigDescription description = item.Description; object[] array2 = ((description != null) ? description.Tags : null); if (array2 == null || !array2.Contains("Hidden")) { string section2 = item.Definition.Section; if (!dictionary.TryGetValue(section2, out var value)) { value = (dictionary[section2] = new List<ConfigEntryBase>()); } value.Add(item); } } pluginContainer.ConfigSection = dictionary.Select((KeyValuePair<string, List<ConfigEntryBase>> section) => new PluginContainer.ConfigEntrySection { Section = section.Key, ConfigEntries = section.Value.ToArray() }).ToArray(); if (pluginContainer.ConfigSection.Length == 0) { continue; } } list.Add(pluginContainer); } return list; } } public class PluginContainer { public class ConfigEntrySection { public string Section = ""; public ConfigEntryBase[] ConfigEntries = Array.Empty<ConfigEntryBase>(); } public string PluginName = ""; public PluginInfo PluginInfo = null; public ConfigEntrySection[] ConfigSection = Array.Empty<ConfigEntrySection>(); public bool IsWindowOpen = false; public WKLibAPI APIReference = null; } } namespace WKLib.Core.Classes { public enum AudioMixerType { Music, Sfx, UI } internal class AudioManager : MonoSingleton<AudioManager> { private Queue<AudioSource> _audioSourcePool = new Queue<AudioSource>(); private List<AudioSource> _playingSources = new List<AudioSource>(); public static void CreateAudioManager() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)MonoSingleton<AudioManager>.Instance)) { MonoSingleton<AudioManager>.Instance = new GameObject("AudioManager").AddComponent<AudioManager>(); } } public AudioSource PlaySound(AudioClip clip, Vector3 position, Transform parent = null, float volume = 1f, float pitch = 1f, bool loop = false, float spatial = 1f, float reverbMix = 1f, bool bypassEffects = false, float minDistance = 0f, float? maxDistance = null, float? dopplerLevel = null, float? spread = null, AudioRolloffMode? rolloffMode = null, AnimationCurve customRolloffCurve = null, AudioMixerType mixerType = AudioMixerType.Sfx, string sourceType = "") { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)clip)) { return null; } if (_audioSourcePool.Count == 0) { CreateAudioSource(); } AudioSource val = _audioSourcePool.Dequeue(); val.clip = clip; ((Component)val).transform.position = position; if (Object.op_Implicit((Object)(object)parent)) { ((Component)val).transform.SetParent(parent, true); } val.volume = volume; val.pitch = pitch; val.loop = loop; val.spatialBlend = spatial; val.reverbZoneMix = reverbMix; val.bypassEffects = bypassEffects; val.minDistance = minDistance; if (!string.IsNullOrEmpty(sourceType) && AudioManager.sourceTypeDict.TryGetValue(sourceType, out var value)) { AudioSource audioSourcePrefab = value.audioSourcePrefab; val.dopplerLevel = dopplerLevel ?? audioSourcePrefab.dopplerLevel; val.spread = spread ?? audioSourcePrefab.spread; val.maxDistance = maxDistance ?? audioSourcePrefab.maxDistance; if (!rolloffMode.HasValue) { AnimationCurve customCurve = audioSourcePrefab.GetCustomCurve((AudioSourceCurveType)0); val.rolloffMode = (AudioRolloffMode)2; val.SetCustomCurve((AudioSourceCurveType)0, customRolloffCurve ?? customCurve); } } else { AudioSource defaultAudio = AudioManager.defaultAudio; val.dopplerLevel = dopplerLevel ?? defaultAudio.dopplerLevel; val.spread = spread ?? defaultAudio.spread; val.maxDistance = maxDistance ?? defaultAudio.maxDistance; if (!rolloffMode.HasValue) { AnimationCurve customCurve2 = defaultAudio.GetCustomCurve((AudioSourceCurveType)0); val.rolloffMode = (AudioRolloffMode)2; val.SetCustomCurve((AudioSourceCurveType)0, customRolloffCurve ?? customCurve2); } } val.rolloffMode = (AudioRolloffMode)(((??)rolloffMode) ?? val.rolloffMode); AudioSource val2 = val; if (1 == 0) { } AudioMixerGroup outputAudioMixerGroup = (AudioMixerGroup)(mixerType switch { AudioMixerType.Music => AudioManager.instance.soundtrackMixer, AudioMixerType.Sfx => AudioManager.instance.gameMixer, AudioMixerType.UI => AudioManager.instance.UIMixer, _ => val.outputAudioMixerGroup, }); if (1 == 0) { } val2.outputAudioMixerGroup = outputAudioMixerGroup; ((Component)val).gameObject.SetActive(true); _playingSources.Add(val); val.Play(); return val; } private void CreateAudioSource() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) AudioSource val = new GameObject("AudioSource").AddComponent<AudioSource>(); ((Component)val).transform.SetParent(((Component)this).transform); val.playOnAwake = false; _audioSourcePool.Enqueue(val); } private void SendBackToPool(AudioSource source) { _audioSourcePool.Enqueue(source); ((Component)source).transform.SetParent(((Component)this).transform); ((Component)source).gameObject.SetActive(false); } private void Update() { for (int num = _playingSources.Count - 1; num >= 0; num--) { AudioSource val = _playingSources[num]; if (!Object.op_Implicit((Object)(object)val)) { _playingSources.RemoveAt(num); } else if (!val.isPlaying) { _playingSources.RemoveAt(num); SendBackToPool(val); } } } } [DefaultExecutionOrder(-200)] internal abstract class MonoSingleton : MonoBehaviour { } internal abstract class MonoSingleton<T> : MonoSingleton where T : MonoSingleton<T> { private static T instance; public static T Instance { get { return instance; } set { instance = value; } } public virtual void Awake() { if (Object.op_Implicit((Object)(object)Instance) && (Object)(object)Instance != (Object)(object)this) { Object.Destroy((Object)(object)this); } else { Instance = (T)this; } } public virtual void OnEnable() { Instance = (T)this; } } } namespace WKLib.Core.Attributes { [AttributeUsage(AttributeTargets.Class, Inherited = false)] internal sealed class PatchOnEntryAttribute : Attribute { } } namespace WKLib.API { public class WKLibAPI { internal static List<WKLibAPI> internalAPIs = new List<WKLibAPI>(); public string DisplayName { get; internal set; } = string.Empty; public string GUID { get; internal set; } = string.Empty; public List<WKLibWindow> Windows { get; internal set; } = new List<WKLibWindow>(); public ModTab ModTab { get; internal set; } = null; public AssetService AssetService { get; internal set; } = null; private WKLibAPI(string displayName, string guid, string defaultConfigFileName) { DisplayName = displayName; GUID = guid; AssetService = new AssetService(this); } public static WKLibAPI Create(string displayName, string guid) { return Create_Internal(displayName, guid); } public static WKLibAPI Create(string displayName, string guid, string defaultConfigFileName) { return Create_Internal(displayName, guid, defaultConfigFileName); } private static WKLibAPI Create_Internal(string displayName, string guid, string defaultConfigFileName = "DefaultConfig") { foreach (WKLibAPI internalAPI in internalAPIs) { if (string.Equals(guid, internalAPI.GUID)) { throw new Exception(displayName + " collides with " + internalAPI.DisplayName + ", they both have the same guid, " + guid); } } WKLibAPI wKLibAPI = new WKLibAPI(displayName, guid, defaultConfigFileName); internalAPIs.Add(wKLibAPI); internalAPIs.Sort((WKLibAPI a, WKLibAPI b) => string.Compare(a.DisplayName, b.DisplayName, StringComparison.OrdinalIgnoreCase)); return wKLibAPI; } public void AddWindow(WKLibWindow window) { if (!Windows.Contains(window)) { Windows.Add(window); } } public void AddToModList(ModTab modTab) { if (ModTab != null) { throw new Exception("Mod tab already exists, cant add new one"); } ModTab = modTab; } public void Destroy() { if (internalAPIs.Contains(this)) { internalAPIs.Remove(this); } } } } namespace WKLib.API.UI { public abstract class ModTab { public abstract string DisplayName { get; } public abstract void DrawSubMenu(ImGui gui); } public class PopupSettings { public string PopupText = ""; public float PopupTime = 2.5f; public float TimeTillClose = -1f; public PopupSettings() { } public PopupSettings(string text, float seconds = 2.5f) { PopupText = text; PopupTime = seconds; TimeTillClose = Time.realtimeSinceStartup + PopupTime; } } public static class UIUtility { public struct LabeledScope : IDisposable { private ImGui gui; public LabeledScope(ImGui gui, ReadOnlySpan<char> label, float firstRectSize = 0.4f) { //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_003f: Unknown result type (might be due to invalid IL or missing references) this.gui = gui; gui.PushId(label); ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui); ImLayoutUtility.BeginHorizontal(gui, 0f, 0f); ImRect val = ImLayoutUtility.AddLayoutRect(gui, ImLayoutUtility.GetLayoutWidth(gui) * firstRectSize, ImLayoutUtility.GetRowHeight(gui)); ImText.Text(gui, label, val, false, (ImTextOverflow)1); ImLayoutUtility.BeginVertical(gui, 0f, 0f); } public void Dispose() { ImLayoutUtility.EndVertical(gui); ImLayoutUtility.EndHorizontal(gui); gui.PopId(); } } public static bool Keybind(this ImGui gui, string label, ref KeyCode keyCode) { //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_0050: 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_00c9: 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_008b: Unknown result type (might be due to invalid IL or missing references) bool result = false; uint controlId = gui.GetControlId(label.AsSpan()); gui.PushId(controlId); ImLayoutUtility.AddSpacingIfLayoutFrameNotEmpty(gui); ImLayoutUtility.BeginHorizontal(gui, 0f, 0f); ImRect val = ImLayoutUtility.AddLayoutRect(gui, ImLayoutUtility.GetLayoutWidth(gui) * 0.8f, ImLayoutUtility.GetRowHeight(gui)); ImText.Text(gui, label.AsSpan(), val, false, (ImTextOverflow)1); ImLayoutUtility.BeginVertical(gui, 0f, 0f); if (gui.GetActiveControl() == controlId) { ImButton.Button(gui, "...".AsSpan(), default(ImSize), (ImButtonFlag)0); if (SetToPressedKey(gui, ref keyCode)) { result = true; gui.ResetActiveControl(); } } else if (ImButton.Button(gui, ((object)(KeyCode)(ref keyCode)).ToString().AsSpan(), default(ImSize), (ImButtonFlag)0)) { gui.SetActiveControl(controlId, (ImControlFlag)0); } ImLayoutUtility.EndVertical(gui); ImLayoutUtility.EndHorizontal(gui); gui.PopId(); return result; static bool SetToPressedKey(ImGui gui, ref KeyCode keyCode) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Invalid comparison between Unknown and I4 //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected I4, but got Unknown KeyCode? firstActiveKey = InputUtility.GetFirstActiveKey(); if (!firstActiveKey.HasValue) { return false; } if ((int)firstActiveKey.GetValueOrDefault() == 323 || (int)firstActiveKey.GetValueOrDefault() == 324) { return true; } if ((int)firstActiveKey.GetValueOrDefault() == 27) { keyCode = (KeyCode)0; return true; } keyCode = (KeyCode)(int)firstActiveKey.Value; return true; } } public static void DrawConfigEntry(ImGui gui, ConfigEntryBase configEntry) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_00b0: 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_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_0b19: Unknown result type (might be due to invalid IL or missing references) //IL_0b29: Unknown result type (might be due to invalid IL or missing references) //IL_0b39: Unknown result type (might be due to invalid IL or missing references) //IL_0b3e: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_03a1: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_0424: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_04b4: Unknown result type (might be due to invalid IL or missing references) //IL_04ba: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05d1: Unknown result type (might be due to invalid IL or missing references) //IL_066a: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_0771: Unknown result type (might be due to invalid IL or missing references) //IL_0776: Unknown result type (might be due to invalid IL or missing references) //IL_07e2: Unknown result type (might be due to invalid IL or missing references) //IL_07e7: Unknown result type (might be due to invalid IL or missing references) //IL_0791: Unknown result type (might be due to invalid IL or missing references) //IL_0797: Unknown result type (might be due to invalid IL or missing references) //IL_070f: Unknown result type (might be due to invalid IL or missing references) //IL_0715: Unknown result type (might be due to invalid IL or missing references) //IL_0853: Unknown result type (might be due to invalid IL or missing references) //IL_0858: Unknown result type (might be due to invalid IL or missing references) //IL_0802: Unknown result type (might be due to invalid IL or missing references) //IL_0808: Unknown result type (might be due to invalid IL or missing references) //IL_07a5: Unknown result type (might be due to invalid IL or missing references) //IL_08c7: Unknown result type (might be due to invalid IL or missing references) //IL_08cc: Unknown result type (might be due to invalid IL or missing references) //IL_08d0: Unknown result type (might be due to invalid IL or missing references) //IL_08d7: Unknown result type (might be due to invalid IL or missing references) //IL_08de: Unknown result type (might be due to invalid IL or missing references) //IL_08e5: Unknown result type (might be due to invalid IL or missing references) //IL_0873: Unknown result type (might be due to invalid IL or missing references) //IL_0879: Unknown result type (might be due to invalid IL or missing references) //IL_0816: Unknown result type (might be due to invalid IL or missing references) //IL_090a: Unknown result type (might be due to invalid IL or missing references) //IL_0910: Unknown result type (might be due to invalid IL or missing references) //IL_0887: Unknown result type (might be due to invalid IL or missing references) //IL_0993: Unknown result type (might be due to invalid IL or missing references) //IL_0998: Unknown result type (might be due to invalid IL or missing references) //IL_099f: Unknown result type (might be due to invalid IL or missing references) //IL_09a5: Unknown result type (might be due to invalid IL or missing references) //IL_091e: Unknown result type (might be due to invalid IL or missing references) //IL_0925: Unknown result type (might be due to invalid IL or missing references) //IL_092c: Unknown result type (might be due to invalid IL or missing references) //IL_0933: Unknown result type (might be due to invalid IL or missing references) //IL_093a: Unknown result type (might be due to invalid IL or missing references) //IL_0a11: Unknown result type (might be due to invalid IL or missing references) //IL_0a16: Unknown result type (might be due to invalid IL or missing references) //IL_09b3: Unknown result type (might be due to invalid IL or missing references) //IL_0a28: Unknown result type (might be due to invalid IL or missing references) //IL_0a82: Unknown result type (might be due to invalid IL or missing references) //IL_0a88: Unknown result type (might be due to invalid IL or missing references) string key = configEntry.Definition.Key; string description = configEntry.Description.Description; description = InsertLineBreaks(description, 40); object boxedValue = configEntry.BoxedValue; Type settingType = configEntry.SettingType; float availableWidth = gui.Layout.GetAvailableWidth(); float rowHeight = ImLayoutUtility.GetRowHeight(gui); Vector2 nextPosition = gui.Layout.GetNextPosition(rowHeight); ImRect val = default(ImRect); ((ImRect)(ref val))..ctor(nextPosition.x, nextPosition.y, availableWidth, rowHeight); uint nextControlId = gui.GetNextControlId(); gui.RegisterGroup(nextControlId, val); if (settingType == typeof(bool)) { bool flag = (bool)boxedValue; if (ImCheckbox.Checkbox(gui, ref flag, key.AsSpan(), default(ImSize))) { configEntry.BoxedValue = flag; } } else if (settingType == typeof(byte)) { byte b = (byte)boxedValue; using (new LabeledScope(gui, key.AsSpan())) { if (ImNumericEdit.NumericEdit(gui, ref b, default(ImSize), default(ReadOnlySpan<char>), (byte)1, (byte)0, byte.MaxValue, (ImNumericEditFlag)2)) { configEntry.BoxedValue = b; } } } else if (settingType == typeof(sbyte)) { int num = (sbyte)boxedValue; using (new LabeledScope(gui, key.AsSpan())) { if (ImNumericEdit.NumericEdit(gui, ref num, default(ImSize), default(ReadOnlySpan<char>), 1, -128, 127, (ImNumericEditFlag)2)) { configEntry.BoxedValue = (sbyte)num; } } } else if (settingType == typeof(short)) { short num2 = (short)boxedValue; using (new LabeledScope(gui, key.AsSpan())) { if (ImNumericEdit.NumericEdit(gui, ref num2, default(ImSize), default(ReadOnlySpan<char>), (short)1, short.MinValue, short.MaxValue, (ImNumericEditFlag)2)) { configEntry.BoxedValue = num2; } } } else if (settingType == typeof(ushort)) { int num3 = (ushort)boxedValue; using (new LabeledScope(gui, key.AsSpan())) { if (ImNumericEdit.NumericEdit(gui, ref num3, default(ImSize), default(ReadOnlySpan<char>), 1, 0, 65535, (ImNumericEditFlag)2)) { configEntry.BoxedValue = (ushort)num3; } } } else if (settingType == typeof(int)) { int num4 = (int)boxedValue; using (new LabeledScope(gui, key.AsSpan())) { if (ImNumericEdit.NumericEdit(gui, ref num4, default(ImSize), default(ReadOnlySpan<char>), 1, int.MinValue, int.MaxValue, (ImNumericEditFlag)2)) { configEntry.BoxedValue = num4; } } } else if (settingType == typeof(uint)) { long num5 = (uint)boxedValue; using (new LabeledScope(gui, key.AsSpan())) { if (ImNumericEdit.NumericEdit(gui, ref num5, default(ImSize), default(ReadOnlySpan<char>), 1L, 0L, 4294967295L, (ImNumericEditFlag)2)) { configEntry.BoxedValue = (uint)num5; } } } else if (settingType == typeof(long)) { long num6 = (long)boxedValue; using (new LabeledScope(gui, key.AsSpan())) { if (ImNumericEdit.NumericEdit(gui, ref num6, default(ImSize), default(ReadOnlySpan<char>), 1L, long.MinValue, long.MaxValue, (ImNumericEditFlag)2)) { configEntry.BoxedValue = num6; } } } else if (settingType == typeof(ulong)) { long num7 = (long)boxedValue; using (new LabeledScope(gui, key.AsSpan())) { if (ImNumericEdit.NumericEdit(gui, ref num7, default(ImSize), default(ReadOnlySpan<char>), 1L, 0L, l