Decompiled source of Custom Item Behaviour Library v1.2.7
BepInEx/plugins/CustomItemBehaviourLibrary/CustomItemBehaviourLibrary.dll
Decompiled 3 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using CustomItemBehaviourLibrary.AbstractItems; using CustomItemBehaviourLibrary.Compatibility; using CustomItemBehaviourLibrary.Manager; using CustomItemBehaviourLibrary.Misc; using CustomItemBehaviourLibrary.NetcodePatcher; using CustomItemBehaviourLibrary.Patches; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using MoreShipUpgrades.Patches.Enemies; using MoreShipUpgrades.UpgradeComponents.TierUpgrades.AttributeUpgrades; using Unity.Netcode; using UnityEngine; using UnityEngine.Events; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] internal class <Module> { static <Module>() { } } 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; } } } namespace MoreShipUpgrades.Patches.Enemies { [HarmonyPatch(typeof(BaboonBirdAI))] internal static class BaboonBirdAIPatcher { [HarmonyPatch("DoLOSCheck")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> DoLOSCheckTranspiler(IEnumerable<CodeInstruction> instructions) { List<CodeInstruction> codes = new List<CodeInstruction>(instructions); int index = 0; PatchCheckItemInContainer(ref index, ref codes); return codes; } private static void PatchCheckItemInContainer(ref int index, ref List<CodeInstruction> codes) { //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown MethodInfo method = typeof(ContainerBehaviour).GetMethod("CheckIfItemInContainer"); while (index < codes.Count) { if (codes[index].opcode == OpCodes.Ldloc_S && codes[index].operand.ToString() == "GrabbableObject (18)" && !(codes[index + 1].opcode != OpCodes.Ldnull)) { codes.Insert(index + 3, new CodeInstruction(OpCodes.And, (object)null)); codes.Insert(index + 3, new CodeInstruction(OpCodes.Not, (object)null)); codes.Insert(index + 3, new CodeInstruction(OpCodes.Call, (object)method)); codes.Insert(index + 3, new CodeInstruction(OpCodes.Ldloc_S, codes[index].operand)); break; } index++; } index++; } } } namespace CustomItemBehaviourLibrary { [BepInPlugin("com.github.WhiteSpike.CustomItemBehaviourLibrary", "Custom Item Behaviour Library", "1.2.7")] public class Plugin : BaseUnityPlugin { internal static readonly Harmony harmony = new Harmony("com.github.WhiteSpike.CustomItemBehaviourLibrary"); internal static readonly ManualLogSource mls = Logger.CreateLogSource("Custom Item Behaviour Library"); private void Awake() { IEnumerable<Type> enumerable; try { enumerable = Assembly.GetExecutingAssembly().GetTypes(); } catch (ReflectionTypeLoadException ex) { enumerable = ex.Types.Where((Type t) => t != null); } foreach (Type item in enumerable) { MethodInfo[] methods = item.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic); MethodInfo[] array = methods; foreach (MethodInfo methodInfo in array) { object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false); if (customAttributes.Length != 0) { methodInfo.Invoke(null, null); } } } PatchMainVersion(); PatchBetaVersion(); mls.LogInfo((object)"Custom Item Behaviour Library 1.2.7 has been loaded successfully."); } internal static void PatchMainVersion() { harmony.PatchAll(typeof(BaboonBirdAIPatcher)); harmony.PatchAll(typeof(SpringManAIPatcher)); harmony.PatchAll(typeof(HUDManagerPatcher)); harmony.PatchAll(typeof(PlayerControllerBPatcher)); harmony.PatchAll(typeof(EntranceTeleportPatcher)); mls.LogInfo((object)"Patched relevant components for correct item behaviours..."); } internal static void PatchBetaVersion() { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); for (int i = 0; i < assemblies.Length; i++) { if (assemblies[i].GetName().Name != "Assembly-CSharp") { continue; } Type[] types = assemblies[i].GetTypes(); for (int j = 0; j < types.Length; j++) { if (types[j].Name == "BeltBagItem") { harmony.PatchAll(typeof(BeltBagItemPatcher)); mls.LogInfo((object)"Patched belt bag for correct behaviour with containers."); break; } } break; } } } public static class PluginInfo { public const string PLUGIN_GUID = "CustomItemBehaviourLibrary"; public const string PLUGIN_NAME = "CustomItemBehaviourLibrary"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace CustomItemBehaviourLibrary.Util { internal static class Constants { } } namespace CustomItemBehaviourLibrary.Patches { [HarmonyPatch(typeof(BeltBagItem))] internal static class BeltBagItemPatcher { [HarmonyPrefix] [HarmonyPatch("PutObjectInBagLocalClient")] private static void GrabObjectClientRpcPostfix(GrabbableObject gObject) { PlayerControllerBPatcher.ContainerUnparenting(gObject); } [HarmonyTranspiler] [HarmonyPatch("ItemInteractLeftRight")] private static IEnumerable<CodeInstruction> ItemInteractLeftRightTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown FieldInfo field = typeof(GrabbableObject).GetField("isHeldByEnemy"); MethodInfo method = typeof(BeltBagItemPatcher).GetMethod("IsContainer"); List<CodeInstruction> codes = new List<CodeInstruction>(instructions); int index = 0; Tools.FindField(ref index, ref codes, field, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: true, requireInstance: false, "Couldn't find the isHeldByEnemy field"); codes.Insert(index, new CodeInstruction(OpCodes.Ldloc_1, (object)null)); return codes; } public static bool IsContainer(GrabbableObject gObject) { return (Object)(object)((Component)gObject).GetComponent<ContainerBehaviour>() != (Object)null; } } [HarmonyPatch(typeof(EntranceTeleport))] internal static class EntranceTeleportPatcher { [HarmonyPatch("TeleportPlayerClientRpc")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TeleportPlayerClientRpcTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Expected O, but got Unknown MethodInfo method = typeof(ContainerBehaviour).GetMethod("ToggleStoredItemsBooleans"); FieldInfo field = typeof(EntranceTeleport).GetField("isEntranceToBuilding"); FieldInfo field2 = typeof(EntranceTeleport).GetField("playersManager"); FieldInfo field3 = typeof(StartOfRound).GetField("allPlayerScripts"); FieldInfo field4 = typeof(PlayerControllerB).GetField("ItemSlots"); List<CodeInstruction> codes = new List<CodeInstruction>(instructions); int index = 0; Tools.FindField(ref index, ref codes, field, null, skip: true); Tools.FindField(ref index, ref codes, field, null, skip: true); index++; codes.Insert(index, new CodeInstruction(OpCodes.Call, (object)method)); codes.Insert(index, new CodeInstruction(OpCodes.Ldfld, (object)field)); codes.Insert(index, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); codes.Insert(index, new CodeInstruction(OpCodes.Ldelem_Ref, (object)null)); codes.Insert(index, new CodeInstruction(OpCodes.Ldloc_0, (object)null)); codes.Insert(index, new CodeInstruction(OpCodes.Ldfld, (object)field4)); codes.Insert(index, new CodeInstruction(OpCodes.Ldelem_Ref, (object)null)); codes.Insert(index, new CodeInstruction(OpCodes.Ldarg_1, (object)null)); codes.Insert(index, new CodeInstruction(OpCodes.Ldfld, (object)field3)); codes.Insert(index, new CodeInstruction(OpCodes.Ldfld, (object)field2)); codes.Insert(index, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); return codes; } [HarmonyPatch("TeleportPlayer")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> TeleportPlayerTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Expected O, but got Unknown //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Expected O, but got Unknown //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown MethodInfo method = typeof(ContainerBehaviour).GetMethod("ToggleStoredItemsBooleans"); FieldInfo field = typeof(EntranceTeleport).GetField("isEntranceToBuilding"); MethodInfo methodInfo = AccessTools.DeclaredPropertyGetter(typeof(GameNetworkManager), "Instance"); FieldInfo field2 = typeof(GameNetworkManager).GetField("localPlayerController"); FieldInfo field3 = typeof(PlayerControllerB).GetField("ItemSlots"); List<CodeInstruction> codes = new List<CodeInstruction>(instructions); int index = 0; Tools.FindField(ref index, ref codes, field, null, skip: true); Tools.FindField(ref index, ref codes, field, null, skip: true); index++; codes.Insert(index, new CodeInstruction(OpCodes.Call, (object)method)); codes.Insert(index, new CodeInstruction(OpCodes.Ldfld, (object)field)); codes.Insert(index, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); codes.Insert(index, new CodeInstruction(OpCodes.Ldelem_Ref, (object)null)); codes.Insert(index, new CodeInstruction(OpCodes.Ldloc_2, (object)null)); codes.Insert(index, new CodeInstruction(OpCodes.Ldfld, (object)field3)); codes.Insert(index, new CodeInstruction(OpCodes.Ldfld, (object)field2)); codes.Insert(index, new CodeInstruction(OpCodes.Call, (object)methodInfo)); return codes; } } [HarmonyPatch(typeof(HUDManager))] internal static class HUDManagerPatcher { [HarmonyPostfix] [HarmonyPatch("MeetsScanNodeRequirements")] private static void MeetsScanNodeRequirementsPostFix(ScanNodeProperties node, ref bool __result) { if (!((Object)(object)node == (Object)null) && !((Object)(object)((Component)node).transform.parent == (Object)null)) { GrabbableObject component = ((Component)((Component)node).transform.parent).GetComponent<GrabbableObject>(); if (!((Object)(object)component == (Object)null) && (Object)(object)((Component)component).gameObject.GetComponentInParent<ContainerBehaviour>() != (Object)null) { __result = false; } } } } [HarmonyPatch(typeof(PlayerControllerB))] internal static class PlayerControllerBPatcher { [HarmonyPrefix] [HarmonyPatch("DropAllHeldItems")] private static bool DontDropItems(PlayerControllerB __instance) { if (!PortableTeleporterBehaviour.TPButtonPressed) { return true; } PortableTeleporterBehaviour.TPButtonPressed = false; __instance.isSinking = false; __instance.isUnderwater = false; __instance.sinkingValue = 0f; __instance.statusEffectAudio.Stop(); return false; } [HarmonyPostfix] [HarmonyPatch("Awake")] private static void StartPostfix(PlayerControllerB __instance) { ((Component)__instance).gameObject.AddComponent<PlayerManager>(); } [HarmonyPostfix] [HarmonyPatch("KillPlayer")] private static void KillPlayerPostfix(PlayerControllerB __instance) { if ((Object)(object)__instance != (Object)(object)GameNetworkManager.Instance.localPlayerController || !PlayerManager.instance.holdingContainer) { return; } if (LategameCompatibility.Enabled) { GrabbableObject[] itemSlots = __instance.ItemSlots; foreach (GrabbableObject val in itemSlots) { ContainerBehaviour component = ((Component)val).GetComponent<ContainerBehaviour>(); if (!((Object)(object)component == (Object)null)) { component.UpdatePlayerAttributes(grabbing: false); break; } } } else { ContainerBehaviour component2 = ((Component)__instance.currentlyHeldObjectServer).GetComponent<ContainerBehaviour>(); component2.UpdatePlayerAttributes(grabbing: false); } } [HarmonyTranspiler] [HarmonyPatch("SetPlayerSanityLevel")] private static IEnumerable<CodeInstruction> SetPlayerSanityLevelTranspiler(IEnumerable<CodeInstruction> instructions) { MethodInfo method = typeof(PlayerManager).GetMethod("DecreaseSanityIncrease"); int index = 0; List<CodeInstruction> codes = new List<CodeInstruction>(instructions); Tools.FindFloat(ref index, ref codes, 0.8f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first insanity multiplier"); Tools.FindFloat(ref index, ref codes, 0.2f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first insanity multiplier"); Tools.FindFloat(ref index, ref codes, -2f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first insanity multiplier"); Tools.FindFloat(ref index, ref codes, 0.5f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first insanity multiplier"); Tools.FindFloat(ref index, ref codes, 0.3f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first insanity multiplier"); Tools.FindFloat(ref index, ref codes, -3f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first insanity multiplier"); return codes; } [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions) { MethodInfo method = typeof(ContainerBehaviour).GetMethod("CheckIfPlayerCarryingContainerMovement"); FieldInfo field = typeof(PlayerControllerB).GetField("carryWeight"); int index = 0; List<CodeInstruction> codes = new List<CodeInstruction>(instructions); Tools.FindField(ref index, ref codes, field, null, skip: true, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find first carryWeight occurence"); Tools.FindField(ref index, ref codes, field, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find second carryWeight occurence"); Tools.FindField(ref index, ref codes, field, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find second carryWeight occurence"); return codes; } [HarmonyPatch("PlayerLookInput")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> PlayerLookInputTranspiler(IEnumerable<CodeInstruction> instructions) { MethodInfo method = typeof(ContainerBehaviour).GetMethod("CheckIfPlayerCarryingContainerLookSensitivity"); List<CodeInstruction> codes = new List<CodeInstruction>(instructions); int index = 0; Tools.FindFloat(ref index, ref codes, 0.008f, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: false, requireInstance: false, "Couldn't find look sensitivity value we wanted to influence"); return codes; } [HarmonyPatch("Crouch_performed")] [HarmonyTranspiler] private static IEnumerable<CodeInstruction> CrouchPerformmedTranspiler(IEnumerable<CodeInstruction> instructions) { MethodInfo method = typeof(ContainerBehaviour).GetMethod("CheckIfPlayerCarryingContainer"); FieldInfo field = typeof(QuickMenuManager).GetField("isMenuOpen"); List<CodeInstruction> codes = new List<CodeInstruction>(instructions); int index = 0; Tools.FindField(ref index, ref codes, field, method, skip: false, notInstruction: false, andInstruction: false, orInstruction: true, requireInstance: false, "Couldn't find isMenuOpen field"); return codes; } [HarmonyPostfix] [HarmonyPatch("GrabObjectClientRpc")] private static void GrabObjectClientRpcPostfix(PlayerControllerB __instance) { ContainerUnparenting(__instance.currentlyHeldObjectServer); } internal static void ContainerUnparenting(GrabbableObject heldObject) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)heldObject == (Object)null)) { ContainerBehaviour componentInParent = ((Component)heldObject).GetComponentInParent<ContainerBehaviour>(); if (!((Object)(object)componentInParent == (Object)null) && !(heldObject is ContainerBehaviour)) { ((Component)heldObject).transform.SetParent(heldObject.parentObject); ((Component)heldObject).transform.localScale = heldObject.originalScale; componentInParent.DecrementStoredItems(); } } } } [HarmonyPatch(typeof(SpringManAI))] internal static class SpringManAIPatcher { [HarmonyPrefix] [HarmonyPatch("DoAIInterval")] private static void DoAllIntervalPrefix(ref SpringManAI __instance) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) if (LookoutBehaviour.HasLineOfSightToPeepers(((Component)__instance).transform.position)) { ((EnemyAI)__instance).currentBehaviourStateIndex = 1; } } [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> Update_Transpiler(IEnumerable<CodeInstruction> instructions) { //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Expected O, but got Unknown //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Expected O, but got Unknown //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown MethodInfo method = typeof(LookoutBehaviour).GetMethod("HasLineOfSightToPeepers", BindingFlags.Static | BindingFlags.Public); MethodInfo method2 = typeof(SpringManAI).GetMethod("get_transform"); MethodInfo method3 = typeof(Transform).GetMethod("get_position"); bool flag = false; List<CodeInstruction> list = new List<CodeInstruction>(instructions); for (int i = 1; i < list.Count; i++) { if (flag) { break; } if (!(list[i - 1].opcode != OpCodes.Ldc_I4_0) && !(list[i].opcode != OpCodes.Stloc_3)) { list.Insert(i, new CodeInstruction(OpCodes.Or, (object)null)); list.Insert(i, new CodeInstruction(OpCodes.Call, (object)method)); list.Insert(i, new CodeInstruction(OpCodes.Callvirt, (object)method3)); list.Insert(i, new CodeInstruction(OpCodes.Call, (object)method2)); list.Insert(i, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); flag = true; } } return list; } } } namespace CustomItemBehaviourLibrary.Misc { public static class AssetBundleHandler { public static AudioClip[] GetAudioClipList(this AssetBundle bundle, string name, int length) { AudioClip[] array = (AudioClip[])(object)new AudioClip[length]; for (int i = 0; i < length; i++) { array[i] = bundle.TryLoadAudioClipAsset($"{name} {i}"); } return array; } public static AudioClip TryLoadAudioClipAsset(this AssetBundle bundle, string path) { return bundle.LoadAsset<AudioClip>(path); } } internal static class Metadata { public const string GUID = "com.github.WhiteSpike.CustomItemBehaviourLibrary"; public const string NAME = "Custom Item Behaviour Library"; public const string VERSION = "1.2.7"; } internal static class Tools { public static void FindCodeInstruction(ref int index, ref List<CodeInstruction> codes, object findValue, MethodInfo addCode, bool skip = false, bool requireInstance = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, string errorMessage = "Not found") { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown bool flag = false; while (index < codes.Count) { if (CheckCodeInstruction(codes[index], findValue)) { flag = true; if (!skip) { if (andInstruction) { codes.Insert(index + 1, new CodeInstruction(OpCodes.And, (object)null)); } if (!andInstruction && orInstruction) { codes.Insert(index + 1, new CodeInstruction(OpCodes.Or, (object)null)); } if (notInstruction) { codes.Insert(index + 1, new CodeInstruction(OpCodes.Not, (object)null)); } codes.Insert(index + 1, new CodeInstruction(OpCodes.Call, (object)addCode)); if (requireInstance) { codes.Insert(index + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); } } break; } index++; } if (!flag) { Plugin.mls.LogError((object)errorMessage); } index++; } public static void FindLocalField(ref int index, ref List<CodeInstruction> codes, int localIndex, object addCode = null, bool skip = false, bool store = false, bool requireInstance = false, string errorMessage = "Not found") { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Expected O, but got Unknown bool flag = false; while (index < codes.Count) { if (CheckCodeInstruction(codes[index], localIndex, store)) { flag = true; if (!skip) { codes.Insert(index + 1, new CodeInstruction(OpCodes.Call, addCode)); if (requireInstance) { codes.Insert(index + 1, new CodeInstruction(OpCodes.Ldarg_0, (object)null)); } } break; } index++; } if (!flag) { Plugin.mls.LogError((object)errorMessage); } index++; } public static void FindString(ref int index, ref List<CodeInstruction> codes, string findValue, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage); } public static void FindField(ref int index, ref List<CodeInstruction> codes, FieldInfo findField, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { FindCodeInstruction(ref index, ref codes, findField, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage); } public static void FindMethod(ref int index, ref List<CodeInstruction> codes, MethodInfo findMethod, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { FindCodeInstruction(ref index, ref codes, findMethod, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage); } public static void FindFloat(ref int index, ref List<CodeInstruction> codes, float findValue, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage); } public static void FindInteger(ref int index, ref List<CodeInstruction> codes, sbyte findValue, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction, andInstruction, orInstruction, errorMessage); } public static void FindSub(ref int index, ref List<CodeInstruction> codes, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { object findValue = OpCodes.Sub; bool notInstruction2 = notInstruction; bool andInstruction2 = andInstruction; bool orInstruction2 = orInstruction; FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction2, andInstruction2, orInstruction2, errorMessage); } public static void FindDiv(ref int index, ref List<CodeInstruction> codes, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { object findValue = OpCodes.Div; bool notInstruction2 = notInstruction; bool andInstruction2 = andInstruction; bool orInstruction2 = orInstruction; FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction2, andInstruction2, orInstruction2, errorMessage); } public static void FindAdd(ref int index, ref List<CodeInstruction> codes, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { object findValue = OpCodes.Add; bool notInstruction2 = notInstruction; bool andInstruction2 = andInstruction; bool orInstruction2 = orInstruction; FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction2, andInstruction2, orInstruction2, errorMessage); } public static void FindMul(ref int index, ref List<CodeInstruction> codes, MethodInfo addCode = null, bool skip = false, bool notInstruction = false, bool andInstruction = false, bool orInstruction = false, bool requireInstance = false, string errorMessage = "Not found") { object findValue = OpCodes.Mul; bool notInstruction2 = notInstruction; bool andInstruction2 = andInstruction; bool orInstruction2 = orInstruction; FindCodeInstruction(ref index, ref codes, findValue, addCode, skip, requireInstance, notInstruction2, andInstruction2, orInstruction2, errorMessage); } private static bool CheckCodeInstruction(CodeInstruction code, int localIndex, bool store = false) { if (!store) { return localIndex switch { 0 => code.opcode == OpCodes.Ldloc_0, 1 => code.opcode == OpCodes.Ldloc_1, 2 => code.opcode == OpCodes.Ldloc_2, 3 => code.opcode == OpCodes.Ldloc_3, _ => code.opcode == OpCodes.Ldloc && (int)code.operand == localIndex, }; } return localIndex switch { 0 => code.opcode == OpCodes.Stloc_0, 1 => code.opcode == OpCodes.Stloc_1, 2 => code.opcode == OpCodes.Stloc_2, 3 => code.opcode == OpCodes.Stloc_3, _ => code.opcode == OpCodes.Stloc && (int)code.operand == localIndex, }; } private static bool CheckCodeInstruction(CodeInstruction code, object findValue) { if (findValue is sbyte) { return CheckIntegerCodeInstruction(code, findValue); } if (findValue is float) { return code.opcode == OpCodes.Ldc_R4 && code.operand.Equals(findValue); } if (findValue is string) { return code.opcode == OpCodes.Ldstr && code.operand.Equals(findValue); } if (findValue is MethodInfo) { return (code.opcode == OpCodes.Call || code.opcode == OpCodes.Callvirt) && code.operand == findValue; } if (findValue is FieldInfo) { return (code.opcode == OpCodes.Ldfld || code.opcode == OpCodes.Stfld) && code.operand == findValue; } if (findValue is OpCode) { return code.opcode == (OpCode)findValue; } return false; } private static bool CheckIntegerCodeInstruction(CodeInstruction code, object findValue) { return (sbyte)findValue switch { 0 => code.opcode == OpCodes.Ldc_I4_0, 1 => code.opcode == OpCodes.Ldc_I4_1, 2 => code.opcode == OpCodes.Ldc_I4_2, 3 => code.opcode == OpCodes.Ldc_I4_3, 4 => code.opcode == OpCodes.Ldc_I4_4, 5 => code.opcode == OpCodes.Ldc_I4_5, 6 => code.opcode == OpCodes.Ldc_I4_6, 7 => code.opcode == OpCodes.Ldc_I4_7, 8 => code.opcode == OpCodes.Ldc_I4_8, _ => code.opcode == OpCodes.Ldc_I4_S && code.operand.Equals(findValue), }; } public static void ShuffleList<T>(List<T> list) { if (list == null) { throw new ArgumentNullException("list"); } Random random = new Random(); int num = list.Count; while (num > 1) { num--; int index = random.Next(num + 1); T value = list[index]; list[index] = list[num]; list[num] = value; } } public static bool SpawnMob(string mob, Vector3 position, int numToSpawn) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < RoundManager.Instance.currentLevel.Enemies.Count; i++) { if (RoundManager.Instance.currentLevel.Enemies[i].enemyType.enemyName == mob) { for (int j = 0; j < numToSpawn; j++) { RoundManager.Instance.SpawnEnemyOnServer(position, 0f, i); } return true; } } return false; } internal static string GenerateInfoForUpgrade(string infoFormat, int initialPrice, int[] incrementalPrices, Func<int, float> infoFunction, bool skipFirst = false) { string text = (skipFirst ? "" : string.Format(infoFormat, 1, initialPrice, infoFunction(0))); for (int i = 0; i < incrementalPrices.Length; i++) { float num = infoFunction(i + 1); text = ((num % 1f != 0f) ? (text + string.Format(infoFormat, i + 2, incrementalPrices[i], num)) : (text + string.Format(infoFormat, i + 2, incrementalPrices[i], Mathf.RoundToInt(num)))); } return text; } public static Color ConvertValueToColor(string hex, Color defaultValue) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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) Color result = default(Color); if (hex == null || !ColorUtility.TryParseHtmlString("#" + hex.Trim('#', ' '), ref result)) { return defaultValue; } return result; } internal static string WrapText(string text, int availableLength, string leftPadding = "", string rightPadding = "", bool padLeftFirst = true) { int num = availableLength - leftPadding.Length - rightPadding.Length; string text2 = ""; string text3 = ""; int num2 = 0; int num3 = -1; bool flag = true; bool flag2 = false; for (int i = 0; i < text.Length; i++) { char c = text[i]; if (c == '<') { flag2 = true; } if (c == ' ' && !flag2) { num3 = text3.Length; } if (c != '\n') { text3 += c; if (!flag2) { num2++; } } if (c == '>' && flag2) { flag2 = false; } if (num2 < num && c != '\n') { continue; } if (c != '\n' && c != ' ') { if (num3 != -1) { string text4 = ((padLeftFirst || !flag) ? leftPadding : "") + text3.Substring(0, num3) + new string(' ', Mathf.Max(0, num - num3)) + rightPadding; text2 = text2 + text4 + "\n"; text3 = text3.Substring(num3 + 1); } else { string text5 = ((padLeftFirst || !flag) ? leftPadding : "") + text3 + rightPadding; text2 = text2 + text5 + "\n"; text3 = ""; } } else { if (text3 != "") { text2 = text2 + ((padLeftFirst || !flag) ? leftPadding : "") + text3 + new string(' ', Mathf.Max(0, num - num2)) + rightPadding + "\n"; } text3 = ""; } num3 = -1; flag = false; num2 = text3.Length; } if (text3 != "") { text2 = text2 + ((padLeftFirst || !flag) ? leftPadding : "") + text3 + new string(' ', Mathf.Max(0, num - num2)) + rightPadding + "\n"; } return text2; } internal static void SpawnExplosion(Vector3 explosionPosition, bool spawnExplosionEffect = false, float killRange = 1f, float damageRange = 1f, int nonLethalDamage = 50, float physicsForce = 0f, GameObject overridePrefab = null, bool goThroughCar = false) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Landmine.SpawnExplosion(explosionPosition, spawnExplosionEffect, killRange, damageRange, nonLethalDamage, physicsForce, overridePrefab, goThroughCar); } } } namespace CustomItemBehaviourLibrary.Manager { internal class PlayerManager : MonoBehaviour { internal const float DEFAULT_MULTIPLIER = 1f; internal float sensitivityMultiplier = 1f; internal float sloppyMultiplier = 1f; internal bool holdingContainer = false; internal float sanityOvertimeTimer; internal float sanityOvertimeReplenish; internal static PlayerManager instance; private void Start() { instance = this; sanityOvertimeReplenish = 0f; sanityOvertimeTimer = 0f; } private void Update() { DepleteSanityOvertime(); } internal void DepleteSanityOvertime() { if (!(sanityOvertimeReplenish <= 0f)) { sanityOvertimeTimer -= Time.deltaTime; if (sanityOvertimeTimer <= 0f) { sanityOvertimeReplenish = 0f; } } } internal void AddSanityOvertimeTimer(float sanityOvertimeTimer) { this.sanityOvertimeTimer += sanityOvertimeTimer; } internal void SetSanityOvertimeReplenish(float sanityOvertimeReplenish) { this.sanityOvertimeReplenish = sanityOvertimeReplenish; } internal static float GetSanityOvertimeReplenish() { return instance.sanityOvertimeReplenish; } public static float DecreaseSanityIncrease(float defaultValue) { return defaultValue - instance.sanityOvertimeReplenish; } internal void SetSensitivityMultiplier(float sensitivityMultiplier) { this.sensitivityMultiplier = sensitivityMultiplier; } internal void SetSloppyMultiplier(float sloppyMultiplier) { this.sloppyMultiplier = sloppyMultiplier; } internal void SetHoldingContainer(bool holdingContainer) { this.holdingContainer = holdingContainer; } internal void ResetSensitivityMultiplier() { sensitivityMultiplier = 1f; } internal void ResetSloppyMultiplier() { sloppyMultiplier = 1f; } public float GetSensitivityMultiplier() { return sensitivityMultiplier; } public float GetSloppyMultiplier() { return sloppyMultiplier; } public bool GetHoldingContainer() { return holdingContainer; } } } namespace CustomItemBehaviourLibrary.Compatibility { internal static class LategameCompatibility { public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.malco.lethalcompany.moreshipupgrades"); internal static void AddWeight(ContainerBehaviour containerBehaviour) { PlayerControllerB playerHeldBy = ((GrabbableObject)containerBehaviour).playerHeldBy; playerHeldBy.carryWeight -= Mathf.Clamp(BackMuscles.DecreasePossibleWeight(((GrabbableObject)containerBehaviour).itemProperties.weight - 1f), 0f, 10f); PlayerControllerB playerHeldBy2 = ((GrabbableObject)containerBehaviour).playerHeldBy; playerHeldBy2.carryWeight += Mathf.Clamp(BackMuscles.DecreasePossibleWeight(containerBehaviour.totalWeight - 1f), 0f, 10f); } internal static void AddTotalWeight(ContainerBehaviour containerBehaviour) { PlayerControllerB playerHeldBy = ((GrabbableObject)containerBehaviour).playerHeldBy; playerHeldBy.carryWeight += Mathf.Clamp(BackMuscles.DecreasePossibleWeight(containerBehaviour.totalWeight - 1f), 0f, 10f); } internal static void RemoveTotalWeight(ContainerBehaviour containerBehaviour) { PlayerControllerB playerHeldBy = ((GrabbableObject)containerBehaviour).playerHeldBy; playerHeldBy.carryWeight -= Mathf.Clamp(BackMuscles.DecreasePossibleWeight(containerBehaviour.totalWeight - 1f), 0f, 10f); } internal static void RemoveWeight(ContainerBehaviour containerBehaviour) { PlayerControllerB playerHeldBy = ((GrabbableObject)containerBehaviour).playerHeldBy; playerHeldBy.carryWeight += Mathf.Clamp(BackMuscles.DecreasePossibleWeight(((GrabbableObject)containerBehaviour).itemProperties.weight - 1f), 0f, 10f); PlayerControllerB playerHeldBy2 = ((GrabbableObject)containerBehaviour).playerHeldBy; playerHeldBy2.carryWeight -= Mathf.Clamp(BackMuscles.DecreasePossibleWeight(containerBehaviour.totalWeight - 1f), 0f, 10f); } } } namespace CustomItemBehaviourLibrary.AbstractItems { public abstract class ContainerBehaviour : GrabbableObject { public enum Restrictions { None, TotalWeight, ItemCount, All } internal const float VELOCITY_APPLY_EFFECT_THRESHOLD = 5f; protected Restrictions restriction; private Random randomNoise; private AudioSource wheelsNoise; protected AudioClip[] wheelsClip; protected float noiseRange; private float soundCounter; protected int maximumAmountItems; protected float maximumWeightAllowed; private int currentAmountItems; internal float totalWeight; protected float weightReduceMultiplier; protected float defaultWeight; protected float sloppiness; protected float lookSensitivityDrawback; protected bool makeItemsInvisible; private BoxCollider container; protected InteractTrigger[] triggers; protected BoxCollider[] triggerColliders; protected bool playSounds; private Dictionary<Restrictions, Func<bool>> checkMethods; protected List<Collider> noItemsDepositedCollider; protected List<Collider> itemsDepositedCollider; private const string NO_ITEMS_TEXT = "No items to deposit..."; private const string FULL_TEXT = "Too many items in the container"; private const string TOO_MUCH_WEIGHT_TEXT = "Too much weight in the container..."; private const string ALL_FULL_TEXT = "Cannot insert any more items in the container..."; private const string WHEELBARROWCEPTION_TEXT = "You're not allowed to do that..."; private const string ENEMY_DEPOSIT_TEXT = "You shouldn't put alive things in here..."; private const string DEPOSIT_TEXT = "Depositing item..."; private const string START_DEPOSIT_TEXT = "Deposit item: [LMB]"; private const string WITHDRAW_ITEM_TEXT = "Withdraw item: [LMB]"; public override void Start() { ((GrabbableObject)this).Start(); randomNoise = new Random(StartOfRound.Instance.randomMapSeed + 80); defaultWeight = base.itemProperties.weight; totalWeight = defaultWeight; soundCounter = 0f; wheelsNoise = ((Component)this).GetComponent<AudioSource>(); triggers = ((Component)this).GetComponentsInChildren<InteractTrigger>(); triggerColliders = (BoxCollider[])(object)new BoxCollider[triggers.Length]; BoxCollider[] componentsInChildren = ((Component)this).GetComponentsInChildren<BoxCollider>(); foreach (BoxCollider val in componentsInChildren) { if (!(((Object)val).name != "PlaceableBounds")) { container = val; break; } } for (int j = 0; j < triggers.Length; j++) { InteractTrigger val2 = triggers[j]; ((UnityEvent<PlayerControllerB>)(object)val2.onInteract).AddListener((UnityAction<PlayerControllerB>)InteractContainer); ((Component)val2).tag = "InteractTrigger"; val2.interactCooldown = false; val2.cooldownTime = 0f; triggerColliders[j] = ((Component)val2).GetComponent<BoxCollider>(); } checkMethods = new Dictionary<Restrictions, Func<bool>> { [Restrictions.ItemCount] = CheckContainerItemCountRestriction, [Restrictions.TotalWeight] = CheckContainerWeightRestriction, [Restrictions.All] = CheckContainerAllRestrictions }; noItemsDepositedCollider = new List<Collider>(); itemsDepositedCollider = new List<Collider>(); foreach (Collider item in base.propColliders.Where((Collider x) => ((Component)x).CompareTag("PhysicsProp"))) { if (!item.enabled) { noItemsDepositedCollider.Add(item); } else { itemsDepositedCollider.Add(item); } } ToggleGrabColliders(currentAmountItems > 0); SetupItemAttributes(); } public float GetSloppiness() { return sloppiness; } public float GetLookSensitivityDrawback() { return lookSensitivityDrawback; } public override void Update() { ((GrabbableObject)this).Update(); UpdateContainerSounds(); UpdateInteractTriggers(); bool enabled = ShowDepositPrompts(); for (int i = 0; i < triggerColliders.Length; i++) { BoxCollider val = triggerColliders[i]; ((Collider)val).enabled = enabled; } } protected virtual void ToggleGrabColliders(bool deposittedItems) { foreach (Collider item in noItemsDepositedCollider) { item.enabled = !deposittedItems; } foreach (Collider item2 in itemsDepositedCollider) { item2.enabled = deposittedItems; } } public void UpdateContainerDrop() { if (base.isHeld && !((Object)(object)base.playerHeldBy != (Object)(object)GameNetworkManager.Instance.localPlayerController) && currentAmountItems > 0) { DropAllItemsInContainerServerRpc(); } } [ServerRpc(RequireOwnership = false)] private void DropAllItemsInContainerServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(76295531u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 76295531u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { DropAllItemsInContainerClientRpc(); } } } [ClientRpc] private void DropAllItemsInContainerClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3995238815u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3995238815u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } GrabbableObject[] componentsInChildren = ((Component)this).GetComponentsInChildren<GrabbableObject>(); for (int i = 0; i < componentsInChildren.Length; i++) { if (!((Object)(object)componentsInChildren[i] == (Object)(object)this)) { DropItem(ref componentsInChildren[i]); } } UpdateContainerWeightServerRpc(); } protected void DropItem(ref GrabbableObject grabbableObject) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) grabbableObject.parentObject = null; grabbableObject.heldByPlayerOnServer = false; if (base.isInElevator) { ((Component)grabbableObject).transform.SetParent(base.playerHeldBy.playersManager.elevatorTransform, true); } else { ((Component)grabbableObject).transform.SetParent(base.playerHeldBy.playersManager.propsContainer, true); } base.playerHeldBy.SetItemInElevator(base.playerHeldBy.isInHangarShipRoom, base.isInElevator, grabbableObject); grabbableObject.EnablePhysics(true); grabbableObject.EnableItemMeshes(true); ((Component)grabbableObject).transform.localScale = grabbableObject.originalScale; grabbableObject.isHeld = false; grabbableObject.isPocketed = false; grabbableObject.startFallingPosition = ((Component)grabbableObject).transform.parent.InverseTransformPoint(((Component)grabbableObject).transform.position); grabbableObject.FallToGround(true, false, default(Vector3)); grabbableObject.fallTime = Random.Range(-0.3f, 0.05f); grabbableObject.hasHitGround = false; if (!grabbableObject.itemProperties.syncDiscardFunction) { grabbableObject.playerHeldBy = null; } } public override void EquipItem() { ((GrabbableObject)this).EquipItem(); GrabbableObject[] componentsInChildren = ((Component)this).GetComponentsInChildren<GrabbableObject>(); for (int i = 0; i < componentsInChildren.Length; i++) { if (!((Object)(object)componentsInChildren[i] == (Object)(object)this)) { componentsInChildren[i].EnableItemMeshes(!makeItemsInvisible); } } } private void UpdateContainerSounds() { //IL_0045: 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_00fd: Unknown result type (might be due to invalid IL or missing references) soundCounter += Time.deltaTime; if (!base.isHeld || (Object)(object)wheelsNoise == (Object)null) { return; } Vector3 velocity = base.playerHeldBy.thisController.velocity; if (((Vector3)(ref velocity)).magnitude == 0f) { wheelsNoise.Stop(); } else if (!(soundCounter < 2f)) { soundCounter = 0f; int num = randomNoise.Next(0, wheelsClip.Length); if (playSounds) { wheelsNoise.PlayOneShot(wheelsClip[num], 0.2f); } if (playSounds) { WalkieTalkie.TransmitOneShotAudio(wheelsNoise, wheelsClip[num], 0.2f); } RoundManager.Instance.PlayAudibleNoise(((Component)this).transform.position, noiseRange, 0.8f, 0, base.isInElevator && StartOfRound.Instance.hangarDoorsClosed, 0); } } private void UpdateInteractTriggers() { PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null) { SetInteractTriggers(interactable: false, "No items to deposit..."); return; } if (!localPlayerController.isHoldingObject) { SetInteractTriggers(interactable: false, "No items to deposit..."); return; } GrabbableObject currentlyHeldObjectServer = localPlayerController.currentlyHeldObjectServer; if ((Object)(object)((Component)currentlyHeldObjectServer).GetComponent<ContainerBehaviour>() != (Object)null) { SetInteractTriggers(interactable: false, "You're not allowed to do that..."); return; } EnemyAI component = ((Component)currentlyHeldObjectServer).GetComponent<EnemyAI>(); if ((Object)(object)component != (Object)null && !component.isEnemyDead) { SetInteractTriggers(interactable: false, "You shouldn't put alive things in here..."); } else if (!CheckContainerRestrictions()) { SetInteractTriggers(interactable: true); } } private void SetInteractTriggers(bool interactable = false, string hoverTip = "Deposit item: [LMB]") { InteractTrigger[] array = triggers; foreach (InteractTrigger val in array) { val.interactable = interactable; if (interactable) { val.hoverTip = hoverTip; } else { val.disabledHoverTip = hoverTip; } } } private void EnableInteractTriggers(bool enabled) { InteractTrigger[] array = triggers; foreach (InteractTrigger val in array) { ((Component)val).gameObject.SetActive(enabled); } } private bool CheckContainerRestrictions() { if (restriction == Restrictions.None) { return false; } return checkMethods[restriction](); } private bool CheckContainerAllRestrictions() { bool flag = totalWeight > 1f + maximumWeightAllowed / 100f; bool flag2 = currentAmountItems >= maximumAmountItems; if (flag || flag2) { SetInteractTriggers(interactable: false, "Cannot insert any more items in the container..."); return true; } return false; } private bool CheckContainerWeightRestriction() { if (totalWeight > 1f + maximumWeightAllowed / 100f) { SetInteractTriggers(interactable: false, "Too much weight in the container..."); return true; } return false; } private bool CheckContainerItemCountRestriction() { if (currentAmountItems >= maximumAmountItems) { SetInteractTriggers(interactable: false, "Too many items in the container"); return true; } return false; } internal void UpdatePlayerAttributes(bool grabbing) { if (grabbing) { if (LategameCompatibility.Enabled) { LategameCompatibility.AddWeight(this); } else { PlayerControllerB playerHeldBy = base.playerHeldBy; playerHeldBy.carryWeight -= Mathf.Clamp(base.itemProperties.weight - 1f, 0f, 10f); PlayerControllerB playerHeldBy2 = base.playerHeldBy; playerHeldBy2.carryWeight += Mathf.Clamp(totalWeight - 1f, 0f, 10f); } PlayerManager.instance.SetSensitivityMultiplier(lookSensitivityDrawback); PlayerManager.instance.SetSloppyMultiplier(sloppiness); PlayerManager.instance.SetHoldingContainer(holdingContainer: true); } else { if (LategameCompatibility.Enabled) { LategameCompatibility.RemoveWeight(this); } else { PlayerControllerB playerHeldBy3 = base.playerHeldBy; playerHeldBy3.carryWeight += Mathf.Clamp(base.itemProperties.weight - 1f, 0f, 10f); PlayerControllerB playerHeldBy4 = base.playerHeldBy; playerHeldBy4.carryWeight -= Mathf.Clamp(totalWeight - 1f, 0f, 10f); } PlayerManager.instance.ResetSensitivityMultiplier(); PlayerManager.instance.ResetSloppyMultiplier(); PlayerManager.instance.SetHoldingContainer(holdingContainer: false); } } public override void DiscardItem() { wheelsNoise.Stop(); if (Object.op_Implicit((Object)(object)base.playerHeldBy) && (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)base.playerHeldBy) { UpdatePlayerAttributes(grabbing: false); EnableInteractTriggers(enabled: true); } GrabbableObject[] componentsInChildren = ((Component)this).GetComponentsInChildren<GrabbableObject>(); for (int i = 0; i < componentsInChildren.Length; i++) { if (!(componentsInChildren[i] is ContainerBehaviour)) { base.playerHeldBy.SetItemInElevator(base.playerHeldBy.isInHangarShipRoom, base.playerHeldBy.isInElevator, componentsInChildren[i]); componentsInChildren[i].EnableItemMeshes(!makeItemsInvisible); } } ToggleGrabColliders(currentAmountItems > 0); ((GrabbableObject)this).DiscardItem(); } public override void GrabItem() { ((GrabbableObject)this).GrabItem(); if (Object.op_Implicit((Object)(object)base.playerHeldBy) && (Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)(object)base.playerHeldBy) { UpdatePlayerAttributes(grabbing: true); EnableInteractTriggers(enabled: false); if (base.playerHeldBy.isCrouching) { base.playerHeldBy.Crouch(!base.playerHeldBy.isCrouching); } } ToggleGrabColliders(currentAmountItems > 0); } private void SetupItemAttributes() { base.grabbable = true; base.grabbableToEnemies = true; base.itemProperties.toolTips = SetupContainerTooltips(); SetupScanNodeProperties(); } protected abstract string[] SetupContainerTooltips(); protected abstract void SetupScanNodeProperties(); public void DecrementStoredItems() { UpdateContainerWeightServerRpc(); } [ServerRpc(RequireOwnership = false)] private void UpdateContainerWeightServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(368202541u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 368202541u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { UpdateContainerWeightClientRpc(); } } } [ClientRpc] private void UpdateContainerWeightClientRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(871837224u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 871837224u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 || (!networkManager.IsClient && !networkManager.IsHost)) { return; } GrabbableObject[] componentsInChildren = ((Component)this).GetComponentsInChildren<GrabbableObject>(); if (base.isHeld && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController) { if (LategameCompatibility.Enabled) { LategameCompatibility.RemoveTotalWeight(this); } else { PlayerControllerB playerHeldBy = base.playerHeldBy; playerHeldBy.carryWeight -= Mathf.Clamp(totalWeight - 1f, 0f, 10f); } } totalWeight = defaultWeight; currentAmountItems = 0; for (int i = 0; i < componentsInChildren.Length; i++) { if (!((Object)(object)((Component)componentsInChildren[i]).GetComponent<ContainerBehaviour>() != (Object)null)) { currentAmountItems++; GrabbableObject val3 = componentsInChildren[i]; totalWeight += (val3.itemProperties.weight - 1f) * weightReduceMultiplier; } } if (base.isHeld && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController) { if (LategameCompatibility.Enabled) { LategameCompatibility.AddTotalWeight(this); } else { PlayerControllerB playerHeldBy2 = base.playerHeldBy; playerHeldBy2.carryWeight += Mathf.Clamp(totalWeight - 1f, 0f, 10f); } } ToggleGrabColliders(currentAmountItems > 0); } private void InteractContainer(PlayerControllerB playerInteractor) { if (playerInteractor.isHoldingObject) { StoreItemInContainer(ref playerInteractor); } } private void StoreItemInContainer(ref PlayerControllerB playerInteractor) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) Collider val = (Collider)(object)container; Vector3 val2 = RoundManager.RandomPointInBounds(val.bounds); Bounds bounds = val.bounds; val2.y = ((Bounds)(ref bounds)).max.y; val2.y += playerInteractor.currentlyHeldObjectServer.itemProperties.verticalOffset; val2 = ((Component)((Component)this).GetComponent<NetworkObject>()).transform.InverseTransformPoint(val2); GrabbableObject currentlyHeldObjectServer = playerInteractor.currentlyHeldObjectServer; playerInteractor.DiscardHeldObject(true, ((Component)this).GetComponent<NetworkObject>(), val2, false); currentlyHeldObjectServer.EnableItemMeshes(!makeItemsInvisible); UpdateContainerWeightServerRpc(); } public static float CheckIfPlayerCarryingContainerLookSensitivity(float defaultValue) { //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) PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null || (Object)(object)localPlayerController.thisController == (Object)null) { return defaultValue; } Vector3 velocity = localPlayerController.thisController.velocity; if (((Vector3)(ref velocity)).magnitude <= 5f) { return defaultValue; } return defaultValue * PlayerManager.instance.GetSensitivityMultiplier(); } public static float CheckIfPlayerCarryingContainerMovement(float defaultValue) { //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) PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController; if ((Object)(object)localPlayerController == (Object)null || (Object)(object)localPlayerController.thisController == (Object)null) { return defaultValue; } Vector3 velocity = localPlayerController.thisController.velocity; if (((Vector3)(ref velocity)).magnitude <= 5f) { return defaultValue; } return defaultValue * PlayerManager.instance.GetSloppyMultiplier(); } public static void ToggleStoredItemsBooleans(GrabbableObject grabbableObject, bool isEntranceToBuilding) { if (!(grabbableObject is ContainerBehaviour containerBehaviour)) { return; } GrabbableObject[] componentsInChildren = ((Component)containerBehaviour).GetComponentsInChildren<GrabbableObject>(); for (int i = 0; i < componentsInChildren.Length; i++) { if (!(componentsInChildren[i] is ContainerBehaviour)) { componentsInChildren[i].isInFactory = isEntranceToBuilding; componentsInChildren[i].EnableItemMeshes(!containerBehaviour.makeItemsInvisible); } } } public static bool CheckIfPlayerCarryingContainer() { return PlayerManager.instance.GetHoldingContainer(); } public static bool CheckIfItemInContainer(GrabbableObject item) { if ((Object)(object)item == (Object)null) { return false; } return (Object)(object)((Component)item).GetComponentInParent<ContainerBehaviour>() != (Object)null; } protected virtual bool ShowDepositPrompts() { return true; } public int GetCurrentAmountItems() { return currentAmountItems; } public float GetTotalWeight() { return totalWeight; } protected override void __initializeVariables() { ((GrabbableObject)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_ContainerBehaviour() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(76295531u, new RpcReceiveHandler(__rpc_handler_76295531)); NetworkManager.__rpc_func_table.Add(3995238815u, new RpcReceiveHandler(__rpc_handler_3995238815)); NetworkManager.__rpc_func_table.Add(368202541u, new RpcReceiveHandler(__rpc_handler_368202541)); NetworkManager.__rpc_func_table.Add(871837224u, new RpcReceiveHandler(__rpc_handler_871837224)); } private static void __rpc_handler_76295531(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((ContainerBehaviour)(object)target).DropAllItemsInContainerServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3995238815(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)2; ((ContainerBehaviour)(object)target).DropAllItemsInContainerClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_368202541(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)1; ((ContainerBehaviour)(object)target).UpdateContainerWeightServerRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_871837224(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { target.__rpc_exec_stage = (__RpcExecStage)2; ((ContainerBehaviour)(object)target).UpdateContainerWeightClientRpc(); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "ContainerBehaviour"; } } public abstract class GunBehaviour : GrabbableObject { [CompilerGenerated] private sealed class <HandleReloadLogic>d__62 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GunBehaviour <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <HandleReloadLogic>d__62(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; ((GrabbableObject)<>4__this).playerHeldBy.DestroyItemInSlot(<>4__this.ammoSlotToUse); <>4__this.ammoSlotToUse = -1; <>4__this.currentAmmo = Mathf.Clamp(<>4__this.currentAmmo + <>4__this.ammoObtained, 0, <>4__this.maxAmmo); <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; 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 <reloadGunAnimation>d__60 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GunBehaviour <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <reloadGunAnimation>d__60(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>4__this.ToggleReloading(); <>2__current = <>4__this.PrefixReloadGunAnimation(); <>1__state = 1; return true; case 1: <>1__state = -1; <>2__current = <>4__this.HandleReloadLogic(); <>1__state = 2; return true; case 2: <>1__state = -1; <>2__current = <>4__this.PostfixReloadGunAnimation(); <>1__state = 3; return true; case 3: <>1__state = -1; <>4__this.ToggleReloading(); 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(); } } protected AudioSource audioSource; protected AudioClip safetyShootClip; protected AudioClip safetyTurningOnClip; protected AudioClip safetyTurningOffClip; protected AudioClip[] shootClips; protected AudioClip noAmmoClip; protected ParticleSystem shootParticles; protected Coroutine gunReload; protected Animator gunAnimator; protected SortedList<float, float> earRingingRanges = new SortedList<float, float>(); protected SortedList<float, int> rangePlayerDamages = new SortedList<float, int>(); protected SortedList<float, int> rangeEnemyDamages = new SortedList<float, int>(); protected int maxAmmo; protected int currentAmmo; protected int ammoUsage; protected int ammoObtained; private int ammoSlotToUse; protected int compatibleAmmoId; protected bool isReloading; protected bool safetyEnabled; protected bool safetyOn; protected RaycastHit[] enemyHits; protected int maximumHits; protected Transform gunShootPoint; protected PlayerControllerB previousPlayer; protected EnemyAI holdingEnemy; private bool shootServerRPC; public override void Start() { ((GrabbableObject)this).Start(); audioSource = ((Component)this).GetComponent<AudioSource>(); gunAnimator = ((Component)this).GetComponent<Animator>(); shootParticles = ((Component)this).GetComponent<ParticleSystem>(); isReloading = false; shootServerRPC = false; previousPlayer = null; InitializeGun(); } protected abstract void InitializeGun(); public override void DiscardItemFromEnemy() { ((GrabbableObject)this).DiscardItemFromEnemy(); holdingEnemy = null; } public override void GrabItemFromEnemy(EnemyAI enemy) { ((GrabbableObject)this).GrabItemFromEnemy(enemy); holdingEnemy = enemy; } public override void EquipItem() { ((GrabbableObject)this).EquipItem(); previousPlayer = base.playerHeldBy; previousPlayer.equippedUsableItemQE = true; } public override void DiscardItem() { ((GrabbableObject)this).DiscardItem(); StopUsingGun(); } public override void PocketItem() { ((GrabbableObject)this).PocketItem(); StopUsingGun(); } protected virtual void StopUsingGun() { previousPlayer.equippedUsableItemQE = false; if (isReloading) { if (gunReload != null) { ((MonoBehaviour)this).StopCoroutine(gunReload); } gunReload = null; audioSource.Stop(); if ((Object)(object)previousPlayer != (Object)null) { ResetGunAnimator(ref previousPlayer); } isReloading = false; previousPlayer = null; } } protected abstract void ResetGunAnimator(ref PlayerControllerB previousPlayer); public override int GetItemDataToSave() { if (!base.itemProperties.saveItemVariable) { return 0; } return currentAmmo; } public override void LoadItemSaveData(int saveData) { if (base.itemProperties.saveItemVariable) { currentAmmo = saveData; } } public override void ItemInteractLeftRight(bool right) { ((GrabbableObject)this).ItemInteractLeftRight(right); if (!((Object)(object)base.playerHeldBy == (Object)null)) { if (right) { StartReload(); } else if (safetyEnabled) { ToggleSafety(); SetSafetyControlTip(); HandleSafetyAnimations(); } } } protected abstract void HandleSafetyAnimations(); public override void SetControlTipsForItem() { string[] toolTips = base.itemProperties.toolTips; if (!safetyEnabled || toolTips.Length <= 2) { HUDManager.Instance.ChangeControlTipMultiple(toolTips, true, base.itemProperties); return; } if (safetyOn) { toolTips[2] = "Turn safety off: [Q]"; } else { toolTips[2] = "Turn safety on: [Q]"; } HUDManager.Instance.ChangeControlTipMultiple(toolTips, true, base.itemProperties); } protected virtual void SetSafetyControlTip() { string text = ((!safetyOn) ? "Turn safety on: [Q]" : "Turn safety off: [Q]"); if (((NetworkBehaviour)this).IsOwner) { HUDManager.Instance.ChangeControlTip(3, text, false); } } public override void ItemActivate(bool used, bool buttonDown = true) { ((GrabbableObject)this).ItemActivate(used, buttonDown); if (!isReloading) { if (currentAmmo <= 0) { StartReload(); } else if (IsSafetyOn()) { audioSource.PlayOneShot(safetyShootClip); } else if (((NetworkBehaviour)this).IsOwner) { FireGun(); } } } public virtual void FireGun() { //IL_0015: 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) //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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_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) Vector3 val = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.position - ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.up * 0.45f; Vector3 forward = ((Component)GameNetworkManager.Instance.localPlayerController.gameplayCamera).transform.forward; ShootGun(val, forward); shootServerRPC = true; ShootGunServerRpc(val, forward); } [ServerRpc] public void ShootGunServerRpc(Vector3 position, Vector3 forward) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Invalid comparison between Unknown and I4 //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Invalid comparison between Unknown and I4 NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { if (((NetworkBehaviour)this).OwnerClientId != networkManager.LocalClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } return; } ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(2675360650u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref position); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref forward); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 2675360650u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ShootGunClientRpc(position, forward); } } [ClientRpc] public void ShootGunClientRpc(Vector3 firingPosition, Vector3 forward) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 2 && (networkManager.IsServer || networkManager.IsHost)) { ClientRpcParams val = default(ClientRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendClientRpc(3735819763u, val, (RpcDelivery)0); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref firingPosition); ((FastBufferWriter)(ref val2)).WriteValueSafe(ref forward); ((NetworkBehaviour)this).__endSendClientRpc(ref val2, 3735819763u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 2 && (networkManager.IsClient || networkManager.IsHost)) { if (shootServerRPC) { shootServerRPC = false; } else { ShootGun(firingPosition, forward); } } } protected virtual void ShootGun(Vector3 firingPosition, Vector3 forward) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) isReloading = false; bool flag = base.isHeld && (Object)(object)base.playerHeldBy != (Object)null && (Object)(object)base.playerHeldBy == (Object)(object)GameNetworkManager.Instance.localPlayerController; if (flag) { SetPlayerShootingAnimation(); } RoundManager.PlayRandomClip(audioSource, shootClips, true, 1f, 1850, 1000); shootParticles.Play(true); currentAmmo = Mathf.Clamp(currentAmmo - ammoUsage, 0, maxAmmo); HandleShootingPlayer(firingPosition, forward, flag); if (((NetworkBehaviour)this).IsOwner) { int numHits = FetchEnemyColliders(firingPosition, forward); ProcessEnemies(numHits, firingPosition, forward); } } protected virtual void HandleShootingPlayer(Vector3 firingPosition, Vector3 forward, bool heldByLocalPlayer) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)GameNetworkManager.Instance.localPlayerController == (Object)null)) { PlayerControllerB localPlayer = GameNetworkManager.Instance.localPlayerController; float distanceFromShootingPoint = Vector3.Distance(((Component)localPlayer).transform.position, gunShootPoint.position); bool flag = CheckForHitOnLocalPlayer(ref localPlayer, firingPosition, forward, heldByLocalPlayer); if (!flag) { HandlePossibleRicochet(firingPosition, forward); } if (flag) { HandleHittingLocalPlayer(ref localPlayer, distanceFromShootingPoint); } } } protected abstract bool CheckForHitOnLocalPlayer(ref PlayerControllerB localPlayer, Vector3 firingPosition, Vector3 forward, bool heldByLocalPlayer); protected virtual void ProcessEnemies(int numHits, Vector3 firingPosition, Vector3 forward) { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: 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_00e0: Unknown result type (might be due to invalid IL or missing references) List<EnemyAI> list = new List<EnemyAI>(); RaycastHit val = default(RaycastHit); IHittable val2 = default(IHittable); for (int i = 0; i < numHits; i++) { EnemyAICollisionDetect component = ((Component)((RaycastHit)(ref enemyHits[i])).transform).GetComponent<EnemyAICollisionDetect>(); if ((Object)(object)component == (Object)null) { continue; } EnemyAI mainScript = component.mainScript; if ((!base.isHeldByEnemy || !((Object)(object)holdingEnemy == (Object)(object)mainScript)) && !Physics.Linecast(firingPosition, ((RaycastHit)(ref enemyHits[i])).point, ref val, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) && ((Component)((RaycastHit)(ref enemyHits[i])).transform).TryGetComponent<IHittable>(ref val2)) { float distance = Vector3.Distance(firingPosition, ((RaycastHit)(ref enemyHits[i])).point); int forceByDistance = GetForceByDistance(distance); if (!list.Contains(mainScript) && val2.Hit(forceByDistance, forward, base.playerHeldBy, true, -1)) { list.Add(mainScript); } } } } private V GetValueBetweenRanges<V>(SortedList<float, V> orderedCollection, float distance) { V result = default(V); foreach (KeyValuePair<float, V> item in orderedCollection) { if (distance < item.Key) { continue; } result = item.Value; return result; } return result; } protected virtual int GetForceByDistance(float distance) { return GetValueBetweenRanges(rangeEnemyDamages, distance); } protected abstract int FetchEnemyColliders(Vector3 firingPosition, Vector3 forward); protected virtual void HandleHittingLocalPlayer(ref PlayerControllerB localPlayer, float distanceFromShootingPoint) { //IL_001d: 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) int valueBetweenRanges = GetValueBetweenRanges(rangePlayerDamages, distanceFromShootingPoint); localPlayer.DamagePlayer(valueBetweenRanges, true, true, (CauseOfDeath)7, 0, false, gunShootPoint.forward * 10f); } protected virtual void HandleEarRinging(float distanceFromShootingPoint) { float valueBetweenRanges = GetValueBetweenRanges(earRingingRanges, distanceFromShootingPoint); ShakeScreen(valueBetweenRanges); if (valueBetweenRanges > 0f && SoundManager.Instance.timeSinceEarsStartedRinging > 16f) { ((MonoBehaviour)this).StartCoroutine(delayedEarsRinging(valueBetweenRanges)); } } protected abstract void ShakeScreen(float earRingingTone); protected abstract IEnumerator delayedEarsRinging(float earRingingTone); protected abstract void HandlePossibleRicochet(Vector3 firingPosition, Vector3 forward); protected abstract void SetPlayerShootingAnimation(); public virtual void StartReload() { if (isReloading || currentAmmo >= maxAmmo) { return; } if (!CanReload()) { audioSource.PlayOneShot(noAmmoClip); } else if (((NetworkBehaviour)this).IsOwner) { if (gunReload != null) { ((MonoBehaviour)this).StopCoroutine(gunReload); } gunReload = ((MonoBehaviour)this).StartCoroutine(reloadGunAnimation()); } } [IteratorStateMachine(typeof(<reloadGunAnimation>d__60))] protected virtual IEnumerator reloadGunAnimation() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <reloadGunAnimation>d__60(0) { <>4__this = this }; } protected abstract IEnumerator PrefixReloadGunAnimation(); [IteratorStateMachine(typeof(<HandleReloadLogic>d__62))] protected virtual IEnumerator HandleReloadLogic() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <HandleReloadLogic>d__62(0) { <>4__this = this }; } protected abstract IEnumerator PostfixReloadGunAnimation(); protected virtual bool CanReload() { int num = FindAmmoInInventory(compatibleAmmoId); if (num == -1) { return false; } ammoSlotToUse = num; return true; } protected int FindAmmoInInventory<T>() where T : GrabbableObject { for (int i = 0; i < base.playerHeldBy.ItemSlots.Length; i++) { if (!((Object)(object)base.playerHeldBy.ItemSlots[i] == (Object)null)) { GrabbableObject obj = base.playerHeldBy.ItemSlots[i]; T val = (T)(object)((obj is T) ? obj : null); if ((Object)(object)val != (Object)null) { return i; } } } return -1; } protected int FindAmmoInInventory(int compatibleAmmoID) { for (int i = 0; i < base.playerHeldBy.ItemSlots.Length; i++) { if (!((Object)(object)base.playerHeldBy.ItemSlots[i] == (Object)null)) { GrabbableObject obj = base.playerHeldBy.ItemSlots[i]; GunAmmo val = (GunAmmo)(object)((obj is GunAmmo) ? obj : null); if ((Object)(object)val != (Object)null && val.ammoType == compatibleAmmoID) { return i; } } } return -1; } public void ToggleReloading() { ToggleReloading(!isReloading); } public void ToggleReloading(bool isReloading) { this.isReloading = isReloading; } public bool IsSafetyOn() { return safetyEnabled && safetyOn; } public void ToggleSafety() { ToggleSafety(!safetyOn); } public void ToggleSafety(bool value) { safetyOn = value; AudioClip val = (safetyOn ? safetyTurningOnClip : safetyTurningOffClip); audioSource.PlayOneShot(val); WalkieTalkie.TransmitOneShotAudio(audioSource, val, 1f); } protected override void __initializeVariables() { ((GrabbableObject)this).__initializeVariables(); } [RuntimeInitializeOnLoadMethod] internal static void InitializeRPCS_GunBehaviour() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown NetworkManager.__rpc_func_table.Add(2675360650u, new RpcReceiveHandler(__rpc_handler_2675360650)); NetworkManager.__rpc_func_table.Add(3735819763u, new RpcReceiveHandler(__rpc_handler_3735819763)); } private static void __rpc_handler_2675360650(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0023: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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) //IL_0055: Invalid comparison between Unknown and I4 NetworkManager networkManager = target.NetworkManager; if (networkManager == null || !networkManager.IsListening) { return; } if (rpcParams.Server.Receive.SenderClientId != target.OwnerClientId) { if ((int)networkManager.LogLevel <= 1) { Debug.LogError((object)"Only the owner can invoke a ServerRpc that requires ownership!"); } } else { Vector3 position = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref position); Vector3 forward = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref forward); target.__rpc_exec_stage = (__RpcExecStage)1; ((GunBehaviour)(object)target).ShootGunServerRpc(position, forward); target.__rpc_exec_stage = (__RpcExecStage)0; } } private static void __rpc_handler_3735819763(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams) { //IL_0043: 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_0052: 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) NetworkManager networkManager = target.NetworkManager; if (networkManager != null && networkManager.IsListening) { Vector3 firingPosition = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref firingPosition); Vector3 forward = default(Vector3); ((FastBufferReader)(ref reader)).ReadValueSafe(ref forward); target.__rpc_exec_stage = (__RpcExecStage)2; ((GunBehaviour)(object)target).ShootGunClientRpc(firingPosition, forward); target.__rpc_exec_stage = (__RpcExecStage)0; } } protected internal override string __getTypeName() { return "GunBehaviour"; } } public abstract class LookoutBehaviour : GrabbableObject { private static List<LookoutBehaviour> coilHeadItems = new List<LookoutBehaviour>(); private bool Active; protected int maximumRange; public override void Start() { ((GrabbableObject)this).Start(); coilHeadItems.Add(this); } public override void Update() { ((GrabbableObject)this).Update(); SetActive(!base.isHeld && !base.isHeldByEnemy); } protected virtual void SetActive(bool enable) { Active = enable; } protected virtual bool HasLineOfSightToPosition(Vector3 pos) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!Active) { return false; } float num = Vector3.Distance(((Component)this).transform.position, pos); return num < (float)maximumRange && !Physics.Linecast(((Component)this).transform.position, pos, StartOfRound.Instance.collidersRoomDefaultAndFoliage, (QueryTriggerInteraction)1); } public static bool HasLineOfSightToPeepers(Vector3 springPosition) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) foreach (LookoutBehaviour item in coilHeadItems.ToList()) { if ((Object)(object)item == (Object)null) { coilHeadItems.Remove(item); } else if (item.HasLineOfSightToPosition(springPosition)) { return true; } } return false; } protected override void __initializeVariables() { ((GrabbableObject)this).__initializeVariables(); } protected internal override string __getTypeName() { return "LookoutBehaviour"; } } public abstract class PortableTeleporterBehaviour : GrabbableObject { [CompilerGenerated] private sealed class <WaitToTP>d__8 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ShipTeleporter tele; public PortableTeleporterBehaviour <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <WaitToTP>d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0.15f); <>1__state = 1; return true; case 1: <>1__state = -1; if (<>4__this.keepItems) { <>4__this.ReqUpdateTpDropStatusServerRpc(); } tele.PressTeleportButtonOnLocalClient(); 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(); } } internal static bool TPButtonPressed; protected bool keepItems; private ShipTeleporter shipTeleporter; public override void ItemActivate(bool used, bool buttonDown = true) { if (CanUsePortableTeleporter()) { int playerRadarIndex = SearchForPlayerInRadar(); ShipTeleporter teleporter = GetShipTeleporter(); TeleportPlayer(playerRadarIndex, ref teleporter); } } protected virtual void TeleportPlayer(int playerRadarIndex, ref ShipTeleporter teleporter) { if (playerRadarIndex == -1) { StartOfRound.Instance.mapScreen.targetedPlayer = base.playerHeldBy; TPButtonPressed = true; teleporter.PressTeleportButtonOnLocalClient(); } else { StartOfRound.Instance.mapScreen.SwitchRadarTargetAndSync(playerRadarIndex); ((MonoBehaviour)this).StartCoroutine(WaitToTP(teleporter)); } } private int SearchForPlayerInRadar() { int result = -1; for (int i = 0; i < StartOfRound.Instance.mapScreen.radarTargets.Count; i++) { if (!((Object)(object)((Component)StartOfRound.Instance.mapScreen.radarTargets[i].transform).gameObject.GetComponent<PlayerControllerB>() != (Object)(object)base.playerHeldBy)) { result = i; break; } } return result; } protected virtual bool CanUsePortableTeleporter() { if (base.itemUsedUp) { return false; } ShipTeleporter val = GetShipTeleporter(); if ((Object)(object)val == (Object)null || !val.buttonTrigger.interactable) { return false; } return true; } private ShipTeleporter GetShipTeleporter() { if ((Object)(object)shipTeleporter != (Object)null) { return shipTeleporter; } ShipTeleporter[] array = Object.FindObjectsOfType<ShipTeleporter>(); ShipTeleporter val = null; ShipTeleporter[] array2 = array; foreach (ShipTeleporter val2 in array2) { if (!val2.isInverseTeleporter) { val = val2; break; } } shipTeleporter = val; return shipTeleporter; } [IteratorStateMachine(typeof(<WaitToTP>d__8))] protected virtual IEnumerator WaitToTP(ShipTeleporter tele) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <WaitToTP>d__8(0) { <>4__this = this, tele = tele }; } [ServerRpc(RequireOwnership = false)] public void ReqUpdateTpDropStatusServerRpc() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Invalid comparison between Unknown and I4 //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007c: Unknown result type (might be due to invalid IL or missing references) NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager; if (networkManager != null && networkManager.IsListening) { if ((int)((NetworkBehaviour)this).__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost)) { ServerRpcParams val = default(ServerRpcParams); FastBufferWriter val2 = ((NetworkBehaviour)this).__beginSendServerRpc(1894825709u, val, (RpcDelivery)0); ((NetworkBehaviour)this).__endSendServerRpc(ref val2, 1894825709u, val, (RpcDelivery)0); } if ((int)((NetworkBehaviour)this).__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost)) { ChangeTPBut