using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EasyTextEffects.Editor.MyBoxCopy.Extensions; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Networking; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("baer1")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (c) baer1 2026")] [assembly: AssemblyDescription("A collection of useful modding utilities for Lethal Company")] [assembly: AssemblyFileVersion("1.0.1.0")] [assembly: AssemblyInformationalVersion("1.0.1+33d2c5d8c67912b72a91bd73bbf87c78eb0f962b")] [assembly: AssemblyProduct("LethalModUtils")] [assembly: AssemblyTitle("baer1.LethalModUtils")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/baerchen201/LethalModUtils.git")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.1.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 LethalModUtils { public static class Audio { public class UnknownTypeError : Exception { public UnknownTypeError(string fileExtension) : base("Unrecognized audio file type: " + fileExtension) { } } public class RequestError : Exception { public RequestError(string errorMessage) : base("WebRequest error: " + errorMessage) { } } public class ClipError : Exception { public ClipError(AudioDataLoadState? state) { //IL_0014: 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) object obj; if (!state.HasValue) { obj = null; } else { AudioDataLoadState valueOrDefault = state.GetValueOrDefault(); obj = ((object)(AudioDataLoadState)(ref valueOrDefault)).ToString(); } if (obj == null) { obj = "null"; } base..ctor("Clip load error: " + (string?)obj); } } public class AudioPlayer { public enum PlayerState { Playing, Paused, Finished } private class _MonoBehaviour : MonoBehaviour { } [CompilerGenerated] private sealed class d__54 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public AudioPlayer <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__54(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 2) { try { } finally { <>m__Finally1(); } } <>1__state = -2; } private bool MoveNext() { try { int num = <>1__state; AudioPlayer audioPlayer = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; <>1__state = -3; break; case 2: <>1__state = -3; break; } if (!audioPlayer.finished && Object.op_Implicit((Object)(object)audioPlayer.AudioSource) && Object.op_Implicit((Object)(object)audioPlayer.GameObject)) { audioPlayer.MainLoop?.Invoke(audioPlayer); <>2__current = null; <>1__state = 2; return true; } <>m__Finally1(); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; AudioPlayer audioPlayer = <>4__this; audioPlayer.Cancel(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal readonly AudioSource AudioSource; internal readonly GameObject GameObject; private readonly Action? MainLoop; private bool finished; public PlayerState State { get { if (!finished) { if (!AudioSource.isPlaying) { return PlayerState.Paused; } return PlayerState.Playing; } return PlayerState.Finished; } } public bool Muted { get { return AudioSource.mute; } set { AudioSource.mute = value; } } public bool BypassEffects { get { return AudioSource.bypassEffects; } set { AudioSource.bypassEffects = value; } } public bool BypassListenerEffects { get { return AudioSource.bypassListenerEffects; } set { AudioSource.bypassListenerEffects = value; } } public bool BypassReverbZones { get { return AudioSource.bypassReverbZones; } set { AudioSource.bypassReverbZones = value; } } public bool Loop { get { return AudioSource.loop; } set { AudioSource.loop = value; } } public int Priority { get { return AudioSource.priority; } set { AudioSource.priority = value; } } public float Volume { get { return AudioSource.volume; } set { AudioSource.volume = value; } } public float Pitch { get { return AudioSource.pitch; } set { AudioSource.pitch = value; } } public float DopplerLevel { get { return AudioSource.dopplerLevel; } set { AudioSource.dopplerLevel = value; } } public float MaxDistance => AudioSource.maxDistance; public float MinDistance => AudioSource.minDistance; public AudioRolloffMode RolloffMode => AudioSource.rolloffMode; public AnimationCurve RolloffCurve => AudioSource.GetCustomCurve((AudioSourceCurveType)0); public AudioSource _audioSource => AudioSource; private AudioPlayer() { throw new InvalidOperationException(); } internal AudioPlayer(AudioClip audioClip, Action? mainLoop) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown LethalModUtils.Logger.LogDebug((object)$">> AudioPlayer({audioClip}, {mainLoop.str()})"); MainLoop = mainLoop; GameObject = new GameObject(); AudioSource = GameObject.AddComponent(); Object.DontDestroyOnLoad((Object)(object)GameObject); ((Object)GameObject).hideFlags = (HideFlags)61; AudioSource.clip = audioClip; finished = false; ((MonoBehaviour)GameObject.AddComponent<_MonoBehaviour>()).StartCoroutine(this.mainLoop()); } public void SetRange(float? maxDistance, float? minDistance = null) { AudioSource.spatialBlend = 1f; if (maxDistance.HasValue) { AudioSource.maxDistance = maxDistance.Value; } if (minDistance.HasValue) { AudioSource.minDistance = minDistance.Value; } } public void SetRange() { AudioSource.spatialBlend = 0f; } public void SetRolloff(bool linear = true) { AudioSource.rolloffMode = (AudioRolloffMode)(linear ? 1 : 0); } public void SetRolloff(AnimationCurve curve) { AudioSource.SetCustomCurve((AudioSourceCurveType)0, curve); AudioSource.rolloffMode = (AudioRolloffMode)2; } public void Cancel() { LethalModUtils.Logger.LogDebug((object)$">> AudioPlayer.Cancel() State:{State} AudioSource:{AudioSource.str()} GameObject:{GameObject.str()}"); if (Object.op_Implicit((Object)(object)AudioSource)) { Object.Destroy((Object)(object)AudioSource); } if (Object.op_Implicit((Object)(object)GameObject)) { Object.Destroy((Object)(object)GameObject); } finished = true; } public void Pause() { AudioSource audioSource = AudioSource; if (audioSource != null) { audioSource.Pause(); } } public void Stop() { AudioSource audioSource = AudioSource; if (audioSource != null) { audioSource.Stop(); } } public void Resume() { AudioSource audioSource = AudioSource; if (audioSource != null) { audioSource.Play(); } } [IteratorStateMachine(typeof(d__54))] private IEnumerator mainLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__54(0) { <>4__this = this }; } public override string ToString() { return $"{GetType().Name} {{ State:{State}, Volume:{Volume}, Muted:{Muted}, MainLoop:{MainLoop.str()} }}"; } } [CompilerGenerated] private sealed class d__9 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Uri path; public TaskCompletionSource task; private UnityWebRequest 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Invalid comparison between Unknown and I4 //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Invalid comparison between Unknown and I4 //IL_0175: Unknown result type (might be due to invalid IL or missing references) AudioClip content; bool flag; switch (<>1__state) { default: return false; case 0: { <>1__state = -1; string text = Path.GetExtension(path.AbsolutePath).ToLower(); AudioType audioType = GetAudioType(text); LethalModUtils.Logger.LogDebug((object)$">> Audio.LoadEnumerator({path}, {task}) audioType:{audioType}"); if ((int)audioType == 0) { UnknownTypeError unknownTypeError = new UnknownTypeError(text); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {unknownTypeError.Message}"); task.SetException(unknownTypeError); return false; } 5__2 = UnityWebRequestMultimedia.GetAudioClip(path, audioType); ((DownloadHandlerAudioClip)5__2.downloadHandler).streamAudio = !LethalModUtils.Instance.PreloadAudio; <>2__current = 5__2.SendWebRequest(); <>1__state = 1; return true; } case 1: { <>1__state = -1; if ((int)5__2.result != 1) { RequestError requestError = new RequestError(5__2.error); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {requestError.Message}"); task.SetException(requestError); return false; } content = DownloadHandlerAudioClip.GetContent(5__2); if (content != null) { AudioDataLoadState loadState = content.loadState; if ((int)loadState == 2) { flag = false; goto IL_0161; } } flag = true; goto IL_0161; } IL_0161: if (flag) { ClipError clipError = new ClipError((content != null) ? new AudioDataLoadState?(content.loadState) : null); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {clipError.Message}"); task.SetException(clipError); return false; } LethalModUtils.Logger.LogInfo((object)$"Loaded {path}"); task.SetResult(content); 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(); } } private static AudioType GetAudioType(string ext) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) return (AudioType)(ext.ToLower() switch { ".ogg" => 14, ".mp3" => 13, ".wav" => 20, ".m4a" => 1, ".aiff" => 2, _ => 0, }); } public static AudioClip Load(Uri path, TimeSpan? timeout = null) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Invalid comparison between Unknown and I4 //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Invalid comparison between Unknown and I4 //IL_015a: Unknown result type (might be due to invalid IL or missing references) string text = Path.GetExtension(path.AbsolutePath).ToLower(); AudioType audioType = GetAudioType(text); LethalModUtils.Logger.LogDebug((object)$">> Audio.Load({path}, {timeout.str()}) audioType:{audioType}"); if ((int)audioType == 0) { UnknownTypeError unknownTypeError = new UnknownTypeError(text); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {unknownTypeError.Message}"); throw unknownTypeError; } UnityWebRequest audioClip = UnityWebRequestMultimedia.GetAudioClip(path, audioType); ((DownloadHandlerAudioClip)audioClip.downloadHandler).streamAudio = !LethalModUtils.Instance.PreloadAudio; audioClip.SendWebRequest(); if (timeout.HasValue) { Task task = Task.Delay(timeout.Value); while (!audioClip.isDone && !task.IsCompleted) { } if (!audioClip.isDone) { TimeoutException ex = new TimeoutException(); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {ex.Message}"); throw ex; } } else { while (!audioClip.isDone) { } } if ((int)audioClip.result != 1) { RequestError requestError = new RequestError(audioClip.error); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {requestError.Message}"); throw requestError; } AudioClip content = DownloadHandlerAudioClip.GetContent(audioClip); bool flag; if (content != null) { AudioDataLoadState loadState = content.loadState; if ((int)loadState == 2) { flag = false; goto IL_0146; } } flag = true; goto IL_0146; IL_0146: if (flag) { ClipError clipError = new ClipError((content != null) ? new AudioDataLoadState?(content.loadState) : null); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {clipError.Message}"); throw clipError; } LethalModUtils.Logger.LogInfo((object)$"Loaded {path}"); return content; } public static AudioClip? TryLoad(Uri path, TimeSpan? timeout = null) { LethalModUtils.Logger.LogDebug((object)$">> Audio.TryLoad({path}, {timeout.str()})"); try { return Load(path, timeout); } catch (Exception arg) { LethalModUtils.Logger.LogDebug((object)$"<< Audio.TryLoad null ({arg})"); } return null; } public static AudioClip Load(Uri path, out UnityWebRequest webRequest, TimeSpan? timeout = null) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Invalid comparison between Unknown and I4 //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Invalid comparison between Unknown and I4 //IL_0160: Unknown result type (might be due to invalid IL or missing references) string text = Path.GetExtension(path.AbsolutePath).ToLower(); AudioType audioType = GetAudioType(text); LethalModUtils.Logger.LogDebug((object)$">> Audio.Load({path}, {timeout.str()}) audioType:{audioType}"); if ((int)audioType == 0) { UnknownTypeError unknownTypeError = new UnknownTypeError(text); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {unknownTypeError.Message}"); throw unknownTypeError; } webRequest = UnityWebRequestMultimedia.GetAudioClip(path, audioType); ((DownloadHandlerAudioClip)webRequest.downloadHandler).streamAudio = !LethalModUtils.Instance.PreloadAudio; webRequest.SendWebRequest(); if (timeout.HasValue) { Task task = Task.Delay(timeout.Value); while (!webRequest.isDone && !task.IsCompleted) { } if (!webRequest.isDone) { TimeoutException ex = new TimeoutException(); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {ex.Message}"); throw ex; } } else { while (!webRequest.isDone) { } } if ((int)webRequest.result != 1) { RequestError requestError = new RequestError(webRequest.error); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {requestError.Message}"); throw requestError; } AudioClip content = DownloadHandlerAudioClip.GetContent(webRequest); bool flag; if (content != null) { AudioDataLoadState loadState = content.loadState; if ((int)loadState == 2) { flag = false; goto IL_014c; } } flag = true; goto IL_014c; IL_014c: if (flag) { ClipError clipError = new ClipError((content != null) ? new AudioDataLoadState?(content.loadState) : null); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {clipError.Message}"); throw clipError; } LethalModUtils.Logger.LogInfo((object)$"Loaded {path}"); return content; } public static AudioClip? TryLoad(Uri path, out UnityWebRequest? webRequest, TimeSpan? timeout = null) { webRequest = null; LethalModUtils.Logger.LogDebug((object)$">> Audio.TryLoad({path}, {timeout.str()})"); try { return Load(path, out webRequest, timeout); } catch (Exception arg) { LethalModUtils.Logger.LogDebug((object)$"<< Audio.TryLoad null ({arg})"); } return null; } public static Task LoadAsync(Uri path, TimeSpan? timeout = null) { LethalModUtils.Logger.LogDebug((object)$">> Audio.LoadAsync({path}, {timeout.str()})"); TaskCompletionSource taskCompletionSource = new TaskCompletionSource(); ((MonoBehaviour)LethalModUtils.Instance).StartCoroutine(LoadEnumerator(path, taskCompletionSource)); if (timeout.HasValue) { Task task = Task.Delay(timeout.Value); if (Task.WhenAny(new Task[2] { taskCompletionSource.Task, task }) == task) { TimeoutException ex = new TimeoutException(); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {ex.Message}"); throw ex; } } return taskCompletionSource.Task; } [IteratorStateMachine(typeof(d__9))] private static IEnumerator LoadEnumerator(Uri path, TaskCompletionSource task) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__9(0) { path = path, task = task }; } public static async Task TryLoadAsync(Uri path, TimeSpan? timeout = null) { LethalModUtils.Logger.LogDebug((object)$">> Audio.TryLoadAsync({path}, {timeout.str()})"); try { return await LoadAsync(path, timeout); } catch (Exception arg) { LethalModUtils.Logger.LogDebug((object)$"<< Audio.TryLoadAsync null ({arg})"); } return null; } public static AudioPlayer Play(this AudioClip audioClip, Action? mainLoop = null) { AudioPlayer audioPlayer = new AudioPlayer(audioClip, mainLoop); audioPlayer.Resume(); return audioPlayer; } public static AudioPlayer CreatePlayer(this AudioClip audioClip, Action? mainLoop = null) { return new AudioPlayer(audioClip, mainLoop); } public static AudioPlayer PlayAt(this AudioClip audioClip, Vector3 position, Action? mainLoop = null) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) AudioPlayer audioPlayer = new AudioPlayer(audioClip, mainLoop); audioPlayer.GameObject.transform.position = position; audioPlayer.Resume(); return audioPlayer; } public static AudioPlayer PlayAt(this AudioClip audioClip, Transform parent, Action? mainLoop = null) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) AudioPlayer audioPlayer = new AudioPlayer(audioClip, mainLoop); audioPlayer.GameObject.transform.parent = parent; audioPlayer.GameObject.transform.localPosition = Vector3.zero; audioPlayer.Resume(); return audioPlayer; } public static AudioPlayer PlayAt(this AudioClip audioClip, Transform parent, Vector3 offset, Action? mainLoop = null) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) AudioPlayer audioPlayer = new AudioPlayer(audioClip, mainLoop); audioPlayer.GameObject.transform.parent = parent; audioPlayer.GameObject.transform.localPosition = offset; audioPlayer.Resume(); return audioPlayer; } public static AudioPlayer PlayAt(this AudioClip audioClip, Vector3 position, Transform parent, Action? mainLoop = null) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) AudioPlayer audioPlayer = new AudioPlayer(audioClip, mainLoop); audioPlayer.GameObject.transform.position = position; audioPlayer.GameObject.transform.parent = parent; audioPlayer.Resume(); return audioPlayer; } public static AudioPlayer CreatePlayerAt(this AudioClip audioClip, Vector3 position, Action? mainLoop = null) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) AudioPlayer audioPlayer = new AudioPlayer(audioClip, mainLoop); audioPlayer.GameObject.transform.position = position; return audioPlayer; } public static AudioPlayer CreatePlayerAt(this AudioClip audioClip, Transform parent, Action? mainLoop = null) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) AudioPlayer audioPlayer = new AudioPlayer(audioClip, mainLoop); audioPlayer.GameObject.transform.parent = parent; audioPlayer.GameObject.transform.localPosition = Vector3.zero; return audioPlayer; } public static AudioPlayer CreatePlayerAt(this AudioClip audioClip, Transform parent, Vector3 offset, Action? mainLoop = null) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) AudioPlayer audioPlayer = new AudioPlayer(audioClip, mainLoop); audioPlayer.GameObject.transform.parent = parent; audioPlayer.GameObject.transform.localPosition = offset; return audioPlayer; } public static AudioPlayer CreatePlayerAt(this AudioClip audioClip, Vector3 position, Transform parent, Action? mainLoop = null) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) AudioPlayer audioPlayer = new AudioPlayer(audioClip, mainLoop); audioPlayer.GameObject.transform.position = position; audioPlayer.GameObject.transform.parent = parent; return audioPlayer; } } public static class CodeMatcherExtensions { private static string MatchesToString(params CodeMatch[] matches) { return string.Join(';', matches.Select((CodeMatch i) => ((object)i).ToString())); } public static CodeMatcher MatchForward(this CodeMatcher codeMatcher, params CodeMatch[] matches) { int pos = Math.Clamp(codeMatcher.Pos, 0, codeMatcher.Length - 1); if (codeMatcher.MatchForward(true, matches).IsInvalid) { int _pos = -1; LethalModUtils.Logger.LogError((object)string.Format("Start position: {0}\n{1}", pos, string.Join('\n', from i in codeMatcher.Instructions() select string.Format("{0} #{1,2} {2}{3}{4}", (++_pos > pos) ? "=" : ((_pos == pos) ? "v" : " "), _pos, i.opcode, (i.operand == null) ? string.Empty : (" " + i.operand), (i.labels.Count <= 0) ? string.Empty : (" " + string.Join(" ", i.labels.Select((Label l) => $"[{l}]"))))))); throw new InvalidOperationException("MatchForward failed: " + MatchesToString(matches)); } return codeMatcher; } public static CodeMatcher MatchBack(this CodeMatcher codeMatcher, params CodeMatch[] matches) { int pos = Math.Clamp(codeMatcher.Pos, 0, codeMatcher.Length - 1); if (codeMatcher.MatchBack(true, matches).IsInvalid) { int _pos = -1; LethalModUtils.Logger.LogError((object)string.Format("Start position: {0}\n{1}", pos, string.Join('\n', from i in codeMatcher.Instructions() select string.Format("{0} #{1,2} {2}{3}{4}", (++_pos < pos) ? "=" : ((_pos == pos) ? "^" : " "), _pos, i.opcode, (i.operand == null) ? string.Empty : (" " + i.operand), (i.labels.Count <= 0) ? string.Empty : (" " + string.Join(" ", i.labels.Select((Label l) => $"[{l}]"))))))); throw new InvalidOperationException("MatchBack failed: " + MatchesToString(matches)); } return codeMatcher; } [Obsolete] public static CodeMatcher LogDebug(this CodeMatcher codeMatcher) { CodeMatcher codeMatcher2 = codeMatcher; int pos = 0; LethalModUtils.Logger.LogDebug((object)string.Format("Current position: {0}\n{1}", codeMatcher2.Pos, string.Join('\n', from i in codeMatcher2.Instructions() select string.Format("{0} #{1,2} {2}{3}{4}", (++pos == codeMatcher2.Pos) ? ">" : " ", pos, i.opcode, (i.operand == null) ? string.Empty : (" " + i.operand), (i.labels.Count <= 0) ? string.Empty : (" " + string.Join(" ", i.labels.Select((Label l) => $"[{l}]"))))))); return codeMatcher2; } } public static class Crc32 { private static readonly uint[] table = new uint[256] { 0u, 1996959894u, 3993919788u, 2567524794u, 124634137u, 1886057615u, 3915621685u, 2657392035u, 249268274u, 2044508324u, 3772115230u, 2547177864u, 162941995u, 2125561021u, 3887607047u, 2428444049u, 498536548u, 1789927666u, 4089016648u, 2227061214u, 450548861u, 1843258603u, 4107580753u, 2211677639u, 325883990u, 1684777152u, 4251122042u, 2321926636u, 335633487u, 1661365465u, 4195302755u, 2366115317u, 997073096u, 1281953886u, 3579855332u, 2724688242u, 1006888145u, 1258607687u, 3524101629u, 2768942443u, 901097722u, 1119000684u, 3686517206u, 2898065728u, 853044451u, 1172266101u, 3705015759u, 2882616665u, 651767980u, 1373503546u, 3369554304u, 3218104598u, 565507253u, 1454621731u, 3485111705u, 3099436303u, 671266974u, 1594198024u, 3322730930u, 2970347812u, 795835527u, 1483230225u, 3244367275u, 3060149565u, 1994146192u, 31158534u, 2563907772u, 4023717930u, 1907459465u, 112637215u, 2680153253u, 3904427059u, 2013776290u, 251722036u, 2517215374u, 3775830040u, 2137656763u, 141376813u, 2439277719u, 3865271297u, 1802195444u, 476864866u, 2238001368u, 4066508878u, 1812370925u, 453092731u, 2181625025u, 4111451223u, 1706088902u, 314042704u, 2344532202u, 4240017532u, 1658658271u, 366619977u, 2362670323u, 4224994405u, 1303535960u, 984961486u, 2747007092u, 3569037538u, 1256170817u, 1037604311u, 2765210733u, 3554079995u, 1131014506u, 879679996u, 2909243462u, 3663771856u, 1141124467u, 855842277u, 2852801631u, 3708648649u, 1342533948u, 654459306u, 3188396048u, 3373015174u, 1466479909u, 544179635u, 3110523913u, 3462522015u, 1591671054u, 702138776u, 2966460450u, 3352799412u, 1504918807u, 783551873u, 3082640443u, 3233442989u, 3988292384u, 2596254646u, 62317068u, 1957810842u, 3939845945u, 2647816111u, 81470997u, 1943803523u, 3814918930u, 2489596804u, 225274430u, 2053790376u, 3826175755u, 2466906013u, 167816743u, 2097651377u, 4027552580u, 2265490386u, 503444072u, 1762050814u, 4150417245u, 2154129355u, 426522225u, 1852507879u, 4275313526u, 2312317920u, 282753626u, 1742555852u, 4189708143u, 2394877945u, 397917763u, 1622183637u, 3604390888u, 2714866558u, 953729732u, 1340076626u, 3518719985u, 2797360999u, 1068828381u, 1219638859u, 3624741850u, 2936675148u, 906185462u, 1090812512u, 3747672003u, 2825379669u, 829329135u, 1181335161u, 3412177804u, 3160834842u, 628085408u, 1382605366u, 3423369109u, 3138078467u, 570562233u, 1426400815u, 3317316542u, 2998733608u, 733239954u, 1555261956u, 3268935591u, 3050360625u, 752459403u, 1541320221u, 2607071920u, 3965973030u, 1969922972u, 40735498u, 2617837225u, 3943577151u, 1913087877u, 83908371u, 2512341634u, 3803740692u, 2075208622u, 213261112u, 2463272603u, 3855990285u, 2094854071u, 198958881u, 2262029012u, 4057260610u, 1759359992u, 534414190u, 2176718541u, 4139329115u, 1873836001u, 414664567u, 2282248934u, 4279200368u, 1711684554u, 285281116u, 2405801727u, 4167216745u, 1634467795u, 376229701u, 2685067896u, 3608007406u, 1308918612u, 956543938u, 2808555105u, 3495958263u, 1231636301u, 1047427035u, 2932959818u, 3654703836u, 1088359270u, 936918000u, 2847714899u, 3736837829u, 1202900863u, 817233897u, 3183342108u, 3401237130u, 1404277552u, 615818150u, 3134207493u, 3453421203u, 1423857449u, 601450431u, 3009837614u, 3294710456u, 1567103746u, 711928724u, 3020668471u, 3272380065u, 1510334235u, 755167117u }; public static uint Calculate(byte[] bytes) { return bytes.Aggregate(uint.MaxValue, (uint current, byte b) => (current >> 8) ^ table[(current ^ b) & 0xFF]) ^ 0xFFFFFFFFu; } } internal static class ObjectExtensions { internal static string str(this object? obj) { if (obj != null) { return obj.ToString(); } return "null"; } } public static class FS { public enum ProcessFilter { All, None, DirectoriesOnly, FilesOnly } public static int IterateDirectories(DirectoryInfo root, Func callback, Func? filter = null) { Func callback2 = callback; Func filter2 = filter; LethalModUtils.Logger.LogDebug((object)$">> IterateDirectories(root: {root}, callback: {callback2}, filter: {filter2})"); if (!root.Exists) { return 0; } ProcessFilter processFilter = filter2?.Invoke(root) ?? ProcessFilter.All; int num = 0; if ((processFilter == ProcessFilter.All || processFilter == ProcessFilter.DirectoriesOnly) ? true : false) { num += ((IEnumerable)root.GetDirectories()).Sum((Func)RecurseWithParameters); } if ((processFilter == ProcessFilter.All || processFilter == ProcessFilter.FilesOnly) ? true : false) { num += root.GetFiles().Count(callback2); } return num; int RecurseWithParameters(DirectoryInfo _root) { return IterateDirectories(_root, callback2, filter2); } } public static void IterateDirectories(DirectoryInfo root, Action callback, Func? filter = null) { Action callback2 = callback; Func filter2 = filter; LethalModUtils.Logger.LogDebug((object)$">> IterateDirectories(root: {root}, callback: {callback2}, filter: {filter2})"); if (root.Exists) { ProcessFilter processFilter = filter2?.Invoke(root) ?? ProcessFilter.All; if ((processFilter == ProcessFilter.All || processFilter == ProcessFilter.DirectoriesOnly) ? true : false) { MyCollections.ForEach((IEnumerable)root.GetDirectories(), (Action)RecurseWithParameters); } if ((processFilter == ProcessFilter.All || processFilter == ProcessFilter.FilesOnly) ? true : false) { MyCollections.ForEach((IEnumerable)root.GetFiles(), callback2); } } void RecurseWithParameters(DirectoryInfo _root) { IterateDirectories(_root, callback2, filter2); } } } public class Image { public class RequestError : Exception { public RequestError(string errorMessage) : base("WebRequest error: " + errorMessage) { } } public class TextureError : Exception { public TextureError() : base("Texture is null") { } } [CompilerGenerated] private sealed class d__3 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Uri path; public TaskCompletionSource task; private UnityWebRequest 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Invalid comparison between Unknown and I4 switch (<>1__state) { default: return false; case 0: <>1__state = -1; LethalModUtils.Logger.LogDebug((object)$">> Image.LoadEnumerator({path}, {task})"); 5__2 = UnityWebRequestTexture.GetTexture(path); <>2__current = 5__2.SendWebRequest(); <>1__state = 1; return true; case 1: { <>1__state = -1; if ((int)5__2.result != 1) { RequestError requestError = new RequestError(5__2.error); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {requestError.Message}"); task.SetException(requestError); return false; } Texture2D content = DownloadHandlerTexture.GetContent(5__2); if (content == null) { TextureError textureError = new TextureError(); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {textureError.Message}"); task.SetException(textureError); return false; } LethalModUtils.Logger.LogInfo((object)$"Loaded {path}"); task.SetResult(content); 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 Task LoadAsync(Uri path, TimeSpan? timeout = null) { LethalModUtils.Logger.LogDebug((object)$">> Image.LoadAsync({path}, {timeout.str()})"); TaskCompletionSource taskCompletionSource = new TaskCompletionSource(); ((MonoBehaviour)LethalModUtils.Instance).StartCoroutine(LoadEnumerator(path, taskCompletionSource)); if (timeout.HasValue) { Task task = Task.Delay(timeout.Value); if (Task.WhenAny(new Task[2] { taskCompletionSource.Task, task }) == task) { TimeoutException ex = new TimeoutException(); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {ex.Message}"); throw ex; } } return taskCompletionSource.Task; } [IteratorStateMachine(typeof(d__3))] private static IEnumerator LoadEnumerator(Uri path, TaskCompletionSource task) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(0) { path = path, task = task }; } public static async Task TryLoadAsync(Uri path, TimeSpan? timeout = null) { LethalModUtils.Logger.LogDebug((object)$">> Image.TryLoadAsync({path}, {timeout.str()})"); try { return await LoadAsync(path, timeout); } catch (Exception arg) { LethalModUtils.Logger.LogDebug((object)$"<< Image.TryLoadAsync null ({arg})"); } return null; } public static Sprite Texture2DToSprite(Texture2D texture, bool centered = true) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) return Sprite.Create(texture, new Rect(0f, 0f, (float)((Texture)texture).width, (float)((Texture)texture).height), (Vector2)(centered ? new Vector2(0.5f, 0.5f) : Vector2.zero)); } } public static class Texture2DExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Sprite ToSprite(this Texture2D texture, bool centered = true) { return Image.Texture2DToSprite(texture, centered); } } [BepInPlugin("baer1.LethalModUtils", "LethalModUtils", "1.0.1")] public class LethalModUtils : BaseUnityPlugin { internal ConfigEntry exportStaticData; private ConfigEntry preloadAudio; public static LethalModUtils Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } public bool PreloadAudio { get; private set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; preloadAudio = ((BaseUnityPlugin)this).Config.Bind("Audio", "PreloadAudio", true, "Whether to pre-load audio into RAM"); PreloadAudio = preloadAudio.Value; Patch(); Logger.LogInfo((object)"baer1.LethalModUtils v1.0.1 has loaded!"); static void Patch() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (Harmony == null) { Harmony = new Harmony("baer1.LethalModUtils"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "baer1.LethalModUtils"; public const string PLUGIN_NAME = "LethalModUtils"; public const string PLUGIN_VERSION = "1.0.1"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }