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 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: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+31d33a1e262fb9cd936a8fd3f583fdd7bc996e5a")]
[assembly: AssemblyProduct("ExtractorShrinker")]
[assembly: AssemblyTitle("ExtractorShrinker")]
[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 Empress.ShrinkOnExtract
{
[BepInPlugin("Empress.ShrinkOnExtract", "ShrinkOnExtract", "1.0.6")]
public class ShrinkOnExtract : BaseUnityPlugin
{
internal static ShrinkOnExtract Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
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} 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();
}
}
}
[HarmonyPatch(typeof(ValuableObject))]
public static class Patch_ValuableObject_Awake
{
[HarmonyPostfix]
[HarmonyPatch("Awake")]
public static void Postfix(ValuableObject __instance)
{
if (!Object.op_Implicit((Object)(object)((Component)__instance).gameObject.GetComponent<EmpressShrinkWatcher>()))
{
((Component)__instance).gameObject.AddComponent<EmpressShrinkWatcher>();
}
}
}
public class EmpressShrinkWatcher : MonoBehaviour
{
private ValuableObject valuable;
private PhysGrabObject grabObj;
private PhysGrabObjectImpactDetector impact;
private PhotonView pv;
private Vector3 originalScale;
private bool shrunk;
private bool prevInside;
private bool prevInCart;
private bool pendingInsideDrop;
private const float targetScale = 0.3f;
private const float entryRadius = 2.5f;
private static List<ExtractionPoint> cachedExtractionPoints = new List<ExtractionPoint>();
private static float lastCacheTime = 0f;
private const float cacheRefreshInterval = 8f;
private void Awake()
{
//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)
valuable = ((Component)this).GetComponent<ValuableObject>();
grabObj = ((Component)this).GetComponent<PhysGrabObject>();
impact = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>();
pv = ((Component)this).GetComponent<PhotonView>();
if (!Object.op_Implicit((Object)(object)pv))
{
pv = ((Component)this).GetComponentInParent<PhotonView>();
}
originalScale = ((Component)this).transform.localScale;
}
private void Update()
{
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: 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)
if (shrunk || !PhotonNetwork.IsMasterClient || (Object)(object)valuable == (Object)null || ((Object)(object)impact != (Object)null && impact.isCart))
{
return;
}
ExtractionPoint val = FindNearestExtraction(((Component)this).transform.position);
if ((Object)(object)val == (Object)null)
{
return;
}
bool flag = Vector3.Distance(((Component)this).transform.position, ((Component)val).transform.position) <= 2.5f;
bool flag2 = ((Object)(object)impact != (Object)null && impact.inCart) || ((Object)(object)grabObj != (Object)null && (Object)(object)grabObj.impactDetector != (Object)null && grabObj.impactDetector.inCart);
if (flag && !flag2 && (!prevInside || prevInCart || pendingInsideDrop))
{
Shrink();
return;
}
if (flag && flag2)
{
pendingInsideDrop = true;
}
if (!flag)
{
pendingInsideDrop = false;
}
prevInside = flag;
prevInCart = flag2;
}
private ExtractionPoint FindNearestExtraction(Vector3 origin)
{
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
if (Time.time - lastCacheTime >= 8f || cachedExtractionPoints.Count == 0)
{
cachedExtractionPoints.Clear();
ExtractionPoint[] array = Object.FindObjectsOfType<ExtractionPoint>(true);
foreach (ExtractionPoint val in array)
{
if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeInHierarchy)
{
cachedExtractionPoints.Add(val);
}
}
lastCacheTime = Time.time;
}
ExtractionPoint result = null;
float num = float.MaxValue;
for (int j = 0; j < cachedExtractionPoints.Count; j++)
{
ExtractionPoint val2 = cachedExtractionPoints[j];
Vector3 val3 = ((Component)val2).transform.position - origin;
float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
if (sqrMagnitude < num)
{
num = sqrMagnitude;
result = val2;
}
}
return result;
}
private void Shrink()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
shrunk = true;
pendingInsideDrop = false;
if ((Object)(object)pv != (Object)null)
{
pv.RPC("Empress_ShrinkRPC", (RpcTarget)3, new object[1] { 0.3f });
}
else
{
((Component)this).transform.localScale = originalScale * 0.3f;
}
}
[PunRPC]
public void Empress_ShrinkRPC(float s, PhotonMessageInfo info)
{
//IL_0001: 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_001d: Unknown result type (might be due to invalid IL or missing references)
if (SemiFunc.MasterOnlyRPC(info))
{
((Component)this).transform.localScale = originalScale * s;
}
}
}
}