using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; 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("PersistItemsMod")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PersistItemsMod")] [assembly: AssemblyTitle("PersistItemsMod")] [assembly: AssemblyVersion("1.0.0.0")] namespace PersistItemsMod; [BepInPlugin("yourname.persistitems", "Persist Items", "1.0.0")] public class PersistItemsPlugin : BaseUnityPlugin { public const string PluginGuid = "yourname.persistitems"; public const string PluginName = "Persist Items"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("yourname.persistitems").PatchAll(); Log.LogInfo((object)"Persist Items v1.0.0 загружен. ВАЖНО: должен быть установлен у ВСЕХ игроков в лобби."); } } [HarmonyPatch(typeof(PersistentObjectsHolder), "FindPersistantObjects")] internal static class PersistentObjectsHolder_FindPersistantObjects_Patch { private static FieldInfo _dicField; private static MethodInfo _addMethod; [HarmonyPostfix] private static void Postfix(PersistentObjectsHolder __instance) { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Invalid comparison between Unknown and I4 if (_dicField == null) { _dicField = AccessTools.Field(typeof(PersistentObjectsHolder), "m_PersistentObjectDic"); } if (_addMethod == null) { _addMethod = AccessTools.Method(typeof(PersistentObjectsHolder), "AddPersistentObject", new Type[2] { typeof(Pickup), typeof(Item) }, (Type[])null); } Dictionary dictionary = (Dictionary)_dicField.GetValue(__instance); int num = 0; Pickup[] array = Object.FindObjectsOfType(); foreach (Pickup val in array) { if ((Object)(object)val == (Object)null || dictionary.ContainsKey(val)) { continue; } ItemInstance itemInstance = val.itemInstance; if (!((Object)(object)itemInstance == (Object)null) && !((Object)(object)itemInstance.item == (Object)null)) { Item item = itemInstance.item; if ((int)item.itemType != 0 && (int)item.itemType != 2) { _addMethod.Invoke(__instance, new object[2] { val, item }); num++; } } } if (num > 0) { PersistItemsPlugin.Log.LogInfo((object)$"Дополнительно помечено для сохранения предметов: {num}"); } } }