using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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("Halichu")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+86ee1e9bdb07a39ca4155fc85cdeb17021f1b505")]
[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("Halichu.ComeBackEquipment", "ComeBackEquipment", "1.2.1")]
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<bool> DoTeleport { get; private set; }
internal static ConfigEntry<bool> EnableCart { get; private set; }
private void Awake()
{
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Expected O, but got Unknown
Instance = this;
((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!");
DoTeleport = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DoTeleport", false, new ConfigDescription("Whether equippables teleport back to the truck or bounce in death pit.", (AcceptableValueBase)null, Array.Empty<object>()));
EnableCart = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableCart", false, new ConfigDescription("Whether cart comes back.", (AcceptableValueBase)null, Array.Empty<object>()));
}
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(typeof(HurtCollider))]
internal static class HurtColliderPatch
{
[CompilerGenerated]
private sealed class <CustomColliderCheck>d__3 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public HurtCollider __instance;
private Collider[] <array>5__1;
private Vector3 <center>5__2;
private Vector3 <vector>5__3;
private Vector3 <center2>5__4;
private float <radius>5__5;
private Collider[] <array2>5__6;
private Collider[] <>s__7;
private int <>s__8;
private Collider <collider>5__9;
private PlayerAvatar <playerAvatar>5__10;
private PlayerController <componentInParent>5__11;
private PhysGrabObject <componentInParent2>5__12;
private bool <isCartCheck>5__13;
private bool <flag>5__14;
private PlayerTumble <componentInParent3>5__15;
private EnemyRigidbody <enemyRigidbody>5__16;
private bool <flag2>5__17;
private PhysGrabObjectImpactDetector <componentInParent4>5__18;
private PhysGrabHinge <component>5__19;
private PhysGrabHinge <component2>5__20;
private bool <isDestroyCart>5__21;
private PhysGrabHinge <component3>5__22;
private List<PhysGrabber>.Enumerator <>s__23;
private PhysGrabber <item>5__24;
private Enemy <componentInParent5>5__25;
private EnemyParent <componentInParent6>5__26;
private EnemyRigidbody <componentInChildren>5__27;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <CustomColliderCheck>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<array>5__1 = null;
<array2>5__6 = null;
<>s__7 = null;
<collider>5__9 = null;
<playerAvatar>5__10 = null;
<componentInParent>5__11 = null;
<componentInParent2>5__12 = null;
<componentInParent3>5__15 = null;
<enemyRigidbody>5__16 = null;
<componentInParent4>5__18 = null;
<component>5__19 = null;
<component2>5__20 = null;
<component3>5__22 = null;
<>s__23 = default(List<PhysGrabber>.Enumerator);
<item>5__24 = null;
<componentInParent5>5__25 = null;
<componentInParent6>5__26 = null;
<componentInChildren>5__27 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_0105: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0145: 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_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: 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_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005e: Expected O, but got Unknown
//IL_0b44: Unknown result type (might be due to invalid IL or missing references)
//IL_0b4e: Expected O, but got Unknown
//IL_0a10: Unknown result type (might be due to invalid IL or missing references)
//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
//IL_0902: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = null;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
goto IL_006f;
case 2:
<>1__state = -1;
goto IL_006f;
case 3:
{
<>1__state = -1;
<array>5__1 = null;
break;
}
IL_006f:
if (!Object.op_Implicit((Object)(object)LevelGenerator.Instance) || !LevelGenerator.Instance.Generated)
{
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 2;
return true;
}
break;
}
if (__instance.ColliderIsBox)
{
<center>5__2 = ((Component)__instance).transform.TransformPoint(__instance.BoxCollider.center);
<vector>5__3 = new Vector3(((Component)__instance).transform.lossyScale.x * __instance.BoxCollider.size.x, ((Component)__instance).transform.lossyScale.y * __instance.BoxCollider.size.y, ((Component)__instance).transform.lossyScale.z * __instance.BoxCollider.size.z);
<array>5__1 = Physics.OverlapBox(<center>5__2, <vector>5__3 * 0.5f, ((Component)__instance).transform.rotation, LayerMask.op_Implicit(__instance.LayerMask), (QueryTriggerInteraction)2);
}
else
{
Bounds bounds = __instance.Collider.bounds;
<center2>5__4 = ((Bounds)(ref bounds)).center;
<radius>5__5 = ((Component)__instance).transform.lossyScale.x * __instance.SphereCollider.radius;
<array>5__1 = Physics.OverlapSphere(<center2>5__4, <radius>5__5, LayerMask.op_Implicit(__instance.LayerMask), (QueryTriggerInteraction)2);
}
if (<array>5__1.Length != 0)
{
<array2>5__6 = <array>5__1;
<>s__7 = <array2>5__6;
for (<>s__8 = 0; <>s__8 < <>s__7.Length; <>s__8++)
{
<collider>5__9 = <>s__7[<>s__8];
if (__instance.playerLogic && __instance.playerDamageCooldown > 0f && ((Component)<collider>5__9).gameObject.CompareTag("Player"))
{
<playerAvatar>5__10 = ((Component)<collider>5__9).gameObject.GetComponentInParent<PlayerAvatar>();
if (!Object.op_Implicit((Object)(object)<playerAvatar>5__10))
{
<componentInParent>5__11 = ((Component)<collider>5__9).gameObject.GetComponentInParent<PlayerController>();
if (Object.op_Implicit((Object)(object)<componentInParent>5__11))
{
<playerAvatar>5__10 = <componentInParent>5__11.playerAvatarScript;
}
<componentInParent>5__11 = null;
}
if (Object.op_Implicit((Object)(object)<playerAvatar>5__10))
{
__instance.PlayerHurt(<playerAvatar>5__10);
}
<playerAvatar>5__10 = null;
}
if (!(__instance.enemyDamageCooldown > 0f) && !(__instance.physDamageCooldown > 0f) && !(__instance.playerDamageCooldown > 0f))
{
continue;
}
if (((Component)<collider>5__9).gameObject.CompareTag("Phys Grab Object"))
{
<componentInParent2>5__12 = ((Component)<collider>5__9).gameObject.GetComponentInParent<PhysGrabObject>();
<isCartCheck>5__13 = !ComeBackEquipment.EnableCart.Value && (Object)(object)<componentInParent2>5__12.impactDetector != (Object)null && <componentInParent2>5__12.impactDetector.isCart && (Object)(object)((Component)<collider>5__9).transform.parent != (Object)null && ((Object)((Component)((Component)<collider>5__9).transform.parent).gameObject).name != "Phys Object Collider";
if ((__instance.ignoreObjects.Contains(<componentInParent2>5__12) || !Object.op_Implicit((Object)(object)<componentInParent2>5__12)) | <isCartCheck>5__13)
{
continue;
}
<flag>5__14 = false;
<componentInParent3>5__15 = ((Component)<collider>5__9).gameObject.GetComponentInParent<PlayerTumble>();
if (Object.op_Implicit((Object)(object)<componentInParent3>5__15))
{
<flag>5__14 = true;
}
if ((__instance.playerLogic && __instance.playerDamageCooldown > 0f) & <flag>5__14)
{
__instance.PlayerHurt(<componentInParent3>5__15.playerAvatar);
}
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
continue;
}
<enemyRigidbody>5__16 = null;
if (__instance.enemyLogic && !<flag>5__14)
{
<enemyRigidbody>5__16 = ((Component)<collider>5__9).gameObject.GetComponentInParent<EnemyRigidbody>();
__instance.EnemyHurtRigidbody(<enemyRigidbody>5__16, <componentInParent2>5__12);
}
if (((!__instance.physLogic || Object.op_Implicit((Object)(object)<enemyRigidbody>5__16)) | <flag>5__14) || !(__instance.physDamageCooldown > 0f) || !__instance.CanHit(((Component)<componentInParent2>5__12).gameObject, __instance.physDamageCooldown, __instance.physRayCast, <componentInParent2>5__12.centerPoint, (HitType)1))
{
continue;
}
<flag2>5__17 = false;
<componentInParent4>5__18 = ((Component)<collider>5__9).gameObject.GetComponentInParent<PhysGrabObjectImpactDetector>();
if (Object.op_Implicit((Object)(object)<componentInParent4>5__18))
{
if (__instance.physHingeDestroy)
{
<component>5__19 = ((Component)<componentInParent2>5__12).GetComponent<PhysGrabHinge>();
if (Object.op_Implicit((Object)(object)<component>5__19))
{
<component>5__19.DestroyHinge();
<flag2>5__17 = true;
}
<component>5__19 = null;
}
else if (__instance.physHingeBreak)
{
<component2>5__20 = ((Component)<componentInParent2>5__12).GetComponent<PhysGrabHinge>();
if (Object.op_Implicit((Object)(object)<component2>5__20) && Object.op_Implicit((Object)(object)<component2>5__20.joint))
{
((Joint)<component2>5__20.joint).breakForce = 0f;
((Joint)<component2>5__20.joint).breakTorque = 0f;
<flag2>5__17 = true;
}
<component2>5__20 = null;
}
if (!<flag2>5__17)
{
if (__instance.physDestroy)
{
<isDestroyCart>5__21 = !ComeBackEquipment.EnableCart.Value || !<componentInParent4>5__18.isCart;
if (!<componentInParent4>5__18.destroyDisable && (!Object.op_Implicit((Object)(object)((Component)<componentInParent4>5__18).gameObject.GetComponent<ItemEquippable>()) & <isDestroyCart>5__21))
{
<component3>5__22 = ((Component)<componentInParent2>5__12).GetComponent<PhysGrabHinge>();
if (Object.op_Implicit((Object)(object)<component3>5__22))
{
<component3>5__22.DestroyHinge();
}
else
{
<componentInParent4>5__18.DestroyObject(true);
}
<component3>5__22 = null;
}
else
{
__instance.PhysObjectHurt(<componentInParent2>5__12, (BreakImpact)3, 50f, 30f, true, true, (Enemy)null);
}
<flag2>5__17 = true;
}
else if (Object.op_Implicit((Object)(object)<componentInParent2>5__12))
{
if (__instance.physReleaseGrab)
{
<>s__23 = <componentInParent2>5__12.playerGrabbing.ToList().GetEnumerator();
try
{
while (<>s__23.MoveNext())
{
<item>5__24 = <>s__23.Current;
if (!SemiFunc.IsMultiplayer())
{
<item>5__24.ReleaseObject(<componentInParent2>5__12.photonView.ViewID, 0.25f);
continue;
}
<item>5__24.photonView.RPC("ReleaseObjectRPC", (RpcTarget)0, new object[3]
{
false,
0.25f,
<componentInParent2>5__12.photonView.ViewID
});
<item>5__24 = null;
}
}
finally
{
((IDisposable)<>s__23).Dispose();
}
<>s__23 = default(List<PhysGrabber>.Enumerator);
}
if (__instance.PhysObjectHurt(<componentInParent2>5__12, __instance.physImpact, __instance.physHitForce, __instance.physHitTorque, true, false, (Enemy)null))
{
<flag2>5__17 = true;
}
}
}
}
if (<flag2>5__17)
{
__instance.onImpactAny.Invoke();
__instance.onImpactPhysObject.Invoke();
}
<componentInParent2>5__12 = null;
<componentInParent3>5__15 = null;
<enemyRigidbody>5__16 = null;
<componentInParent4>5__18 = null;
}
else
{
if (!SemiFunc.IsMasterClientOrSingleplayer() || !__instance.enemyLogic)
{
continue;
}
<componentInParent5>5__25 = ((Component)<collider>5__9).gameObject.GetComponentInParent<Enemy>();
if (Object.op_Implicit((Object)(object)<componentInParent5>5__25) && !<componentInParent5>5__25.HasRigidbody && __instance.CanHit(((Component)<componentInParent5>5__25).gameObject, __instance.enemyDamageCooldown, __instance.enemyRayCast, ((Component)<componentInParent5>5__25).transform.position, (HitType)2) && __instance.EnemyHurt(<componentInParent5>5__25))
{
__instance.onImpactAny.Invoke();
__instance.onImpactEnemyEnemy = <componentInParent5>5__25;
__instance.onImpactEnemy.Invoke();
}
if (!__instance.enemyHitTriggers)
{
continue;
}
<componentInParent6>5__26 = ((Component)<collider>5__9).gameObject.GetComponentInParent<EnemyParent>();
if (Object.op_Implicit((Object)(object)<componentInParent6>5__26))
{
<componentInChildren>5__27 = ((Component)<componentInParent6>5__26).GetComponentInChildren<EnemyRigidbody>();
if (Object.op_Implicit((Object)(object)<componentInChildren>5__27))
{
__instance.EnemyHurtRigidbody(<componentInChildren>5__27, <componentInChildren>5__27.physGrabObject);
}
<componentInChildren>5__27 = null;
}
<componentInParent5>5__25 = null;
<componentInParent6>5__26 = null;
}
<collider>5__9 = null;
}
<>s__7 = null;
<array2>5__6 = null;
}
<>2__current = (object)new WaitForSeconds(0.05f);
<>1__state = 3;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[HarmonyPrefix]
[HarmonyPatch("PhysObjectHurt")]
private static bool PhysObjectHurt_Prefix(HurtCollider __instance, PhysGrabObject physGrabObject, BreakImpact impact, float hitForce, float hitTorque, bool apply, bool destroyLaunch, Enemy enemy = null)
{
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
bool flag = ComeBackEquipment.EnableCart.Value && physGrabObject.impactDetector.isCart;
if ((ComeBackEquipment.DoTeleport.Value && (Object.op_Implicit((Object)(object)((Component)physGrabObject).GetComponent<ItemEquippable>()) || flag) && destroyLaunch) || (!ComeBackEquipment.DoTeleport.Value && flag && destroyLaunch))
{
physGrabObject.Teleport(((Component)TruckSafetySpawnPoint.instance).transform.position, ((Component)TruckSafetySpawnPoint.instance).transform.rotation);
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch("PlayerHurt")]
private static void PlayerHurt_Prefix(HurtCollider __instance, PlayerAvatar _player)
{
if (GameManager.Multiplayer() && _player.isLocal && __instance.deathPit && !SemiFunc.RunIsArena() && !SemiFunc.RunIsShop() && !RunManager.instance.levelIsShop)
{
Inventory instance = Inventory.instance;
int? obj;
if (instance == null)
{
obj = null;
}
else
{
PhysGrabber physGrabber = instance.physGrabber;
obj = ((physGrabber != null) ? new int?(physGrabber.photonView.ViewID) : null);
}
if (obj == _player.physGrabber.photonView.ViewID)
{
Inventory.instance.ForceUnequip();
}
}
}
[HarmonyPrefix]
[HarmonyPatch("ColliderCheck")]
private static bool ColliderCheck_Prefix(HurtCollider __instance, ref IEnumerator __result)
{
__result = CustomColliderCheck(__instance);
return false;
}
[IteratorStateMachine(typeof(<CustomColliderCheck>d__3))]
private static IEnumerator CustomColliderCheck(HurtCollider __instance)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <CustomColliderCheck>d__3(0)
{
__instance = __instance
};
}
}
}