Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LethalModUtils v0.1.4
baer1.LethalModUtils.dll
Decompiled 2 weeks agousing 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.Text; using System.Threading.Tasks; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using EasyTextEffects.Editor.MyBoxCopy.Extensions; using HarmonyLib; using Microsoft.CodeAnalysis; using Newtonsoft.Json; 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 2025")] [assembly: AssemblyDescription("A collection of useful modding utilities for Lethal Company")] [assembly: AssemblyFileVersion("0.1.4.0")] [assembly: AssemblyInformationalVersion("0.1.4+14c2ea79ed58e16b0499ad613f6db182b2c14c3e")] [assembly: AssemblyProduct("LethalModUtils")] [assembly: AssemblyTitle("baer1.LethalModUtils")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/baerchen201/LethalModUtils.git")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.4.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 <mainLoop>d__54 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public AudioPlayer <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <mainLoop>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<AudioPlayer>? 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<AudioPlayer>? 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<AudioSource>(); 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(<mainLoop>d__54))] private IEnumerator mainLoop() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <mainLoop>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 <LoadEnumerator>d__9 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Uri path; public TaskCompletionSource<AudioClip> task; private UnityWebRequest <webRequest>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadEnumerator>d__9(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <webRequest>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; } <webRequest>5__2 = UnityWebRequestMultimedia.GetAudioClip(path, audioType); ((DownloadHandlerAudioClip)<webRequest>5__2.downloadHandler).streamAudio = !LethalModUtils.Instance.PreloadAudio; <>2__current = <webRequest>5__2.SendWebRequest(); <>1__state = 1; return true; } case 1: { <>1__state = -1; if ((int)<webRequest>5__2.result != 1) { RequestError requestError = new RequestError(<webRequest>5__2.error); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {requestError.Message}"); task.SetException(requestError); return false; } content = DownloadHandlerAudioClip.GetContent(<webRequest>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<AudioClip> LoadAsync(Uri path, TimeSpan? timeout = null) { LethalModUtils.Logger.LogDebug((object)$">> Audio.LoadAsync({path}, {timeout.str()})"); TaskCompletionSource<AudioClip> taskCompletionSource = new TaskCompletionSource<AudioClip>(); ((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(<LoadEnumerator>d__9))] private static IEnumerator LoadEnumerator(Uri path, TaskCompletionSource<AudioClip> task) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadEnumerator>d__9(0) { path = path, task = task }; } public static async Task<AudioClip?> 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<AudioPlayer>? mainLoop = null) { AudioPlayer audioPlayer = new AudioPlayer(audioClip, mainLoop); audioPlayer.Resume(); return audioPlayer; } public static AudioPlayer CreatePlayer(this AudioClip audioClip, Action<AudioPlayer>? mainLoop = null) { return new AudioPlayer(audioClip, mainLoop); } public static AudioPlayer PlayAt(this AudioClip audioClip, Vector3 position, Action<AudioPlayer>? 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<AudioPlayer>? 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<AudioPlayer>? 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<AudioPlayer>? 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<AudioPlayer>? 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<AudioPlayer>? 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<AudioPlayer>? 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<AudioPlayer>? 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())); } internal 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; } internal 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] internal 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<FileInfo, bool> callback, Func<DirectoryInfo, ProcessFilter>? filter = null) { Func<FileInfo, bool> callback2 = callback; Func<DirectoryInfo, ProcessFilter> 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<DirectoryInfo>)root.GetDirectories()).Sum((Func<DirectoryInfo, int>)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<FileInfo> callback, Func<DirectoryInfo, ProcessFilter>? filter = null) { Action<FileInfo> callback2 = callback; Func<DirectoryInfo, ProcessFilter> 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<DirectoryInfo>((IEnumerable<DirectoryInfo>)root.GetDirectories(), (Action<DirectoryInfo>)RecurseWithParameters); } if ((processFilter == ProcessFilter.All || processFilter == ProcessFilter.FilesOnly) ? true : false) { MyCollections.ForEach<FileInfo>((IEnumerable<FileInfo>)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 <LoadEnumerator>d__3 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Uri path; public TaskCompletionSource<Texture2D> task; private UnityWebRequest <webRequest>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <LoadEnumerator>d__3(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <webRequest>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})"); <webRequest>5__2 = UnityWebRequestTexture.GetTexture(path); <>2__current = <webRequest>5__2.SendWebRequest(); <>1__state = 1; return true; case 1: { <>1__state = -1; if ((int)<webRequest>5__2.result != 1) { RequestError requestError = new RequestError(<webRequest>5__2.error); LethalModUtils.Logger.LogWarning((object)$"Error loading {path}: {requestError.Message}"); task.SetException(requestError); return false; } Texture2D content = DownloadHandlerTexture.GetContent(<webRequest>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<Texture2D> LoadAsync(Uri path, TimeSpan? timeout = null) { LethalModUtils.Logger.LogDebug((object)$">> Image.LoadAsync({path}, {timeout.str()})"); TaskCompletionSource<Texture2D> taskCompletionSource = new TaskCompletionSource<Texture2D>(); ((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(<LoadEnumerator>d__3))] private static IEnumerator LoadEnumerator(Uri path, TaskCompletionSource<Texture2D> task) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <LoadEnumerator>d__3(0) { path = path, task = task }; } public static async Task<Texture2D?> 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 { public static Sprite ToSprite(this Texture2D texture, bool centered = true) { return Image.Texture2DToSprite(texture, centered); } } [BepInPlugin("baer1.LethalModUtils", "LethalModUtils", "0.1.4")] public class LethalModUtils : BaseUnityPlugin { internal ConfigEntry<bool> exportStaticData; private ConfigEntry<bool> 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; InitConfig(); Patch(); Logger.LogInfo((object)"baer1.LethalModUtils v0.1.4 has loaded!"); void InitConfig() { exportStaticData = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ExportStaticData", false, "Set to true to export static game data to file on next opportunity"); exportStaticData.SettingChanged += delegate { if (exportStaticData.Value && Object.op_Implicit((Object)(object)StartOfRound.Instance)) { ExportStaticData(StartOfRound.Instance); } }; preloadAudio = ((BaseUnityPlugin)this).Config.Bind<bool>("Audio", "PreloadAudio", true, "Whether to pre-load audio into RAM"); PreloadAudio = preloadAudio.Value; } 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 void ExportStaticData(StartOfRound __instance) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown Logger.LogInfo((object)"Requested static data export..."); exportStaticData.Value = false; try { using FileStream fileStream = File.Open(Path.Combine(Environment.CurrentDirectory, "StaticData.json"), FileMode.Create, FileAccess.Write); using StreamWriter streamWriter = new StreamWriter(fileStream, Encoding.UTF8); JsonTextWriter val = new JsonTextWriter((TextWriter)streamWriter); try { StaticData.ImportUtil.Import(GameNetworkManager.Instance?.gameVersionNum ?? (-1), __instance.allItemsList, __instance.levels).Serialize((JsonWriter)(object)val); ((JsonWriter)val).Flush(); streamWriter.Flush(); fileStream.Flush(); Logger.LogInfo((object)$"Exported static data to {Path.GetFullPath(fileStream.Name)} ({fileStream.Position} bytes)"); } finally { ((IDisposable)val)?.Dispose(); } } catch (Exception ex) { Debug.LogException(ex); } } } public struct StaticData { public static class ImportUtil { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Keyframe ToUnity(AnimationCurve.Keyframe keyframe) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) return new Keyframe(keyframe.time, keyframe.value, keyframe.inTangent, keyframe.outTangent, keyframe.inWeight, keyframe.outWeight); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AnimationCurve.Keyframe Import(Keyframe keyframe) { AnimationCurve.Keyframe result = default(AnimationCurve.Keyframe); result.time = ((Keyframe)(ref keyframe)).time; result.value = ((Keyframe)(ref keyframe)).value; result.inTangent = ((Keyframe)(ref keyframe)).inTangent; result.outTangent = ((Keyframe)(ref keyframe)).outTangent; result.inWeight = ((Keyframe)(ref keyframe)).inWeight; result.outWeight = ((Keyframe)(ref keyframe)).outWeight; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AnimationCurve ToUnity(AnimationCurve animationCurve) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown return new AnimationCurve(animationCurve.keys.Select(ToUnity).ToArray()); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static AnimationCurve Import(AnimationCurve animationCurve) { AnimationCurve result = default(AnimationCurve); result.keys = animationCurve.keys.Select(Import).ToArray(); return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Color ToUnity(Color color) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) return new Color(color.r, color.g, color.b, color.a); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Color Import(Color color) { //IL_000a: 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_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); result.r = color.r; result.g = color.g; result.b = color.b; result.a = color.a; return result; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector3 ToUnity(Vector3 vector3) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) return new Vector3(vector3.x, vector3.y, vector3.z); } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static Vector3 Import(Vector3 vector3) { //IL_000a: 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_0024: Unknown result type (might be due to invalid IL or missing references) Vector3 result = default(Vector3); result.x = vector3.x; result.y = vector3.y; result.z = vector3.z; return result; } public static ItemType Import(Item item) { //IL_0303: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)item)) { return default(ItemType); } ItemType result = default(ItemType); result.Id = item.itemId; result.Name = item.itemName; result.LockedInDemo = item.lockedInDemo; result.PrefabName = ((object)item.spawnPrefab)?.ToString() ?? string.Empty; result.ItemIcon = ((object)item.itemIcon)?.ToString() ?? string.Empty; result.SpawnPositionTypes = item.spawnPositionTypes?.Select((ItemGroup i) => i.itemSpawnTypeName).ToArray() ?? Array.Empty<string>(); result.TwoHanded = item.twoHanded; result.TwoHandedAnimation = item.twoHandedAnimation; result.DisableHandsOnWall = item.disableHandsOnWall; result.CanBeGrabbedBeforeGameStart = item.canBeGrabbedBeforeGameStart; result.DisallowUtilitySlot = item.disallowUtilitySlot; result.Weight = item.weight; result.IsTrigger = item.itemIsTrigger; result.HoldButtonUse = item.holdButtonUse; result.SpawnsOnGround = item.itemSpawnsOnGround; result.IsConductive = item.isConductiveMetal; result.IsScrap = item.isScrap; result.Value = item.creditsWorth; result.MaxValue = item.maxValue; result.MinValue = item.minValue; result.MaxSalePercentage = item.highestSalePercentage; result.UsesBattery = item.requiresBattery; result.BatteryUsage = item.batteryUsage; result.AutomaticallySetUsingPower = item.automaticallySetUsingPower; result.GrabAnimation = item.grabAnim; result.GrabAnimationTime = item.grabAnimationTime; result.UseAnimation = item.useAnim; result.PocketAnimation = item.pocketAnim; result.ThrowAnimation = item.throwAnim; result.GrabSFX = ((object)item.grabSFX)?.ToString() ?? string.Empty; result.DropSFX = ((object)item.dropSFX)?.ToString() ?? string.Empty; result.PocketSFX = ((object)item.pocketSFX)?.ToString() ?? string.Empty; result.ThrowSFX = ((object)item.throwSFX)?.ToString() ?? string.Empty; result.SyncGrabFunction = item.syncGrabFunction; result.SyncUseFunction = item.syncUseFunction; result.SyncDiscardFunction = item.syncDiscardFunction; result.SyncInteractLRFunction = item.syncInteractLRFunction; result.SaveItemVariable = item.saveItemVariable; result.IsWeapon = item.isDefensiveWeapon; result.ToolTips = item.toolTips; result.VerticalOffset = item.verticalOffset; result.FloorYOffset = item.floorYOffset; result.DropAheadOfPlayer = item.allowDroppingAheadOfPlayer; result.RestingRotation = Import(item.restingRotation); result.RotationOffset = Import(item.rotationOffset); result.PositionOffset = Import(item.positionOffset); result.MeshOffset = item.meshOffset; result.MeshVariants = toSArr(item.meshVariants); result.MaterialVariants = toSArr(item.materialVariants); result.ClinkAudios = toSArr(item.clinkAudios); result.UsableInSpecialAnimations = false; result.CanBeInspected = false; result._imported_from = item; return result; } public static EnemyType.Animation Import(MiscAnimation miscAnimation) { EnemyType.Animation result = default(EnemyType.Animation); result.Name = miscAnimation.AnimString; result.AudioClip = ((object)miscAnimation.AnimVoiceclip)?.ToString() ?? string.Empty; result.Length = miscAnimation.AnimLength; result.Priority = miscAnimation.priority; return result; } public static EnemyType Import(EnemyType enemyType) { //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected I4, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected I4, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected I4, but got Unknown if (!Object.op_Implicit((Object)(object)enemyType)) { return default(EnemyType); } EnemyType result = default(EnemyType); result.Name = enemyType.enemyName; result.PrefabName = ((object)enemyType.enemyPrefab)?.ToString() ?? string.Empty; result.ProbabilityCurve = Import(enemyType.probabilityCurve); result.Disabled = enemyType.spawningDisabled; result.SpawnFromWeeds = enemyType.spawnFromWeeds; result.SpawnFalloff = Import(enemyType.numberSpawnedFalloff); result.UseSpawnFalloff = enemyType.useNumberSpawnedFalloff; result.SpawnInGroups = enemyType.spawnInGroupsOf; result.RequireNestObject = enemyType.requireNestObjectsToSpawn; result.PowerLevel = enemyType.PowerLevel; result.DiversityPowerLevel = enemyType.DiversityPowerLevel; result.MaxCount = enemyType.MaxCount; result.IsOutsideEnemy = enemyType.isOutsideEnemy; result.IsDaytimeEnemy = enemyType.isDaytimeEnemy; result.IncreasedChanceInterior = enemyType.increasedChanceInterior; result.NormalizedTimeInDayToLeave = enemyType.normalizedTimeInDayToLeave; result.StunTimeMultiplier = enemyType.stunTimeMultiplier; result.DoorSpeedMultiplier = enemyType.doorSpeedMultiplier; result.StunGameDifficultyMultiplier = enemyType.stunGameDifficultyMultiplier; result.CanBeStunned = enemyType.canBeStunned; result.CanDie = enemyType.canDie; result.CanBeDestroyed = enemyType.canBeDestroyed; result.DestroyOnDeath = enemyType.destroyOnDeath; result.CanSeeThroughFog = enemyType.canSeeThroughFog; result.DisableAnimatorWhenFar = enemyType.disableAnimatorWhenFar; result.PushPlayerForce = enemyType.pushPlayerForce; result.PushPlayerDistance = enemyType.pushPlayerDistance; result.SizeLimit = (int)enemyType.SizeLimit; result.EnemySize = (int)enemyType.EnemySize; result.WaterType = (int)enemyType.WaterType; result.TimeToPlayAudio = enemyType.timeToPlayAudio; result.LoudnessMultiplier = enemyType.loudnessMultiplier; result.OverrideVentSFX = ((object)enemyType.overrideVentSFX)?.ToString() ?? string.Empty; result.NestPrefabName = ((object)enemyType.nestSpawnPrefab)?.ToString() ?? string.Empty; result.NestPrefabWidth = enemyType.nestSpawnPrefabWidth; result.NestDistanceFromShip = enemyType.nestDistanceFromShip; result.UseMinEnemyThresholdForNest = enemyType.useMinEnemyThresholdForNest; result.MinEnemiesToSpawnNest = enemyType.minEnemiesToSpawnNest; result.HitBodySFX = ((object)enemyType.hitBodySFX)?.ToString() ?? string.Empty; result.HitEnemyVoiceSFX = ((object)enemyType.hitEnemyVoiceSFX)?.ToString() ?? string.Empty; result.DeathSFX = ((object)enemyType.deathSFX)?.ToString() ?? string.Empty; result.StunSFX = ((object)enemyType.stunSFX)?.ToString() ?? string.Empty; result.MiscAudioClips = toSArr(enemyType.audioClips); result.MiscAnimations = enemyType.miscAnimations?.Select(Import).ToArray() ?? Array.Empty<EnemyType.Animation>(); result._imported_from = enemyType; return result; } public static Level.WeatherWithVariables Import(RandomWeatherWithVariables randomWeatherWithVariables) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected I4, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) Level.WeatherWithVariables result = default(Level.WeatherWithVariables); result.Weather = (int)randomWeatherWithVariables.weatherType; result.Variable1 = randomWeatherWithVariables.weatherVariable; result.Variable2 = randomWeatherWithVariables.weatherVariable2; result.Color = Import(randomWeatherWithVariables.weatherVariableColor); return result; } public static Level.LevelAmbience.WeightedAudioClip Import(RandomAudioClip randomAudioClip) { Level.LevelAmbience.WeightedAudioClip result = default(Level.LevelAmbience.WeightedAudioClip); result.AudioClip = ((object)randomAudioClip.audioClip)?.ToString() ?? string.Empty; result.Rarity = randomAudioClip.chance; return result; } public static Level.LevelAmbience Import(LevelAmbienceLibrary levelAmbienceLibrary) { if (!Object.op_Implicit((Object)(object)levelAmbienceLibrary)) { return default(Level.LevelAmbience); } Level.LevelAmbience result = default(Level.LevelAmbience); result.insanityMusicAudios = toSArr(levelAmbienceLibrary.insanityMusicAudios); result.insideAmbience = toSArr(levelAmbienceLibrary.insideAmbience); result.insideAmbienceInsanity = toWArr(levelAmbienceLibrary.insideAmbienceInsanity); result.shipAmbience = toSArr(levelAmbienceLibrary.shipAmbience); result.shipAmbienceInsanity = toWArr(levelAmbienceLibrary.shipAmbienceInsanity); result.outsideAmbience = toSArr(levelAmbienceLibrary.outsideAmbience); result.outsideAmbienceInsanity = toWArr(levelAmbienceLibrary.outsideAmbienceInsanity); return result; static Level.LevelAmbience.WeightedAudioClip[] toWArr(IEnumerable<RandomAudioClip>? enumerable) { return enumerable?.Select(Import).ToArray() ?? Array.Empty<Level.LevelAmbience.WeightedAudioClip>(); } } public static Level.Interior Import(IntWithRarity intWithRarity) { Level.Interior result = default(Level.Interior); result.Id = intWithRarity.id; result.Rarity = intWithRarity.rarity; result.OverridesLevelAmbience = Object.op_Implicit((Object)(object)intWithRarity.overrideLevelAmbience); result.LevelAmbience = Import(intWithRarity.overrideLevelAmbience); return result; } public static Level.InsideHazard.HazardType Import(IndoorMapHazardType indoorMapHazardType) { if (!Object.op_Implicit((Object)(object)indoorMapHazardType)) { return default(Level.InsideHazard.HazardType); } Level.InsideHazard.HazardType result = default(Level.InsideHazard.HazardType); result.PrefabName = ((object)indoorMapHazardType.prefabToSpawn)?.ToString() ?? string.Empty; result.SpawnFacingAwayFromWall = indoorMapHazardType.spawnFacingAwayFromWall; result.SpawnFacingWall = indoorMapHazardType.spawnFacingWall; result.SpawnWithBackToWall = indoorMapHazardType.spawnWithBackToWall; result.SpawnWithBackFlushAgainstWall = indoorMapHazardType.spawnWithBackFlushAgainstWall; result.RequireDistanceBetweenSpawns = indoorMapHazardType.requireDistanceBetweenSpawns; result.DisallowSpawningNearEntrances = indoorMapHazardType.disallowSpawningNearEntrances; result.SpawnInMineshaft = indoorMapHazardType.allowInMineshaft; return result; } public static Level.InsideHazard Import(IndoorMapHazard indoorMapHazard) { Level.InsideHazard result = default(Level.InsideHazard); result.Hazard = Import(indoorMapHazard.hazardType); result.SpawnAmount = Import(indoorMapHazard.numberToSpawn); return result; } public static Level.OutsideHazard.HazardType Import(SpawnableOutsideObject spawnableOutsideObject) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)spawnableOutsideObject)) { return default(Level.OutsideHazard.HazardType); } Level.OutsideHazard.HazardType result = default(Level.OutsideHazard.HazardType); result.PrefabName = ((object)spawnableOutsideObject.prefabToSpawn)?.ToString() ?? string.Empty; result.SpawnFacingAwayFromWall = spawnableOutsideObject.spawnFacingAwayFromWall; result.ObjectWidth = spawnableOutsideObject.objectWidth; result.DestroyTrees = spawnableOutsideObject.destroyTrees; result.SpawnableFloorTags = spawnableOutsideObject.spawnableFloorTags; result.RotationOffset = Import(spawnableOutsideObject.rotationOffset); return result; } public static Level.OutsideHazard Import(SpawnableOutsideObjectWithRarity spawnableOutsideObjectWithRarity) { Level.OutsideHazard result = default(Level.OutsideHazard); result.Hazard = Import(spawnableOutsideObjectWithRarity.spawnableObject); result.SpawnAmount = Import(spawnableOutsideObjectWithRarity.randomAmount); return result; } public static StaticData Import(int gameVersion, AllItemsList allItemsList, SelectableLevel[] selectableLevels) { //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected I4, but got Unknown List<ItemType> ItemTable = new List<ItemType>(); List<EnemyType> EnemyTable = new List<EnemyType>(); List<Level> list = new List<Level>(); if (Object.op_Implicit((Object)(object)allItemsList)) { foreach (Item items in allItemsList.itemsList) { GetOrImportItemType(items); } } foreach (SelectableLevel val in selectableLevels) { list.Add(new Level { Name = val.PlanetName, SceneName = val.sceneName, LockedForDemo = val.lockedForDemo, SpawnEnemiesAndScrap = val.spawnEnemiesAndScrap, LevelDescription = val.LevelDescription, RiskLevel = val.riskLevel, LandingTime = val.timeToArrive, VideoPreview = (((object)val.videoReel)?.ToString() ?? string.Empty), LevelIcon = val.levelIconString, HasTime = val.planetHasTime, OffsetFromGlobalTime = val.OffsetFromGlobalTime, DaySpeedMultiplier = val.DaySpeedMultiplier, HasStaticWeather = val.overrideWeather, StaticWeather = (int)val.overrideWeatherType, Weathers = val.randomWeathers.Select(Import).ToArray(), InteriorSizeMultiplier = val.factorySizeMultiplier, Interiors = val.dungeonFlowTypes.Select(Import).ToArray(), HasAmbienceClips = Object.op_Implicit((Object)(object)val.levelAmbienceClips), AmbienceClips = Import(val.levelAmbienceClips), SpawnableInsideObjects = val.indoorMapHazards.Select(Import).ToArray(), SpawnableOutsideObjects = val.spawnableOutsideObjects.Select(Import).ToArray(), CanSpawnMold = val.canSpawnMold, MoldSpreadIterations = val.moldSpreadIterations, MoldStartPosition = val.moldStartPosition, MoldType = val.moldType, SpawnableScrap = val.spawnableScrap.Select(delegate(SpawnableItemWithRarity i) { Level.SpawnableItem result3 = default(Level.SpawnableItem); result3.ItemIndex = GetOrImportItemType(i.spawnableItem); result3.Rarity = i.rarity; return result3; }).ToArray(), MinScrap = val.minScrap, MaxScrap = val.maxScrap, MinTotalScrapValue = val.minTotalScrapValue, MaxTotalScrapValue = val.maxTotalScrapValue, MaxEnemyPowerCount = val.maxEnemyPowerCount, MaxOutsideEnemyPowerCount = val.maxOutsideEnemyPowerCount, MaxDaytimeEnemyPowerCount = val.maxDaytimeEnemyPowerCount, MaxInsideDiversityPowerCount = val.maxInsideDiversityPowerCount, MaxOutsideDiversityPowerCount = val.maxOutsideDiversityPowerCount, InsideEnemies = toEArr(val.Enemies), SpecialEnemyRarity = new Level.OverrideSpawnableEnemy { EnemyIndex = GetOrImportEnemyType(val.specialEnemyRarity.overrideEnemy), Chance = val.specialEnemyRarity.percentageChance }, OutsideEnemies = toEArr(val.OutsideEnemies), DaytimeEnemies = toEArr(val.DaytimeEnemies), InsideEnemySpawnChanceThroughoutDay = Import(val.enemySpawnChanceThroughoutDay), OutsideEnemySpawnChanceThroughoutDay = Import(val.outsideEnemySpawnChanceThroughDay), DaytimeEnemySpawnChanceThroughoutDay = Import(val.daytimeEnemySpawnChanceThroughDay), EnemySpawnProbabilityRange = val.spawnProbabilityRange, DaytimeEnemySpawnProbabilityRange = val.daytimeEnemiesProbabilityRange, SnowFootprints = val.levelIncludesSnowFootprints }); } StaticData result = default(StaticData); result.GameVersion = gameVersion; result.ModVersion = "0.1.4"; result.ImportTime = DateTimeOffset.UtcNow.ToUnixTimeSeconds(); result.NavSizeLimitValues = enumToDict<NavSizeLimit>(); result.EnemySizeValues = enumToDict<EnemySize>(); result.EnemyWaterTypeValues = enumToDict<EnemyWaterType>(); result.LevelWeatherTypeValues = enumToDict<LevelWeatherType>(); result.ItemTable = ItemTable.ToArray(); result.EnemyTable = EnemyTable.ToArray(); result.Levels = list.ToArray(); return result; int GetOrImportEnemyType(EnemyType gEnemyType) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown int num = 0; foreach (EnemyType item in EnemyTable) { if (item._imported_from != null && (Object)(object)gEnemyType == (Object)(EnemyType)item._imported_from) { return num; } num++; } EnemyTable.Add(Import(gEnemyType)); return num; } int GetOrImportItemType(Item item) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown int num2 = 0; foreach (ItemType item2 in ItemTable) { if (item2._imported_from != null && (Object)(object)item == (Object)(Item)item2._imported_from) { return num2; } num2++; } ItemTable.Add(Import(item)); return num2; } static Dictionary<int, string> enumToDict<T>() where T : struct, Enum { return ((int[])Enum.GetValues(typeof(T))).ToDictionary((int v) => v, (int v) => Enum.GetName(typeof(T), v)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] Level.SpawnableEnemy[] toEArr(IEnumerable<SpawnableEnemyWithRarity>? enumerable) { return enumerable?.Select(delegate(SpawnableEnemyWithRarity i) { Level.SpawnableEnemy result2 = default(Level.SpawnableEnemy); result2.EnemyIndex = GetOrImportEnemyType(i.enemyType); result2.Rarity = i.rarity; return result2; }).ToArray() ?? Array.Empty<Level.SpawnableEnemy>(); } } } public struct AnimationCurve { public struct Keyframe { public float time; public float value; public float inTangent; public float outTangent; public float inWeight; public float outWeight; } public Keyframe[] keys; } public struct Color { public float r; public float g; public float b; public float a; } public struct Vector3 { public float x; public float y; public float z; } public struct ItemType { public int Id; public string Name; public bool LockedInDemo; public string PrefabName; public string ItemIcon; public string[] SpawnPositionTypes; public bool TwoHanded; public bool TwoHandedAnimation; public bool DisableHandsOnWall; public bool CanBeGrabbedBeforeGameStart; public bool DisallowUtilitySlot; public float Weight; public bool IsTrigger; public bool HoldButtonUse; public bool SpawnsOnGround; public bool IsConductive; public bool IsScrap; public int Value; public int MaxValue; public int MinValue; public int MaxSalePercentage; public bool UsesBattery; public float BatteryUsage; public bool AutomaticallySetUsingPower; public string GrabAnimation; public float GrabAnimationTime; public string UseAnimation; public string PocketAnimation; public string ThrowAnimation; public string GrabSFX; public string DropSFX; public string PocketSFX; public string ThrowSFX; public bool SyncGrabFunction; public bool SyncUseFunction; public bool SyncDiscardFunction; public bool SyncInteractLRFunction; public bool SaveItemVariable; public bool IsWeapon; public string[] ToolTips; public float VerticalOffset; public int FloorYOffset; public bool DropAheadOfPlayer; public Vector3 RestingRotation; public Vector3 RotationOffset; public Vector3 PositionOffset; public bool MeshOffset; public string[] MeshVariants; public string[] MaterialVariants; public string[] ClinkAudios; public bool UsableInSpecialAnimations; public bool CanBeInspected; [JsonIgnore] internal object? _imported_from; } public struct EnemyType { public struct Animation { public string Name; public string AudioClip; public float Length; public int Priority; } public string Name; public string PrefabName; public AnimationCurve ProbabilityCurve; public bool Disabled; public bool SpawnFromWeeds; public AnimationCurve SpawnFalloff; public bool UseSpawnFalloff; public int SpawnInGroups; public bool RequireNestObject; public float PowerLevel; public int DiversityPowerLevel; public int MaxCount; public bool IsOutsideEnemy; public bool IsDaytimeEnemy; public int IncreasedChanceInterior; public float NormalizedTimeInDayToLeave; public float StunTimeMultiplier; public float DoorSpeedMultiplier; public float StunGameDifficultyMultiplier; public bool CanBeStunned; public bool CanDie; public bool CanBeDestroyed; public bool DestroyOnDeath; public bool CanSeeThroughFog; public bool DisableAnimatorWhenFar; public float PushPlayerForce; public float PushPlayerDistance; public int SizeLimit; public int EnemySize; public int WaterType; public float TimeToPlayAudio; public float LoudnessMultiplier; public string OverrideVentSFX; public string NestPrefabName; public float NestPrefabWidth; public float NestDistanceFromShip; public bool UseMinEnemyThresholdForNest; public int MinEnemiesToSpawnNest; public string HitBodySFX; public string HitEnemyVoiceSFX; public string DeathSFX; public string StunSFX; public string[] MiscAudioClips; public Animation[] MiscAnimations; [JsonIgnore] internal object? _imported_from; } public struct Level { public struct WeatherWithVariables { public int Weather; public int Variable1; public int Variable2; public Color Color; } public struct LevelAmbience { public struct WeightedAudioClip { public string AudioClip; public int Rarity; } public string[] insanityMusicAudios; public string[] insideAmbience; public WeightedAudioClip[] insideAmbienceInsanity; public string[] shipAmbience; public WeightedAudioClip[] shipAmbienceInsanity; public string[] outsideAmbience; public WeightedAudioClip[] outsideAmbienceInsanity; } public struct Interior { public int Id; public int Rarity; public bool OverridesLevelAmbience; public LevelAmbience LevelAmbience; } public struct InsideHazard { public struct HazardType { public string PrefabName; public bool SpawnFacingAwayFromWall; public bool SpawnFacingWall; public bool SpawnWithBackToWall; public bool SpawnWithBackFlushAgainstWall; public bool RequireDistanceBetweenSpawns; public bool DisallowSpawningNearEntrances; public bool SpawnInMineshaft; } public HazardType Hazard; public AnimationCurve SpawnAmount; } public struct OutsideHazard { public struct HazardType { public string PrefabName; public bool SpawnFacingAwayFromWall; public int ObjectWidth; public bool DestroyTrees; public string[] SpawnableFloorTags; public Vector3 RotationOffset; } public HazardType Hazard; public AnimationCurve SpawnAmount; } public struct SpawnableItem { public int ItemIndex; public int Rarity; } public struct SpawnableEnemy { public int EnemyIndex; public int Rarity; } public struct OverrideSpawnableEnemy { public int EnemyIndex; public float Chance; } public string Name; public string SceneName; public bool LockedForDemo; public bool SpawnEnemiesAndScrap; public string LevelDescription; public string RiskLevel; public float LandingTime; public string VideoPreview; public string LevelIcon; public bool HasTime; public float OffsetFromGlobalTime; public float DaySpeedMultiplier; public bool HasStaticWeather; public int StaticWeather; public WeatherWithVariables[] Weathers; public float InteriorSizeMultiplier; public Interior[] Interiors; public bool HasAmbienceClips; public LevelAmbience AmbienceClips; public InsideHazard[] SpawnableInsideObjects; public OutsideHazard[] SpawnableOutsideObjects; public bool CanSpawnMold; public int MoldSpreadIterations; public int MoldStartPosition; public int MoldType; public SpawnableItem[] SpawnableScrap; public int MinScrap; public int MaxScrap; public int MinTotalScrapValue; public int MaxTotalScrapValue; public int MaxEnemyPowerCount; public int MaxOutsideEnemyPowerCount; public int MaxDaytimeEnemyPowerCount; public int MaxInsideDiversityPowerCount; public int MaxOutsideDiversityPowerCount; public SpawnableEnemy[] InsideEnemies; public OverrideSpawnableEnemy SpecialEnemyRarity; public SpawnableEnemy[] OutsideEnemies; public SpawnableEnemy[] DaytimeEnemies; public AnimationCurve InsideEnemySpawnChanceThroughoutDay; public AnimationCurve OutsideEnemySpawnChanceThroughoutDay; public AnimationCurve DaytimeEnemySpawnChanceThroughoutDay; public float EnemySpawnProbabilityRange; public float DaytimeEnemySpawnProbabilityRange; public bool SnowFootprints; } public int GameVersion; public string ModVersion; public long ImportTime; public Dictionary<int, string> NavSizeLimitValues; public Dictionary<int, string> EnemySizeValues; public Dictionary<int, string> EnemyWaterTypeValues; public Dictionary<int, string> LevelWeatherTypeValues; public ItemType[] ItemTable; public EnemyType[] EnemyTable; public Level[] Levels; [MethodImpl(MethodImplOptions.AggressiveInlining)] private static string[] toSArr<T>(IEnumerable<T>? enumerable) { return enumerable?.Select(delegate(T i) { object obj = i?.ToString(); if (obj == null) { obj = string.Empty; } return (string)obj; }).ToArray() ?? Array.Empty<string>(); } public static StaticData Deserialize(JsonReader reader) { return JsonSerializer.Create().Deserialize<StaticData>(reader); } public void Serialize(JsonWriter writer) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Expected O, but got Unknown JsonSerializer.Create(new JsonSerializerSettings()).Serialize(writer, (object)this); } } [HarmonyPatch(typeof(StartOfRound), "Awake")] internal static class StartOfRound_Awake { private static void Postfix(ref StartOfRound __instance) { try { if (LethalModUtils.Instance.exportStaticData.Value) { LethalModUtils.Instance.ExportStaticData(__instance); } } catch (Exception ex) { Debug.LogException(ex); } } } public static class MyPluginInfo { public const string PLUGIN_GUID = "baer1.LethalModUtils"; public const string PLUGIN_NAME = "LethalModUtils"; public const string PLUGIN_VERSION = "0.1.4"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }