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 RNGConfigurator v1.2.0
RNGConfigurator.dll
Decompiled a year agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; 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 BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("RNGConfigurator")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Allows the host to override the chance of random events.")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0")] [assembly: AssemblyProduct("RNGConfigurator")] [assembly: AssemblyTitle("RNGConfigurator")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RNGConfigurator { [HarmonyPatch] internal static class FogPatches { [HarmonyTranspiler] [HarmonyPatch(typeof(RoundManager), "RefreshEnemiesList")] private static IEnumerable<CodeInstruction> OverrideChance(IEnumerable<CodeInstruction> instructions) { //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); Label? label = default(Label?); for (int i = 11; i < list.Count; i++) { if (CodeInstructionExtensions.Branches(list[i - 11], ref label) && CodeInstructionExtensions.LoadsField(list[i - 9], AccessTools.Field(typeof(RoundManager), "indoorFog"), false) && CodeInstructionExtensions.Calls(list[i - 8], AccessTools.PropertyGetter(typeof(Component), "gameObject")) && CodeInstructionExtensions.Calls(list[i - 4], Plugin.randomNextIntInt) && CodeInstructionExtensions.Calls(list[i - 1], AccessTools.Method(typeof(GameObject), "SetActive", (Type[])null, (Type[])null)) && list[i].labels.Contains((Label)list[i - 11].operand)) { list.RemoveRange(i -= 6, 5); list.InsertRange(i, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[3] { CodeInstruction.Call(typeof(Random), "NextDouble", (Type[])null, (Type[])null), new CodeInstruction(OpCodes.Ldc_R8, (object)Plugin.fogChance), new CodeInstruction(OpCodes.Clt_Un, (object)null) })); return list; } } throw Plugin.PatchFailedException; } [HarmonyTranspiler] [HarmonyPatch(typeof(RoundManager), "RefreshEnemiesList")] private static IEnumerable<CodeInstruction> OverrideInfestedChance(IEnumerable<CodeInstruction> instructions) { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); for (int i = 8; i < list.Count; i++) { if (CodeInstructionExtensions.LoadsField(list[i - 8], AccessTools.Field(typeof(RoundManager), "indoorFog"), false) && CodeInstructionExtensions.Calls(list[i - 7], AccessTools.PropertyGetter(typeof(Component), "gameObject")) && CodeInstructionExtensions.Calls(list[i - 3], Plugin.randomNextIntInt) && CodeInstructionExtensions.Calls(list[i], AccessTools.Method(typeof(GameObject), "SetActive", (Type[])null, (Type[])null))) { list.RemoveRange(i -= 5, 5); list.InsertRange(i, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[3] { CodeInstruction.Call(typeof(Random), "NextDouble", (Type[])null, (Type[])null), new CodeInstruction(OpCodes.Ldc_R8, (object)Plugin.fogInfestedChance), new CodeInstruction(OpCodes.Clt_Un, (object)null) })); return list; } } throw Plugin.PatchFailedException; } } [HarmonyPatch] internal static class InfestationPatches { [HarmonyTranspiler] [HarmonyPatch(typeof(RoundManager), "RefreshEnemiesList")] private static IEnumerable<CodeInstruction> OverrideChance(IEnumerable<CodeInstruction> instructions) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); Label? label = default(Label?); for (int i = 12; i < list.Count; i++) { if (CodeInstructionExtensions.Branches(list[i - 12], ref label) && CodeInstructionExtensions.IsLdloc(list[i - 11], (LocalBuilder)null) && CodeInstructionExtensions.Calls(list[i - 8], Plugin.randomNextIntInt) && CodeInstructionExtensions.Branches(list[i - 6], ref label) && CodeInstructionExtensions.IsLdloc(list[i - 5], (LocalBuilder)null) && CodeInstructionExtensions.Calls(list[i - 2], Plugin.randomNextIntInt) && CodeInstructionExtensions.Branches(list[i], ref label)) { list[i - 12] = new CodeInstruction(OpCodes.Pop, (object)null); list.RemoveRange(i -= 10, 10); list.InsertRange(i, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[2] { CodeInstruction.Call(typeof(Random), "NextDouble", (Type[])null, (Type[])null), new CodeInstruction(OpCodes.Ldc_R8, (object)Plugin.infestationChance) })); return list; } } throw Plugin.PatchFailedException; } } [HarmonyPatch] internal static class MeteorPatches { [HarmonyTranspiler] [HarmonyPatch(typeof(TimeOfDay), "DecideRandomDayEvents")] private static IEnumerable<CodeInstruction> OverrideChance(IEnumerable<CodeInstruction> instructions) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); LocalBuilder localBuilder = null; Label? label = default(Label?); for (int i = 4; i < list.Count; i++) { if (CodeInstructionExtensions.LoadsField(list[i - 1], AccessTools.Field(typeof(TimeOfDay), "overrideMeteorChance"), false) && CodeInstructionExtensions.IsStloc(list[i], (LocalBuilder)null)) { localBuilder = (LocalBuilder)list[i].operand; } if (CodeInstructionExtensions.Calls(list[i - 2], Plugin.randomNextIntInt) && CodeInstructionExtensions.IsLdloc(list[i - 1], localBuilder) && CodeInstructionExtensions.Branches(list[i], ref label)) { list.RemoveRange(i -= 4, 4); list.InsertRange(i, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[2] { CodeInstruction.Call(typeof(Random), "NextDouble", (Type[])null, (Type[])null), new CodeInstruction(OpCodes.Ldc_R8, (object)Plugin.meteorChance) })); return list; } } throw Plugin.PatchFailedException; } [HarmonyTranspiler] [HarmonyPatch(typeof(TimeOfDay), "DecideRandomDayEvents")] private static IEnumerable<CodeInstruction> OverrideStartTime(IEnumerable<CodeInstruction> instructions) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); for (int i = 6; i < list.Count; i++) { if (CodeInstructionExtensions.Calls(list[i - 4], Plugin.randomNextIntInt) && list[i - 3].opcode == OpCodes.Conv_R4 && list[i - 1].opcode == OpCodes.Div && CodeInstructionExtensions.StoresField(list[i], AccessTools.Field(typeof(TimeOfDay), "meteorShowerAtTime"))) { list.RemoveRange(i -= 6, 6); list.InsertRange(i, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[6] { CodeInstruction.Call(typeof(Random), "NextDouble", (Type[])null, (Type[])null), new CodeInstruction(OpCodes.Ldc_R8, (object)(Plugin.meteorMaxStart - Plugin.meteorMinStart)), new CodeInstruction(OpCodes.Mul, (object)null), new CodeInstruction(OpCodes.Ldc_R8, (object)Plugin.meteorMinStart), new CodeInstruction(OpCodes.Add, (object)null), new CodeInstruction(OpCodes.Conv_R4, (object)null) })); return list; } } throw Plugin.PatchFailedException; } [HarmonyTranspiler] [HarmonyPatch(typeof(TimeOfDay), "MoveTimeOfDay")] private static IEnumerable<CodeInstruction> FixZeroStartTime(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> list = instructions.ToList(); Label? label = default(Label?); for (int i = 2; i < list.Count; i++) { if (CodeInstructionExtensions.LoadsField(list[i - 2], AccessTools.Field(typeof(TimeOfDay), "meteorShowerAtTime"), false) && CodeInstructionExtensions.Is(list[i - 1], OpCodes.Ldc_R4, (object)0) && CodeInstructionExtensions.Branches(list[i], ref label)) { list[i].opcode = OpCodes.Blt_Un; return list; } } throw Plugin.PatchFailedException; } [HarmonyTranspiler] [HarmonyPatch(typeof(MeteorShowers), "SetStartMeteorShower")] private static IEnumerable<CodeInstruction> FixLateStartTime(IEnumerable<CodeInstruction> instructions) { //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); Label? label = default(Label?); for (int i = 3; i < list.Count; i++) { if (CodeInstructionExtensions.LoadsField(list[i - 2], AccessTools.Field(typeof(TimeOfDay), "normalizedTimeOfDay"), false) && list[i - 1].opcode == OpCodes.Ldc_R4 && CodeInstructionExtensions.Branches(list[i], ref label)) { list.RemoveRange(i -= 3, 4); list.Insert(i, new CodeInstruction(OpCodes.Br, (object)label)); return list; } } throw Plugin.PatchFailedException; } } [BepInPlugin("RNGConfigurator", "RNGConfigurator", "1.2.0")] public class Plugin : BaseUnityPlugin { internal static MethodInfo randomNextIntInt = AccessTools.Method(typeof(Random), "Next", new Type[2] { typeof(int), typeof(int) }, (Type[])null); internal static double sidChance; internal static double fogChance; internal static double fogInfestedChance; internal static double infestationChance; internal static double meteorChance; internal static double meteorMinStart; internal static double meteorMaxStart; private static readonly Harmony harmony = new Harmony("RNGConfigurator"); internal static Exception PatchFailedException => new InvalidOperationException("Failed to find matching instructions."); private void Awake() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Expected O, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Expected O, but got Unknown //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Expected O, but got Unknown //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown sidChance = ((BaseUnityPlugin)this).Config.Bind<double>("Single Item Day", "Chance", 5.2, new ConfigDescription("The chance of any given day being a single item day.", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.0, 100.0), Array.Empty<object>())).Value / 100.0; fogChance = ((BaseUnityPlugin)this).Config.Bind<double>("Indoor Fog", "Chance", 2.0, new ConfigDescription("The chance of a day without an infestation having indoor fog.", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.0, 100.0), Array.Empty<object>())).Value / 100.0; fogInfestedChance = ((BaseUnityPlugin)this).Config.Bind<double>("Indoor Fog", "Infested Chance", 20.0, new ConfigDescription("The chance of a day with an infestation having indoor fog.", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.0, 100.0), Array.Empty<object>())).Value / 100.0; infestationChance = ((BaseUnityPlugin)this).Config.Bind<double>("Infestation", "Chance", 2.91, new ConfigDescription("The chance of an infestation occurring on any given day.", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.0, 100.0), Array.Empty<object>())).Value / 100.0; meteorChance = ((BaseUnityPlugin)this).Config.Bind<double>("Meteor Shower", "Chance", 0.7, new ConfigDescription("The chance of a meteor shower occurring on any given day.", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.0, 100.0), Array.Empty<object>())).Value / 100.0; meteorMinStart = ((BaseUnityPlugin)this).Config.Bind<double>("Meteor Shower", "Min Start Time", 5.0, new ConfigDescription("The earliest normalized time a meteor shower can start.", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.0, 100.0), Array.Empty<object>())).Value / 100.0; meteorMaxStart = ((BaseUnityPlugin)this).Config.Bind<double>("Meteor Shower", "Max Start Time", 80.0, new ConfigDescription("The latest normalized time a meteor shower can start.", (AcceptableValueBase)(object)new AcceptableValueRange<double>(0.0, 100.0), Array.Empty<object>())).Value / 100.0; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Config loaded successfully."); harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Patches completed successfully."); } } [HarmonyPatch] internal static class SIDPatches { [HarmonyTranspiler] [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")] private static IEnumerable<CodeInstruction> OverrideChance(IEnumerable<CodeInstruction> instructions) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown List<CodeInstruction> list = instructions.ToList(); LocalBuilder localBuilder = null; Label? label = default(Label?); Label? label2 = default(Label?); for (int i = 10; i < list.Count; i++) { if (list[i - 8].opcode == OpCodes.Ldc_I4_M1 && CodeInstructionExtensions.IsStloc(list[i - 7], (LocalBuilder)null) && CodeInstructionExtensions.Calls(list[i - 2], Plugin.randomNextIntInt) && CodeInstructionExtensions.Branches(list[i], ref label)) { localBuilder = (LocalBuilder)list[i - 7].operand; list.RemoveRange(i -= 4, 5); list.InsertRange(i, new <>z__ReadOnlyArray<CodeInstruction>((CodeInstruction[])(object)new CodeInstruction[3] { CodeInstruction.Call(typeof(Random), "NextDouble", (Type[])null, (Type[])null), new CodeInstruction(OpCodes.Ldc_R8, (object)Plugin.sidChance), new CodeInstruction(OpCodes.Bge, (object)label) })); i += 3; } if (CodeInstructionExtensions.IsLdloc(list[i - 10], (LocalBuilder)null) && CodeInstructionExtensions.Branches(list[i - 9], ref label2) && CodeInstructionExtensions.Calls(list[i - 4], Plugin.randomNextIntInt) && CodeInstructionExtensions.Branches(list[i - 2], ref label2) && list[i - 1].opcode == OpCodes.Ldc_I4_M1 && CodeInstructionExtensions.IsStloc(list[i], localBuilder)) { list.RemoveRange(i - 1, 2); return list; } } throw Plugin.PatchFailedException; } } public static class PluginInfo { public const string PLUGIN_GUID = "RNGConfigurator"; public const string PLUGIN_NAME = "RNGConfigurator"; public const string PLUGIN_VERSION = "1.2.0"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => _items.Length; T IReadOnlyList<T>.this[int index] => _items[index]; int ICollection<T>.Count => _items.Length; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return ((IEnumerable<T>)_items).GetEnumerator(); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return ((ICollection<T>)_items).Contains(item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { ((ICollection<T>)_items).CopyTo(array, arrayIndex); } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { return ((IList<T>)_items).IndexOf(item); } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } }