using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("Vippy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+517f166ebdcded82167aa7823653030463f0c10f")]
[assembly: AssemblyProduct("CartFix")]
[assembly: AssemblyTitle("CartFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.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 CartFix
{
[BepInPlugin("Vippy.CartFix", "CartFix", "1.0.3")]
public class Plugin : BaseUnityPlugin
{
internal const float LoadMassFactor = 2f;
internal static bool Enabled { get; private set; } = true;
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded.");
}
}
}
namespace CartFix.Patches
{
[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "FixedUpdate")]
internal static class CartLerpBoostPatch
{
private const float LerpCoefficient = 15f;
private const float SettledRelativeSpeed = 1.5f;
private static void Postfix(PhysGrabObjectImpactDetector __instance)
{
//IL_00ad: 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)
//IL_00be: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: 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_0120: 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)
if (!Plugin.Enabled || !__instance.inCart || __instance.isEnemy || __instance.physGrabObject.playerGrabbing.Count != 0 || (Object)(object)__instance.currentCart == (Object)null || (Object)(object)__instance.rb == (Object)null || __instance.rb.isKinematic || (Object)(object)((Component)__instance).GetComponent<PlayerTumble>() != (Object)null || (GameManager.instance.gameMode == 1 && !PhotonNetwork.IsMasterClient))
{
return;
}
PhysGrabCart component = ((Component)__instance.currentCart).GetComponent<PhysGrabCart>();
if ((Object)(object)component == (Object)null || ((Vector3)(ref component.actualVelocity)).magnitude > 1f)
{
return;
}
Rigidbody rb = __instance.rb;
Vector3 val = component.actualVelocity + Vector3.Cross(component.rb.angularVelocity, rb.worldCenterOfMass - component.rb.worldCenterOfMass);
Vector3 val2 = rb.velocity - val;
if (!(((Vector3)(ref val2)).magnitude > 1.5f))
{
float y = rb.velocity.y;
Vector3 val3 = Vector3.Lerp(rb.velocity, val, 15f * Time.fixedDeltaTime);
if (val3.y > y)
{
val3.y = y;
}
rb.velocity = val3;
}
}
}
[HarmonyPatch(typeof(PhysGrabCart), "CartMassOverride")]
internal static class CartMassOverrideScalePatch
{
private static void Prefix(PhysGrabCart __instance, ref float mass)
{
if (!Plugin.Enabled)
{
return;
}
float num = 0f;
List<PhysGrabObject> itemsInCart = __instance.itemsInCart;
for (int i = 0; i < itemsInCart.Count; i++)
{
PhysGrabObject val = itemsInCart[i];
if (!((Object)(object)val == (Object)null) && !((Object)(object)val.rb == (Object)null))
{
num += ((val.massOriginal > 0f) ? val.massOriginal : val.rb.mass);
}
}
mass += num * 2f;
}
}
}