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 LCUtils v1.0.5
plugins/LCUtils.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using LethalConfig; using LethalConfig.ConfigItems; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("LethalConfig")] [assembly: AssemblyCompany("DBJ")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A compilation of utils specific to Lethal Company")] [assembly: AssemblyFileVersion("1.0.5.0")] [assembly: AssemblyInformationalVersion("1.0.5+92c067e7d6109daa8a8b8c70a36ccd7ce203f329")] [assembly: AssemblyProduct("LCUtils")] [assembly: AssemblyTitle("com.github.decibillyjoel.LCUtils")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/DecibillyJoel/LCUtils")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.5.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; } } } internal static class BepPluginInfo { public const string PLUGIN_GUID = "com.github.decibillyjoel.LCUtils"; public const string PLUGIN_NAME = "LCUtils"; public const string PLUGIN_TS_TEAM = "DBJ"; public const string PLUGIN_VERSION = "1.0.5"; } namespace LCUtils { public class BlendedRandom : Random { private readonly Random _random1; private readonly Random _random2; private readonly double _blendFactor; private readonly double _blendFactorInv; public BlendedRandom(Random? random1, Random? random2, double blendFactor) { if (blendFactor < 0.0 || blendFactor > 1.0) { throw new ArgumentOutOfRangeException("blendFactor", "blendFactor must be between 0.0 and 1.0."); } _random1 = random1 ?? new Random(); _random2 = random2 ?? new Random(); _blendFactor = blendFactor; _blendFactorInv = 1.0 - blendFactor; } public override double NextDouble() { return (_random1.NextDouble() * _blendFactor + _random2.NextDouble() * _blendFactorInv) % 1.0; } public override int Next() { return Next(0, int.MaxValue); } public override int Next(int maxValue) { if (maxValue <= 0) { throw new ArgumentOutOfRangeException("maxValue", "maxValue must be greater than 0."); } return Next(0, maxValue); } public override int Next(int minValue, int maxValue) { if (maxValue < minValue) { throw new ArgumentOutOfRangeException("maxValue", "maxValue must be greater than minValue."); } return (int)(NextDouble() * (double)(maxValue - minValue) + (double)minValue); } } public static class LethalConfigNicerizer { internal const string LethalConfig_GUID = "ainavt.lc.lethalconfig"; public static bool CanHasNicerizationPlease => Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static ConfigEntry<T> Nicerize<T>(ConfigEntry<T> entry, bool restartRequired = false, Assembly? callingAssembly = null) { if (entry is ConfigEntry<int>) { if (CanHasNicerizationPlease) { AddConfigItem(entry as ConfigEntry<int>, restartRequired, callingAssembly ?? Assembly.GetCallingAssembly()); } } else if (entry is ConfigEntry<float>) { if (CanHasNicerizationPlease) { AddConfigItem(entry as ConfigEntry<float>, restartRequired, callingAssembly ?? Assembly.GetCallingAssembly()); } } else if (entry is ConfigEntry<bool>) { if (CanHasNicerizationPlease) { AddConfigItem(entry as ConfigEntry<bool>, restartRequired, callingAssembly ?? Assembly.GetCallingAssembly()); } } else if (entry is ConfigEntry<string>) { if (CanHasNicerizationPlease) { AddConfigItem(entry as ConfigEntry<string>, restartRequired, callingAssembly ?? Assembly.GetCallingAssembly()); } } else { if (!(entry is ConfigEntry<Enum>)) { throw new ArgumentException($"[LCUtils.LethalConfigNicerizer.Nicerize] Cannot Nicerize ConfigEntry<{typeof(T)}>!"); } if (CanHasNicerizationPlease) { AddConfigItem(entry as ConfigEntry<Enum>, restartRequired, callingAssembly ?? Assembly.GetCallingAssembly()); } } return entry; } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigItem(ConfigEntry<int> entry, bool restartRequired = false, Assembly? callingAssembly = null) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (((ConfigEntryBase)entry).Description.AcceptableValues != null) { LethalConfigManager.AddConfigItem((BaseConfigItem)new IntSliderConfigItem(entry, restartRequired), callingAssembly); } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(entry, restartRequired), callingAssembly); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigItem(ConfigEntry<float> entry, bool restartRequired = false, Assembly? callingAssembly = null) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (((ConfigEntryBase)entry).Description.AcceptableValues != null) { LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatSliderConfigItem(entry, restartRequired), callingAssembly); } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(entry, restartRequired), callingAssembly); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigItem(ConfigEntry<bool> entry, bool restartRequired = false, Assembly? callingAssembly = null) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(entry, restartRequired), callingAssembly); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigItem(ConfigEntry<string> entry, bool restartRequired = false, Assembly? callingAssembly = null) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (((ConfigEntryBase)entry).Description.AcceptableValues != null) { LethalConfigManager.AddConfigItem((BaseConfigItem)new TextDropDownConfigItem(entry, restartRequired), callingAssembly); } else { LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(entry, restartRequired), callingAssembly); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfigItem(ConfigEntry<Enum> entry, bool restartRequired = false, Assembly? callingAssembly = null) { LethalConfigManager.AddConfigItem((BaseConfigItem)(object)new EnumDropDownConfigItem<Enum>(entry, restartRequired), callingAssembly); } } [BepInPlugin("com.github.decibillyjoel.LCUtils", "DBJ.LCUtils", "1.0.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PLUGIN_GUID = "com.github.decibillyjoel.LCUtils"; public const string PLUGIN_NAME = "LCUtils"; public const string PLUGIN_VERSION = "1.0.5"; public const string PLUGIN_TS_TEAM = "DBJ"; public static ManualLogSource PluginLogger; public static void Log(LogLevel logLevel, string logMessage) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) PluginLogger.Log(logLevel, (object)(logMessage ?? "")); } public static void Log(string logMessage) { Log((LogLevel)16, logMessage); } private void Awake() { PluginLogger = ((BaseUnityPlugin)this).Logger; Log("[v1.0.5] Finished loading!"); } } public static class Probability { public static int GetRandomWeightedIndex(List<double> weights, Random? randomSeed = null) { if (weights == null || weights.Count == 0) { Plugin.Log((LogLevel)4, "[libs.Probability.GetRandomWeightedIndex] Could not get random weighted index; list is empty or null."); return -1; } if (weights.Any((double weight) => weight < 0.0)) { Plugin.Log((LogLevel)4, "[libs.Probability.GetRandomWeightedIndex] Could not get random weighted index; list contains negative weights."); return -1; } if (randomSeed == null) { randomSeed = new Random(); } double num = weights.Sum(); if (num <= 0.0) { return randomSeed.Next(0, weights.Count); } double randomValue = randomSeed.NextDouble() * weights.Sum(); double accumulatedValue = 0.0; return weights.FindIndex((double weight) => (accumulatedValue += weight) > randomValue); } public static int GetRandomWeightedIndex(List<int> weights, Random? randomSeed = null) { if (weights == null || weights.Count == 0) { Plugin.Log((LogLevel)4, "[libs.Probability.GetRandomWeightedIndex] Could not get random weighted index; list is empty or null."); return -1; } if (weights.Any((int weight) => weight < 0)) { Plugin.Log((LogLevel)4, "[libs.Probability.GetRandomWeightedIndex] Could not get random weighted index; list contains negative weights."); return -1; } if (randomSeed == null) { randomSeed = new Random(); } int num = weights.Sum(); if (num <= 0) { return randomSeed.Next(0, weights.Count); } int randomValue = randomSeed.Next(0, num); int accumulatedValue = 0; return weights.FindIndex((int weight) => (accumulatedValue += weight) > randomValue); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }