Decompiled source of ResourcefulHands v1.0.0
plugins/monksilly.ResourcefulHands.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
#define DEBUG using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; 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 DG.Tweening; using HarmonyLib; using Imui.Controls; using Imui.Core; using Imui.IO.Touch; using Imui.Rendering; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using ResourcefulHands.Assets; using ResourcefulHands.Core; using ResourcefulHands.EmbedResources; using ResourcefulHands.Systems; using ResourcefulHands.UI; using ResourcefulHands.UI.Imui; using ResourcefulHands.UI.Imui.Utility; using ResourcefulHands.Utility; using Steamworks; using UnityEngine; using UnityEngine.Networking; using UnityEngine.SceneManagement; using UnityEngine.UI; using WKLib.API; using WKLib.API.Audio; using WKLib.API.Input; using WKLib.API.UI; using WKLib.Core.Classes; [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("monksilly.ResourcefulHands")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+db6b499586df40314e04ef6acc39aa85a7289f02")] [assembly: AssemblyProduct("Resourceful Hands")] [assembly: AssemblyTitle("monksilly.ResourcefulHands")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ResourcefulHands { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("monksilly.resourcefulhands", "Resourceful Hands", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "monksilly.resourcefulhands"; public const string Name = "Resourceful Hands"; public const string Version = "1.0.0"; public const string DeprecatedRHGuid = "triggeredidiot.wkd.resourcefulhands"; public GameObject? ofHolder; public static WKLibAPI WKLibAPI = WKLibAPI.Create("Resourceful Hands", "monksilly.resourcefulhands"); internal static int TargetFps = 60; private static int _mainThreadId; public static Plugin Instance { get; private set; } = null; private Harmony? Harmony { get; set; } public static bool IsWindows => RuntimeInformation.IsOSPlatform(OSPlatform.Windows); public static bool IsMainThread => Thread.CurrentThread.ManagedThreadId == _mainThreadId; public void Awake() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown ModLogger.InitLog(((BaseUnityPlugin)this).Logger); ModLogger.Debug("Checking for old RH version...", 56, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Plugin.cs"); CheckDeprecation(); VersionChecker.Check(); RHConfig.InitConfigs(((BaseUnityPlugin)this).Config); ModLogger.Debug("Patching...", 64, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Plugin.cs"); Harmony = new Harmony("monksilly.resourcefulhands"); Harmony.PatchAll(); ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Task.Run((Func<Task?>)ResourcePacksManager.InitLoad); _mainThreadId = Thread.CurrentThread.ManagedThreadId; Instance = this; ModLogger.Debug("Initializing UI...", 75, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Plugin.cs"); WKLibAPI.AddToModList((ModTab)(object)new ModListTab()); WKLibAPI.AddWindow((WKLibWindow)(object)WindowsDeclarations.PacksWindow); WKLibAPI.AddWindow((WKLibWindow)(object)WindowsDeclarations.SettingsWindow); RHResources.InitResources(); ModLogger.Debug("Hooking loaded event...", 82, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Plugin.cs"); bool flag = false; SceneManager.sceneLoaded += SceneHandler.OnSceneLoaded; ModLogger.Info("Resourceful Hands has loaded!", 86, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Plugin.cs"); } private void CheckDeprecation() { if (Chainloader.PluginInfos.ContainsKey("triggeredidiot.wkd.resourcefulhands")) { PluginInfo val = Chainloader.PluginInfos["triggeredidiot.wkd.resourcefulhands"]; ModLogger.Warning("Detected deprecated mod [" + val.Metadata.Name + "]. Disabling it...", 94, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Plugin.cs"); BaseUnityPlugin instance = val.Instance; if (!((Object)(object)instance == (Object)null)) { ((Behaviour)instance).enabled = false; Harmony.UnpatchID("triggeredidiot.wkd.resourcefulhands"); Object.Destroy((Object)(object)((Component)instance).gameObject); } } } } internal class CoroutineDispatcher : MonoBehaviour { private static CoroutineDispatcher? _instance; private static Dictionary<string, Action> updateActions = new Dictionary<string, Action>(); public static Queue<Action> threadQueue = new Queue<Action>(); public static Coroutine? Dispatch(IEnumerator routine) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) IEnumerator routine2 = routine; if (!Plugin.IsMainThread) { RunOnMainThread(delegate { Dispatch(routine2); }); return null; } if ((Object)(object)_instance == (Object)null) { _instance = new GameObject("CoroutineDispatcher").AddComponent<CoroutineDispatcher>(); Object.DontDestroyOnLoad((Object)(object)_instance); } return ((MonoBehaviour)_instance).StartCoroutine(routine2); } public static bool StopDispatch(Coroutine routine) { Coroutine routine2 = routine; if (!Plugin.IsMainThread) { RunOnMainThread(delegate { StopDispatch(routine2); }); return false; } if ((Object)(object)_instance == (Object)null) { return false; } ((MonoBehaviour)_instance).StopCoroutine(routine2); return true; } public static async Task RunOnMainThreadAndWait(Action action, [CallerLineNumber] int lineNumber = 0, [CallerFilePath] string file = "") { string file2 = file; Action action2 = action; bool hasRan = false; lock (threadQueue) { threadQueue.Enqueue(delegate { ModLogger.Debug($"Running [{Path.GetFileName(file2)}:{lineNumber}] on the main thread...", 75, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Utility/CoroutineDispatcher.cs"); try { action2(); } catch (Exception data) { ModLogger.Error(data, 82, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Utility/CoroutineDispatcher.cs"); } hasRan = true; }); } int fps = Mathf.Clamp(Plugin.TargetFps, -1, 120); if (fps < 1) { fps = 60; } while (!hasRan) { await Task.Delay(Mathf.FloorToInt(1f / (float)fps * 1000f)); } ModLogger.Debug($"[{Path.GetFileName(file2)}:{lineNumber}] has executed!", 97, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Utility/CoroutineDispatcher.cs"); } public static void RunOnMainThread(Action action) { lock (threadQueue) { threadQueue.Enqueue(action); } } public static void RunOnMainThreadOrCurrent(Action action) { if (Plugin.IsMainThread) { action(); return; } lock (threadQueue) { threadQueue.Enqueue(action); } } public static string AddToUpdate(Action action) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_instance == (Object)null) { _instance = new GameObject("CoroutineDispatcher").AddComponent<CoroutineDispatcher>(); Object.DontDestroyOnLoad((Object)(object)_instance); } string text = Guid.NewGuid().ToString(); lock (updateActions) { updateActions.Add(text, action); } return text; } public static void RemoveFromUpdate(string guid) { lock (updateActions) { updateActions.Remove(guid); } } public void LateUpdate() { lock (updateActions) { foreach (Action value in updateActions.Values) { value(); } } lock (threadQueue) { while (threadQueue.Count > 0) { threadQueue.Dequeue()?.Invoke(); } } } } public class RHDispatcher : MonoBehaviour { private static RHDispatcher? _instance; private static readonly Queue<Action> ExecutionQueue = new Queue<Action>(); public static void Initialize() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (!Object.op_Implicit((Object)(object)_instance)) { GameObject val = new GameObject("RH_Dispatcher"); _instance = val.AddComponent<RHDispatcher>(); Object.DontDestroyOnLoad((Object)(object)val); } } public static void RunOnMainThread(Action action) { lock (ExecutionQueue) { ExecutionQueue.Enqueue(action); } } private void Update() { lock (ExecutionQueue) { while (ExecutionQueue.Count > 0) { ExecutionQueue.Dequeue()(); } } } public static Coroutine? StartStaticCoroutine(IEnumerator routine) { RHDispatcher? instance = _instance; return (instance != null) ? ((MonoBehaviour)instance).StartCoroutine(routine) : null; } } } namespace ResourcefulHands.Utility { public static class AudioUtils { [CompilerGenerated] private sealed class <LoadAudioClipFromFile>d__1 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public string path; public Action<AudioClip> callback; private UnityWebRequest <uwr>5__1; private AudioClip <clip>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadAudioClipFromFile>d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <uwr>5__1 = null; <clip>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Invalid comparison between Unknown and I4 bool result; try { switch (<>1__state) { default: result = false; break; case 0: <>1__state = -1; <uwr>5__1 = UnityWebRequestMultimedia.GetAudioClip("file://" + path, (AudioType)20); <>1__state = -3; <>2__current = <uwr>5__1.SendWebRequest(); <>1__state = 1; result = true; break; case 1: <>1__state = -3; if ((int)<uwr>5__1.result != 1) { ModLogger.Debug(<uwr>5__1.error, 38, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Utility/AudioUtils.cs"); result = false; <>m__Finally1(); break; } <clip>5__2 = DownloadHandlerAudioClip.GetContent(<uwr>5__1); ((Object)<clip>5__2).name = Path.GetFileNameWithoutExtension(path); ModLogger.Debug("Loaded Clip: " + ((Object)<clip>5__2).name, 44, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Utility/AudioUtils.cs"); callback?.Invoke(<clip>5__2); <clip>5__2 = null; <>m__Finally1(); <uwr>5__1 = null; result = false; break; } } catch { //try-fault ((IDisposable)this).Dispose(); throw; } return result; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<uwr>5__1 != null) { ((IDisposable)<uwr>5__1).Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static AudioClip CreateAudioClip(float[] samples, int sampleRate, int channels, string name = "GeneratedClip") { int num = samples.Length / channels; AudioClip val = AudioClip.Create(name, num, channels, sampleRate, true); val.SetData(samples, 0); return val; } [IteratorStateMachine(typeof(<LoadAudioClipFromFile>d__1))] public static IEnumerator LoadAudioClipFromFile(string path, Action<AudioClip> callback) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadAudioClipFromFile>d__1(0) { path = path, callback = callback }; } } public interface ICosmeticPack { Cosmetic_Info CosmeticInfo { get; set; } Texture2D Icon { get; set; } bool IsActive { get; set; } } public class CosmeticHandPack : ICosmeticPack { public Cosmetic_HandItem_Data CosmeticData { get; set; } public ExtendedHandItemData ExtendedCosmeticData { get; set; } public Cosmetic_Info CosmeticInfo { get; set; } public Texture2D Icon { get; set; } public bool IsActive { get; set; } } public class CosmeticVoicePack : ICosmeticPack { public Cosmetic_Voice_Data CosmeticData { get; set; } public Cosmetic_Info CosmeticInfo { get; set; } public Texture2D Icon { get; set; } public bool IsActive { get; set; } } public class ExtendedHandItemData : Cosmetic_HandItem_Data { public List<EmoteEntry>? emotes { get; set; } = null; } public enum SoundPlayMode { Random, Sequential } public enum EmotePlayMode { Loop, LoopGlobal, Once } public class EmoteEntry : HandEmote { public List<string> SpriteNames { get; set; } = null; public List<Sprite> Sprites { get; set; } = null; public float Framerate { get; set; } = 1f; public EmotePlayMode PlayMode { get; set; } = EmotePlayMode.Loop; public Vector3 Scale { get; set; } = Vector3.one; public float Rotation { get; set; } public string Sound { get; set; } = null; public List<string> SoundFiles { get; set; } = null; public List<AudioClip?> SoundClips { get; set; } = null; public SoundPlayMode SoundPlayMode { get; set; } = SoundPlayMode.Random; public bool SoundLoop { get; set; } = false; } public class PaletteEntry : ColorPalette { } public class SwapSpriteEntry : SwapSprite { } public class InteractSwapEntry : InteractSwap { } public class SecondaryTextureEntry : SecondaryTextures { public List<string> SecondaryTextureNames { get; set; } = null; } public static class FileUtils { public static string GetSHA256Checksum(string filePath) { using FileStream inputStream = File.OpenRead(filePath); using SHA256 sHA = SHA256.Create(); byte[] array = sHA.ComputeHash(inputStream); StringBuilder stringBuilder = new StringBuilder(); byte[] array2 = array; foreach (byte b in array2) { stringBuilder.Append(b.ToString("x2")); } return stringBuilder.ToString(); } } public static class RHExtensions { public static void WriteString(this Stream stream, string value) { foreach (char c in value) { stream.WriteByte((byte)c); } } public static void WriteInteger(this Stream stream, uint value) { stream.WriteByte((byte)(value & 0xFFu)); stream.WriteByte((byte)((value >> 8) & 0xFFu)); stream.WriteByte((byte)((value >> 16) & 0xFFu)); stream.WriteByte((byte)((value >> 24) & 0xFFu)); } public static void WriteShort(this Stream stream, ushort value) { stream.WriteByte((byte)(value & 0xFFu)); stream.WriteByte((byte)((uint)(value >> 8) & 0xFFu)); } public static RenderTexture ConvertToARGB32(this RenderTexture self) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)self.format == 0) { return self; } RenderTexture temporary = RenderTexture.GetTemporary(((Texture)self).width, ((Texture)self).height, 0, (RenderTextureFormat)0); Graphics.Blit((Texture)(object)self, temporary); return temporary; } public static string CleanString(string str) { char[] invalidFileNameChars = Path.GetInvalidFileNameChars(); char[] array = invalidFileNameChars; foreach (char c in array) { str = str.Replace(c.ToString(), ""); } StringBuilder stringBuilder = new StringBuilder(); string text = str; foreach (char c2 in text) { if (c2 <= '\u007f') { stringBuilder.Append(c2); } } return stringBuilder.ToString(); } } public static class TransformExtensions { public static Transform? FindParentWithName(this Transform current, string name) { while ((Object)(object)current != (Object)null && ((Object)current).name != name) { current = current.parent; } return current; } public static Transform? FindTopmostParent(this Transform current) { while ((Object)(object)current.parent != (Object)null) { current = current.parent; } return current; } public static T? FindAt<T>(this Transform t, string path) where T : Component { string[] array = path.Split('/'); string[] array2 = array; foreach (string text in array2) { t = t.Find(text); if ((Object)(object)t == (Object)null) { return default(T); } } return ((Component)t).GetComponentInChildren<T>(); } } } namespace ResourcefulHands.UI { public class OF_CosmeticPage : MonoBehaviour { [CompilerGenerated] private sealed class <InitializeCosmeticsRoutine>d__17 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public OF_CosmeticPage <>4__this; private Task <packTask>5__1; private GameObject <candidate>5__2; private UI_CosmeticsMenu <menu>5__3; object? IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <InitializeCosmeticsRoutine>d__17(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <packTask>5__1 = null; <candidate>5__2 = null; <menu>5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; ModLogger.Info("Waiting for Resource Packs to finish loading...", 80, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); <packTask>5__1 = ResourcePacksManager.InitialLoadTask; goto IL_006f; case 1: <>1__state = -1; goto IL_006f; case 2: <>1__state = -1; goto IL_00ce; case 3: { <>1__state = -1; break; } IL_006f: if (!<packTask>5__1.IsCompleted) { <>2__current = null; <>1__state = 1; return true; } ModLogger.Info("Packs loaded. Now waiting for Unity Cosmetics Menu to initialize...", 88, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); <candidate>5__2 = null; goto IL_00ce; IL_00ce: if ((Object)(object)<candidate>5__2 == (Object)null) { <candidate>5__2 = GameObject.Find("Canvas - Screens/Screens/Canvas - Screen - Other/Cosmetics"); <>2__current = (object)new WaitForSeconds(0.1f); <>1__state = 2; return true; } <menu>5__3 = <candidate>5__2.GetComponent<UI_CosmeticsMenu>(); break; } if ((Object)(object)<menu>5__3 == (Object)null || <menu>5__3.cosmeticPages == null) { <>2__current = null; <>1__state = 3; return true; } ModLogger.Info("Game UI ready. Injecting RH Cosmetic Page...", 104, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); <>4__this.FindCosmeticsTemplate(); <>4__this.PrepareCosmeticPage(); <>4__this.PrepareCosmetics(); <>4__this.IsReady = true; ModLogger.Info("RH Cosmetics are ready.", 111, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static OF_CosmeticPage instance; private CosmeticPage? cosmeticPage; private GameObject? cosmeticsMenuObject; private UI_CosmeticsMenu? cosmeticsMenu; private UI_Page? pageTemplate; private UI_PageHolder? pageHolder; private GameObject? RHPage; private Tab? RHTab; public List<Cosmetic_Base> RHHands = new List<Cosmetic_Base>(); public bool IsReady { get; private set; } = false; private void Awake() { } private void OnSceneLoadedDelegate(Scene scene, LoadSceneMode mode) { OnSceneLoaded(((Scene)(ref scene)).name); } private void OnSceneLoaded(string sceneName) { if (!((Object)(object)instance != (Object)(object)this)) { if (sceneName != "Main-Menu") { cosmeticPage = null; cosmeticsMenuObject = null; cosmeticsMenu = null; pageTemplate = null; RHPage = null; RHTab = null; ((MonoBehaviour)instance).StopAllCoroutines(); } else if (!Object.op_Implicit((Object)(object)RHPage)) { ((MonoBehaviour)instance).StartCoroutine(InitializeCosmeticsRoutine()); } } } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoadedDelegate; } [IteratorStateMachine(typeof(<InitializeCosmeticsRoutine>d__17))] private IEnumerator InitializeCosmeticsRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <InitializeCosmeticsRoutine>d__17(0) { <>4__this = this }; } private void FindCosmeticsTemplate() { if (Object.op_Implicit((Object)(object)cosmeticsMenuObject) && Object.op_Implicit((Object)(object)cosmeticsMenu)) { return; } ModLogger.Debug("Finding Cosmetics Template", 119, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); GameObject val = GameObject.Find("Canvas - Screens/Screens/Canvas - Screen - Other/Cosmetics"); if (!Object.op_Implicit((Object)(object)val)) { ModLogger.Error("Cosmetics template game object not found", 123, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); return; } UI_CosmeticsMenu component = val.GetComponent<UI_CosmeticsMenu>(); if (!Object.op_Implicit((Object)(object)component)) { ModLogger.Error("Cosmetics menu template not found", 129, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); return; } ModLogger.Debug("Cosmetics template found", 132, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); cosmeticsMenuObject = val; cosmeticsMenu = component; } private void PrepareCosmeticPage() { //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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown if (cosmeticPage == null) { CosmeticPage val = cosmeticsMenu?.cosmeticPages.Find((CosmeticPage p) => p.cosmeticType == "hand"); ModLogger.Error($"Cosmetic page: {val} | ", 218, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); cosmeticPage = new CosmeticPage { name = "Hands", cosmeticType = "hand", pageHolder = val?.pageHolder }; } } public void PrepareCosmetics() { //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0170: 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) //IL_0187: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Expected O, but got Unknown //IL_01b7: 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_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01df: 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_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown //IL_0431: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_049d: 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_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Expected O, but got Unknown //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0314: 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_0326: 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_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Expected O, but got Unknown if (RHHands.Count > 0) { return; } foreach (ResourcePack loadedPack in ResourcePacksManager.LoadedPacks) { bool flag = false; foreach (KeyValuePair<string, Texture2D> texture in loadedPack.Textures) { if (!texture.Key.Contains("Sprite_Library")) { continue; } flag = true; break; } if (!flag) { continue; } ModLogger.Debug("Loading " + loadedPack.name + " in Experimental Menu", 250, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); Cosmetic_HandItem val = ScriptableObject.CreateInstance<Cosmetic_HandItem>(); ((Object)val).name = loadedPack.name; val.currentEmoteIds = new List<int>(2) { 0, 0 }; val.currentPaletteId = 0; Sprite val2 = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => ((Object)s).name == "card-blank-foreground")); ModLogger.Debug($"Card template: {val2}", 257, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); Texture2D tex = TextureCompositor.CreatePackCard(loadedPack.Icon, TextureCompositor.SpriteToTexture(val2)); ((Cosmetic_Base)val).cosmeticInfo = new Cosmetic_Info { id = loadedPack.guid, cosmeticName = loadedPack.name, tag = "hand", author = loadedPack.author, description = loadedPack.desc, unlock = "", cardForeground = TextureCompositor.TextureToSprite(tex) }; val.cosmeticData = new Cosmetic_HandItem_Data { swapSprites = new List<SwapSprite>(), cosmeticName = loadedPack.name, author = loadedPack.author, description = loadedPack.desc, unlock = "", id = loadedPack.guid }; Dictionary<string, SwapSprite> dictionary = new Dictionary<string, SwapSprite>(); Dictionary<string, InteractSwap> dictionary2 = new Dictionary<string, InteractSwap>(); ModLogger.Debug("Loading swaps", 286, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); foreach (KeyValuePair<string, Texture2D> texture2 in loadedPack.Textures) { if (texture2.Value == null) { continue; } if (texture2.Key.Contains("Sprite_Library")) { int layer = int.Parse(texture2.Key.Split('_')[^1]); DynamicHandSlicer.SheetType sheetType = ((!texture2.Key.Contains("Background")) ? DynamicHandSlicer.SheetType.Foreground : DynamicHandSlicer.SheetType.Background); Dictionary<Vector2, Texture2D> slices = DynamicHandSlicer.SliceSheet(texture2.Value, 4, 4); Dictionary<string, Texture2D> namedSlicesFromSlicedSheet = DynamicHandSlicer.GetNamedSlicesFromSlicedSheet(sheetType, slices, layer); foreach (KeyValuePair<string, Texture2D> item in namedSlicesFromSlicedSheet) { string key = item.Key; Texture2D value = item.Value; ModLogger.Debug(key ?? "", 302, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); SwapSprite val3 = new SwapSprite { framerate = 1f, hand = -1, loopTimeOffset = 0f, offset = Vector2.zero }; Sprite val4 = TextureCompositor.TextureToSprite(value); ((Object)val4).name = key; val3.materialBase = ""; val3.replacementSpriteNames = new List<string>(1) { key }; val3.replacementSprites = new List<Sprite>(1) { val4 }; val3.rotation = 0f; val3.scale = 1f; val3.secondaryTextures = new List<SecondaryTextures>(); val3.spriteName = key; val3.usePalette = true; dictionary.TryAdd(val3.spriteName, val3); } } if (!texture2.Key.Contains("hand-sheet")) { continue; } Dictionary<Vector2, Texture2D> dictionary3 = DynamicHandSlicer.SliceSheet(texture2.Value, 4, 4); for (int i = 0; i < 4; i++) { dictionary3.TryGetValue(new Vector2(0f, (float)i), out var value2); Sprite replacementSprite = TextureCompositor.TextureToSprite(value2); string text = ""; switch (i) { case 0: text = "interact-hand-open"; break; case 1: text = "interact-hand-grabbed"; break; case 2: text = "interact-hand-point"; break; case 3: text = "interact-hand-item"; break; } InteractSwap val5 = new InteractSwap { replacementSprite = replacementSprite, replacementSpriteName = text, spriteName = text }; dictionary2.TryAdd(val5.spriteName, val5); } } Cosmetic_HandItem_Data cosmeticData = val.cosmeticData; if (cosmeticData.swapSprites == null) { cosmeticData.swapSprites = new List<SwapSprite>(); } cosmeticData = val.cosmeticData; if (cosmeticData.interactSwaps == null) { cosmeticData.interactSwaps = new List<InteractSwap>(); } foreach (string key2 in dictionary.Keys) { ModLogger.Debug(key2, 374, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); } foreach (string key3 in dictionary2.Keys) { ModLogger.Debug(key3, 379, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); } val.cosmeticData.swapSprites.AddRange(dictionary.Values); val.cosmeticData.interactSwaps.AddRange(dictionary2.Values); RHHands.Add((Cosmetic_Base)(object)val); SafeInitialize(val); } } private void SafeInitialize(Cosmetic_HandItem item) { if (!(typeof(Cosmetic_HandItem).GetField("swapDict", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(item) is IDictionary dictionary) || dictionary.Count == 0) { ModLogger.Debug("Initializing " + ((Object)item).name + "...", 401, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); InvokePrivateMethod(item, "Initialize"); } else { ModLogger.Warning(((Object)item).name + " was already initialized! Skipping to avoid Dictionary crash.", 406, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); } } private void ApplyCosmetics() { if (!Object.op_Implicit((Object)(object)cosmeticsMenu) || RHHands.Count == 0) { return; } InjectIntoCosmeticManager(); FieldInfo field = typeof(CosmeticPage).GetField("cosmetics", BindingFlags.Instance | BindingFlags.NonPublic); if (cosmeticPage != null && field != null) { List<Cosmetic_Base> list = new List<Cosmetic_Base>(); list.AddRange(RHHands); field.SetValue(cosmeticPage, list); } try { cosmeticsMenu.FillCosmeticPage(RHHands, "Only RH", cosmeticPage); } catch (Exception ex) { ModLogger.Error("FillCosmeticPage failed: " + ex.Message, 433, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); } } public void InjectIntoCosmeticManager() { try { Type typeFromHandle = typeof(CL_CosmeticManager); FieldInfo field = typeFromHandle.GetField("cosmeticHands", BindingFlags.Static | BindingFlags.NonPublic); FieldInfo field2 = typeFromHandle.GetField("cosmeticHandDict", BindingFlags.Static | BindingFlags.NonPublic); FieldInfo field3 = typeFromHandle.GetField("loadedCosmetics", BindingFlags.Static | BindingFlags.NonPublic); List<Cosmetic_HandItem> list = (List<Cosmetic_HandItem>)field.GetValue(null); Dictionary<string, Cosmetic_HandItem> dictionary = (Dictionary<string, Cosmetic_HandItem>)field2.GetValue(null); List<Cosmetic_Base> list2 = (List<Cosmetic_Base>)field3.GetValue(null); foreach (Cosmetic_Base rHHand in RHHands) { Cosmetic_HandItem val = (Cosmetic_HandItem)(object)((rHHand is Cosmetic_HandItem) ? rHHand : null); if (!((Object)(object)val == (Object)null) && !dictionary.ContainsKey(((Cosmetic_Base)val).cosmeticInfo.id)) { list.Add(val); dictionary.Add(((Cosmetic_Base)val).cosmeticInfo.id, val); list2.Add((Cosmetic_Base)(object)val); SettingsManager.settings.cosmeticSaveData.FillNewCosmeticInfo((Cosmetic_Base)(object)val); ModLogger.Info("Successfully injected " + ((Object)val).name + " into CL_CosmeticManager", 469, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); } } } catch (Exception ex) { ModLogger.Error("Failed to inject into CL_CosmeticManager: " + ex.Message, 475, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); } } public static void InvokePrivateMethod(object obj, string methodName, params object[] args) { MethodInfo method = obj.GetType().GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method != null) { method.Invoke(obj, args); } else { ModLogger.Error("Method '" + methodName + "' not found on " + obj.GetType().Name, 493, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/UI/OF_CosmeticPage.cs"); } } } } namespace ResourcefulHands.UI.Imui { public class ModListTab : ModTab { public override string DisplayName => "Resourceful Hands"; public override void DrawSubMenu(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_0045: 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) if (ImButton.Button(gui, "Pack menu".AsSpan(), default(ImSize), (ImButtonFlag)0)) { ((WKLibWindow)WindowsDeclarations.PacksWindow).isOpen = !((WKLibWindow)WindowsDeclarations.PacksWindow).isOpen; } if (ImButton.Button(gui, "Settings menu".AsSpan(), default(ImSize), (ImButtonFlag)0)) { ((WKLibWindow)WindowsDeclarations.SettingsWindow).isOpen = !((WKLibWindow)WindowsDeclarations.SettingsWindow).isOpen; } } } public class PacksMenu : WKLibWindow { private ImScrollFlag scrollBarFlags = (ImScrollFlag)10; private string searchBuffer = ""; public override void Draw(ImGui gui, bool isRootPanelOpen) { //IL_0026: 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_008c: 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) if (isRootPanelOpen && ImWindow.BeginWindow(gui, "RH Packs", ref base.isOpen, new ImSize(800f, 400f), (ImWindowFlag)0)) { ImSeparator.Separator(gui, "Pack selection".AsSpan()); float layoutWidth = ImLayoutUtility.GetLayoutWidth(gui); float spacing = gui.Style.Layout.Spacing; ImLayoutUtility.AddSpacing(gui, spacing); ref string reference = ref searchBuffer; ReadOnlySpan<char> readOnlySpan = "Search for a pack here.".AsSpan(); ImTextEdit.TextEdit(gui, ref reference, default(ImSize), (bool?)null, 0, (ImTouchKeyboardType)0, readOnlySpan); ImLayoutUtility.AddSpacing(gui, spacing * 2f); float layoutHeight = ImLayoutUtility.GetLayoutHeight(gui); float num = layoutWidth * 0.5f - spacing * 0.5f; float num2 = layoutHeight - ImLayoutUtility.GetRowHeight(gui) - spacing * 3f; ImLayoutUtility.BeginHorizontal(gui, num, num2); ImLayoutUtility.BeginVertical(gui, 0f, 0f); DrawInactivePacks(gui); ImLayoutUtility.EndVertical(gui); ImLayoutUtility.AddSpacing(gui, spacing); ImLayoutUtility.BeginVertical(gui, num, num2); DrawActivePacks(gui); ImLayoutUtility.EndVertical(gui); ImLayoutUtility.EndHorizontal(gui); ImLayoutUtility.AddSpacing(gui, spacing * 2f); DrawActions(gui); gui.EndWindow(scrollBarFlags); } } private void DrawActions(ImGui gui) { //IL_004d: 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) float spacing = gui.Style.Layout.Spacing; ImLayoutUtility.BeginHorizontal(gui, 0f, 0f); if (ImButton.Button(gui, "Open Packs folder".AsSpan(), ImSize.op_Implicit((ImLayoutUtility.GetLayoutWidth(gui) * 0.5f - spacing * 0.5f, ImLayoutUtility.GetRowHeight(gui))), (ImButtonFlag)0)) { Application.OpenURL("file://" + RHConfig.PacksFolder.Replace("\\", "/")); } if (ImButton.Button(gui, "Reload Packs".AsSpan(), ImSize.op_Implicit((ImSizeMode)3), (ImButtonFlag)0)) { ResourcePacksManager.ReloadPacks(); } ImLayoutUtility.EndHorizontal(gui); } private void DrawActivePacks(ImGui gui) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_01a5: 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_01b8: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0186: 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_051b: 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_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: 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_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020f: 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_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: 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_0265: 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_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) gui.PushId("ActivePacks".AsSpan()); bool flag = searchBuffer.Trim().Length > 0; float spacing = gui.Style.Layout.Spacing; float num = 100f; ImSeparator.Separator(gui, "Active packs".AsSpan()); ImList.BeginList(gui, ImSize.op_Implicit((ImLayoutUtility.GetLayoutWidth(gui), ImLayoutUtility.GetLayoutHeight(gui)))); ImGridState val = ImGrid.BeginGrid(gui, 1, num); bool flag2 = false; bool flag3 = false; int num2 = -1; for (int i = 0; i < PackManager.ActiveCosmeticPacks.Count; i++) { ICosmeticPack loadedPack = PackManager.ActiveCosmeticPacks[i]; if (loadedPack == null || (flag && !loadedPack.CosmeticInfo.cosmeticName.ToLower().Contains(searchBuffer.Trim().ToLower()) && !loadedPack.CosmeticInfo.author.ToLower().Contains(searchBuffer.Trim().ToLower()) && !loadedPack.CosmeticInfo.description.ToLower().Contains(searchBuffer.Trim().ToLower()))) { continue; } ImRect val2 = ImGrid.GridNextCell(gui, ref val); uint nextControlId = gui.GetNextControlId(); gui.RegisterGroup(nextControlId, val2); bool flag4 = gui.IsGroupHovered(nextControlId); if (flag4) { gui.Canvas.RectOutline(val2, gui.Style.Button.Normal.BorderColor, 2f, ImRectRadius.op_Implicit(2f), 0f); } float w = val2.W; ImRect val3 = DrawIcon(gui, loadedPack, val2, num, w); w -= val3.W + spacing; if (w <= 0f) { continue; } ImRect val4 = DrawTitle(gui, loadedPack, val2, val3, num, w); ImRect val5 = DrawAuthor(gui, loadedPack, val2, val3, num, w); ImRect val6 = DrawDescription(gui, loadedPack, val2, val3, num, w); w -= val4.W + spacing; if (w <= 0f || !flag4) { continue; } bool flag5 = PackManager.ActiveCosmeticPacks.Count == 1; ImRect val7 = DrawMakeInactive(gui, ref loadedPack, val2, val4, flag5, num, w); w -= val7.W + spacing; if (w <= 0f) { continue; } bool flag6 = i == 0; bool flag7 = i == ResourcePacksManager.ActivePacks.Length - 1; if (flag5) { continue; } if (flag6) { flag3 = DrawMoveDown(gui, loadedPack, val2, val7, num, w); } else if (flag7) { flag2 = DrawMoveUp(gui, loadedPack, val2, val7, num, w); } else { flag2 = DrawMoveUp(gui, loadedPack, val2, val7, num, w); flag3 = DrawMoveDown(gui, loadedPack, val2, val7, num, w); } if (!(flag3 || flag2)) { continue; } for (int j = 0; j < ResourcePacksManager.LoadedPacks.Count; j++) { if (ResourcePacksManager.LoadedPacks[j] == loadedPack) { num2 = j; break; } } } if (num2 >= 0 && num2 < ResourcePacksManager.LoadedPacks.Count) { if (flag2) { int num3 = -1; for (int k = 0; k < ResourcePacksManager.LoadedPacks.Count; k++) { ResourcePack resourcePack = ResourcePacksManager.LoadedPacks[k]; if (resourcePack.IsActive) { if (k >= num2) { break; } num3 = k; } } List<ResourcePack> loadedPacks = ResourcePacksManager.LoadedPacks; ResourcePack item = loadedPacks[num2]; loadedPacks.RemoveAt(num2); int num4 = ((num3 >= 0) ? num3 : 0); if (num4 > num2) { num4--; } loadedPacks.Insert(num4, item); } else if (flag3) { int num5 = -1; for (int l = num2 + 1; l < ResourcePacksManager.LoadedPacks.Count; l++) { ResourcePack resourcePack2 = ResourcePacksManager.LoadedPacks[l]; if (resourcePack2.IsActive) { num5 = l; break; } } List<ResourcePack> loadedPacks2 = ResourcePacksManager.LoadedPacks; ResourcePack item2 = loadedPacks2[num2]; loadedPacks2.RemoveAt(num2); int num6 = -1; num6 = ((num5 < 0) ? loadedPacks2.Count : num5); loadedPacks2.Insert(num6, item2); } ResourcePacksManager.SaveDisabledPacks(); ResourcePacksManager.SavePackOrder(); } ImGrid.EndGrid(gui, ref val); gui.EndList(scrollBarFlags); gui.PopId(); } private void DrawInactivePacks(ImGui gui) { //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_018a: 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_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_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0204: 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_020f: 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_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021b: 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_0250: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) gui.PushId("InactivePacks".AsSpan()); bool flag = searchBuffer.Trim().Length > 0; float spacing = gui.Style.Layout.Spacing; float num = 100f; ImSeparator.Separator(gui, "Inactive packs".AsSpan()); ImList.BeginList(gui, ImSize.op_Implicit((ImLayoutUtility.GetLayoutWidth(gui), ImLayoutUtility.GetLayoutHeight(gui)))); ImGridState val = ImGrid.BeginGrid(gui, 1, num); int num2 = -1; for (int i = 0; i < PackManager.CosmeticPacks.Count; i++) { ICosmeticPack loadedPack = PackManager.CosmeticPacks[i]; if (loadedPack == null || loadedPack.IsActive || (flag && !loadedPack.CosmeticInfo.cosmeticName.ToLower().Contains(searchBuffer.Trim().ToLower()) && !loadedPack.CosmeticInfo.author.ToLower().Contains(searchBuffer.Trim().ToLower()) && !loadedPack.CosmeticInfo.description.ToLower().Contains(searchBuffer.Trim().ToLower()))) { continue; } ImRect val2 = ImGrid.GridNextCell(gui, ref val); uint nextControlId = gui.GetNextControlId(); gui.RegisterGroup(nextControlId, val2); bool flag2 = gui.IsGroupHovered(nextControlId); if (flag2) { gui.Canvas.RectOutline(val2, gui.Style.Button.Normal.BorderColor, 2f, ImRectRadius.op_Implicit(2f), 0f); } float w = val2.W; ImRect val3 = DrawIcon(gui, loadedPack, val2, num, w); w -= val3.W + spacing; if (w <= 0f) { continue; } ImRect val4 = DrawTitle(gui, loadedPack, val2, val3, num, w); ImRect val5 = DrawAuthor(gui, loadedPack, val2, val3, num, w); ImRect val6 = DrawDescription(gui, loadedPack, val2, val3, num, w); w -= val4.W + spacing; if (!(w <= 0f) && flag2) { if (DrawMakeActive(gui, ref loadedPack, val2, val4, num, w, out var rect)) { loadedPack.IsActive = true; num2 = i; } w -= rect.W + spacing; if (!(w <= 0f)) { } } } if (num2 != -1) { List<ResourcePack> loadedPacks = ResourcePacksManager.LoadedPacks; ResourcePack item = loadedPacks[num2]; loadedPacks.RemoveAt(num2); loadedPacks.Insert(0, item); ResourcePacksManager.SaveDisabledPacks(); ResourcePacksManager.SavePackOrder(); } ImGrid.EndGrid(gui, ref val); gui.EndList(scrollBarFlags); gui.PopId(); } private ImRect DrawIcon(ImGui gui, ICosmeticPack loadedPack, ImRect gridRect, float cellHeight, float cellWidth) { //IL_0014: 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_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_0087: 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) float spacing = gui.Style.Layout.Spacing; ImRect val = default(ImRect); ((ImRect)(ref val))..ctor(gridRect); val.X += spacing; val.H -= spacing; val.Y += spacing / 2f; val.W = val.H; if (WindowsDeclarations.SettingsWindow.DebugUIBoxes) { gui.Canvas.RectOutline(val, new Color32(byte.MaxValue, byte.MaxValue, (byte)0, byte.MaxValue), 2f, ImRectRadius.op_Implicit(0f), 0f); } ImImage.Image(gui, (Texture)(object)loadedPack.Icon, val, true); return val; } private ImRect DrawTitle(ImGui gui, ICosmeticPack loadedPack, ImRect gridRect, ImRect previousRect, float cellHeight, float cellWidth) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) float spacing = gui.Style.Layout.Spacing; float w = cellWidth * 0.8f - spacing * 2f; float h = cellHeight * 0.25f - spacing; float num = spacing + previousRect.W + spacing; float num2 = cellHeight * 0.75f; ImRect val = default(ImRect); ((ImRect)(ref val))..ctor(gridRect); val.X += num; val.Y += num2; val.H = h; val.W = w; if (WindowsDeclarations.SettingsWindow.DebugUIBoxes) { gui.Canvas.RectOutline(val, new Color32((byte)0, (byte)125, byte.MaxValue, byte.MaxValue), 2f, ImRectRadius.op_Implicit(0f), 0f); } ImText.Text(gui, loadedPack.CosmeticInfo.cosmeticName.AsSpan(), val, false, (ImTextOverflow)0); return val; } private ImRect DrawAuthor(ImGui gui, ICosmeticPack loadedPack, ImRect gridRect, ImRect previousRect, float cellHeight, float cellWidth) { //IL_002f: 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_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00e1: Unknown result type (might be due to invalid IL or missing references) float spacing = gui.Style.Layout.Spacing; float w = cellWidth * 0.8f - spacing * 2f; float h = cellHeight * 0.25f - spacing; float num = spacing + previousRect.W + spacing; float num2 = cellHeight * 0.5f + spacing; ImRect val = default(ImRect); ((ImRect)(ref val))..ctor(gridRect); val.X += num; val.Y += num2; val.H = h; val.W = w; if (WindowsDeclarations.SettingsWindow.DebugUIBoxes) { gui.Canvas.RectOutline(val, new Color32((byte)0, byte.MaxValue, byte.MaxValue, byte.MaxValue), 2f, ImRectRadius.op_Implicit(0f), 0f); } ImText.Text(gui, loadedPack.CosmeticInfo.author.AsSpan(), val, false, (ImTextOverflow)0); return val; } private ImRect DrawDescription(ImGui gui, ICosmeticPack loadedPack, ImRect gridRect, ImRect previousRect, float cellHeight, float cellWidth) { //IL_002f: 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_00c5: 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_00d1: 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_0095: 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_00d5: Unknown result type (might be due to invalid IL or missing references) float spacing = gui.Style.Layout.Spacing; float w = cellWidth * 0.8f - spacing * 2f; float h = cellHeight * 0.5f - spacing; float num = spacing + previousRect.W + spacing; float num2 = spacing; ImRect val = default(ImRect); ((ImRect)(ref val))..ctor(gridRect); val.X += num; val.Y += num2; val.H = h; val.W = w; if (WindowsDeclarations.SettingsWindow.DebugUIBoxes) { gui.Canvas.RectOutline(val, new Color32((byte)125, (byte)0, byte.MaxValue, byte.MaxValue), 2f, ImRectRadius.op_Implicit(0f), 0f); } ImText.Text(gui, loadedPack.CosmeticInfo.description.AsSpan(), val, true, (ImTextOverflow)1); return val; } private bool DrawMakeActive(ImGui gui, ref ICosmeticPack loadedPack, ImRect gridRect, ImRect previousRect, float cellHeight, float cellWidth, out ImRect rect) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: 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) float spacing = gui.Style.Layout.Spacing; float num = Math.Abs(previousRect.X - gridRect.X); float w = cellWidth * 1f - spacing * 2f; float h = cellHeight * 1f - spacing * 2f; float num2 = num + previousRect.W + spacing; float num3 = spacing; ImRect val = default(ImRect); ((ImRect)(ref val))..ctor(gridRect); val.X += num2; val.Y += num3; val.H = h; val.W = w; rect = val; if (WindowsDeclarations.SettingsWindow.DebugUIBoxes) { gui.Canvas.RectOutline(val, new Color32((byte)0, (byte)67, (byte)245, byte.MaxValue), 2f, ImRectRadius.op_Implicit(0f), 0f); } return ImButton.Button(gui, ">".AsSpan(), val, (ImButtonFlag)0); } private ImRect DrawMakeInactive(ImGui gui, ref ICosmeticPack loadedPack, ImRect gridRect, ImRect previousRect, bool isOnlyElement, float cellHeight, float cellWidth) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0054: 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_00e6: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) float spacing = gui.Style.Layout.Spacing; float num = Math.Abs(previousRect.X - gridRect.X); float w = cellWidth * (isOnlyElement ? 1f : 0.5f) - spacing * 2f; float h = cellHeight * 1f - spacing * 2f; float num2 = num + previousRect.W + spacing; float num3 = spacing; ImRect val = default(ImRect); ((ImRect)(ref val))..ctor(gridRect); val.X += num2; val.Y += num3; val.H = h; val.W = w; if (WindowsDeclarations.SettingsWindow.DebugUIBoxes) { gui.Canvas.RectOutline(val, new Color32((byte)0, (byte)67, (byte)245, byte.MaxValue), 2f, ImRectRadius.op_Implicit(0f), 0f); } if (ImButton.Button(gui, "<".AsSpan(), val, (ImButtonFlag)0)) { loadedPack.IsActive = false; } return val; } private bool DrawMoveUp(ImGui gui, ICosmeticPack loadedPack, ImRect gridRect, ImRect previousRect, float cellHeight, float cellWidth) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_00dc: 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_00b2: 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) float spacing = gui.Style.Layout.Spacing; float num = Math.Abs(previousRect.X - gridRect.X); float w = cellWidth * 1f - spacing * 2f; float h = cellHeight * 0.5f - spacing; float num2 = num + previousRect.W + spacing; float num3 = cellHeight * 0.5f; ImRect val = default(ImRect); ((ImRect)(ref val))..ctor(gridRect); val.X += num2; val.Y += num3; val.H = h; val.W = w; if (WindowsDeclarations.SettingsWindow.DebugUIBoxes) { gui.Canvas.RectOutline(val, new Color32((byte)0, (byte)67, (byte)245, byte.MaxValue), 2f, ImRectRadius.op_Implicit(0f), 0f); } return ImButton.Button(gui, "^".AsSpan(), val, (ImButtonFlag)0); } private bool DrawMoveDown(ImGui gui, ICosmeticPack loadedPack, ImRect gridRect, ImRect previousRect, float cellHeight, float cellWidth) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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) float spacing = gui.Style.Layout.Spacing; float num = Math.Abs(previousRect.X - gridRect.X); float w = cellWidth * 1f - spacing * 2f; float h = cellHeight * 0.5f - spacing * 2f; float num2 = num + previousRect.W + spacing; float num3 = spacing; ImRect val = default(ImRect); ((ImRect)(ref val))..ctor(gridRect); val.X += num2; val.Y += num3; val.H = h; val.W = w; if (WindowsDeclarations.SettingsWindow.DebugUIBoxes) { gui.Canvas.RectOutline(val, new Color32((byte)0, (byte)67, (byte)245, byte.MaxValue), 2f, ImRectRadius.op_Implicit(0f), 0f); } return ImButton.Button(gui, "v".AsSpan(), val, (ImButtonFlag)0); } public override void HandleInput(ImGui gui) { } } public class SettingsMenu : WKLibWindow { public bool DebugUIBoxes = false; public override void Draw(ImGui gui, bool isRootPanelOpen) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) if (isRootPanelOpen && ImWindow.BeginWindow(gui, "RH Settings", ref base.isOpen, new ImSize(400f, 400f), (ImWindowFlag)0)) { ImSeparator.Separator(gui, "General".AsSpan()); UIUtility.DrawConfigEntry(gui, (ConfigEntryBase)(object)RHConfig.LazyManip); UIUtility.DrawConfigEntry(gui, (ConfigEntryBase)(object)RHConfig.UseOldSprReplace); UIUtility.DrawConfigEntry(gui, (ConfigEntryBase)(object)RHConfig.UseOutdatedPacks); ImLayoutUtility.AddSpacing(gui); ImSeparator.Separator(gui, "Emotes".AsSpan()); UIUtility.DrawConfigEntry(gui, (ConfigEntryBase)(object)RHConfig.EmoteWheelKey); UIUtility.DrawConfigEntry(gui, (ConfigEntryBase)(object)RHConfig.EmoteWheelKeyAlt); UIUtility.DrawConfigEntry(gui, (ConfigEntryBase)(object)RHConfig.ToggleWheel); UIUtility.DrawConfigEntry(gui, (ConfigEntryBase)(object)RHConfig.EmoteLeftKey); UIUtility.DrawConfigEntry(gui, (ConfigEntryBase)(object)RHConfig.EmoteLeftKeyAlt); UIUtility.DrawConfigEntry(gui, (ConfigEntryBase)(object)RHConfig.EmoteRightKey); UIUtility.DrawConfigEntry(gui, (ConfigEntryBase)(object)RHConfig.EmoteRightKeyAlt); UIUtility.DrawConfigEntry(gui, (ConfigEntryBase)(object)RHConfig.ToggleEmotes); ImLayoutUtility.AddSpacing(gui); ImSeparator.Separator(gui, "Debugging".AsSpan()); UIUtility.DrawConfigEntry(gui, (ConfigEntryBase)(object)RHConfig.ColorConsole); UIUtility.DrawConfigEntry(gui, (ConfigEntryBase)(object)RHConfig.AlwaysDebug); ImCheckbox.Checkbox(gui, ref DebugUIBoxes, "Debug UI Boxes".AsSpan(), default(ImSize)); ImWindow.EndWindow(gui); } } public override void HandleInput(ImGui gui) { } } public static class WindowsDeclarations { public static PacksMenu PacksWindow = new PacksMenu(); public static SettingsMenu SettingsWindow = new SettingsMenu(); } } namespace ResourcefulHands.UI.Imui.Utility { public static class CustomImList { public static void EndList(this ImGui gui, ImScrollFlag flags = 0) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ImScroll.EndScrollable(gui, flags); gui.Canvas.PopClipRect(); gui.Canvas.PopRectMask(); gui.Layout.Pop(); } } public static class CustomImWindow { public static void EndWindow(this ImGui gui, ImScrollFlag scrollFlags) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) ImScroll.EndScrollable(gui, scrollFlags); gui.Layout.Pop(); gui.WindowManager.EndWindow(); gui.Canvas.PopClipRect(); gui.Canvas.PopRectMask(); gui.Canvas.PopOrder(); gui.PopId(); } } } namespace ResourcefulHands.Systems { public static class RHCommands { private static readonly string[] ordinals = new string[6] { "first", "second", "third", "fourth", "fifth", "sixth" }; public const string DumpCommand = "dumptopack"; public const string ReloadCommand = "reloadpacks"; public const string MoveCommand = "reorderpack"; public const string ListCommand = "listpacks"; public const string EnableCommand = "enablepack"; public const string DisableCommand = "disablepack"; public const string EnableAllCommand = "enablepack_all"; public const string DisableAllCommand = "disablepack_all"; public const string ToggleDebug = "rhtoggledebug"; public const string DumpPackInfo = "dumppackinfo"; public const string AssignHandPack = "assignhandpack"; public const string ClearHandPack = "clearhandpack"; public const string ListHandPacks = "listhandpacks"; public static void RefreshCommands() { CommandConsole instance = CommandConsole.instance; if (!Object.op_Implicit((Object)(object)instance)) { return; } CommandConsole.RemoveCommand("dumptopack"); CommandConsole.RemoveCommand("reloadpacks"); CommandConsole.RemoveCommand("reorderpack"); CommandConsole.RemoveCommand("listpacks"); CommandConsole.RemoveCommand("enablepack"); CommandConsole.RemoveCommand("disablepack"); CommandConsole.RemoveCommand("enablepack_all"); CommandConsole.RemoveCommand("disablepack_all"); CommandConsole.RemoveCommand("rhtoggledebug"); CommandConsole.RemoveCommand("dumppackinfo"); CommandConsole.AddCommand("dumptopack", (Action<string[]>)DumpAllToPack, false); CommandConsole.AddCommand("reloadpacks", (Action<string[]>)ReloadPacks, false); CommandConsole.AddCommand("reorderpack", (Action<string[]>)MovePacks, false); CommandConsole.AddCommand("listpacks", (Action<string[]>)ListPacks, false); CommandConsole.AddCommand("enablepack", (Action<string[]>)EnablePack, false); CommandConsole.AddCommand("disablepack", (Action<string[]>)DisablePack, false); CommandConsole.AddCommand("enablepack_all", (Action<string[]>)EnableAll, false); CommandConsole.AddCommand("disablepack_all", (Action<string[]>)DisableAll, false); CommandConsole.AddCommand("rhtoggledebug", (Action<string[]>)delegate { RHDebugTools.isOn = !RHDebugTools.isOn; }, false); CommandConsole.AddCommand("dumppackinfo", (Action<string[]>)delegate(string[] args) { ResourcePack packFromArgs = GetPackFromArgs(args, ModLogger.Player.Error); if (packFromArgs == null) { ModLogger.Player.Info("The first argument must be a pack!"); } else { ModLogger.Player.Info("-- " + packFromArgs.name + " --"); ModLogger.Player.Info("- [textures] -"); ModLogger.Player.Info(packFromArgs.relativeTexturesPath ?? ""); foreach (KeyValuePair<string, Texture2D> texture in packFromArgs.Textures) { ModLogger.Player.Info($"{texture.Key}: {texture.Value}"); } ModLogger.Player.Info("- [sounds] -"); ModLogger.Player.Info(packFromArgs.relativeSoundsPath ?? ""); foreach (KeyValuePair<string, AudioClip> sound in packFromArgs.Sounds) { ModLogger.Player.Info($"{sound.Key}: {sound.Value}"); } ModLogger.Player.Info("- [misc] -"); ModLogger.Player.Info($"{packFromArgs.relativeIconPath}: {packFromArgs.Icon}"); ModLogger.Player.Info("packVer: " + packFromArgs.packVersion); ModLogger.Player.Info("gameVer: " + packFromArgs.gameVersionString); ModLogger.Player.Info($"frmtVer: {packFromArgs.formatVersion}"); } }, false); CommandConsole.AddCommand("assignhandpack", (Action<string[]>)AssignHandResourcePack, false); CommandConsole.AddCommand("clearhandpack", (Action<string[]>)ClearHandResourcePack, false); CommandConsole.AddCommand("listhandpacks", (Action<string[]>)ListHandResourcePack, false); } private static void MovePacks(string[] args) { if (args.Length != 2) { ModLogger.Player.Error("Invalid number of arguments!"); ModLogger.Player.Info("Usage: reorderpack [pack guid/pack index] [up/down]\nResource packs at the bottom of the loaded list will override textures at the top, use this command to move a resource pack up or down the list."); return; } ResourcePack pack = GetPackFromArgs(args, ModLogger.Player.Error); if (pack == null) { ModLogger.Player.Info("Usage: reorderpack [pack guid/pack index] [up/down]\nResource packs at the bottom of the loaded list will override textures at the top, use this command to move a resource pack up or down the list."); return; } string text = args[1].ToLower(); bool flag; switch (text) { case "up": case "down": case "u": case "d": flag = true; break; default: flag = false; break; } if (!flag) { ModLogger.Player.Error("Invalid second argument!\nExpected: up or down"); ModLogger.Player.Info("Usage: reorderpack [pack guid/pack index] [up/down]\nResource packs at the bottom of the loaded list will override textures at the top, use this command to move a resource pack up or down the list."); return; } flag = ((text == "up" || text == "u") ? true : false); bool isUp = flag; ResourcePacksManager.MovePack(pack, isUp); ModLogger.Player.Info("Reloading packs..."); ResourcePacksManager.ReloadPacks(waitTillReady: true, delegate { ModLogger.Player.Info(string.Format("Moved {0} {1}{2}{3} {4} successfully!", pack.name, '{', pack.guid, '}', isUp ? "up" : "down")); }); } private static void ListPacks(string[] args) { for (int i = 0; i < ResourcePacksManager.LoadedPacks.Count; i++) { ResourcePack resourcePack = ResourcePacksManager.LoadedPacks[i]; ModLogger.Player.Info(((!resourcePack.IsActive) ? "[DISABLED] " : $"[{i}] ") + resourcePack.name + " by " + resourcePack.author + "\n-- description:\n" + resourcePack.desc + "\n-- guid: '" + resourcePack.guid + "'\n____"); } } private static void ReloadPacks(string[] args) { ResourcePacksManager.ReloadPacks(waitTillReady: true, delegate { ModLogger.Player.Info("Resource packs reloaded successfully!"); }); } private static ResourcePack? GetPackFromArgs(string[] args, Action<string> logErr, int indexOverride = 0) { string text = "first"; if (indexOverride != 0) { text = ((indexOverride > 6) ? indexOverride.ToString() : ordinals[indexOverride - 1]); } ResourcePack resourcePack = null; if (int.TryParse(args[indexOverride], out var result)) { resourcePack = ((result >= 0 && result < ResourcePacksManager.LoadedPacks.Count) ? ResourcePacksManager.LoadedPacks[result] : null); if (resourcePack == null) { logErr($"Invalid {text} argument!\nThe resource pack at index {result} doesn't exist!"); return null; } } else { string packName = args[indexOverride].ToLower(); resourcePack = ResourcePacksManager.LoadedPacks.FirstOrDefault((ResourcePack p) => p.guid.ToLower() == packName); if (resourcePack == null) { logErr("Invalid " + text + " argument!\nThe resource pack with guid '" + packName + "' doesn't exist!"); return null; } } return resourcePack; } private static void DisablePack(string[] args) { ResourcePack pack = GetPackFromArgs(args, ModLogger.Player.Error); if (pack == null) { ModLogger.Player.Info("Usage: disablepack [pack guid/pack index]\nDisables a resource pack."); return; } pack.IsActive = false; ModLogger.Player.Info("Reloading packs..."); ResourcePacksManager.ReloadPacks(waitTillReady: true, delegate { ModLogger.Player.Info($"Disabled {pack.name} {'{'}{pack.guid}{'}'} successfully!"); }); } private static void EnablePack(string[] args) { ResourcePack pack = GetPackFromArgs(args, ModLogger.Player.Error); if (pack == null) { ModLogger.Player.Info("Usage: enablepack [pack guid/pack index]\nEnables a resource pack."); return; } pack.IsActive = true; ModLogger.Player.Info("Reloading packs..."); ResourcePacksManager.ReloadPacks(waitTillReady: true, delegate { ModLogger.Player.Info($"Enabled {pack.name} {'{'}{pack.guid}{'}'} successfully!"); }); ModLogger.Player.Info($"Enabled {pack.name} {'{'}{pack.guid}{'}'} successfully!"); } private static void DisableAll(string[] args) { ResourcePacksManager.LoadedPacks.ForEach(delegate(ResourcePack p) { p.IsActive = false; }); ModLogger.Player.Info("Reloading packs..."); ResourcePacksManager.ReloadPacks(waitTillReady: true, delegate { ModLogger.Player.Info("Disabled all packs successfully!"); }); } private static void EnableAll(string[] args) { ResourcePacksManager.LoadedPacks.ForEach(delegate(ResourcePack p) { p.IsActive = true; }); ModLogger.Player.Info("Reloading packs..."); ResourcePacksManager.ReloadPacks(waitTillReady: true, delegate { ModLogger.Player.Info("Enabled all packs successfully!"); }); } private static void DumpAllToPack(string[] args) { if (args.Any((string arg) => arg.ToLower() == "help")) { ModLogger.Player.Info("Use this command to generate a resource pack that contains every in-game asset. Good to find assets to replace but beware that there will probably be unused assets!"); return; } if (!args.Any((string arg) => arg.ToLower() == "confirm")) { ModLogger.Player.Error("Warning: This takes up alot of storage space due to uncompressed audio!\nTHIS WILL ALSO END YOUR RUN AND LOAD YOU BACK TO THE MAIN MENU!!\nARE YOU SURE? (type 'dumptopack confirm')"); return; } ModLogger.Player.Info("Dumping all resources to a template resource pack [this will take some time]..."); List<Texture2D> textures = new List<Texture2D>(); List<Texture2D> spriteTextures = new List<Texture2D>(); List<AudioClip> sounds = new List<AudioClip>(); Texture2D[] source = Resources.FindObjectsOfTypeAll<Texture2D>(); textures.AddRange(source.Where((Texture2D tex) => !textures.Contains(tex))); AudioClip[] source2 = Resources.FindObjectsOfTypeAll<AudioClip>(); sounds.AddRange(source2.Where((AudioClip sound) => !sounds.Contains(sound))); Sprite[] source3 = Resources.FindObjectsOfTypeAll<Sprite>(); spriteTextures.AddRange(from sprite in source3 where Object.op_Implicit((Object)(object)sprite.texture) && !spriteTextures.Contains(sprite.texture) select sprite.texture); ModLogger.Player.Info("Loading Playground [to extract assets]"); SceneManager.LoadScene("Playground"); source = Resources.FindObjectsOfTypeAll<Texture2D>(); textures.AddRange(source.Where((Texture2D tex) => !textures.Contains(tex))); source2 = Resources.FindObjectsOfTypeAll<AudioClip>(); sounds.AddRange(source2.Where((AudioClip sound) => !sounds.Contains(sound))); source3 = Resources.FindObjectsOfTypeAll<Sprite>(); spriteTextures.AddRange(from sprite in source3 where Object.op_Implicit((Object)(object)sprite.texture) && !spriteTextures.Contains(sprite.texture) select sprite.texture); ModLogger.Player.Info("Loading Training-Level [to extract assets]"); SceneManager.LoadScene("Training-Level"); source = Resources.FindObjectsOfTypeAll<Texture2D>(); textures.AddRange(source.Where((Texture2D tex) => !textures.Contains(tex))); source2 = Resources.FindObjectsOfTypeAll<AudioClip>(); sounds.AddRange(source2.Where((AudioClip sound) => !sounds.Contains(sound))); source3 = Resources.FindObjectsOfTypeAll<Sprite>(); spriteTextures.AddRange(from sprite in source3 where Object.op_Implicit((Object)(object)sprite.texture) && !spriteTextures.Contains(sprite.texture) select sprite.texture); ModLogger.Player.Info("Loading Main-Menu [to extract assets and finish]"); SceneManager.LoadScene("Main-Menu"); source = Resources.FindObjectsOfTypeAll<Texture2D>(); textures.AddRange(source.Where((Texture2D tex) => !textures.Contains(tex))); source2 = Resources.FindObjectsOfTypeAll<AudioClip>(); sounds.AddRange(source2.Where((AudioClip sound) => !sounds.Contains(sound))); source3 = Resources.FindObjectsOfTypeAll<Sprite>(); spriteTextures.AddRange(from sprite in source3 where Object.op_Implicit((Object)(object)sprite.texture) && !spriteTextures.Contains(sprite.texture) select sprite.texture); ModLogger.Player.Info("Packing assets..."); int count = textures.Count; int count2 = spriteTextures.Count; int count3 = sounds.Count; string text = Path.Combine(RHConfig.PacksFolder, $"extracted-assets-{count + count3 + count2}-{DateTimeOffset.UtcNow.ToUnixTimeSeconds()}"); if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } string texturesPath = Path.Combine(text, "Textures"); string path = Path.Combine(texturesPath, "Sprites"); string text2 = Path.Combine(text, "Sounds"); if (!Directory.Exists(texturesPath)) { Directory.CreateDirectory(texturesPath); } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (!Directory.Exists(text2)) { Directory.CreateDirectory(text2); } StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); StringBuilder stringBuilder3 = new StringBuilder(); stringBuilder.AppendLine("-- ingame textures list --"); stringBuilder2.AppendLine("-- ingame sprite textures list --"); stringBuilder3.AppendLine("-- ingame sounds list --"); int num = 0; int num2 = 0; int num3 = 0; for (int i = 0; i < count; i++) { Texture2D val = textures[i]; ModLogger.Player.Info($"Saving textures ({i}/{count})"); stringBuilder.Append(((Object)val).name); bool flag = false; try { flag = ExportTexture(val); } catch (Exception ex) { ModLogger.Player.Error(((Object)val).name + " failed because " + ex.Message); } if (flag) { num++; } stringBuilder.AppendLine(flag ? "" : " [failed to extract]"); } for (int j = 0; j < count2; j++) { Texture2D val2 = spriteTextures[j]; ModLogger.Player.Info($"Saving textures ({j}/{count2})"); stringBuilder2.Append(((Object)val2).name); bool flag2 = false; try { flag2 = ExportTexture(val2); } catch (Exception ex2) { ModLogger.Player.Error(((Object)val2).name + " failed because " + ex2.Message); } if (flag2) { num3++; } stringBuilder2.AppendLine(flag2 ? "" : " [failed to extract]"); } for (int k = 0; k < count3; k++) { AudioClip val3 = sounds[k]; ModLogger.Player.Info($"Saving sounds ({k}/{count3})"); stringBuilder3.Append(((Object)val3).name); bool flag3 = false; try { string path2 = Path.Combine(text2, ((Object)val3).name + ".wav"); float[] array = new float[val3.samples * val3.channels]; if (!val3.GetData(array, 0)) { ModLogger.Player.Error("Failed to access " + ((Object)val3).name + "'s audio data!"); stringBuilder3.AppendLine(" [failed to extract]"); continue; } using (FileStream stream = new FileStream(path2, FileMode.CreateNew, FileAccess.Write)) { ushort num4 = 16; string value = "RIFF"; string value2 = "WAVE"; string value3 = "fmt "; uint value4 = 16u; ushort value5 = 1; ushort num5 = (ushort)val3.channels; uint frequency = (uint)val3.frequency; uint value6 = (uint)(frequency * val3.channels * num4 / 8); ushort value7 = (ushort)(num5 * num4 / 8); string value8 = "data"; uint num6 = (uint)(array.Length * val3.channels * num4 / 8); uint value9 = 36 + num6; stream.WriteString(value); stream.WriteInteger(value9); stream.WriteString(value2); stream.WriteString(value3); stream.WriteInteger(value4); stream.WriteShort(value5); stream.WriteShort(num5); stream.WriteInteger(frequency); stream.WriteInteger(value6); stream.WriteShort(value7); stream.WriteShort(num4); stream.WriteString(value8); stream.WriteInteger(num6); float[] array2 = array; foreach (float num7 in array2) { short num8 = 0; if (num7 > 0f) { float num9 = num7 * 32767f; if (num9 > 32767f) { num9 = 32767f; } num8 = (short)num9; } if (num7 < 0f) { float num10 = num7 * 32768f; if (num10 < -32768f) { num10 = -32768f; } num8 = (short)num10; } stream.WriteShort((ushort)num8); } num2++; flag3 = true; } goto IL_088c; } catch (Exception ex3) { ModLogger.Player.Info(((Object)val3).name + " failed because " + ex3.Message); goto IL_088c; } IL_088c: stringBuilder3.AppendLine(flag3 ? "" : " [failed to extract]"); } ModLogger.Player.Info("Writing data files"); File.WriteAllText(Path.Combine(text, "info.json"), "{\n \"name\":\"generated-game-assets\",\n \"desc\":\"Every game asset\",\n \"author\":\"Dark Machine Games\",\n \n \"pack-version\":\"0.50\",\n \"steamid\":0,\n \n \"guid\":\"generated.game.assets.unique\",\n \"hidden-from-list\":true,\n \"only-in-full-game\":false,\n \n \"game-string\":\"b0.50p\",\n \n \"textures-folder\":\"Textures\",\n \"sounds-folder\":\"Sounds\",\n \"icon-file\":\"pack.png\",\n \"icon-filter\":false,\n \n \"format-version\":3\n}"); File.WriteAllText(Path.Combine(text, "textures_list.txt"), stringBuilder.ToString()); File.WriteAllText(Path.Combine(text, "sprite_textures_list.txt"), stringBuilder2.ToString()); File.WriteAllText(Path.Combine(text, "audio_list.txt"), stringBuilder3.ToString()); ModLogger.Player.Info($"Successfully saved {num} of {count} textures!"); ModLogger.Player.Info($"Successfully saved {num3} of {count2} sprite textures!"); ModLogger.Player.Info($"Successfully saved {num2} of {count3} sounds!"); ModLogger.Player.Info("Packed all assets to '" + text + "'"); bool ExportTexture(Texture2D texture) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0072: 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_007f: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) bool result = false; try { if (!((Texture)texture).isReadable) { ModLogger.Player.Info(((Object)texture).name + " isn't readable, saving the slow way..."); RenderTexture val4 = new RenderTexture(((Texture)texture).width, ((Texture)texture).height, 24); RenderTexture active = RenderTexture.active; try { RenderTexture.active = val4; Graphics.Blit((Texture)(object)texture, val4); RenderTexture val6 = (RenderTexture.active = val4.ConvertToARGB32()); Texture2D val7 = new Texture2D(((Texture)texture).width, ((Texture)texture).height, texture.format, false); val7.ReadPixels(new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), 0, 0); val7.Apply(); val6.Release(); byte[] bytes = ImageConversion.EncodeToPNG(val7); File.WriteAllBytes(Path.Combine(texturesPath, ((Object)texture).name + ".png"), bytes); result = true; } catch { } RenderTexture.active = active; val4.Release(); } else { byte[] bytes2 = ImageConversion.EncodeToPNG(texture); File.WriteAllBytes(Path.Combine(texturesPath, ((Object)texture).name + ".png"), bytes2); result = true; } } catch (Exception ex4) { ModLogger.Player.Error(((Object)texture).name + " failed because " + ex4.Message); } return result; } } private static void AssignHandResourcePack(string[] args) { if (args.Length != 2) { ModLogger.Player.Error("Invalid number of arguments!"); ModLogger.Player.Info("Usage: assignhandpack [hand] [pack guid/pack index]\nHand: left or right (case insensitive)\nUse 'listpacks' to see available pack GUIDs"); return; } int handIdFromString = GetHandIdFromString(args[0]); if (handIdFromString < 0) { ModLogger.Player.Error("Invalid hand! Must be 'left' or 'right'"); ModLogger.Player.Info("Usage: assignhandpack [hand] [pack guid/pack index]\nHand: left or right (case insensitive)\nUse 'listpacks' to see available pack GUIDs"); return; } ResourcePack packFromArgs = GetPackFromArgs(args, ModLogger.Player.Error, 1); if (packFromArgs == null) { ModLogger.Player.Error("Invalid pack!"); ModLogger.Player.Info("Usage: assignhandpack [hand] [pack guid/pack index]\nHand: left or right (case insensitive)\nUse 'listpacks' to see available pack GUIDs"); return; } RHSpriteManager.OverrideHands(packFromArgs.guid, handIdFromString == 0); if (handIdFromString == 0) { RHConfig.PackPrefs.LeftHandPack = packFromArgs.guid; } else { RHConfig.PackPrefs.RightHandPack = packFromArgs.guid; } RHSpriteManager.ClearHandSprites(); string text = ((handIdFromString == 0) ? "left" : "right"); ModLogger.Player.Info("Assigned resource pack '" + packFromArgs.guid + "' to " + text + " hand"); } private static void ClearHandResourcePack(string[] args) { if (args.Length != 1) { ModLogger.Player.Error("Invalid number of arguments!"); ModLogger.Player.Info("Usage: clearhandpack [hand]\nHand: left or right (case insensitive)"); return; } int handIdFromString = GetHandIdFromString(args[0]); if (handIdFromString < 0) { ModLogger.Player.Error("Invalid hand! Must be 'left' or 'right'"); ModLogger.Player.Info("Usage: clearhandpack [hand]\nHand: left or right (case insensitive)"); return; } RHSpriteManager.ClearHandsOverride(handIdFromString == 0); if (handIdFromString == 0) { RHConfig.PackPrefs.LeftHandPack = ""; } else { RHConfig.PackPrefs.RightHandPack = ""; } RHSpriteManager.ClearHandSprites(); string text = ((handIdFromString == 0) ? "left" : "right"); ModLogger.Player.Info("Cleared resource pack from " + text + " hand"); } private static void ListHandResourcePack(string[] args) { ModLogger.Player.Info("Hand Resource Pack Assignments:"); for (int i = 0; i < 2; i++) { string text = ((i == 0) ? "Left" : "Right"); string packGuid = RHSpriteManager.GetHandsOverride(i == 0); if (string.IsNullOrEmpty(packGuid)) { ModLogger.Player.Info(text + " Hand: No custom pack assigned"); continue; } string text2 = ResourcePacksManager.LoadedPacks.FirstOrDefault((ResourcePack p) => p.guid == packGuid)?.name ?? "Unknown Pack"; ModLogger.Player.Info(text + " Hand: " + text2 + " (" + packGuid + ")"); } ModLogger.Player.Info("Use 'assignhandpack [hand] [pack guid/pack index]' to assign a pack"); ModLogger.Player.Info("Use 'clearhandpack [hand]' to clear a hand's pack"); } private static int GetHandIdFromString(string handString) { if (string.IsNullOrEmpty(handString)) { return -1; } string text = handString.Trim().ToLowerInvariant(); if (text == "left" || text == "l") { return 0; } if (text == "right" || text == "r") { return 1; } return -1; } } public static class CosmeticStructureRepairer { private static readonly HashSet<string> ProcessedFolders = new HashSet<string>(); private static readonly HashSet<string> ReservedNames = new HashSet<string> { "icon", "manifest", "readme", "card-foreground", "card-background" }; public static bool NeedsFixing(string modFolderPath) { return !Directory.Exists(Path.Combine(modFolderPath, "Sprites")) || !Directory.Exists(Path.Combine(modFolderPath, "Interacts")); } public static void FixModStructure(string modFolderPath, string jsonFileName = "cosmetic-handitem-settings.json") { if (string.IsNullOrEmpty(modFolderPath) || !Directory.Exists(modFolderPath)) { ModLogger.Warning("[Fixer] Provided path is invalid: " + modFolderPath, 41, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Systems/CosmeticStructureRepairer.cs"); } else { if (ProcessedFolders.Contains(modFolderPath)) { return; } try { string text = Path.Combine(modFolderPath, jsonFileName); if (!File.Exists(text)) { ModLogger.Debug("[Fixer] No settings JSON found in " + modFolderPath + ". Skipping...", 52, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Systems/CosmeticStructureRepairer.cs"); return; } ModLogger.Info("[Fixer] Checking structure for mod: " + Path.GetFileName(modFolderPath), 56, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Systems/CosmeticStructureRepairer.cs"); string text2 = File.ReadAllText(text); Cosmetic_HandItem_Data val = JsonConvert.DeserializeObject<Cosmetic_HandItem_Data>(text2); if (val == null) { ModLogger.Error("[Fixer] Failed to deserialize JSON at " + text, 63, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Systems/CosmeticStructureRepairer.cs"); return; } string path = Path.Combine(modFolderPath, "Sprites"); string path2 = Path.Combine(modFolderPath, "Interacts"); string text3 = Path.Combine(modFolderPath, "Palettes"); Directory.CreateDirectory(path); Directory.CreateDirectory(path2); Directory.CreateDirectory(text3); HashSet<string> hashSet = new HashSet<string>(); HashSet<string> hashSet2 = new HashSet<string>(); HashSet<string> hashSet3 = new HashSet<string>(); if (val.globalSecondary != null) { foreach (SecondaryTextures item2 in val.globalSecondary) { foreach (string secondaryTextureName in item2.secondaryTextureNames) { hashSet3.Add(secondaryTextureName.ToLower()); } } } ModLogger.Debug($"[Fixer] JSON parsed. Found {hashSet.Count} sprites, {hashSet2.Count} interacts, {hashSet3.Count} secondary textures.", 100, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Systems/CosmeticStructureRepairer.cs"); MoveMatchingFiles(modFolderPath, hashSet, "Sprites", "HND_"); MoveMatchingFiles(modFolderPath, hashSet, "Sprites", "stamina_"); MoveMatchingFiles(modFolderPath, hashSet2, "Interacts", "interact-"); MoveMatchingFiles(modFolderPath, hashSet3, "Palettes", "stamina"); string[] files = Directory.GetFiles(modFolderPath, "*.png"); string[] array = files; foreach (string text4 in array) { string item = Path.GetFileNameWithoutExtension(text4).ToLower(); if (ReservedNames.Contains(item)) { continue; } try { string fileName = Path.GetFileName(text4); string text5 = Path.Combine(text3, fileName); if (File.Exists(text5)) { File.Delete(text5); } File.Move(text4, text5); ModLogger.Debug("[Fixer] Moving leftover file " + fileName + " -> Palettes/", 125, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Systems/CosmeticStructureRepairer.cs"); } catch (Exception ex) { ModLogger.Error("[Fixer] Failed to move leftover file " + text4 + ": " + ex.Message, 129, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Systems/CosmeticStructureRepairer.cs"); } } ModLogger.Info("[Fixer] Finished organizing " + Path.GetFileName(modFolderPath), 133, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Systems/CosmeticStructureRepairer.cs"); ProcessedFolders.Add(modFolderPath); } catch (Exception ex2) { ModLogger.Error("[Fixer] CRITICAL ERROR fixing structure at " + modFolderPath + ": " + ex2.Message + "\n" + ex2.StackTrace, 138, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Systems/CosmeticStructureRepairer.cs"); } } } private static void MoveMatchingFiles(string root, HashSet<string> targets, string subFolder, string prefixFallback = null) { string text = Path.Combine(root, subFolder); string[] files = Directory.GetFiles(root, "*.png"); string[] array = files; foreach (string text2 in array) { string text3 = Path.GetFileNameWithoutExtension(text2).ToLower(); string fileName = Path.GetFileName(text2); bool flag = targets.Contains(text3); if (!flag && !string.IsNullOrEmpty(prefixFallback) && text3.StartsWith(prefixFallback.ToLower())) { flag = true; } if (!flag) { continue; } try { if (!Directory.Exists(text)) { Directory.CreateDirectory(text); } string text4 = Path.Combine(text, fileName); ModLogger.Debug("[Fixer] Moving " + fileName + " -> " + subFolder + "/", 175, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Systems/CosmeticStructureRepairer.cs"); if (File.Exists(text4)) { ModLogger.Warning("[Fixer] File " + fileName + " already exists in " + subFolder + ". Overwriting.", 179, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Systems/CosmeticStructureRepairer.cs"); File.Delete(text4); } File.Move(text2, text4); } catch (IOException ex) { ModLogger.Error("[Fixer] Failed to move " + fileName + ". File may be in use. Error: " + ex.Message, 187, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Systems/CosmeticStructureRepairer.cs"); } } } } public static class CosmeticSystem { private static GameObject? _holder; public static void EnsureExists() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (!((Object)(object)_holder != (Object)null)) { _holder = new GameObject("RHCosmeticSystem"); _holder.AddComponent<OF_CosmeticPage>(); Object.DontDestroyOnLoad((Object)(object)_holder); ModLogger.Info("Official Cosmetic Integration initialized.", 19, "/mnt/LinuxData/ModdingStuff/WhiteKnuckle/ResourcefulHands/Systems/CosmeticSystem.cs"); } } } public class RHDebugTools : MonoBehaviour { [CompilerGenerated] private sealed class <_queueSound>d__7 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public AudioClip clip; public bool force; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <_queueSound>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (!force && PlayingClips.Contains(clip)) { return false; } PlayingClips.Add(clip); <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; if (Object.op_Implicit((Object)(object)clip)) { PlayingClips.Remove(clip); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static RHDebugTools? Instance; public static bool isOn; private static readonly List<AudioClip> PlayingClips = new List<AudioClip>(); private GUIStyle _style = GUIStyle.none; private bool _enableNextFrame; internal static void Create() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Instance = new GameObject("DebugTools").AddComponent<RHDebugTools>(); Object.DontDestroyOnLoad((Object)(object)Instance); } public static void QueueSound(AudioClip clip, bool force = false) { CoroutineDispatcher.Dispatch(_queueSound(clip, force)); } [IteratorStateMachine(typeof(<_queueSound>d__7))] private static IEnumerator _queueSound(AudioClip clip, bool force) { //yiel