using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using UnityEngine; [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: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("HappyCats")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+fdbfd18d1c826ffb5a7d1b352cf43c55998f026c")] [assembly: AssemblyProduct("ComeBackEquipment")] [assembly: AssemblyTitle("ComeBackEquipment")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ComeBackEquipment { [BepInPlugin("HappyCats.ComeBackEquipment", "ComeBackEquipment", "2.0.4")] public class ComeBackEquipment : BaseUnityPlugin { internal static ComeBackEquipment Instance { get; private set; } internal static ManualLogSource Logger => Instance._logger; private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger; internal Harmony? Harmony { get; set; } internal static ConfigEntry TeleportItemsToTruck { get; private set; } internal static ConfigEntry TeleportHaulersToTruck { get; private set; } private void Awake() { Instance = this; TeleportItemsToTruck = ((BaseUnityPlugin)this).Config.Bind("General", "Teleport Items To Truck", false, "When a dead player loses equipment in a death pit, return the item to the truck instead of bouncing it back out."); TeleportHaulersToTruck = ((BaseUnityPlugin)this).Config.Bind("General", "Teleport Haulers To Truck", false, "When a hauler falls into a death pit, return it to the truck instead of letting it be destroyed."); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Patch(); Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!"); } internal void Patch() { //IL_001a: 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_0021: Expected O, but got Unknown //IL_0026: Expected O, but got Unknown if (Harmony == null) { Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID); Harmony val2 = val; Harmony = val; } Harmony.PatchAll(); } internal void Unpatch() { Harmony? harmony = Harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { } } [HarmonyPatch] internal static class HurtColliderPatch { private static bool IsHaulerVehicle(PhysGrabObject physGrabObject) { return (Object)(object)((Component)physGrabObject).GetComponentInParent()?.valuableBox != (Object)null; } private static bool TryTeleportToTruck(PhysGrabObject physGrabObject) { //IL_001d: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)TruckSafetySpawnPoint.instance)) { return false; } physGrabObject.rb.velocity = Vector3.zero; physGrabObject.rb.angularVelocity = Vector3.zero; physGrabObject.Teleport(((Component)TruckSafetySpawnPoint.instance).transform.position, ((Component)TruckSafetySpawnPoint.instance).transform.rotation); physGrabObject.DeathPitEffectCreate(); return true; } private static bool ShouldTeleportToTruck(PhysGrabObject physGrabObject) { if (Object.op_Implicit((Object)(object)((Component)physGrabObject).GetComponentInParent())) { return ComeBackEquipment.TeleportHaulersToTruck.Value; } return (Object)(object)((Component)physGrabObject).GetComponentInParent() != (Object)null && ComeBackEquipment.TeleportItemsToTruck.Value; } private static bool ShouldKeepDefaultDestroyBehavior(PhysGrabObjectImpactDetector impactDetector) { return (Object)(object)((Component)impactDetector).GetComponentInParent() != (Object)null || (Object)(object)((Component)impactDetector).GetComponentInParent() != (Object)null || (Object)(object)((Component)impactDetector).GetComponentInParent() != (Object)null || (Object)(object)((Component)impactDetector).GetComponentInParent() != (Object)null || (Object)(object)((Component)impactDetector).GetComponentInParent() != (Object)null || (Object)(object)((Component)impactDetector).GetComponentInParent() != (Object)null; } [HarmonyPostfix] [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "Start")] private static void ImpactDetectorStartPostfix(PhysGrabObjectImpactDetector __instance) { bool flag = (Object)(object)((Component)__instance).GetComponentInParent() != (Object)null; bool flag2 = (Object)(object)((Component)__instance).GetComponentInParent() != (Object)null; if (flag || flag2) { if (flag2 && ComeBackEquipment.TeleportHaulersToTruck.Value) { __instance.destroyDisable = true; } else if (flag && !ShouldKeepDefaultDestroyBehavior(__instance)) { __instance.destroyDisable = true; } } } [HarmonyPostfix] [HarmonyPatch(typeof(ItemEquippable), "RPC_CompleteUnequip")] private static void RPCCompleteUnequipPostfix(ItemEquippable __instance, int physGrabberPhotonViewID, Vector3 teleportPos, bool isForceUnequip) { //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) if (!isForceUnequip || !Object.op_Implicit((Object)(object)__instance)) { return; } PhysGrabber val = null; if (SemiFunc.IsMultiplayer()) { PhotonView obj = PhotonView.Find(physGrabberPhotonViewID); val = ((obj != null) ? ((Component)obj).GetComponent() : null); } else { val = PhysGrabber.instance; } if (val != null && (val.playerAvatar?.deadSet).GetValueOrDefault()) { PhysGrabObject component = ((Component)__instance).GetComponent(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.rb) && !component.rb.isKinematic && SemiFunc.IsMasterClientOrSingleplayer() && (!IsHaulerVehicle(component) || !ComeBackEquipment.TeleportHaulersToTruck.Value || !TryTeleportToTruck(component)) && (!ComeBackEquipment.TeleportItemsToTruck.Value || !TryTeleportToTruck(component))) { Vector3 insideUnitSphere = Random.insideUnitSphere; Vector3 val2 = ((Vector3)(ref insideUnitSphere)).normalized * 4f; val2.y = 0f; Vector3 val3 = (Vector3.up * 20f + val2) * component.rb.mass; insideUnitSphere = Random.insideUnitSphere; Vector3 val4 = ((Vector3)(ref insideUnitSphere)).normalized * 0.25f * component.rb.mass; component.rb.AddForce(val3, (ForceMode)1); component.rb.AddTorque(val4, (ForceMode)1); component.DeathPitEffectCreate(); } } } [HarmonyPrefix] [HarmonyPatch(typeof(HurtCollider), "PhysObjectHurt")] private static bool PhysObjectHurtPrefix(HurtCollider __instance, PhysGrabObject physGrabObject, BreakImpact impact, float hitForce, float hitTorque, bool apply, bool destroyLaunch, ref bool __result, Enemy? enemy = null) { if (!__instance.deathPit || !SemiFunc.IsMasterClientOrSingleplayer() || !Object.op_Implicit((Object)(object)physGrabObject) || !Object.op_Implicit((Object)(object)physGrabObject.rb)) { return true; } if (!ShouldTeleportToTruck(physGrabObject)) { return true; } if (TryTeleportToTruck(physGrabObject)) { __result = true; return false; } return true; } } }