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 RailSafeLoot v1.0.9
SafeLoot2.dll
Decompiled 2 months agousing System; using System.Collections.Generic; using System.Diagnostics; 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 Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("SafeLoot2")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SafeLoot2")] [assembly: AssemblyTitle("SafeLoot2")] [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.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } [BepInPlugin("com.michalis.PersistentItemsModern", "PersistentItems_Modern", "2.0.0")] public class PersistentItemsPlugin : BaseUnityPlugin { public static ManualLogSource Log; public static List<GrabbableObject> scrap = new List<GrabbableObject>(); public static string lastMoon; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("com.michalis.PersistentItemsModern").PatchAll(); Log.LogInfo((object)"PersistentItems 2.0.0 (2026) Loaded: Survival on Death + No Clones."); } } [HarmonyPatch] internal class MainPatch { [HarmonyPatch(typeof(RoundManager), "DespawnPropsAtEndOfRound")] [HarmonyPrefix] public static bool DespawnPropsAtEndOfRound(RoundManager __instance, bool despawnAllItems = false) { if (!NetworkManager.Singleton.IsServer) { return true; } PersistentItemsPlugin.lastMoon = __instance.currentLevel.PlanetName; GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0); foreach (GrabbableObject val in array) { if ((Object)(object)val == (Object)null) { continue; } bool flag = val.isInShipRoom || val.isInElevator; bool flag2 = despawnAllItems || val.deactivated || !flag; if (flag2 && (val.isHeld || val.isPocketed) && (Object)(object)val.playerHeldBy != (Object)null) { if ((Object)(object)val.itemProperties != (Object)null && !val.itemProperties.isScrap) { flag2 = false; } else if (val.playerHeldBy.isInHangarShipRoom) { flag2 = false; } } if (flag2) { if ((Object)(object)((NetworkBehaviour)val).NetworkObject != (Object)null && ((NetworkBehaviour)val).NetworkObject.IsSpawned) { ((NetworkBehaviour)val).NetworkObject.Despawn(true); } else { Object.Destroy((Object)(object)((Component)val).gameObject); } } else { val.scrapPersistedThroughRounds = true; if (!PersistentItemsPlugin.scrap.Contains(val)) { PersistentItemsPlugin.scrap.Add(val); } } if (__instance.spawnedSyncedObjects.Contains(((Component)val).gameObject)) { __instance.spawnedSyncedObjects.Remove(((Component)val).gameObject); } } GameObject[] array2 = GameObject.FindGameObjectsWithTag("TemporaryEffect"); for (int j = 0; j < array2.Length; j++) { Object.Destroy((Object)(object)array2[j]); } return false; } [HarmonyPatch(typeof(GameNetworkManager), "SaveGame")] [HarmonyPrefix] public static void PreSaveCleanup() { GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0); foreach (GrabbableObject val in array) { if (!((Object)(object)val == (Object)null)) { val.scrapPersistedThroughRounds = val.isInShipRoom || val.isInElevator; } } } [HarmonyPatch(typeof(StartOfRound), "StartGame")] [HarmonyPostfix] public static void OnMoonChange(StartOfRound __instance) { if (!NetworkManager.Singleton.IsServer || __instance.currentLevel.PlanetName == PersistentItemsPlugin.lastMoon) { return; } foreach (GrabbableObject item in PersistentItemsPlugin.scrap) { if ((Object)(object)item != (Object)null && (Object)(object)((NetworkBehaviour)item).NetworkObject != (Object)null && ((NetworkBehaviour)item).NetworkObject.IsSpawned && !item.isInShipRoom && !item.isInElevator) { ((NetworkBehaviour)item).NetworkObject.Despawn(true); } } PersistentItemsPlugin.scrap.Clear(); } }