using System; using System.Collections; using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Security; using System.Security.Permissions; using BagConfig.Dependency; using BagConfig.InputUtils; using BagConfig.Networking; using BagConfig.Patches; using BagConfig.Utils; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using HarmonyLib.Public.Patching; using JetBrains.Annotations; using LethalCompanyInputUtils.Api; using LethalConfig; using LethalConfig.ConfigItems; using LethalConfig.ConfigItems.Options; using LobbyCompatibility.Enums; using LobbyCompatibility.Features; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; using MonoMod.RuntimeDetour; using MonoMod.Utils; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: AssemblyCompany("lsy_windy")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.4")] [assembly: AssemblyInformationalVersion("1.0.4+867df470be87d0129e569a7e0a6dcfcb6e1b1e17")] [assembly: AssemblyProduct("BagConfigTooltipFixed")] [assembly: AssemblyTitle("BagConfigTooltipFixed - Plugin")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [CompilerGenerated] internal sealed class <>z__ReadOnlySingleElementList : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator { object IEnumerator.Current => _item; T IEnumerator.Current => _item; public Enumerator(T item) { _item = item; } bool IEnumerator.MoveNext() { if (!_moveNextCalled) { return _moveNextCalled = true; } return false; } void IEnumerator.Reset() { _moveNextCalled = false; } void IDisposable.Dispose() { } } int ICollection.Count => 1; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => 1; T IReadOnlyList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } } int ICollection.Count => 1; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } public <>z__ReadOnlySingleElementList(T item) { _item = item; } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.CopyTo(Array array, int index) { array.SetValue(_item, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return EqualityComparer.Default.Equals(_item, (T)value); } int IList.IndexOf(object value) { if (!EqualityComparer.Default.Equals(_item, (T)value)) { return -1; } return 0; } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return EqualityComparer.Default.Equals(_item, item); } void ICollection.CopyTo(T[] array, int arrayIndex) { array[arrayIndex] = _item; } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { if (!EqualityComparer.Default.Equals(_item, item)) { return -1; } return 0; } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 BagConfig { [BepInPlugin("lsy_windy.BagConfigTooltipFixed", "BagConfigTooltipFixed", "1.0.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class BagConfig : BaseUnityPlugin { internal static readonly ISet Hooks = new HashSet(); internal static readonly Harmony Harmony = new Harmony("lsy_windy.BagConfigTooltipFixed"); public const string GUID = "lsy_windy.BagConfigTooltipFixed"; public const string NAME = "BagConfigTooltipFixed"; public const string VERSION = "1.0.4"; internal static ManualLogSource Log; public static BagConfig INSTANCE { get; private set; } private void Awake() { INSTANCE = this; Log = ((BaseUnityPlugin)this).Logger; try { if (LobbyCompatibilityChecker.Enabled) { LobbyCompatibilityChecker.Init(); } if (InputUtilsProxy.Enabled) { InputUtilsProxy.Init(); } Log.LogInfo((object)"Initializing Configs"); PluginConfig.Init(); Log.LogInfo((object)"Patching Methods"); PatchLateJoin.Init(); Harmony.PatchAll(); BeltBagPatch.Patch(); Log.LogInfo((object)"BagConfigTooltipFixed v1.0.4 Loaded!"); } catch (Exception ex) { Log.LogError((object)("Exception while initializing: \n" + ex)); } } } internal static class PluginConfig { public static class Misc { public static ConfigEntry Tooltip { get; internal set; } public static ConfigEntry DropAll { get; internal set; } public static ConfigEntry HideBag { get; internal set; } public static ConfigEntry GrabRange { get; internal set; } } public static class Host { public static ConfigEntry Capacity { get; internal set; } public static ConfigEntry Category { get; internal set; } public static ConfigEntry Range { get; internal set; } public static ConfigEntry AllowVanilla { get; internal set; } } public static class Limits { public static StringDictionary ItemCategoryAssociations = new StringDictionary(); public static readonly Dictionary CategoryConfigs = new Dictionary(); public static ConfigEntry Capacity { get; internal set; } public static ConfigEntry ItemCategories { get; internal set; } } public interface ICategoryConfig { string CategoryName { get; } bool Allow { get; } int Limit { get; } } public class StaticCategoryConfig : ICategoryConfig { public string CategoryName { get; } public bool Allow { get; } public int Limit { get; } public StaticCategoryConfig(string categoryName, bool allow, int limit) { CategoryName = categoryName; Allow = allow; Limit = limit; } } public class BepInExCategoryConfig : ICategoryConfig { private readonly ConfigEntry _allowConfig; private readonly ConfigEntry _limitConfig; public string CategoryName { get; } public bool Allow => _allowConfig.Value; public int Limit => _limitConfig.Value; public BepInExCategoryConfig(string categoryName, bool allow = false, int max = -1) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown CategoryName = categoryName; _allowConfig = ((BaseUnityPlugin)BagConfig.INSTANCE).Config.Bind("Limit." + CategoryName, "Allow", allow, new ConfigDescription("Allow grabbing this category!", (AcceptableValueBase)null, Array.Empty())); _limitConfig = ((BaseUnityPlugin)BagConfig.INSTANCE).Config.Bind("Limit." + CategoryName, "Max Amount", max, new ConfigDescription("How many items of this category can be stored at the same time?", (AcceptableValueBase)(object)new AcceptableValueRange(-1, Limits.Capacity?.Value ?? int.MaxValue), Array.Empty())); if (LethalConfigProxy.Enabled) { LethalConfigProxy.AddConfig(_allowConfig); LethalConfigProxy.AddConfig(_limitConfig); } } } private const string ToolsCategory = "Tools"; private const string DenyCategory = "Deny"; private const string OneHandedCategory = "One Handed Scrap"; private const string TwoHandedCategory = "Two Handed Scrap"; internal static void Init() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Expected O, but got Unknown //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Expected O, but got Unknown ConfigFile config = ((BaseUnityPlugin)BagConfig.INSTANCE).Config; Misc.Tooltip = config.Bind("Miscellaneous", "Tooltip", true, "Show a tooltip if the target item cannot be stored"); Misc.DropAll = config.Bind("Miscellaneous", "Add Empty Bag Action", true, "Add action to Drop the entire bag inventory"); Misc.HideBag = config.Bind("Miscellaneous", "Hide Bag When Pocketed", false, "Hide the bag when in pocket ( also disables opening it by looking down )"); Misc.GrabRange = config.Bind("Miscellaneous", "Grab Range", 4f, new ConfigDescription("Max range for grabbing items with the bag", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 20f), Array.Empty())); Host.Capacity = config.Bind("Host Settings", "Enforce Capacity", true, "Server-side check to limit the bag Capacity"); Host.Category = config.Bind("Host Settings", "Enforce Restrictions", true, "Server-side check to limit the items allowed inside the Bag"); Host.Range = config.Bind("Host Settings", "Enforce Range", true, "Server-side check to limit the grab range"); Host.AllowVanilla = config.Bind("Host Settings", "Allow Vanilla Clients", false, "Allow clients w/o the mod to join the lobby"); Limits.Capacity = config.Bind("Limits", "Capacity", 15, new ConfigDescription("How many items can the bag store", (AcceptableValueBase)(object)new AcceptableValueRange(0, int.MaxValue), Array.Empty())); Limits.ItemCategories = config.Bind("Limits", "Item Categories", "Body: Deny", new ConfigDescription("Dictionary describing the association between a Item and a Category name", (AcceptableValueBase)null, Array.Empty())); Limits.CategoryConfigs["Tools"] = new BepInExCategoryConfig("Tools", allow: true); Limits.CategoryConfigs["One Handed Scrap"] = new BepInExCategoryConfig("One Handed Scrap"); Limits.CategoryConfigs["Two Handed Scrap"] = new BepInExCategoryConfig("Two Handed Scrap"); Limits.CategoryConfigs["Deny"] = new StaticCategoryConfig("Deny", allow: false, 0); ProcessCategories(Limits.ItemCategories); Limits.ItemCategories.SettingChanged += delegate { ProcessCategories(Limits.ItemCategories); }; if (LethalConfigProxy.Enabled) { LethalConfigProxy.AddConfig(Misc.Tooltip); LethalConfigProxy.AddConfig(Misc.DropAll, requiresRestart: true); LethalConfigProxy.AddConfig(Misc.HideBag); LethalConfigProxy.AddConfig(Misc.GrabRange); LethalConfigProxy.AddConfig(Limits.Capacity); LethalConfigProxy.AddConfig(Limits.ItemCategories); LethalConfigProxy.AddConfig(Host.Capacity); LethalConfigProxy.AddConfig(Host.Category); LethalConfigProxy.AddConfig(Host.Range); LethalConfigProxy.AddConfig(Host.AllowVanilla, requiresRestart: true); LethalConfigProxy.AddButton("Fixes", "Fix Locked BeltBags", "Re-Enable all BeltBags that are in a broken state", "Fix", delegate { NamedMessages.FixBagsClientRpc(); }, () => ((Object)(object)StartOfRound.Instance == (Object)null) ? (result: false, reason: "You need to be in a lobby to call this") : ((!GameNetworkManager.Instance.isHostingGame) ? (result: false, reason: "Only host can call this function") : (result: true, reason: ""))); } CleanAndSave(); static void ProcessCategories(ConfigEntry entry) { Limits.ItemCategoryAssociations = ProcessDictionary(entry); foreach (string value3 in Limits.ItemCategoryAssociations.Values) { if (!Limits.CategoryConfigs.ContainsKey(value3)) { Limits.CategoryConfigs[value3] = new BepInExCategoryConfig(value3, allow: true); } } } static StringDictionary ProcessDictionary(ConfigEntry entry) { string value = entry.Value; StringDictionary stringDictionary = new StringDictionary(); string[] array = value.Split(","); foreach (string text in array) { string text2 = text.Trim(); string[] array2 = text2.Split(":"); if (array2.Length != 2) { BagConfig.Log.LogError((object)("Item Association: malformed Entry! " + text2)); } else { string text3 = array2[0].Trim(); string value2 = array2[1].Trim(); if (stringDictionary.ContainsKey(text3)) { BagConfig.Log.LogWarning((object)("Item Association: " + text3 + " was already defined - overwriting!")); } stringDictionary[text3] = value2; } } return stringDictionary; } } internal static void CleanAndSave() { ConfigFile config = ((BaseUnityPlugin)BagConfig.INSTANCE).Config; PropertyInfo propertyInfo = AccessTools.Property(((object)config).GetType(), "OrphanedEntries"); Dictionary dictionary = (Dictionary)propertyInfo.GetValue(config, null); dictionary.Clear(); config.Save(); } public static ICategoryConfig GetBagCategory(this GrabbableObject grabbable) { if (Limits.ItemCategoryAssociations.ContainsKey(grabbable.itemProperties.itemName)) { return Limits.CategoryConfigs[Limits.ItemCategoryAssociations[grabbable.itemProperties.itemName]]; } bool isScrap = grabbable.itemProperties.isScrap; bool twoHanded = grabbable.itemProperties.twoHanded; if (!isScrap) { return Limits.CategoryConfigs["Tools"]; } if (!twoHanded) { return Limits.CategoryConfigs["One Handed Scrap"]; } return Limits.CategoryConfigs["Two Handed Scrap"]; } } public static class MyPluginInfo { public const string PLUGIN_GUID = "lsy_windy.BagConfigTooltipFixed"; public const string PLUGIN_NAME = "BagConfigTooltipFixed"; public const string PLUGIN_VERSION = "1.0.4"; } } namespace BagConfig.Utils { public static class NgoUtils { private static readonly MethodInfo BeginSendClientRpc = AccessTools.Method(typeof(NetworkBehaviour), "__beginSendClientRpc", (Type[])null, (Type[])null); private static readonly MethodInfo BeginSendServerRpc = AccessTools.Method(typeof(NetworkBehaviour), "__beginSendServerRpc", (Type[])null, (Type[])null); private static readonly __RpcExecStage ClientRpcStage; private static readonly __RpcExecStage ServerRpcStage; public static bool IsRPCClientStage(this NetworkBehaviour self) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = self.NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening) { return false; } if (self.__rpc_exec_stage != ClientRpcStage || (!networkManager.IsClient && !networkManager.IsHost)) { return false; } return true; } public static bool IsRPCServerStage(this NetworkBehaviour self) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = self.NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening) { return false; } if (self.__rpc_exec_stage != ServerRpcStage || (!networkManager.IsServer && !networkManager.IsHost)) { return false; } return true; } internal static bool TryGetRpcID(this MethodInfo methodInfo, out uint rpcID) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Collection instructions = PatchManager.GetMethodPatcher((MethodBase)methodInfo).CopyOriginal().Definition.Body.Instructions; rpcID = 0u; for (int i = 0; i < instructions.Count; i++) { if (instructions[i].OpCode == OpCodes.Ldc_I4 && instructions[i - 1].OpCode == OpCodes.Ldarg_0) { rpcID = (uint)(int)instructions[i].Operand; } if (!(instructions[i].OpCode != OpCodes.Call)) { object operand = instructions[i].Operand; MethodReference val = (MethodReference)((operand is MethodReference) ? operand : null); if (val != null && (Extensions.Is((MemberReference)(object)val, (MemberInfo)BeginSendClientRpc) || Extensions.Is((MemberReference)(object)val, (MemberInfo)BeginSendServerRpc))) { BagConfig.Log.LogDebug((object)$"Rpc Id found for {methodInfo.Name}: {rpcID}U"); return true; } } } BagConfig.Log.LogFatal((object)("Cannot find Rpc ID for " + methodInfo.Name)); return false; } static NgoUtils() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_006d: 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_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) string unityVersion = Application.unityVersion; __RpcExecStage clientRpcStage = ((!(unityVersion == "2022.3.9f1")) ? ((__RpcExecStage)1) : ((__RpcExecStage)2)); ClientRpcStage = clientRpcStage; string unityVersion2 = Application.unityVersion; clientRpcStage = ((!(unityVersion2 == "2022.3.9f1")) ? ((__RpcExecStage)1) : ((__RpcExecStage)1)); ServerRpcStage = clientRpcStage; } } } namespace BagConfig.Patches { [HarmonyPatch] internal static class BeltBagPatch { private class CategoryCount { public int Count; } [HarmonyPatch(typeof(BeltBagItem), "PutObjectInBagLocalClient")] private static class OnItemPutObjectInBag { [UsedImplicitly] private static void Prefix(BeltBagItem __instance, GrabbableObject gObject, ref bool __state) { __state = __instance.objectsInBag.Contains(gObject); } [UsedImplicitly] private static void Postfix(BeltBagItem __instance, GrabbableObject gObject, ref bool __state) { if (__state) { return; } PluginConfig.ICategoryConfig bagCategory = gObject.GetBagCategory(); ConditionalWeakTable orCreateValue = CategoryMemory.GetOrCreateValue(__instance); orCreateValue.GetOrCreateValue(bagCategory).Count++; LungProp val = (LungProp)(object)((gObject is LungProp) ? gObject : null); if (val != null) { if (val.isLungDocked) { val.isLungDocked = false; if (val.disconnectAnimation != null) { ((MonoBehaviour)val).StopCoroutine(val.disconnectAnimation); } val.disconnectAnimation = ((MonoBehaviour)val).StartCoroutine(val.DisconnectFromMachinery()); } if (val.isLungDockedInElevator) { val.isLungDockedInElevator = false; ((Component)val).gameObject.GetComponent().PlayOneShot(val.disconnectSFX); } } if (!((GrabbableObject)__instance).hasBeenHeld) { ((GrabbableObject)__instance).hasBeenHeld = true; if (!((GrabbableObject)__instance).isInShipRoom && !StartOfRound.Instance.inShipPhase && StartOfRound.Instance.currentLevel.spawnEnemiesAndScrap) { RoundManager instance = RoundManager.Instance; instance.valueOfFoundScrapItems += ((GrabbableObject)__instance).scrapValue; } } } } internal static bool Enabled; private static readonly Dictionary OriginalBagToolTips; private static readonly Action BaseInteractMethod; private static readonly ConditionalWeakTable> CategoryMemory; internal static void Patch() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(BeltBagItem), "ItemInteractLeftRight", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(BeltBagPatch), "OverrideGrab", (Type[])null, (Type[])null); BagConfig.Hooks.Add(new Hook((MethodBase)methodInfo, methodInfo2, new HookConfig { Priority = -999 })); } static BeltBagPatch() { Enabled = false; OriginalBagToolTips = new Dictionary(); CategoryMemory = new ConditionalWeakTable>(); MethodInfo meth = AccessTools.Method(typeof(GrabbableObject), "ItemInteractLeftRight", (Type[])null, (Type[])null); DynamicMethod dynamicMethod = new DynamicMethod("Base.ItemInteractLeftRight", null, new Type[2] { typeof(GrabbableObject), typeof(bool) }, typeof(BeltBagItem)); ILGenerator iLGenerator = dynamicMethod.GetILGenerator(); iLGenerator.Emit(OpCodes.Ldarg_0); iLGenerator.Emit(OpCodes.Ldarg_1); iLGenerator.Emit(OpCodes.Call, meth); iLGenerator.Emit(OpCodes.Ret); BaseInteractMethod = (Action)dynamicMethod.CreateDelegate(typeof(Action)); } private static IEnumerator EmptyBagCoroutine(BeltBagItem @this) { while (@this.objectsInBag.Count > 0) { @this.RemoveObjectFromBag(0); yield return (object)new WaitForEndOfFrame(); } } internal static void TryDumpItems(BeltBagItem @this, bool checkInHand = true) { if (PluginConfig.Misc.DropAll.Value && !((Object)(object)((GrabbableObject)@this).playerHeldBy == (Object)null) && (!checkInHand || !((Object)(object)((GrabbableObject)@this).playerHeldBy.currentlyHeldObjectServer != (Object)(object)@this))) { ((MonoBehaviour)@this).StartCoroutine(EmptyBagCoroutine(@this)); } } internal static void TryGrabItem(BeltBagItem @this, bool checkInHand = true) { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)((GrabbableObject)@this).playerHeldBy == (Object)null || (checkInHand && (Object)(object)((GrabbableObject)@this).playerHeldBy.currentlyHeldObjectServer != (Object)(object)@this) || @this.tryingAddToBag) { return; } if (@this.objectsInBag.Count >= PluginConfig.Limits.Capacity.Value) { if (PluginConfig.Misc.Tooltip.Value) { HUDManager.Instance.DisplayTip("Belt bag Info", "This bag is Full!", false, false, "LC_Tip1"); } } else { RaycastHit val = default(RaycastHit); if (!Physics.Raycast(((Component)((GrabbableObject)@this).playerHeldBy.gameplayCamera).transform.position, ((Component)((GrabbableObject)@this).playerHeldBy.gameplayCamera).transform.forward, ref val, PluginConfig.Misc.GrabRange.Value, GameNetworkManager.Instance.localPlayerController.interactableObjectsMask)) { return; } ManualLogSource log = BagConfig.Log; Transform parent = ((Component)((RaycastHit)(ref val)).collider).transform.parent; log.LogDebug((object)("Grab Hit: " + ((parent != null) ? ((Object)parent).name : null) + "." + ((Object)((Component)((RaycastHit)(ref val)).collider).gameObject).name)); if (((Component)((RaycastHit)(ref val)).collider).gameObject.layer == 8 || ((Component)((RaycastHit)(ref val)).collider).tag != "PhysicsProp") { return; } GrabbableObject component = ((Component)((RaycastHit)(ref val)).collider).gameObject.GetComponent(); if (!@this.CanBePutInBag(component)) { return; } if (@this.CheckBagFilters(component, out var limited, out var disallowed)) { @this.TryAddObjectToBag(component); } else if (PluginConfig.Misc.Tooltip.Value) { if (!disallowed && limited) { PluginConfig.ICategoryConfig bagCategory = component.GetBagCategory(); HUDManager.Instance.DisplayTip("Belt bag Info", "Cannot store any more " + bagCategory.CategoryName + " inside of the bag!", false, false, "LC_Tip1"); } else { HUDManager.Instance.DisplayTip("Belt bag Info", "Cannot store " + component.itemProperties.itemName + " inside of the bag!", false, false, "LC_Tip1"); } } } } private static void OverrideGrab(Action orig, BeltBagItem @this, bool right) { if (!Enabled) { orig(@this, arg2: false); return; } BaseInteractMethod((GrabbableObject)(object)@this, right); if (!InputUtilsProxy.Enabled) { if (right) { TryDumpItems(@this); } else { TryGrabItem(@this); } } } private static bool CanBePutInBag(this BeltBagItem @this, GrabbableObject grabbable) { if (Object.op_Implicit((Object)(object)grabbable) && (Object)(object)grabbable != (Object)(object)@this && !grabbable.isHeld && !grabbable.isHeldByEnemy) { return grabbable.itemProperties.itemId != 123984; } return false; } private static bool CheckBagFilters(this BeltBagItem @this, GrabbableObject grabbable, out bool limited, out bool disallowed) { limited = false; PluginConfig.ICategoryConfig bagCategory = grabbable.GetBagCategory(); disallowed = !bagCategory.Allow; int limit = bagCategory.Limit; if (limit < 0) { return !disallowed; } if (limit == 0) { limited = true; return false; } ConditionalWeakTable orCreateValue = CategoryMemory.GetOrCreateValue(@this); if (orCreateValue.TryGetValue(bagCategory, out var value) && value.Count >= limit) { limited = true; return false; } return !disallowed; } [HarmonyPrefix] [HarmonyPatch(typeof(StartOfRound), "Start")] private static void AddBagTooltip(StartOfRound __instance) { if (!PluginConfig.Misc.DropAll.Value) { return; } BeltBagItem val = default(BeltBagItem); foreach (Item items in __instance.allItemsList.itemsList) { if (Object.op_Implicit((Object)(object)items.spawnPrefab) && items.spawnPrefab.TryGetComponent(ref val)) { if (!OriginalBagToolTips.TryGetValue(items, out var value)) { value = items.toolTips?.ToArray() ?? Array.Empty(); OriginalBagToolTips.Add(items, value); } ManualLogSource log = BagConfig.Log; string[] toolTips = items.toolTips; log.LogInfo((object)$"item.toolTips.Size => {((toolTips != null) ? toolTips.Length : 0)}"); BagConfig.Log.LogInfo((object)$"OriginalBagToolTips.Size => {value.Length}"); string[] array = new string[value.Length + 1]; Array.Copy(value, array, value.Length); array[^1] = "Empty Bag: [E]"; items.toolTips = array; } } } [HarmonyPostfix] [HarmonyPatch(typeof(BeltBagItem), "RemoveFromBagLocalClientNonElevatorParent")] [HarmonyPatch(typeof(BeltBagItem), "RemoveFromBagLocalClient")] private static void TrackRemove(BeltBagItem __instance, NetworkObjectReference objectRef) { ConditionalWeakTable orCreateValue = CategoryMemory.GetOrCreateValue(__instance); NetworkObject val = default(NetworkObject); GrabbableObject grabbable = default(GrabbableObject); if (((NetworkObjectReference)(ref objectRef)).TryGet(ref val, (NetworkManager)null) && ((Component)val).TryGetComponent(ref grabbable)) { PluginConfig.ICategoryConfig bagCategory = grabbable.GetBagCategory(); orCreateValue.GetOrCreateValue(bagCategory).Count--; } if (__instance.objectsInBag.Count == 0) { orCreateValue.Clear(); } } [HarmonyPrefix] [HarmonyPatch(typeof(BeltBagItem), "TryAddObjectToBagServerRpc")] private static bool EnforceLimits(BeltBagItem __instance, NetworkObjectReference netObjectRef, int playerWhoAdded) { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (!((NetworkBehaviour)(object)__instance).IsRPCServerStage()) { return true; } NetworkObject val = default(NetworkObject); if (!((NetworkObjectReference)(ref netObjectRef)).TryGet(ref val, (NetworkManager)null)) { return true; } GrabbableObject component = ((Component)val).GetComponent(); if (!__instance.CanBePutInBag(component)) { __instance.CancelAddObjectToBagClientRpc(playerWhoAdded); return false; } if (PluginConfig.Host.Capacity.Value && __instance.objectsInBag.Count >= PluginConfig.Limits.Capacity.Value) { __instance.CancelAddObjectToBagClientRpc(playerWhoAdded); return false; } if (PluginConfig.Host.Category.Value && !__instance.CheckBagFilters(component, out var _, out var _)) { __instance.CancelAddObjectToBagClientRpc(playerWhoAdded); return false; } if (PluginConfig.Host.Range.Value) { Vector3 position = ((Component)component).transform.position; PlayerControllerB playerHeldBy = ((GrabbableObject)__instance).playerHeldBy; if (Vector3.Distance(position, (playerHeldBy != null) ? ((Component)playerHeldBy.gameplayCamera).transform.position : Vector3.positiveInfinity) > PluginConfig.Misc.GrabRange.Value) { __instance.CancelAddObjectToBagClientRpc(playerWhoAdded); return false; } } return true; } [HarmonyPostfix] [HarmonyPatch(typeof(BeltBagItem), "CancelAddObjectToBagClientRpc")] private static void OnServerRefusal(int playerWhoAdded) { if (!((Object)(object)StartOfRound.Instance.allPlayerScripts[playerWhoAdded] != (Object)(object)GameNetworkManager.Instance.localPlayerController)) { HUDManager.Instance.DisplayTip("Belt bag Info", "Host refused your grab request!", true, false, "LC_Tip1"); } } [HarmonyTranspiler] [HarmonyPatch(typeof(BeltBagItem), "RemoveObjectFromBag")] private static IEnumerable FixDrop(IEnumerable instructions, ILGenerator ilGenerator) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown List list = instructions.ToList(); MethodInfo methodInfo = AccessTools.Method(typeof(GrabbableObject), "GetItemFloorPosition", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(BeltBagPatch), "FixVerticalOffset", (Type[])null, (Type[])null); CodeMatcher val = new CodeMatcher((IEnumerable)list, ilGenerator); val.MatchForward(true, (CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)methodInfo, (string)null) }); if (val.IsInvalid) { BagConfig.Log.LogError((object)"Patch RemoveObjectFromBag, Fail - 1 "); return list; } val.Advance(1); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_0, (object)null) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_1, (object)null) }); val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)methodInfo2) }); return val.Instructions(); } private static Vector3 FixVerticalOffset(Vector3 position, BeltBagItem beltBagItem, int index) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0025: Unknown result type (might be due to invalid IL or missing references) if (beltBagItem.objectsInBag.Count <= index) { return position; } GrabbableObject val = beltBagItem.objectsInBag[index]; if (!Object.op_Implicit((Object)(object)val)) { return position; } position += Vector3.down * ((GrabbableObject)beltBagItem).itemProperties.verticalOffset; position += Vector3.up * val.itemProperties.verticalOffset; return position; } [HarmonyPostfix] [HarmonyPatch(typeof(BeltBagItem), "PocketItem")] private static void HideWhenInPocket(BeltBagItem __instance) { if (((NetworkBehaviour)__instance).IsOwner && PluginConfig.Misc.HideBag.Value) { ((Component)__instance.useBagTrigger).GetComponent().enabled = false; ((GrabbableObject)__instance).EnableItemMeshes(false); } } [HarmonyPrefix] [HarmonyPatch(typeof(StartOfRound), "Start")] private static void OnLobbyJoin(StartOfRound __instance) { Enabled = ((NetworkBehaviour)__instance).IsServer; } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "OnClientConnect")] private static void OnClientJoined(StartOfRound __instance, ulong clientId) { if (((NetworkBehaviour)__instance).IsServer) { NamedMessages.HostPresentClientRpc(new <>z__ReadOnlySingleElementList(clientId)); } } [HarmonyPrefix] [HarmonyPatch(typeof(MenuManager), "Start")] private static void OnMainMenu() { Enabled = false; } } [HarmonyPatch] internal class NetworkManagerPatch { [HarmonyPostfix] [HarmonyPatch(typeof(NetworkManager), "Initialize")] private static void AfterInitialize() { BagConfig.Log.LogInfo((object)"Registering Named Messages!"); NamedMessages.RegisterNamedMessages(); } [HarmonyPostfix] [HarmonyPatch(typeof(GameNetworkManager), "SetInstanceValuesBackToDefault")] public static void SetInstanceValuesBackToDefault() { if (!((Object)(object)NetworkManager.Singleton == (Object)null) && NetworkManager.Singleton.CustomMessagingManager != null) { BagConfig.Log.LogInfo((object)"Unregistering Named Messages!"); NamedMessages.UnregisterNamedMessages(); } } [HarmonyPostfix] [HarmonyPatch(typeof(NetworkManager), "SetSingleton")] private static void RegisterPrefab() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (!PluginConfig.Host.AllowVanilla.Value) { GameObject val = new GameObject("BagConfigTooltipFixed Prefab"); ((Object)val).hideFlags = (HideFlags)(((Object)val).hideFlags | 0x3D); Object.DontDestroyOnLoad((Object)(object)val); NetworkObject val2 = val.AddComponent(); val2.GlobalObjectIdHash = GetHash("lsy_windy.BagConfigTooltipFixed"); NetworkManager.Singleton.PrefabHandler.AddNetworkPrefab(val); } static uint GetHash(string value) { return value?.Aggregate(17u, (uint current, char c) => (current * 31) ^ c) ?? 0; } } } internal static class PatchLateJoin { private static uint _tryAddObjectToBagClientRpc; internal static void Init() { MethodInfo methodInfo = AccessTools.Method(typeof(BeltBagItem), "TryAddObjectToBagClientRpc", (Type[])null, (Type[])null); if (!methodInfo.TryGetRpcID(out _tryAddObjectToBagClientRpc)) { throw new MissingMemberException("BeltBagItem", "TryAddObjectToBagClientRpc"); } } [HarmonyPostfix] [HarmonyPatch(typeof(StartOfRound), "SyncAlreadyHeldObjectsClientRpc")] private static void SyncItemsInBags(StartOfRound __instance, NetworkObjectReference[] gObjects, int joiningClientId) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: 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_0089: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: 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_00f6: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)__instance).NetworkManager; if ((Object)(object)networkManager == (Object)null || !networkManager.IsListening || (int)((NetworkBehaviour)__instance).__rpc_exec_stage == 2 || (!networkManager.IsServer && !networkManager.IsHost)) { return; } NetworkObject val2 = default(NetworkObject); BeltBagItem val3 = default(BeltBagItem); for (int i = 0; i < gObjects.Length; i++) { NetworkObjectReference val = gObjects[i]; if (!((NetworkObjectReference)(ref val)).TryGet(ref val2, (NetworkManager)null) || !((Component)val2).TryGetComponent(ref val3)) { continue; } foreach (GrabbableObject item in val3.objectsInBag) { NetworkObjectReference val4 = NetworkObjectReference.op_Implicit(((NetworkBehaviour)item).NetworkObject); ClientRpcParams val5 = new ClientRpcParams { Send = new ClientRpcSendParams { TargetClientIds = new <>z__ReadOnlySingleElementList((ulong)joiningClientId) } }; FastBufferWriter val6 = ((NetworkBehaviour)val3).__beginSendClientRpc(_tryAddObjectToBagClientRpc, val5, (RpcDelivery)0); ((FastBufferWriter)(ref val6)).WriteValueSafe(ref val4, default(ForNetworkSerializable)); BytePacker.WriteValueBitPacked(val6, ((GrabbableObject)val3).playerHeldBy.actualClientId); ((NetworkBehaviour)val3).__endSendClientRpc(ref val6, _tryAddObjectToBagClientRpc, val5, (RpcDelivery)0); } } } } } namespace BagConfig.Networking { internal static class NamedMessages { [CompilerGenerated] private static class <>O { public static HandleNamedMessageDelegate <0>__OnHostPresentClientRpc; public static HandleNamedMessageDelegate <1>__OnFixBagsClientRpc; } private static readonly string BaseName = typeof(NamedMessages).FullName; private static readonly string HostPresentClientRpcMessage = BaseName + "|HostPresentClientRpc"; private static readonly string FixBagsClientRpcMessage = BaseName + "|FixBagsClientRpc"; internal static void RegisterNamedMessages() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown CustomMessagingManager customMessagingManager = NetworkManager.Singleton.CustomMessagingManager; string hostPresentClientRpcMessage = HostPresentClientRpcMessage; object obj = <>O.<0>__OnHostPresentClientRpc; if (obj == null) { HandleNamedMessageDelegate val = OnHostPresentClientRpc; <>O.<0>__OnHostPresentClientRpc = val; obj = (object)val; } customMessagingManager.RegisterNamedMessageHandler(hostPresentClientRpcMessage, (HandleNamedMessageDelegate)obj); CustomMessagingManager customMessagingManager2 = NetworkManager.Singleton.CustomMessagingManager; string fixBagsClientRpcMessage = FixBagsClientRpcMessage; object obj2 = <>O.<1>__OnFixBagsClientRpc; if (obj2 == null) { HandleNamedMessageDelegate val2 = OnFixBagsClientRpc; <>O.<1>__OnFixBagsClientRpc = val2; obj2 = (object)val2; } customMessagingManager2.RegisterNamedMessageHandler(fixBagsClientRpcMessage, (HandleNamedMessageDelegate)obj2); } internal static void UnregisterNamedMessages() { NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(HostPresentClientRpcMessage); NetworkManager.Singleton.CustomMessagingManager.UnregisterNamedMessageHandler(FixBagsClientRpcMessage); } internal static void HostPresentClientRpc(IReadOnlyList targets = null) { //IL_0041: 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) if (NetworkManager.Singleton.IsServer) { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(0, (Allocator)2, -1); if (targets == null) { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(HostPresentClientRpcMessage, val, (NetworkDelivery)3); } else { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(HostPresentClientRpcMessage, targets, val, (NetworkDelivery)3); } } } private static void OnHostPresentClientRpc(ulong senderId, FastBufferReader data) { if (senderId == 0L) { BeltBagPatch.Enabled = true; } } internal static void FixBagsClientRpc(IReadOnlyList targets = null) { //IL_0041: 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) if (NetworkManager.Singleton.IsServer) { FastBufferWriter val = default(FastBufferWriter); ((FastBufferWriter)(ref val))..ctor(0, (Allocator)2, -1); if (targets == null) { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessageToAll(FixBagsClientRpcMessage, val, (NetworkDelivery)3); } else { NetworkManager.Singleton.CustomMessagingManager.SendNamedMessage(FixBagsClientRpcMessage, targets, val, (NetworkDelivery)3); } } } private static void OnFixBagsClientRpc(ulong senderId, FastBufferReader data) { if (senderId == 0L && !((Object)(object)StartOfRound.Instance == (Object)null)) { BagConfig.Log.LogWarning((object)"Host requested all beltBags to be freed!"); BeltBagItem[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); BeltBagItem[] array2 = array; foreach (BeltBagItem val in array2) { BagConfig.Log.LogDebug((object)$"Fixing status of 0x{((NetworkBehaviour)val).NetworkObjectId:X}, was: {val.tryingAddToBag}"); val.tryingAddToBag = false; val.tryingCheckBag = false; } } } } } namespace BagConfig.InputUtils { public class BagInputs : LcInputActions { public static BagInputs Instance { get; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction DropAll { get; set; } [InputAction(/*Could not decode attribute arguments.*/)] public InputAction GrabOne { get; set; } static BagInputs() { Instance = new BagInputs(); Instance.DropAll.performed += delegate { if (BeltBagPatch.Enabled && TryGetBeltBag(out var beltBag)) { BeltBagPatch.TryDumpItems(beltBag); } }; Instance.GrabOne.performed += delegate { if (BeltBagPatch.Enabled && TryGetBeltBag(out var beltBag)) { BeltBagPatch.TryGrabItem(beltBag); } }; static bool TryGetBeltBag(out BeltBagItem beltBag) { beltBag = null; GameNetworkManager instance = GameNetworkManager.Instance; if ((Object)(object)instance == (Object)null) { return false; } GrabbableObject currentlyHeldObjectServer = instance.localPlayerController.currentlyHeldObjectServer; BeltBagItem val = (BeltBagItem)(object)((currentlyHeldObjectServer is BeltBagItem) ? currentlyHeldObjectServer : null); if (val == null) { return false; } beltBag = val; return true; } } } } namespace BagConfig.Dependency { public static class InputUtilsProxy { private static bool? _enabled; public static bool Enabled { get { bool valueOrDefault = _enabled == true; if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("com.rune580.LethalCompanyInputUtils"); _enabled = valueOrDefault; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void Init() { if (Enabled) { _ = BagInputs.Instance; } } } public static class LethalConfigProxy { public struct CanModifyResult { public readonly bool CanModify; public readonly string Reason; public CanModifyResult(bool canModify, string reason) { CanModify = canModify; Reason = reason; } public static implicit operator CanModifyResult((bool result, string reason) tuple) { return new CanModifyResult(tuple.result, tuple.reason); } public static implicit operator (bool result, string reason)(CanModifyResult result) { return (result: result.CanModify, reason: result.Reason); } } public delegate CanModifyResult CanModifyDelegate(); private static bool? _enabled; public static bool Enabled { get { bool valueOrDefault = _enabled == true; if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig"); _enabled = valueOrDefault; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig(ConfigEntry entry, bool requiresRestart = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new TextInputFieldConfigItem(entry, new TextInputFieldOptions { RequiresRestart = requiresRestart, Name = GetPrettyConfigName(entry) })); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig(ConfigEntry entry, bool requiresRestart = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new BoolCheckBoxConfigItem(entry, new BoolCheckBoxOptions { RequiresRestart = requiresRestart, Name = GetPrettyConfigName(entry) })); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig(ConfigEntry entry, bool requiresRestart = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new FloatInputFieldConfigItem(entry, new FloatInputFieldOptions { RequiresRestart = requiresRestart, Name = GetPrettyConfigName(entry) })); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddConfig(ConfigEntry entry, bool requiresRestart = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown LethalConfigManager.AddConfigItem((BaseConfigItem)new IntInputFieldConfigItem(entry, new IntInputFieldOptions { RequiresRestart = requiresRestart, Name = GetPrettyConfigName(entry) })); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddButton(string section, string name, string description, string buttonText, Action callback, CanModifyDelegate canModify = null) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown GenericButtonConfigItem val = new GenericButtonConfigItem(section, name, description, buttonText, (GenericButtonHandler)delegate { callback?.Invoke(); }); if (canModify != null) { ((BaseOptions)val.ButtonOptions).CanModifyCallback = (CanModifyDelegate)(() => CanModifyResult.op_Implicit(((bool result, string reason))canModify())); } LethalConfigManager.AddConfigItem((BaseConfigItem)(object)val); } private static string GetPrettyConfigName(ConfigEntry entry) { return CultureInfo.InvariantCulture.TextInfo.ToTitleCase(((ConfigEntryBase)entry).Definition.Key.Replace("_", " ")); } } public static class LobbyCompatibilityChecker { private static bool? _enabled; public static bool Enabled { get { bool valueOrDefault = _enabled == true; if (!_enabled.HasValue) { valueOrDefault = Chainloader.PluginInfos.ContainsKey("BMX.LobbyCompatibility"); _enabled = valueOrDefault; } return _enabled.Value; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void Init() { PluginHelper.RegisterPlugin("lsy_windy.BagConfigTooltipFixed", Version.Parse("1.0.4"), (CompatibilityLevel)0, (VersionStrictness)2); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }