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 RoundManagerObjectReferenceFix v1.0.0
Plugin/RoundManagerObjectReferenceFix.dll
Decompiled 3 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RoundManagerObjectReferenceFix")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e30c57ba6afa7edb7fe68e4c477bb416e485c535")] [assembly: AssemblyProduct("RoundManagerObjectReferenceFix")] [assembly: AssemblyTitle("RoundManagerObjectReferenceFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.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.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 RoundManagerObjectReferenceFix { [BepInPlugin("RoundManagerObjectReferenceFix", "RoundManagerObjectReferenceFix", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ManualLogSource Logger; private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) Logger = ((BaseUnityPlugin)this).Logger; new Harmony("RoundManagerObjectReferenceFix").PatchAll(); Logger.LogInfo((object)"Plugin [RoundManagerObjectReferenceFix version: 1.0.0] is loaded!"); } } public static class PluginInfo { public const string PLUGIN_GUID = "RoundManagerObjectReferenceFix"; public const string PLUGIN_NAME = "RoundManagerObjectReferenceFix"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace RoundManagerObjectReferenceFix.Patches { [HarmonyPatch(typeof(RoundManager), "SpawnOutsideHazards")] public class SpawnableOutsideObjectsPatch { [HarmonyPrefix] private static void Prefix(RoundManager __instance) { //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Expected O, but got Unknown Plugin.Logger.LogInfo((object)"Checking: SpawnOutsideHazards"); if (__instance.currentLevel.spawnableOutsideObjects == null) { return; } SpawnableOutsideObjectWithRarity[] spawnableOutsideObjects = __instance.currentLevel.spawnableOutsideObjects; foreach (SpawnableOutsideObjectWithRarity val in spawnableOutsideObjects) { if (val == null) { Plugin.Logger.LogWarning((object)"Null outside object entry in spawn list"); continue; } SpawnableOutsideObject spawnAbleObject = val.spawnableObject; if ((Object)(object)spawnAbleObject == (Object)null) { Plugin.Logger.LogWarning((object)"Outside object has null spawnableObject, removing from spawn list"); val.randomAmount = new AnimationCurve(); continue; } if ((Object)(object)spawnAbleObject.prefabToSpawn != (Object)null) { Plugin.Logger.LogInfo((object)("Outside object '" + ((Object)spawnAbleObject).name + "' | Prefab: " + ((Object)spawnAbleObject.prefabToSpawn).name + " OK")); continue; } SpawnableOutsideObject val2 = StartOfRound.Instance.levels.SelectMany((SelectableLevel l) => l.spawnableOutsideObjects).FirstOrDefault((Func<SpawnableOutsideObjectWithRarity, bool>)((SpawnableOutsideObjectWithRarity o) => (Object)(object)o?.spawnableObject?.prefabToSpawn != (Object)null && ((Object)o.spawnableObject).name == ((Object)spawnAbleObject).name))?.spawnableObject; if ((Object)(object)val2 != (Object)null) { Plugin.Logger.LogWarning((object)("Outside object '" + ((Object)spawnAbleObject).name + "' has null prefab, resolving from vanilla level")); spawnAbleObject.prefabToSpawn = val2.prefabToSpawn; } else { Plugin.Logger.LogWarning((object)("Outside object '" + ((Object)spawnAbleObject).name + "' has null prefab, removing from spawn list")); val.randomAmount = new AnimationCurve(); } } } } [HarmonyPatch(typeof(RoundManager), "SpawnMapObjects")] public class SpawnMapObjectsPatch { [HarmonyPrefix] private static void Prefix(RoundManager __instance) { //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown Plugin.Logger.LogInfo((object)"Checking: SpawnMapObjects"); if (__instance.currentLevel.indoorMapHazards == null) { return; } IndoorMapHazard[] indoorMapHazards = __instance.currentLevel.indoorMapHazards; foreach (IndoorMapHazard val in indoorMapHazards) { if (val == null) { Plugin.Logger.LogWarning((object)"Null indoor hazard entry in spawn list"); continue; } IndoorMapHazardType hazardType = val.hazardType; if ((Object)(object)hazardType == (Object)null) { Plugin.Logger.LogWarning((object)"Null hazard type entry in spawn list"); continue; } if ((Object)(object)hazardType.prefabToSpawn != (Object)null) { Plugin.Logger.LogInfo((object)("Indoor Hazard: '" + ((Object)hazardType).name + "' | Prefab: " + ((Object)hazardType.prefabToSpawn).name + " OK")); continue; } IndoorMapHazardType val2 = null; SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val3 in levels) { val2 = ((IEnumerable<IndoorMapHazard>)val3.indoorMapHazards).FirstOrDefault((Func<IndoorMapHazard, bool>)((IndoorMapHazard h) => (Object)(object)h?.hazardType?.prefabToSpawn != (Object)null && ((Object)h.hazardType).name == ((Object)hazardType).name))?.hazardType; if ((Object)(object)val2 != (Object)null) { break; } } if ((Object)(object)val2 != (Object)null) { Plugin.Logger.LogWarning((object)("Indoor hazard '" + ((Object)hazardType).name + "' has null prefab, resolving from vanilla level")); hazardType.prefabToSpawn = val2.prefabToSpawn; } else { Plugin.Logger.LogWarning((object)("Indoor hazard '" + ((Object)hazardType).name + "' has null prefab, removing from spawn list")); val.numberToSpawn = new AnimationCurve(); } } } } [HarmonyPatch(typeof(RoundManager), "SpawnScrapInLevel")] public class SpawnScrapPatch { [HarmonyPrefix] private static void Prefix(RoundManager __instance) { Plugin.Logger.LogInfo((object)"Checking: SpawnScrapInLevel"); List<Item> list = (from s in __instance.currentLevel.spawnableScrap where (Object)(object)s.spawnableItem?.spawnPrefab != (Object)null select s.spawnableItem).ToList(); if (list.Count == 0) { Plugin.Logger.LogWarning((object)"No valid items found in moon's spawn list, cannot replace null prefabs!"); return; } bool flag = true; foreach (SpawnableItemWithRarity item in __instance.currentLevel.spawnableScrap) { if (item == null) { Plugin.Logger.LogWarning((object)"Null scrap entry in spawn list"); flag = false; continue; } Item spawnableItem = item.spawnableItem; if ((Object)(object)spawnableItem == (Object)null) { Plugin.Logger.LogWarning((object)"Scrap entry has null spawnableItem, skipping"); flag = false; } else if (!((Object)(object)spawnableItem.spawnPrefab != (Object)null)) { flag = false; Item val = list[Random.Range(0, list.Count)]; Plugin.Logger.LogWarning((object)("Scrap item '" + ((Object)spawnableItem).name + "' has null prefab, replacing with '" + ((Object)val).name + "'")); item.spawnableItem = val; } } if (flag) { Plugin.Logger.LogInfo((object)"All scrap items OK"); } } } }