using System; using System.Collections; 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.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using Photon.Realtime; using UnityEngine; using UnityEngine.SceneManagement; using Zorro.Core; using Zorro.Core.Serizalization; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("my.pahsiv.MyBackpackAlert")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.2.0")] [assembly: AssemblyInformationalVersion("0.1.2")] [assembly: AssemblyProduct("my.pahsiv.MyBackpackAlert")] [assembly: AssemblyTitle("MyBackpackAlert")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.2.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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace MyBackpackAlert { public static class ColorHelper { public const string White = "FFFFFF"; public const string Black = "000000"; public const string Red = "FF0000"; public const string Green = "00FF00"; public const string Blue = "0000FF"; public const string Yellow = "FFFF00"; public const string Purple = "8765CA"; public const string Gray = "808080"; public const string Orange = "FFA500"; public const string Cyan = "00FFFF"; public const string Magenta = "FF00FF"; public const string Pink = "FFC0CB"; public const string Brown = "A52A2A"; public const string Lime = "00FF00"; public const string Teal = "008080"; public const string Navy = "000080"; public const string Maroon = "800000"; public const string Olive = "808000"; public const string Aqua = "00FFFF"; public const string Silver = "C0C0C0"; public const string Gold = "FFD700"; public const string LightRed = "FF6B6B"; public const string LightGreen = "90EE90"; public const string LightBlue = "ADD8E6"; public const string LightGray = "D3D3D3"; public const string LightPink = "FFB6C1"; public const string DarkRed = "8B0000"; public const string DarkGreen = "006400"; public const string DarkBlue = "00008B"; public const string DarkGray = "A9A9A9"; public const string DarkOrange = "FF8C00"; public const string Pahsiv = "3582E7"; } internal class Patch { [HarmonyPatch(typeof(Player), "SyncInventoryRPC")] public class SyncInventoryRPC_Patch { [HarmonyPostfix] public static void Postfix(Player __instance, byte[] data, bool forceSync) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.EnableBackpackAlert.Value) { return; } try { if ((Object)(object)__instance.character == (Object)(object)Character.localCharacter) { return; } string text = ((Object)__instance).name.Replace("Player: ", ""); if (data != null && data.Length != 0) { InventorySyncData fromManagedArray = IBinarySerializable.GetFromManagedArray(data); if (fromManagedArray.tempSlot.ItemID != ushort.MaxValue && fromManagedArray.tempSlot.Data != null) { string itemName = GetItemName(fromManagedArray.tempSlot.ItemID); if (Plugin.RegisterItem.ContainsKey(fromManagedArray.tempSlot.Data.guid)) { Plugin.Notification(Plugin.AddColor(text, "FF6B6B") + " has taken the " + Plugin.AddColor(itemName, "00FFFF") + " from your backpack!", "FFFFFF", sound: true); } } for (int i = 0; i < fromManagedArray.slots.Length; i++) { SlotData val = fromManagedArray.slots[i]; if (val.ItemID != ushort.MaxValue) { string itemName2 = GetItemName(val.ItemID); if (val.Data != null && Plugin.RegisterItem.ContainsKey(val.Data.guid)) { Plugin.Notification(Plugin.AddColor(text, "FF6B6B") + " has taken the " + Plugin.AddColor(itemName2, "00FFFF") + " from your backpack!", "FFFFFF", sound: true); } } } } else { Plugin.Log.LogMessage((object)"Data is null or empty"); } } catch (Exception arg) { Plugin.Log.LogError((object)$"Error in SyncInventoryRPC_Patch: {arg}"); } } } [HarmonyPatch(typeof(Item), "Interact")] public class InteractPatch { [HarmonyPostfix] public static void Postfix(Item __instance, Character interactor) { if ((Object)(object)__instance != (Object)null && __instance.data != null) { _ = __instance.data.guid; Guid guid = __instance.data.guid; if (Plugin.RegisterItem.ContainsKey(guid)) { int num = Plugin.RegisterItem[guid]; Plugin.RegisterItem.Remove(guid); } } } } [HarmonyPatch(typeof(Item), "PutInBackpackRPC")] public class PutInBackpackRPCPatch { [HarmonyPostfix] public static void Postfix(Item __instance, byte slotID, ref BackpackReference backpackReference) { ItemInstanceData itemInstanceData = ((BackpackReference)(ref backpackReference)).GetItemInstanceData(); Guid guid = itemInstanceData.guid; Guid? registerBackpack = Plugin.RegisterBackpack; if (!(guid == registerBackpack)) { return; } Plugin.RegisterItem.Clear(); BackpackData data = ((BackpackReference)(ref backpackReference)).GetData(); for (int i = 0; i < data.itemSlots.Length; i++) { if (!data.itemSlots[i].IsEmpty()) { Guid guid2 = data.itemSlots[i].data.guid; if (!Plugin.RegisterItem.ContainsKey(guid2)) { Plugin.RegisterItem.Add(guid2, i); } } } } } [HarmonyPatch(typeof(BackpackWheel), "Choose")] public class ChoosePatch { [HarmonyPostfix] public static void Postfix(BackpackWheel __instance) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) if (!__instance.chosenSlice.IsSome || !__instance.chosenSlice.Value.isBackpackWear) { return; } SliceData value = __instance.chosenSlice.Value; Backpack val = default(Backpack); if (!((BackpackReference)(ref value.backpackReference)).TryGetBackpackItem(ref val)) { return; } Plugin.Log.LogMessage((object)$" Picking up backpack : {((Item)val).data.guid}"); Plugin.RegisterBackpack = ((Item)val).data.guid; Plugin.RegisterItem.Clear(); EmptySlotPatch.CancelBackpackRemoval(((Item)val).data.guid); BackpackData data = ((Item)val).GetData((DataEntryKey)7); for (int i = 0; i < data.itemSlots.Length; i++) { if (!data.itemSlots[i].IsEmpty()) { Guid guid = data.itemSlots[i].data.guid; if (!Plugin.RegisterItem.ContainsKey(guid)) { Plugin.RegisterItem.Add(guid, i); } } } } } [HarmonyPatch(typeof(BackpackWheel), "TryStash")] public class TryStashPatch { [HarmonyPrefix] public static void Prefix(BackpackWheel __instance, byte backpackSlotID) { Backpack component = ((Component)__instance.backpack.view).GetComponent(); Guid guid; Guid? registerBackpack; if ((Object)(object)component != (Object)null) { if (!Plugin.RegisterBackpack.HasValue) { return; } guid = ((Item)component).data.guid; registerBackpack = Plugin.RegisterBackpack; if (guid == registerBackpack) { Item currentItem = Character.localCharacter.data.currentItem; Guid guid2 = currentItem.data.guid; if (!Plugin.RegisterItem.ContainsKey(guid2)) { Plugin.RegisterItem.Add(guid2, backpackSlotID); } } return; } guid = ((ItemSlot)((Component)__instance.backpack.view).GetComponent().character.player.backpackSlot).data.guid; registerBackpack = Plugin.RegisterBackpack; if (guid == registerBackpack) { Item currentItem2 = Character.localCharacter.data.currentItem; Guid guid3 = currentItem2.data.guid; if (!Plugin.RegisterItem.ContainsKey(guid3)) { Plugin.RegisterItem.Add(guid3, backpackSlotID); } } } } [HarmonyPatch(typeof(Player), "EmptySlot")] public class EmptySlotPatch { [CompilerGenerated] private sealed class d__5 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Guid backpackGuid; private float 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = Time.time; <>2__current = (object)new WaitForSeconds(Plugin.unregisterTime); <>1__state = 1; return true; case 1: <>1__state = -1; Plugin.Log.LogMessage((object)$"Time passed (actual: {Time.time - 5__2:F2}s). Unregistering backpack: {backpackGuid}"); if (Plugin.RegisterBackpack == backpackGuid) { Plugin.RegisterBackpack = null; Plugin.RegisterItem.Clear(); Plugin.Log.LogMessage((object)"Backpack successfully unregistered"); } else { Plugin.Log.LogMessage((object)"Backpack was already changed, skipping unregister"); } pendingRemovals.Remove(backpackGuid); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static Dictionary pendingRemovals = new Dictionary(); private static MonoBehaviour coroutineRunner; [HarmonyPostfix] public static void Postfix(Player __instance, ref Optionable slot) { if ((Object)(object)coroutineRunner == (Object)null) { coroutineRunner = (MonoBehaviour)(object)__instance; } if (slot.IsNone) { return; } byte value = slot.Value; ItemSlot itemSlot = __instance.GetItemSlot(value); if (itemSlot != null && Plugin.RegisterBackpack.HasValue) { Guid guid = itemSlot.data.guid; Guid? registerBackpack = Plugin.RegisterBackpack; if (registerBackpack.HasValue && guid == registerBackpack.GetValueOrDefault() && Plugin.RegisterBackpack.HasValue) { Plugin.Log.LogMessage((object)$"Backpack dropped: {Plugin.RegisterBackpack}. Will unregister in {Plugin.unregisterTime} seconds."); Guid value2 = Plugin.RegisterBackpack.Value; CancelPendingRemoval(value2); Coroutine value3 = coroutineRunner.StartCoroutine(DelayedBackpackRemoval(value2)); pendingRemovals[value2] = value3; } } } public static void CancelBackpackRemoval(Guid backpackGuid) { if (CancelPendingRemoval(backpackGuid)) { Plugin.Log.LogMessage((object)$"Cancelled backpack removal for: {backpackGuid}"); } } private static bool CancelPendingRemoval(Guid backpackGuid) { if (pendingRemovals.ContainsKey(backpackGuid)) { if ((Object)(object)coroutineRunner != (Object)null) { coroutineRunner.StopCoroutine(pendingRemovals[backpackGuid]); } pendingRemovals.Remove(backpackGuid); return true; } return false; } [IteratorStateMachine(typeof(d__5))] private static IEnumerator DelayedBackpackRemoval(Guid backpackGuid) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__5(0) { backpackGuid = backpackGuid }; } } [HarmonyPatch(typeof(Player), "AddItem")] public class AddItemPatch { [HarmonyPostfix] public static void Postfix(Player __instance, ushort itemID, ItemInstanceData instanceData, bool __result, ref ItemSlot slot) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.EnableBackpackAlert.Value || !PhotonNetwork.IsMasterClient || (Object)(object)__instance.character == (Object)(object)Character.localCharacter) { return; } string text = ((Object)__instance).name.Replace("Player: ", ""); InventorySyncData val = default(InventorySyncData); ((InventorySyncData)(ref val))..ctor(__instance.itemSlots, __instance.backpackSlot, __instance.tempFullSlot); if (val.tempSlot.ItemID != ushort.MaxValue && val.tempSlot.Data != null) { string itemName = GetItemName(val.tempSlot.ItemID); if (Plugin.RegisterItem.ContainsKey(val.tempSlot.Data.guid)) { Plugin.Notification(Plugin.AddColor(text, "FF6B6B") + " has taken the " + Plugin.AddColor(itemName, "00FFFF") + " from your backpack!", "FFFFFF", sound: true); } } for (int i = 0; i < val.slots.Length; i++) { SlotData val2 = val.slots[i]; if (val2.ItemID != ushort.MaxValue) { string itemName2 = GetItemName(val2.ItemID); if (val2.Data != null && Plugin.RegisterItem.ContainsKey(val2.Data.guid)) { Plugin.Notification(Plugin.AddColor(text, "FF6B6B") + " has taken the " + Plugin.AddColor(itemName2, "00FFFF") + " from your backpack!", "FFFFFF", sound: true); } } } } } [HarmonyPatch(typeof(Action_RaycastDart), "RPC_DartImpact")] public class Patch_DartImpact { private static int lastFrameLogged = -1; private static Vector3 lastPosition = Vector3.zero; [HarmonyPrefix] private static void Prefix(Action_RaycastDart __instance, int characterID, Vector3 origin, Vector3 endpoint, PhotonMessageInfo info) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.EnableBlowgunAlert.Value || info.Sender.ActorNumber == PhotonNetwork.LocalPlayer.ActorNumber || (lastFrameLogged == Time.frameCount && Vector3.Distance(lastPosition, endpoint) < 0.1f)) { return; } lastFrameLogged = Time.frameCount; lastPosition = endpoint; Player sender = info.Sender; string text = ((sender != null) ? sender.NickName : "Unknown"); string text2 = "Miss"; bool flag = characterID != -1; if (flag) { PhotonView photonView = PhotonNetwork.GetPhotonView(characterID); Character val = ((photonView != null) ? ((Component)photonView).gameObject.GetComponent() : null); text2 = (((Object)(object)val != (Object)null) ? val.characterName : "Unknown"); if ((Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)Character.localCharacter) { Plugin.Notification(string.Format("{0} Shooter: {1} | Hit: {2} | Position: {3}", Plugin.AddColor("[Dart Shot]", "FF0000"), Plugin.AddColor(text, "FF6B6B"), Plugin.AddColor(text2, "00FFFF"), endpoint), "FFFF00", sound: true); } else { Plugin.Notification(string.Format("[Dart Shot] Shooter: {0} | Hit: {1} | Position: {2}", Plugin.AddColor(text, "FF6B6B"), Plugin.AddColor(text2, "00FFFF"), endpoint), "FFFF00"); } } else { Plugin.Notification(string.Format("[Dart Shot] Shooter: {0} | Hit: {1} | Position: {2}", Plugin.AddColor(text, "FF6B6B"), Plugin.AddColor(text2, "00FFFF"), endpoint), "FFFF00"); } Character shooter = default(Character); if (!flag && (Object)(object)__instance != (Object)null && PlayerHandler.TryGetCharacter(info.Sender.ActorNumber, ref shooter)) { CheckForNearMisses(endpoint, shooter); } } private static void CheckForNearMisses(Vector3 impactPoint, Character shooter) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) Player[] playerList = PhotonNetwork.PlayerList; HashSet hashSet = new HashSet(); Player[] array = playerList; Character val2 = default(Character); foreach (Player val in array) { int actorNumber = val.ActorNumber; if (!PlayerHandler.TryGetCharacter(actorNumber, ref val2) || !((Object)(object)val2 != (Object)(object)shooter)) { continue; } float num = Vector3.Distance(impactPoint, val2.Center); if (num < 3f) { hashSet.Add(val2); string text = $"{num:F2}m"; if ((Object)(object)val2 == (Object)(object)Character.localCharacter) { Plugin.Notification(Plugin.AddColor("[Near Miss]", "FF0000") + " Character: " + Plugin.AddColor(val2.characterName, "FF6B6B") + " | Distance: " + Plugin.AddColor(text, "00FFFF"), "FFFF00", sound: true); } else { Plugin.Notification("[Near Miss] Character: " + Plugin.AddColor(val2.characterName, "00FFFF") + " | Distance: " + Plugin.AddColor(text, "00FFFF"), "FFFF00"); } } } } } public static string GetItemName(ushort itemID) { Item val = default(Item); if (ItemDatabase.TryGetItem(itemID, ref val)) { return ((Object)val).name ?? "Unknown"; } return "Not Found"; } } [BepInPlugin("my.pahsiv.MyBackpackAlert", "MyBackpackAlert", "0.1.2")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__19 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__19(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(5f); <>1__state = 1; return true; case 1: <>1__state = -1; try { if ((Object)(object)Character.localCharacter == (Object)null) { Log.LogMessage((object)"Error: Character.localCharacter is null in CheckBackpack()"); return false; } if ((Object)(object)Character.localCharacter.player == (Object)null) { Log.LogMessage((object)"Error: Character.localCharacter.player is null in CheckBackpack()"); return false; } if (Character.localCharacter.player.backpackSlot == null) { Log.LogMessage((object)"Error: backpackSlot is null in CheckBackpack()"); return false; } if (Character.localCharacter.player.backpackSlot.hasBackpack) { RegisterBackpack = ((ItemSlot)Character.localCharacter.player.backpackSlot).data.guid; Log.LogMessage((object)$"Picking up backpack: {RegisterBackpack}"); BackpackReference fromEquippedBackpack = BackpackReference.GetFromEquippedBackpack(Character.localCharacter); if ((Object)(object)fromEquippedBackpack.view == (Object)null) { Log.LogMessage((object)"Error: BackpackReference.view is null in CheckBackpack()"); return false; } BackpackData data = ((BackpackReference)(ref fromEquippedBackpack)).GetData(); if (data == null) { Log.LogMessage((object)"Error: BackpackData is null in CheckBackpack()"); return false; } if (data.itemSlots == null) { Log.LogMessage((object)"Error: itemSlots array is null in CheckBackpack()"); return false; } for (int i = 0; i < data.itemSlots.Length; i++) { if (!data.itemSlots[i].IsEmpty()) { Guid guid = data.itemSlots[i].data.guid; if (!RegisterItem.ContainsKey(guid)) { RegisterItem.Add(guid, i); } } } } } catch (Exception ex) { Log.LogMessage((object)("Exception in CheckBackpack(): " + ex.Message + "\n" + ex.StackTrace)); } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class d__17 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public Plugin <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__17(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown int num = <>1__state; Plugin plugin = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(5f); <>1__state = 1; return true; case 1: <>1__state = -1; plugin.PerformBackpackCheck(); break; case 2: <>1__state = -1; if (!RegisterBackpack.HasValue) { plugin.PerformBackpackCheck(); } break; } <>2__current = (object)new WaitForSeconds(30f); <>1__state = 2; return true; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } public static ManualLogSource Log = null; public static Guid? RegisterBackpack; public static Dictionary RegisterItem = new Dictionary(); public static float unregisterTime = 30f; private Coroutine backpackCheckCoroutine; public static ConfigEntry EnableBackpackAlert; public static ConfigEntry EnableBlowgunAlert; public const string Id = "my.pahsiv.MyBackpackAlert"; internal static Plugin Instance { get; private set; } = null; public static string Name => "MyBackpackAlert"; public static string Version => "0.1.2"; public Plugin() { Log = ((BaseUnityPlugin)this).Logger; } private void Awake() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown Instance = this; Harmony val = new Harmony("my.pahsiv.MyBackpackAlert"); val.PatchAll(); BindConfig(); SceneManager.sceneLoaded += OnSceneLoaded; Log.LogMessage((object)(" Plugin " + Name + " is loaded!")); } private void BindConfig() { EnableBackpackAlert = ((BaseUnityPlugin)this).Config.Bind("General", "Enable Backpack Alert", true, "Enable or disable alerts for Backpack."); EnableBlowgunAlert = ((BaseUnityPlugin)this).Config.Bind("General", "Enable Blowgun Alert", true, "Enable or disable alerts for Blowgun."); } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (((Scene)(ref scene)).name == "Airport") { StopBackpackCheck(); RegisterBackpack = null; RegisterItem.Clear(); } else if (((Scene)(ref scene)).name.Contains("Level_")) { StartBackpackCheck(); } else if (((Scene)(ref scene)).name.Contains("Title")) { StopBackpackCheck(); RegisterBackpack = null; RegisterItem.Clear(); } } public void StartBackpackCheck() { Log.LogMessage((object)"Backpack check coroutine started."); backpackCheckCoroutine = ((MonoBehaviour)this).StartCoroutine(CheckBackpackRoutine()); } public void StopBackpackCheck() { if (backpackCheckCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(backpackCheckCoroutine); backpackCheckCoroutine = null; Log.LogMessage((object)"Backpack check coroutine stopped."); } } [IteratorStateMachine(typeof(d__17))] private IEnumerator CheckBackpackRoutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__17(0) { <>4__this = this }; } private void PerformBackpackCheck() { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)Character.localCharacter == (Object)null) { Log.LogMessage((object)"Error: Character.localCharacter is null in PerformBackpackCheck()"); } else if ((Object)(object)Character.localCharacter.player == (Object)null) { Log.LogMessage((object)"Error: Character.localCharacter.player is null in PerformBackpackCheck()"); } else if (Character.localCharacter.player.backpackSlot == null) { Log.LogMessage((object)"Error: backpackSlot is null in PerformBackpackCheck()"); } else { if (!Character.localCharacter.player.backpackSlot.hasBackpack) { return; } RegisterBackpack = ((ItemSlot)Character.localCharacter.player.backpackSlot).data.guid; Log.LogMessage((object)$"Picking up backpack: {RegisterBackpack}"); BackpackReference fromEquippedBackpack = BackpackReference.GetFromEquippedBackpack(Character.localCharacter); if ((Object)(object)fromEquippedBackpack.view == (Object)null) { Log.LogMessage((object)"Error: BackpackReference.view is null in PerformBackpackCheck()"); return; } BackpackData data = ((BackpackReference)(ref fromEquippedBackpack)).GetData(); if (data == null) { Log.LogMessage((object)"Error: BackpackData is null in PerformBackpackCheck()"); return; } if (data.itemSlots == null) { Log.LogMessage((object)"Error: itemSlots array is null in PerformBackpackCheck()"); return; } for (int i = 0; i < data.itemSlots.Length; i++) { if (!data.itemSlots[i].IsEmpty()) { Guid guid = data.itemSlots[i].data.guid; if (!RegisterItem.ContainsKey(guid)) { RegisterItem.Add(guid, i); } } } } } catch (Exception ex) { Log.LogMessage((object)("Exception in PerformBackpackCheck(): " + ex.Message + "\n" + ex.StackTrace)); } } [IteratorStateMachine(typeof(d__19))] public static IEnumerator CheckBackpack() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__19(0); } public static void Notification(string message, string color = "FFFFFF", bool sound = false) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) PlayerConnectionLog val = Object.FindFirstObjectByType(); if ((Object)(object)val == (Object)null) { return; } string text = "" + message + ""; MethodInfo method = typeof(PlayerConnectionLog).GetMethod("AddMessage", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { method.Invoke(val, new object[1] { text }); if ((Object)(object)val.sfxJoin != (Object)null && sound) { val.sfxJoin.Play(default(Vector3)); } } else { Log.LogWarning((object)"AddMessage method not found."); } } public static string AddColor(string text, string color) { return "" + text + ""; } public static string GetItemName(ushort itemID) { Item val = default(Item); if (ItemDatabase.TryGetItem(itemID, ref val)) { return ((Object)val).name ?? "Unknown"; } return "Not Found"; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }