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 Infestation Rework v1.2.0
OreoM.InfestationRework.dll
Decompiled 5 months agousing System; 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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using InfestationRework.Network; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using Microsoft.CodeAnalysis; using OreoM.InfestationRework.NetcodePatcher; using Unity.Netcode; 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("Unity.Netcode.Runtime")] [assembly: AssemblyCompany("OreoM.InfestationRework")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.0.0")] [assembly: AssemblyInformationalVersion("1.2.0")] [assembly: AssemblyProduct("InfestationRework")] [assembly: AssemblyTitle("OreoM.InfestationRework")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] 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 InfestationRework { [BepInPlugin("OreoM.InfestationRework", "InfestationRework", "1.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class InfestationRework : BaseUnityPlugin { public const string LethalConfigGUID = "ainavt.lc.lethalconfig"; public InfestationReworkConfig ConfigOptions; public static InfestationRework Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } internal static Harmony? Harmony { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; Instance = this; NetcodePatch(); Patch(); Logger.LogInfo((object)"OreoM.InfestationRework v1.2.0 has loaded!"); } private void NetcodePatch() { Type[] types = Assembly.GetExecutingAssembly().GetTypes(); Type[] array = types; foreach (Type type in array) { MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array2 = methods; foreach (MethodInfo methodInfo in array2) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } } internal 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("OreoM.InfestationRework"); } Logger.LogDebug((object)"Patching..."); Harmony.PatchAll(); Logger.LogDebug((object)"Finished patching!"); } internal static void Unpatch() { Logger.LogDebug((object)"Unpatching..."); Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } Logger.LogDebug((object)"Finished unpatching!"); } } public class InfestationReworkConfig { public bool lethalConfigLoaded; public readonly ConfigEntry<SpawnMethod> spawnMethod; public readonly ConfigEntry<int> baseChance; public readonly ConfigEntry<int> normalFogChance; public readonly ConfigEntry<int> infestFogChance; public readonly ConfigEntry<int> targetChance; public readonly ConfigEntry<int> maxSpawn; public readonly Dictionary<EnemyType, ConfigEntry<bool>> selectableEnemies; public InfestationReworkConfig(ConfigFile cfg, EnemyType[] allEnemies) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown lethalConfigLoaded = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); cfg.SaveOnConfigSet = false; spawnMethod = cfg.Bind<SpawnMethod>("General", "Spawn Method", SpawnMethod.CUSTOM, "Choose between vanilla's and this mod's spawning algorithm"); baseChance = cfg.Bind<int>("General", "Base Chance", 4, new ConfigDescription("% chance of an infestation any day", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); normalFogChance = cfg.Bind<int>("General", "Normal Fog Chance", 2, new ConfigDescription("% chance that a non-infestation day has indoor fog", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); infestFogChance = cfg.Bind<int>("General", "Infestation Fog Chance", 20, new ConfigDescription("% chance that an infestation day has indoor fog", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); targetChance = cfg.Bind<int>("General", "Target Chance", 60, new ConfigDescription("% chance of spawning the current infestation enemy when using the CUSTOM spawn method", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>())); maxSpawn = cfg.Bind<int>("General", "Overwrite Max Spawn", 0, new ConfigDescription("Overwrite the max spawn of the infestation target, leave at 0 to use the enemy's vanilla value", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>())); selectableEnemies = new Dictionary<EnemyType, ConfigEntry<bool>>(); foreach (EnemyType val in allEnemies) { if (val.isDaytimeEnemy || val.isOutsideEnemy) { continue; } if (selectableEnemies.ContainsKey(val)) { InfestationRework.Logger.LogWarning((object)(val.enemyName + " has duplicate entries, skipping...")); continue; } HashSet<char> invalidChar = new HashSet<char> { '\n', '\t', ' ', '\\', '[', ']', '\'', '"' }; ConfigEntry<bool> value = cfg.Bind<bool>("General.Targets", new string(val.enemyName.Where((char c) => !invalidChar.Contains(c)).ToArray()), val.enemyName == "Nutcracker" || val.enemyName == "HoarderBug", "Can choose " + val.enemyName + " for infestations"); selectableEnemies[val] = value; } ClearOrphanedEntries(cfg); cfg.Save(); cfg.SaveOnConfigSet = true; if (lethalConfigLoaded) { AddLethalConfigItems(); ConfigLethalConfigModEntry(); } } private void ClearOrphanedEntries(ConfigFile cfg) { PropertyInfo propertyInfo = AccessTools.Property(typeof(ConfigFile), "OrphanedEntries"); Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)propertyInfo.GetValue(cfg); dictionary.Clear(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private void AddLethalConfigItems() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown //IL_00b0: 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_00bc: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown EnumDropDownConfigItem<SpawnMethod> val = new EnumDropDownConfigItem<SpawnMethod>(spawnMethod, false); ConfigEntry<int> obj = baseChance; IntSliderOptions val2 = new IntSliderOptions(); ((BaseRangeOptions<int>)val2).Min = 0; ((BaseRangeOptions<int>)val2).Max = 100; ((BaseOptions)val2).RequiresRestart = false; IntSliderConfigItem val3 = new IntSliderConfigItem(obj, val2); ConfigEntry<int> obj2 = normalFogChance; IntSliderOptions val4 = new IntSliderOptions(); ((BaseRangeOptions<int>)val4).Min = 0; ((BaseRangeOptions<int>)val4).Max = 100; ((BaseOptions)val4).RequiresRestart = false; IntSliderConfigItem val5 = new IntSliderConfigItem(obj2, val4); ConfigEntry<int> obj3 = infestFogChance; IntSliderOptions val6 = new IntSliderOptions(); ((BaseRangeOptions<int>)val6).Min = 0; ((BaseRangeOptions<int>)val6).Max = 100; ((BaseOptions)val6).RequiresRestart = false; IntSliderConfigItem val7 = new IntSliderConfigItem(obj3, val6); ConfigEntry<int> obj4 = targetChance; IntSliderOptions val8 = new IntSliderOptions(); ((BaseRangeOptions<int>)val8).Min = 0; ((BaseRangeOptions<int>)val8).Max = 100; ((BaseOptions)val8).RequiresRestart = false; IntSliderConfigItem val9 = new IntSliderConfigItem(obj4, val8); ConfigEntry<int> obj5 = maxSpawn; IntSliderOptions val10 = new IntSliderOptions(); ((BaseRangeOptions<int>)val10).Min = 0; ((BaseRangeOptions<int>)val10).Max = 20; ((BaseOptions)val10).RequiresRestart = false; IntSliderConfigItem val11 = new IntSliderConfigItem(obj5, val10); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val3); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val5); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val7); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val9); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val11); foreach (KeyValuePair<EnemyType, ConfigEntry<bool>> selectableEnemy in selectableEnemies) { BoolCheckBoxConfigItem val12 = new BoolCheckBoxConfigItem(selectableEnemy.Value, false); LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val12); } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] private void ConfigLethalConfigModEntry() { LethalConfigManager.SetModDescription("Infestation Rework configs"); } } public enum SpawnMethod { VANILLA, CUSTOM } public static class MyPluginInfo { public const string PLUGIN_GUID = "OreoM.InfestationRework"; public const string PLUGIN_NAME = "InfestationRework"; public const string PLUGIN_VERSION = "1.2.0"; } } namespace InfestationRework.Patches { [HarmonyPatch(typeof(GameNetworkManager))] internal class GameNetworkManagerPatches { [HarmonyPatch("Start")] [HarmonyPostfix] private static void PostStart(GameNetworkManager __instance) { InfestationReworkNetwork.CreateAndRegisterPrefab(); EnemyType[] allEnemies = Resources.FindObjectsOfTypeAll<EnemyType>(); InfestationRework.Instance.ConfigOptions = new InfestationReworkConfig(((BaseUnityPlugin)InfestationRework.Instance).Config, allEnemies); } [HarmonyPatch("Disconnect")] [HarmonyPrefix] private static void PreDisconnect(GameNetworkManager __instance) { InfestationReworkNetwork.DespawnNetworkHandler(); } } [HarmonyPatch(typeof(RoundManager))] internal class RoundManagerPatches { [HarmonyPatch("OnDestroy")] [HarmonyPrefix] private static void PreOnDestroy(RoundManager __instance) { if (__instance.enemyRushIndex > -1 && RoundManagerHelper.saveMaxEnemyCount != 0) { StartOfRound.Instance.currentLevel.Enemies[__instance.enemyRushIndex].enemyType.MaxCount = RoundManagerHelper.saveMaxEnemyCount; RoundManagerHelper.saveMaxEnemyCount = 0; } } [HarmonyPatch("DespawnPropsAtEndOfRound")] [HarmonyPrefix] private static void PreDespawnPropsAtEndOfRound(RoundManager __instance) { if (__instance.enemyRushIndex > -1 && RoundManagerHelper.saveMaxEnemyCount != 0) { StartOfRound.Instance.currentLevel.Enemies[__instance.enemyRushIndex].enemyType.MaxCount = RoundManagerHelper.saveMaxEnemyCount; RoundManagerHelper.saveMaxEnemyCount = 0; } } [HarmonyPatch("RefreshEnemiesList")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TranspileRefreshEnemyList(IEnumerable<CodeInstruction> codes) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown CodeInstruction[] array = (CodeInstruction[])(object)new CodeInstruction[2] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RoundManagerHelper), "OverwriteRushCode", (Type[])null, (Type[])null)) }; return new CodeMatcher(codes, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldloca_S, (object)null, (string)null) }).RemoveInstructions(152).Insert(array) .InstructionEnumeration(); } [HarmonyPatch("AssignRandomEnemyToVent")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TranspileAssignRandomEnemyToVent(IEnumerable<CodeInstruction> codes) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Expected O, but got Unknown //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Expected O, but got Unknown //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown CodeInstruction[] array = (CodeInstruction[])(object)new CodeInstruction[5] { new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldloc_1, (object)null), new CodeInstruction(OpCodes.Ldloc_3, (object)null), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RoundManagerHelper), "SpawnProbabilityCode", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stloc_S, (object)(sbyte)4) }; CodeInstruction[] array2 = (CodeInstruction[])(object)new CodeInstruction[6] { new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(RoundManager), "SpawnProbabilities")), new CodeInstruction(OpCodes.Callvirt, (object)AccessTools.Method(typeof(List<int>), "ToArray", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Ldarg_0, (object)null), new CodeInstruction(OpCodes.Ldfld, (object)AccessTools.Field(typeof(RoundManager), "EnemySpawnRandom")), new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RoundManagerHelper), "GetModifiedRandomWeightedIndex", (Type[])null, (Type[])null)), new CodeInstruction(OpCodes.Stloc_2, (object)null) }; return new CodeMatcher(codes, (ILGenerator)null).MatchForward(false, (CodeMatch[])(object)new CodeMatch[3] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(RoundManager), "enemyRushIndex"), (string)null), new CodeMatch((OpCode?)OpCodes.Ldc_I4_M1, (object)null, (string)null) }).RemoveInstructions(83).InsertAndAdvance(array) .MatchForward(false, (CodeMatch[])(object)new CodeMatch[2] { new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null), new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null) }) .Advance(2) .RemoveInstructions(6) .Insert(array2) .InstructionEnumeration(); } } internal static class RoundManagerHelper { public static int saveMaxEnemyCount; public static void OverwriteRushCode(RoundManager instance) { Random random = new Random(StartOfRound.Instance.randomMapSeed + 2145); int value = InfestationRework.Instance.ConfigOptions.baseChance.Value; int value2 = InfestationRework.Instance.ConfigOptions.normalFogChance.Value; int value3 = InfestationRework.Instance.ConfigOptions.infestFogChance.Value; if (random.Next(0, 100) < value) { if (((NetworkBehaviour)instance).IsServer || ((NetworkBehaviour)instance).IsHost) { InfestationReworkNetwork.Instance.shouldEnableIndoorFog.Value = random.Next(0, 100) < value3; } int num = -1; List<int> list = new List<int>(); for (int i = 0; i < instance.currentLevel.Enemies.Count; i++) { if (InfestationRework.Instance.ConfigOptions.selectableEnemies.TryGetValue(instance.currentLevel.Enemies[i].enemyType, out ConfigEntry<bool> value4) && value4.Value) { list.Add(i); } } if (list.Count == 0) { ((Component)instance.indoorFog).gameObject.SetActive(random.Next(0, 100) < value2); return; } num = (instance.enemyRushIndex = list[random.Next(0, list.Count)]); int value5 = InfestationRework.Instance.ConfigOptions.maxSpawn.Value; if (value5 != 0) { saveMaxEnemyCount = instance.currentLevel.Enemies[num].enemyType.MaxCount; instance.currentLevel.Enemies[num].enemyType.MaxCount = value5; } } else if (((NetworkBehaviour)instance).IsServer || ((NetworkBehaviour)instance).IsHost) { InfestationReworkNetwork.Instance.shouldEnableIndoorFog.Value = random.Next(0, 100) < value2; } } public static int SpawnProbabilityCode(RoundManager instance, EnemyType enemy, int index) { if (InfestationRework.Instance.ConfigOptions.spawnMethod.Value == SpawnMethod.VANILLA && instance.enemyRushIndex != -1) { if (instance.enemyRushIndex == index) { return 100; } return 1; } int num = 0; if (instance.increasedInsideEnemySpawnRateIndex == index) { return 100; } if (!enemy.useNumberSpawnedFalloff) { return (int)((double)instance.currentLevel.Enemies[index].rarity * (double)enemy.probabilityCurve.Evaluate(instance.timeScript.normalizedTimeOfDay)); } return (int)((double)instance.currentLevel.Enemies[index].rarity * (double)enemy.probabilityCurve.Evaluate(instance.timeScript.normalizedTimeOfDay) * (double)enemy.numberSpawnedFalloff.Evaluate((float)enemy.numberSpawned / 10f)); } public static int GetModifiedRandomWeightedIndex(RoundManager instance, int[] SpawnProbabilities, Random EnemySpawnRandom) { SpawnMethod value = InfestationRework.Instance.ConfigOptions.spawnMethod.Value; int value2 = InfestationRework.Instance.ConfigOptions.targetChance.Value; if (instance.enemyRushIndex != -1 && EnemySpawnRandom.Next(0, 100) < value2 && value == SpawnMethod.CUSTOM && !instance.EnemyCannotBeSpawned(instance.enemyRushIndex)) { return instance.enemyRushIndex; } return instance.GetRandomWeightedIndex(SpawnProbabilities, EnemySpawnRandom); } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatches { [HarmonyPatch("Awake")] [HarmonyPrefix] private static void PreAwake(StartOfRound __instance) { InfestationReworkNetwork.SpawnNetworkHandler(); } } } namespace InfestationRework.Network { internal class InfestationReworkNetwork : NetworkBehaviour { private static GameObject prefab; public NetworkVariable<bool> shouldEnableIndoorFog = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0); public static InfestationReworkNetwork Instance { get; private set; } public static void CreateAndRegisterPrefab() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)prefab != (Object)null)) { prefab = new GameObject("OreoM.InfestationRework Prefab"); GameObject obj = prefab; ((Object)obj).hideFlags = (HideFlags)(((Object)obj).hideFlags | 0x3D); NetworkObject val = prefab.AddComponent<NetworkObject>(); val.GlobalObjectIdHash = XXHash.Hash32(((Object)prefab).name); prefab.AddComponent<InfestationReworkNetwork>(); NetworkManager.Singleton.AddNetworkPrefab(prefab); InfestationRework.Logger.LogInfo((object)"Network prefab created and registered"); } } public static void SpawnNetworkHandler() { if (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost) { Object.Instantiate<GameObject>(prefab).GetComponent<NetworkObject>().Spawn(false); InfestationRework.Logger.LogInfo((object)"Network handler spawned"); } } public static void DespawnNetworkHandler() { if ((Object)(object)Instance != (Object)null && ((Component)Instance).gameObject.GetComponent<NetworkObject>().IsSpawned && (NetworkManager.Singleton.IsServer || NetworkManager.Singleton.IsHost)) { ((Component)Instance).gameObject.GetComponent<NetworkObject>().Despawn(true); InfestationRework.Logger.LogInfo((object)"Network handler despawned"); } } private void Awake() { Instance = this; } public override void OnNetworkSpawn() { NetworkVariable<bool> obj = shouldEnableIndoorFog; obj.OnValueChanged = (OnValueChangedDelegate<bool>)(object)Delegate.Combine((Delegate?)(object)obj.OnValueChanged, (Delegate?)(object)new OnValueChangedDelegate<bool>(ChangeIndoorFogState)); } private void ChangeIndoorFogState(bool pValue, bool nValue) { ((Component)RoundManager.Instance.indoorFog).gameObject.SetActive(nValue); } protected override void __initializeVariables() { if (shouldEnableIndoorFog == null) { throw new Exception("InfestationReworkNetwork.shouldEnableIndoorFog cannot be null. All NetworkVariableBase instances must be initialized."); } ((NetworkVariableBase)shouldEnableIndoorFog).Initialize((NetworkBehaviour)(object)this); ((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)shouldEnableIndoorFog, "shouldEnableIndoorFog"); base.NetworkVariableFields.Add((NetworkVariableBase)(object)shouldEnableIndoorFog); ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { ((NetworkBehaviour)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "InfestationReworkNetwork"; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } namespace __GEN { internal class NetworkVariableSerializationHelper { [RuntimeInitializeOnLoadMethod] internal static void InitializeSerialization() { NetworkVariableSerializationTypes.InitializeSerializer_UnmanagedByMemcpy<bool>(); NetworkVariableSerializationTypes.InitializeEqualityChecker_UnmanagedIEquatable<bool>(); } } } namespace OreoM.InfestationRework.NetcodePatcher { [AttributeUsage(AttributeTargets.Module)] internal class NetcodePatchedAssemblyAttribute : Attribute { } }