using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using REPOLib;
using REPOLib.Modules;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("PocketCartPlus")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PocketCartPlus")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6a645c08-4058-479c-8a08-158fd8a4d196")]
[assembly: AssemblyFileVersion("0.4.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.4.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;
}
}
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}
namespace PocketCartPlus
{
internal class CartItem : MonoBehaviour
{
[CompilerGenerated]
private sealed class <EquipToVoid>d__19 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public CartItem <>4__this;
private List<Collider> <coll>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <EquipToVoid>d__19(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<coll>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: 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_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_0394: Unknown result type (might be due to invalid IL or missing references)
//IL_039f: Unknown result type (might be due to invalid IL or missing references)
//IL_02db: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0305: Unknown result type (might be due to invalid IL or missing references)
//IL_030a: Unknown result type (might be due to invalid IL or missing references)
//IL_0337: Unknown result type (might be due to invalid IL or missing references)
//IL_033c: Unknown result type (might be due to invalid IL or missing references)
//IL_033e: Unknown result type (might be due to invalid IL or missing references)
//IL_0343: Unknown result type (might be due to invalid IL or missing references)
//IL_0345: Unknown result type (might be due to invalid IL or missing references)
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0226: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
CartItem cartItem = <>4__this;
switch (num)
{
default:
return false;
case 0:
{
<>1__state = -1;
bool flag = (Object)(object)cartItem.playerRef != (Object)null;
if (flag && HostValues.PlayerSafety.Value)
{
Plugin.Spam("Skipping player!");
return false;
}
if (cartItem.grabObj.isEnemy && HostValues.KeepIgnoreEnemies.Value)
{
Plugin.Spam("Ignoring Enemy!");
return false;
}
if (flag)
{
cartItem.playerRef.tumble.TumbleSet(true, false);
<>2__current = null;
<>1__state = 1;
return true;
}
cartItem.grabObj.rb.isKinematic = true;
cartItem.grabObj.isActive = false;
((Behaviour)cartItem.grabObj.impactDetector).enabled = false;
cartItem.grabObj.impactDetector.isIndestructible = true;
<coll>5__2 = ((Component)cartItem.baseTransform).gameObject.GetComponentsInChildren<Collider>().ToList();
CollectionExtensions.Do<Collider>((IEnumerable<Collider>)<coll>5__2, (Action<Collider>)delegate(Collider c)
{
c.enabled = false;
});
if ((Object)(object)cartItem.EnemyBody != (Object)null && cartItem.EnemyBody.enemy.MasterClient)
{
if (cartItem.EnemyBody.enemy.HasNavMeshAgent && SemiFunc.IsMasterClientOrSingleplayer())
{
cartItem.EnemyBody.enemy.NavMeshAgent.Stop(9999999f);
}
cartItem.EnemyBody.frozen = true;
}
<>2__current = EquipPatch.ChangeSize(0.2f, cartItem.baseTransform.localScale * 0.01f, cartItem.baseTransform.localScale, cartItem.baseTransform);
<>1__state = 2;
return true;
}
case 1:
<>1__state = -1;
cartItem.photonTransformView.Teleport(PocketDimension.ThePocket.transform.position + new Vector3(0f, 5f * ((Component)cartItem.playerRef).transform.localScale.y - Random.Range(0f, 2f), 0f), PocketDimension.ThePocket.transform.rotation);
Plugin.Spam($"Teleporting player to pocket dimension {PocketDimension.ThePocket.transform}");
cartItem.IsStored = true;
return false;
case 2:
{
<>1__state = -1;
if (cartItem.itemLights.Count > 0)
{
CollectionExtensions.Do<Light>((IEnumerable<Light>)cartItem.itemLights, (Action<Light>)delegate(Light i)
{
((Behaviour)i).enabled = false;
});
}
if ((Object)(object)cartItem.EnemyBody != (Object)null)
{
cartItem.IsStored = true;
Plugin.Spam(((Object)((Component)cartItem).gameObject).name + " has been equipped with the cart!");
return false;
}
PocketCartUpgradeSize component = ((Component)cartItem.MyCart).gameObject.GetComponent<PocketCartUpgradeSize>();
Vector3 posOffset = cartItem.PosOffset;
if ((Object)(object)component != (Object)null)
{
posOffset /= component.chosenScale;
}
Vector3 val = cartItem.PosOffset * 40f;
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(1f, 1f, 1f);
cartItem.photonTransformView.Teleport(PocketDimension.voidRef.inCart.transform.position + val + val2, cartItem.baseTransform.rotation);
<>2__current = null;
<>1__state = 3;
return true;
}
case 3:
<>1__state = -1;
if (!Object.op_Implicit((Object)(object)((Component)cartItem).gameObject.GetComponent<PlayerDeathHead>()))
{
<>2__current = EquipPatch.ChangeSize(0.2f, cartItem.OriginalScale * 40f, cartItem.baseTransform.localScale, cartItem.baseTransform);
<>1__state = 4;
return true;
}
break;
case 4:
<>1__state = -1;
break;
}
CollectionExtensions.Do<Collider>((IEnumerable<Collider>)<coll>5__2, (Action<Collider>)delegate(Collider c)
{
c.enabled = true;
});
if (cartItem.itemLights.Count > 0)
{
CollectionExtensions.Do<Light>((IEnumerable<Light>)cartItem.itemLights, (Action<Light>)delegate(Light i)
{
((Behaviour)i).enabled = true;
});
}
cartItem.IsStored = true;
Plugin.Spam(((Object)((Component)cartItem).gameObject).name + " has been equipped with the cart!");
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 <RestoreItem>d__22 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public CartItem <>4__this;
public PhysGrabCart cart;
private bool <isPlayer>5__2;
private List<Collider> <coll>5__3;
private float <timer>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RestoreItem>d__22(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<coll>5__3 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0267: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_042a: Unknown result type (might be due to invalid IL or missing references)
//IL_0434: Expected O, but got Unknown
//IL_014d: Unknown result type (might be due to invalid IL or missing references)
//IL_0326: Unknown result type (might be due to invalid IL or missing references)
//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
CartItem cartItem = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
Plugin.Spam($"{((Object)((Component)cartItem).gameObject).name} position: {cartItem.baseTransform.position}");
<isPlayer>5__2 = (Object)(object)cartItem.playerRef != (Object)null;
<coll>5__3 = ((Component)cartItem.baseTransform).gameObject.GetComponentsInChildren<Collider>().ToList();
if (!<isPlayer>5__2)
{
CollectionExtensions.Do<Collider>((IEnumerable<Collider>)<coll>5__3, (Action<Collider>)delegate(Collider c)
{
c.enabled = false;
});
}
<>2__current = null;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (<isPlayer>5__2)
{
if (VoidController.VoidIsLocked)
{
Plugin.Log.LogMessage((object)("The void is locked! " + cartItem.playerRef.playerName + " will not be returned to play area!!"));
if (cartItem.playerRef.isLocal)
{
ChatManager.instance.PossessChatScheduleStart(0);
ChatManager.instance.PossessChat((PossessChatID)3, stuckMessages[Random.Range(0, stuckMessages.Count - 1)], 5f, Color.red, 0f, true, 0, (UnityEvent)null);
ChatManager.instance.PossessChatScheduleEnd();
}
return false;
}
if (!cartItem.playerRef.isDisabled)
{
cartItem.playerRef.tumble.TumbleSet(true, false);
<>2__current = null;
<>1__state = 2;
return true;
}
cartItem.baseTransform = ((Component)cartItem.playerRef.playerDeathHead).transform;
}
cartItem.baseTransform.localScale = cartItem.OriginalScale * 0.1f;
cartItem.grabObj.isActive = true;
cartItem.IsStored = false;
cartItem.baseTransform.localScale = ((Component)cartItem).transform.localScale;
cartItem.photonTransformView.Teleport(cartItem.ClampToCartBounds(cart), cartItem.baseTransform.rotation);
<timer>5__4 = 0f;
goto IL_02db;
case 2:
<>1__state = -1;
cartItem.photonTransformView.Teleport(cart.inCart.position + new Vector3(0f, 1f, 0f), cart.inCart.rotation);
Plugin.Spam($"Teleporting player back to level {cart.inCart.position}");
cartItem.IsStored = false;
return false;
case 3:
<>1__state = -1;
goto IL_02db;
case 4:
<>1__state = -1;
Plugin.Spam("Returning enemy state");
cartItem.EnemyBody.enemy.CurrentState = cartItem.OriginalState;
goto IL_03fd;
case 5:
{
<>1__state = -1;
cartItem.grabObj.impactDetector.isIndestructible = false;
Plugin.Spam("RestoreItem complete!");
return false;
}
IL_03fd:
((Behaviour)cartItem.grabObj.impactDetector).enabled = true;
cartItem.grabObj.rb.isKinematic = false;
<>2__current = (object)new WaitForSeconds(HostValues.SafetyTimer.Value);
<>1__state = 5;
return true;
IL_02db:
if (<timer>5__4 < HostValues.StabilzeTimer.Value)
{
<timer>5__4 += Time.deltaTime;
cartItem.LerpItem(cart, <timer>5__4);
<>2__current = null;
<>1__state = 3;
return true;
}
if (!<isPlayer>5__2)
{
CollectionExtensions.Do<Collider>((IEnumerable<Collider>)<coll>5__3, (Action<Collider>)delegate(Collider c)
{
c.enabled = true;
});
}
cartItem.baseTransform.localScale = cartItem.OriginalScale;
if ((Object)(object)cartItem.EnemyBody != (Object)null && cartItem.EnemyBody.enemy.MasterClient)
{
((Behaviour)cartItem.EnemyBody).enabled = true;
if (cartItem.EnemyBody.enemy.HasNavMeshAgent && SemiFunc.IsMasterClientOrSingleplayer())
{
Plugin.Spam("Enabling navmesh");
cartItem.EnemyBody.enemy.NavMeshAgent.StopTimer = 0f;
cartItem.EnemyBody.frozen = false;
cartItem.EnemyBody.enemy.EnemyTeleported(cartItem.baseTransform.position);
}
<>2__current = null;
<>1__state = 4;
return true;
}
goto IL_03fd;
}
}
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 Vector3 PosOffset;
internal PhysGrabObject grabObj;
internal Transform baseTransform;
internal Vector3 OriginalScale;
internal PhotonTransformView photonTransformView;
internal PlayerAvatar playerRef;
internal EnemyRigidbody EnemyBody;
internal EnemyState OriginalState;
internal List<Light> itemLights = new List<Light>();
internal PhysGrabCart MyCart;
internal static List<string> stuckMessages = new List<string>(7) { "They left me behind! :(", "I can't believe they locked me out", "**** i'm stuck", "Help?", "Is anyone there?", "Someone PLEASE unlock the void", "I wonder if they can hear my cries..." };
internal bool IsStored { get; private set; }
internal bool IsPlayer()
{
return (Object)(object)playerRef != (Object)null;
}
internal void UpdateItem(PhysGrabObject item, PhysGrabCart cart)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: 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_00b6: 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_0139: 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_0171: 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_0181: 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)
if ((Object)(object)item == (Object)null || (Object)(object)cart == (Object)null)
{
Plugin.ERROR("Unable to update CartItem off of null cart or item!");
return;
}
baseTransform = GetTransform(item);
photonTransformView = ((Component)this).gameObject.GetComponentInChildren<PhotonTransformView>();
PosOffset = baseTransform.position - cart.inCart.position;
OriginalScale = baseTransform.localScale;
MyCart = cart;
grabObj = item;
itemLights = ((Component)this).gameObject.GetComponentsInChildren<Light>().ToList();
if (item.isEnemy)
{
EnemyBody = ((Component)this).gameObject.GetComponent<EnemyRigidbody>();
OriginalState = EnemyBody.enemy.CurrentState;
List<Light> list = ((Component)EnemyBody.enemyParent).gameObject.GetComponentsInChildren<Light>().ToList();
if (list.Count > 0)
{
itemLights.AddRange(list);
}
}
itemLights.Distinct();
itemLights.RemoveAll((Light i) => ((Behaviour)i).enabled = false);
PosOffset = new Vector3(PosOffset.x / cart.inCart.localScale.x, PosOffset.y / cart.inCart.localScale.y, PosOffset.z / cart.inCart.localScale.z);
Plugin.Spam($"---------------\nCartItem updated to store {((Object)((Component)item).gameObject).name}'s offsets:\nPosOffset - {PosOffset}\n---------------");
if (!EquipPatch.AllCartItems.Contains(this))
{
EquipPatch.AllCartItems.Add(this);
}
}
private Transform GetTransform(PhysGrabObject item)
{
PlayerAvatar val = ((!((Object)(object)((Component)item).gameObject.transform.parent == (Object)null)) ? ((Component)((Component)item).gameObject.transform.parent).GetComponentInChildren<PlayerAvatar>() : null);
if (item.isEnemy)
{
return ((Component)((Component)item).gameObject.GetComponent<EnemyRigidbody>().enemyParent).gameObject.transform;
}
if ((Object)(object)val != (Object)null)
{
playerRef = val;
return ((Component)val).gameObject.transform;
}
return ((Component)item).gameObject.transform;
}
internal static void AddToEquip(PhysGrabObject item, PhysGrabCart cart)
{
CartItem cartItem = ((Component)item).gameObject.GetComponent<CartItem>() ?? ((Component)item).gameObject.AddComponent<CartItem>();
cartItem.UpdateItem(item, cart);
((MonoBehaviour)cart).StartCoroutine(cartItem.EquipToVoid());
}
[IteratorStateMachine(typeof(<EquipToVoid>d__19))]
internal IEnumerator EquipToVoid()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <EquipToVoid>d__19(0)
{
<>4__this = this
};
}
internal Vector3 ClampToCartBounds(PhysGrabCart cart)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: 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)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: 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)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: 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_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_00fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: 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_015c: 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_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
Vector3 val = cart.inCart.position + new Vector3(PosOffset.x * cart.inCart.localScale.x, PosOffset.y * cart.inCart.localScale.y, PosOffset.z * cart.inCart.localScale.z);
Bounds combinedBounds = cart.capsuleColliders[0].bounds;
ref Bounds reference = ref combinedBounds;
((Bounds)(ref reference)).min = ((Bounds)(ref reference)).min + new Vector3(0.2f, 0.6f, 0.2f);
ref Bounds reference2 = ref combinedBounds;
((Bounds)(ref reference2)).max = ((Bounds)(ref reference2)).max - new Vector3(0.2f, -0.6f, 0.2f);
CollectionExtensions.Do<Collider>((IEnumerable<Collider>)cart.capsuleColliders, (Action<Collider>)delegate(Collider c)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
((Bounds)(ref combinedBounds)).Encapsulate(c.bounds);
});
Transform obj = baseTransform;
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(Mathf.Clamp(val.x, ((Bounds)(ref combinedBounds)).min.x, ((Bounds)(ref combinedBounds)).max.x), Mathf.Clamp(val.y, ((Bounds)(ref combinedBounds)).min.y, ((Bounds)(ref combinedBounds)).max.y), Mathf.Clamp(val.z, ((Bounds)(ref combinedBounds)).min.z, ((Bounds)(ref combinedBounds)).max.z));
obj.position = val2;
return val2;
}
private void LerpItem(PhysGrabCart cart, float t)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: 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_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
if (OriginalScale != baseTransform.localScale)
{
baseTransform.localScale = Vector3.Lerp(baseTransform.localScale, OriginalScale, t);
}
baseTransform.position = ClampToCartBounds(cart);
}
[IteratorStateMachine(typeof(<RestoreItem>d__22))]
internal IEnumerator RestoreItem(PhysGrabCart cart)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RestoreItem>d__22(0)
{
<>4__this = this,
cart = cart
};
}
}
public class CartManager : MonoBehaviour
{
internal PhotonView photonView;
internal bool isStoringItems;
internal bool isShowingItems;
internal static int CartsStoringItems = 0;
internal PhysGrabCart MyCart;
internal string storedBy = string.Empty;
internal static CartManager firstInstance;
private static Color textColor = new Color(0.81960785f, 41f / 51f, 41f / 51f);
internal bool HasItems()
{
return EquipPatch.AllCartItems.Any((CartItem i) => (Object)(object)i.MyCart == (Object)(object)MyCart);
}
private void Start()
{
Plugin.Spam("CartManager instance created!");
photonView = ((Component)this).gameObject.GetComponent<PhotonView>();
MyCart = ((Component)this).gameObject.GetComponent<PhysGrabCart>();
if ((Object)(object)firstInstance == (Object)null)
{
firstInstance = this;
}
}
private void Destroy()
{
Plugin.Spam("CartManager destroyed!");
}
[PunRPC]
internal void HideCartItems(string steamID)
{
if (!isStoringItems)
{
storedBy = steamID;
isStoringItems = true;
Plugin.Spam("HideCartItems detected!");
CollectionExtensions.Do<PhysGrabObject>((IEnumerable<PhysGrabObject>)MyCart.itemsInCart, (Action<PhysGrabObject>)delegate(PhysGrabObject c)
{
Plugin.Spam("AddToEquip [ " + ((Object)((Component)c).gameObject).name + " ]");
CartItem.AddToEquip(c, MyCart);
});
EquipPatch.AllCartItems.RemoveAll((CartItem c) => (Object)(object)c.grabObj == (Object)null);
isStoringItems = false;
if (storedBy == PlayerAvatar.instance.steamID)
{
CartsStoringItems++;
}
}
}
[PunRPC]
internal void ShowCartItems()
{
Plugin.Message("ShowCartItems detected!");
Plugin.Spam("Starting cart coroutine!");
((MonoBehaviour)MyCart).StartCoroutine(UpdateVisualsPatch.WaitToDisplay(this));
}
[PunRPC]
private void ReceiveItemsUpgrade(int upgradeLevel)
{
if (!UpgradeManager.LocalItemsUpgrade)
{
UpgradeManager.LocalItemsUpgrade = true;
}
if (upgradeLevel != UpgradeManager.CartItemsUpgradeLevel)
{
UpgradeManager.CartItemsUpgradeLevel = upgradeLevel;
}
}
}
[HarmonyPatch(typeof(PhysGrabCart), "StateMessages")]
public class CartMessagePatch
{
internal static Color hintColor = new Color(44f / 51f, 0.8f, 0.7372549f);
public static void Postfix(PhysGrabCart __instance)
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Invalid comparison between Unknown and I4
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Invalid comparison between Unknown and I4
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
if (!PlayerAvatar.instance.physGrabber.grabbed && HintUI.instance.grabHint)
{
HintUI.instance.grabHint = false;
}
if (__instance.physGrabObject.grabbedLocal && ModConfig.AllowDeposit.Value && GetPocketCarts.AllSmallCarts.Contains(__instance) && (HostValues.KeepNoUpgrade.Value || UpgradeManager.LocalItemsUpgrade) && (HostValues.KeepNoUpgrade.Value || !HostValues.KeepItemsLevels.Value || UpgradeManager.CartItemsUpgradeLevel > CartManager.CartsStoringItems) && ((int)__instance.currentState == 2 || (int)__instance.currentState == 1) && !SemiFunc.RunIsShop())
{
if ((Object)(object)((Component)HintUI.instance).transform.parent != (Object)(object)HintUI.instance.normalParent)
{
((Component)HintUI.instance).transform.SetParent(HintUI.instance.normalParent);
}
HintUI.instance.grabHint = true;
HintUI.instance.ShowInfo("Hold <color=#f0bf30>[ALT]</color> to deposit items", HintUI.instance.textColor, 12f);
}
}
}
[HarmonyPatch(typeof(ItemInfoExtraUI), "Start")]
public class CreateHintUI
{
public static GameObject Hinter;
public static void Postfix(ItemInfoExtraUI __instance)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
if (SpawnPlayerStuff.AreWeInGame() && !((Object)(object)HintUI.instance != (Object)null) && !((Object)(object)__instance.Text == (Object)null))
{
Plugin.Spam("Creating Hinter!");
Hinter = new GameObject("Hinter");
TextMeshProUGUI val = Hinter.AddComponent<TextMeshProUGUI>();
((TMP_Text)val).font = ((TMP_Text)__instance.Text).font;
((TMP_Text)val).fontMaterial = ((TMP_Text)__instance.Text).fontMaterial;
((TMP_Text)val).fontSharedMaterial = ((TMP_Text)__instance.Text).fontSharedMaterial;
((TMP_Text)val).fontSharedMaterials = ((TMP_Text)__instance.Text).fontSharedMaterials;
((TMP_Text)val).spriteAsset = ((TMP_Text)__instance.Text).spriteAsset;
((TMP_Text)val).alignment = (TextAlignmentOptions)4098;
((TMP_Text)val).fontSize = 12f;
((TMP_Text)val).fontStyle = (FontStyles)32;
Hinter.AddComponent<RectTransform>();
Hinter.transform.SetParent(((Component)__instance).gameObject.transform);
Hinter.AddComponent<HintUI>();
}
}
}
[HarmonyPatch(typeof(SemiFunc), "OnLevelGenDone")]
public class PocketDimension
{
internal static GameObject ThePocket;
internal static VoidRef voidRef;
public static void Postfix()
{
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: 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)
if (SpawnPlayerStuff.AreWeInGame())
{
if ((Object)(object)ThePocket == (Object)null)
{
ThePocket = Object.Instantiate<GameObject>(Plugin.PocketDimension, new Vector3(999f, 0f, 0f), default(Quaternion), LevelGenerator.Instance.LevelParent.transform);
}
if ((Object)(object)voidRef == (Object)null)
{
voidRef = ThePocket.GetComponentInChildren<VoidRef>();
Plugin.Spam($"voidRef is null - {(Object)(object)voidRef == (Object)null}");
}
}
}
}
[HarmonyPatch(typeof(PlayerAvatar), "SpawnRPC")]
public class SpawnPlayerStuff
{
public static void Postfix(PlayerAvatar __instance)
{
if (AreWeInGame() && __instance.photonView.IsMine)
{
Plugin.Message("Player Spawned: CartsStoringItems set to 0");
CartManager.CartsStoringItems = 0;
}
}
internal static bool AreWeInGame()
{
if ((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelLobbyMenu)
{
return false;
}
if ((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelMainMenu)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(StatsManager), "LoadGame")]
public class StatsManagerLoad
{
public static void Postfix()
{
PocketCartUpgradeItems.LoadStart();
}
}
[HarmonyPatch(typeof(RunManagerPUN), "Start")]
public class NetworkingInstance
{
public static void Postfix()
{
if ((Object)(object)((Component)RunManager.instance.runManagerPUN).gameObject.GetComponent<GlobalNetworking>() == (Object)null)
{
((Component)RunManager.instance.runManagerPUN).gameObject.AddComponent<GlobalNetworking>();
}
HostConfigCheck();
}
internal static void HostConfigCheck()
{
if (!HostConfigBase.HostConfigInit && PhotonNetwork.MasterClient != null)
{
HostValues.StartGame();
}
}
}
[HarmonyPatch(typeof(StatsManager), "Start")]
public class StatsManagerStart
{
public static void Postfix(StatsManager __instance)
{
PocketCartUpgradeItems.InitDictionary();
Plugin.Spam("Updating statsmanager with our save keys!");
if (!__instance.dictionaryOfDictionaries.ContainsKey("playerUpgradePocketcartKeepItems"))
{
__instance.dictionaryOfDictionaries.Add("playerUpgradePocketcartKeepItems", PocketCartUpgradeItems.ClientsUpgradeDictionary);
}
}
}
[HarmonyPatch(typeof(SemiFunc), "OnSceneSwitch")]
public class LeaveToMainReset
{
public static void Postfix(bool _gameOver, bool _leaveGame)
{
if (_gameOver || _leaveGame)
{
PocketCartUpgradeItems.ResetProgress();
}
NetworkingInstance.HostConfigCheck();
if (HostConfigBase.HostConfigInit)
{
HostConfigBase.HostConfigInit = !_leaveGame;
}
}
}
[HarmonyPatch(typeof(SemiFunc), "ShopPopulateItemVolumes")]
public class ModifyItemRarity
{
public static void Prefix()
{
if (SemiFunc.IsMasterClientOrSingleplayer())
{
PocketCartUpgradeItems.ValueRef();
PocketCartUpgradeSize.ValueRef();
VoidController.ValueRef();
PocketCartUpgradeItems.ShopPatch();
PocketCartUpgradeSize.ShopPatch();
VoidController.ShopPatch();
}
}
}
[HarmonyPatch(typeof(PhysGrabCart), "Start")]
public class GetPocketCarts
{
public static List<PhysGrabCart> AllSmallCarts = new List<PhysGrabCart>();
public static void Postfix(PhysGrabCart __instance)
{
if (__instance.isSmallCart)
{
CartManager cartManager = ((Component)__instance).gameObject.GetComponent<CartManager>() ?? ((Component)__instance).gameObject.AddComponent<CartManager>();
AllSmallCarts.RemoveAll((PhysGrabCart c) => (Object)(object)c == (Object)null);
AllSmallCarts.Add(__instance);
}
}
}
[HarmonyPatch(typeof(ItemEquippable), "AnimateUnequip")]
public class FixScaleofPlus
{
public static void Postfix(ItemEquippable __instance)
{
PocketCartUpgradeSize component = ((Component)__instance).gameObject.GetComponent<PocketCartUpgradeSize>();
if ((Object)(object)component != (Object)null)
{
Plugin.Spam("Returning pocketcart plus to original scale!");
component.ReturnScale();
}
}
}
[HarmonyPatch(typeof(ItemEquippable), "RequestEquip")]
public class EquipPatch
{
[CompilerGenerated]
private sealed class <ChangeSize>d__2 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public float duration;
public Transform transform;
public Vector3 originalScale;
public Vector3 targetScale;
private float <elapsed>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ChangeSize>d__2(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0039: 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)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<elapsed>5__2 = 0f;
break;
case 1:
<>1__state = -1;
break;
}
if (<elapsed>5__2 < duration)
{
float num = <elapsed>5__2 / duration;
transform.localScale = Vector3.Lerp(originalScale, targetScale, num);
<elapsed>5__2 += Time.deltaTime;
<>2__current = null;
<>1__state = 1;
return true;
}
transform.localScale = targetScale;
Plugin.Spam($"All items size set to targetscale [ {targetScale} ] in transform!");
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 List<CartItem> AllCartItems = new List<CartItem>();
public static void Postfix(ItemEquippable __instance)
{
ItemEquippable __instance2 = __instance;
if (!UpgradeManager.LocalItemsUpgrade && !HostValues.KeepNoUpgrade.Value)
{
return;
}
Plugin.Spam("Checking item being equipped");
GetPocketCarts.AllSmallCarts.RemoveAll((PhysGrabCart c) => (Object)(object)c == (Object)null);
if (!GetPocketCarts.AllSmallCarts.Any((PhysGrabCart e) => (Object)(object)e.itemEquippable == (Object)(object)__instance2))
{
return;
}
PhysGrabCart val = ((IEnumerable<PhysGrabCart>)GetPocketCarts.AllSmallCarts).FirstOrDefault((Func<PhysGrabCart, bool>)((PhysGrabCart c) => (Object)(object)c.itemEquippable == (Object)(object)__instance2));
if ((Object)(object)val == (Object)null || val.itemsInCart.Count == 0)
{
return;
}
CartManager component = ((Component)val).GetComponent<CartManager>();
if ((Object)(object)component == (Object)null)
{
Plugin.ERROR("Unable to get cartManager component!");
return;
}
if (component.isShowingItems)
{
Plugin.WARNING("cart is currently showing items!");
return;
}
if (!HostValues.KeepNoUpgrade.Value && HostValues.KeepItemsLevels.Value && UpgradeManager.CartItemsUpgradeLevel <= CartManager.CartsStoringItems)
{
Plugin.Message($"Unable to store items with this cart, already storing items in [ {CartManager.CartsStoringItems} ] carts!");
return;
}
if (Keyboard.current.altKey.isPressed && ModConfig.AllowDeposit.Value)
{
Plugin.Message("Deposit key being pressed, not storing items in cart!");
return;
}
if (SemiFunc.IsMultiplayer())
{
component.photonView.RPC("HideCartItems", (RpcTarget)0, new object[1] { PlayerAvatar.instance.steamID });
}
else
{
component.HideCartItems(PlayerAvatar.instance.steamID);
}
Plugin.Spam("Pocket cart equip detected!\nHiding all cart items with cart!");
}
[IteratorStateMachine(typeof(<ChangeSize>d__2))]
internal static IEnumerator ChangeSize(float duration, Vector3 targetScale, Vector3 originalScale, Transform transform)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ChangeSize>d__2(0)
{
duration = duration,
targetScale = targetScale,
originalScale = originalScale,
transform = transform
};
}
}
[HarmonyPatch(typeof(ItemEquippable), "UpdateVisuals")]
public class UpdateVisualsPatch
{
[CompilerGenerated]
private sealed class <>c__DisplayClass1_0
{
public PhysGrabCart cart;
internal bool <WaitToDisplay>b__1(CartItem x)
{
if (x.IsStored)
{
return (Object)(object)x.MyCart == (Object)(object)cart;
}
return false;
}
internal void <WaitToDisplay>b__2(CartItem x)
{
((MonoBehaviour)cart).StartCoroutine(x.RestoreItem(cart));
}
}
[CompilerGenerated]
private sealed class <WaitToDisplay>d__1 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public CartManager cartManager;
private <>c__DisplayClass1_0 <>8__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <WaitToDisplay>d__1(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>8__1 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>8__1 = new <>c__DisplayClass1_0();
if (cartManager.isShowingItems)
{
return false;
}
cartManager.isShowingItems = true;
<>8__1.cart = cartManager.MyCart;
Plugin.Spam("Waiting to Display object group for cart!");
<>2__current = null;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
goto IL_00c1;
case 2:
<>1__state = -1;
if (cartManager.isStoringItems)
{
Plugin.WARNING("Ending display early! Cart is equiping!");
cartManager.isShowingItems = false;
return false;
}
goto IL_00c1;
case 3:
{
<>1__state = -1;
cartManager.isShowingItems = false;
if (cartManager.storedBy == PlayerAvatar.instance.steamID)
{
CartManager.CartsStoringItems = Mathf.Clamp(CartManager.CartsStoringItems - 1, 0, 99);
}
return false;
}
IL_00c1:
if (((Component)<>8__1.cart).transform.localScale != Vector3.one)
{
<>2__current = null;
<>1__state = 2;
return true;
}
Plugin.Spam($"AllCartItems count - {EquipPatch.AllCartItems.Count}\nRemoving null items!");
EquipPatch.AllCartItems.RemoveAll((CartItem c) => (Object)(object)c == (Object)null || (Object)(object)c.grabObj == (Object)null);
Plugin.Spam($"AllCartItems count - {EquipPatch.AllCartItems.Count}\nRestoring items in cart!");
CollectionExtensions.DoIf<CartItem>((IEnumerable<CartItem>)EquipPatch.AllCartItems, (Func<CartItem, bool>)((CartItem x) => x.IsStored && (Object)(object)x.MyCart == (Object)(object)<>8__1.cart), (Action<CartItem>)delegate(CartItem x)
{
((MonoBehaviour)<>8__1.cart).StartCoroutine(x.RestoreItem(<>8__1.cart));
});
<>2__current = null;
<>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();
}
}
public static void Postfix(ItemEquippable __instance)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Invalid comparison between Unknown and I4
ItemEquippable __instance2 = __instance;
if ((int)__instance2.currentState != 3 || (!UpgradeManager.LocalItemsUpgrade && !HostValues.KeepNoUpgrade.Value))
{
return;
}
Plugin.Spam("Unequip detected! Checking if this item is a cart we care about");
GetPocketCarts.AllSmallCarts.RemoveAll((PhysGrabCart c) => (Object)(object)c == (Object)null);
if (!GetPocketCarts.AllSmallCarts.Any((PhysGrabCart e) => (Object)(object)e.itemEquippable == (Object)(object)__instance2))
{
Plugin.Spam("We don't care about this equippable");
return;
}
PhysGrabCart val = ((IEnumerable<PhysGrabCart>)GetPocketCarts.AllSmallCarts).FirstOrDefault((Func<PhysGrabCart, bool>)((PhysGrabCart c) => (Object)(object)c.itemEquippable == (Object)(object)__instance2));
if ((Object)(object)val == (Object)null)
{
Plugin.Spam("Cart is null");
return;
}
CartManager component = ((Component)val).GetComponent<CartManager>();
if ((Object)(object)component == (Object)null)
{
Plugin.ERROR("Unable to get cartManager component!");
}
else if (component.HasItems())
{
if (SemiFunc.IsMultiplayer())
{
component.photonView.RPC("ShowCartItems", (RpcTarget)0, Array.Empty<object>());
}
else
{
component.ShowCartItems();
}
}
}
[IteratorStateMachine(typeof(<WaitToDisplay>d__1))]
internal static IEnumerator WaitToDisplay(CartManager cartManager)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <WaitToDisplay>d__1(0)
{
cartManager = cartManager
};
}
}
public class HintUI : SemiUI
{
public TextMeshProUGUI Text;
public static HintUI instance;
public string messagePrev = "prev";
public float messageTimer;
public Color textColor;
internal Transform normalParent;
internal bool grabHint;
public override void Start()
{
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
((SemiUI)this).Start();
Text = ((Component)this).GetComponent<TextMeshProUGUI>();
Plugin.Spam($"Text == null | {(Object)(object)Text == (Object)null}");
instance = this;
((TMP_Text)Text).text = "";
normalParent = ((Component)this).transform.parent;
base.showPosition.x = 0f;
base.showPosition.y = 0f;
textColor = new Color(0f, 102f, 0f);
base.hidePosition.x = 0f;
base.hidePosition.y = -30f;
}
public void ShowInfo(string message, Color color, float fontSize)
{
//IL_005d: 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_0076: Unknown result type (might be due to invalid IL or missing references)
if (!(messageTimer > 0f))
{
messageTimer = 0.2f;
if (message != messagePrev)
{
((TMP_Text)Text).text = message;
((SemiUI)this).SemiUISpringShakeY(20f, 10f, 0.3f);
((SemiUI)this).SemiUISpringScale(0.4f, 5f, 0.2f);
textColor = color;
((TMP_Text)Text).fontSize = fontSize;
((Graphic)Text).color = textColor;
messagePrev = message;
}
}
}
public override void Update()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
((SemiUI)this).Update();
if (!SemiFunc.RunIsShop())
{
((SemiUI)ItemInfoUI.instance).SemiUIScoot(new Vector2(0f, 8f));
if (messageTimer > 0f)
{
messageTimer -= Time.deltaTime;
return;
}
((Graphic)Text).color = Color.white;
messagePrev = "prev";
((SemiUI)this).Hide();
}
}
}
public interface IValueSetter
{
void SetValue(bool sync);
}
internal abstract class HostConfigBase
{
internal static List<HostConfigBase> HostConfigItems = new List<HostConfigBase>();
internal static List<string> namesToSync = new List<string>();
internal static bool HostConfigInit = false;
internal TaskCompletionSource<bool> areValuesReady = new TaskCompletionSource<bool>();
internal static TaskCompletionSource<bool> isSyncReady = new TaskCompletionSource<bool>();
internal abstract Type ConfigType { get; }
internal abstract object BoxedVal { get; }
internal abstract string Name { get; }
internal abstract bool RequireSync { get; }
protected HostConfigBase()
{
HostConfigItems.Add(this);
}
public static void SyncIsReady()
{
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
Plugin.Spam("Asking host for their config items");
GlobalNetworking.Instance.photonView.RPC("AskHostAll", PhotonNetwork.MasterClient, new object[1] { Enumerable.ToArray(namesToSync) });
isSyncReady.TrySetResult(result: true);
isSyncReady = new TaskCompletionSource<bool>();
}
}
}
internal class HostConfigItem<T> : HostConfigBase, IValueSetter
{
[CompilerGenerated]
private bool <requireSync>P;
internal ConfigEntry<T> configItem;
internal T Value;
internal override Type ConfigType => typeof(T);
internal override bool RequireSync => <requireSync>P;
internal override string Name => ((ConfigEntryBase)configItem).Definition.Key;
internal override object BoxedVal => ((ConfigEntryBase)configItem).BoxedValue;
public HostConfigItem(ConfigEntry<T> entry, bool requireSync = true)
{
<requireSync>P = requireSync;
configItem = entry;
base..ctor();
}
public static HostConfigItem<T> GetItem(string id)
{
string id2 = id;
HostConfigBase hostConfigBase = HostConfigBase.HostConfigItems.Find((HostConfigBase c) => c.Name == id2);
if (hostConfigBase.BoxedVal.GetType() != typeof(T))
{
throw new InvalidCastException($"Config item is not of type {typeof(T)}");
}
return (HostConfigItem<T>)hostConfigBase;
}
void IValueSetter.SetValue(bool sync)
{
Plugin.Spam("Setting value of " + Name);
if (!SpawnPlayerStuff.AreWeInGame() || !sync)
{
Value = configItem.Value;
}
else if (SemiFunc.IsMasterClientOrSingleplayer())
{
Value = configItem.Value;
}
else
{
GetValueFromHost();
}
}
private async Task<T> GetValueFromHost()
{
Plugin.Spam("Adding item to sync: " + Name);
HostConfigBase.namesToSync.Add(Name);
await HostConfigBase.isSyncReady.Task;
await areValuesReady.Task;
Plugin.Spam($"Got value from host {Value}");
return Value;
}
public void ValueIsReady()
{
areValuesReady.TrySetResult(result: true);
areValuesReady = new TaskCompletionSource<bool>();
}
}
internal class HostValues
{
internal static HostConfigItem<bool> KeepNoUpgrade { get; private set; } = new HostConfigItem<bool>(ModConfig.KeepItemsUnlockNoUpgrade);
internal static HostConfigItem<bool> KeepIgnoreEnemies { get; private set; } = new HostConfigItem<bool>(ModConfig.IgnoreEnemies);
internal static HostConfigItem<bool> PlayerSafety { get; private set; } = new HostConfigItem<bool>(ModConfig.PlayerSafetyCheck);
internal static HostConfigItem<float> StabilzeTimer { get; private set; } = new HostConfigItem<float>(ModConfig.CartStabilizationTimer);
internal static HostConfigItem<float> SafetyTimer { get; private set; } = new HostConfigItem<float>(ModConfig.ItemSafetyTimer);
internal static HostConfigItem<bool> KeepItemsLevels { get; private set; } = new HostConfigItem<bool>(ModConfig.CartItemLevels);
internal static HostConfigItem<bool> ShareKeepUpgrade { get; private set; } = new HostConfigItem<bool>(ModConfig.CartItemsUpgradeShared, requireSync: false);
internal static HostConfigItem<float> KeepMinPrice { get; private set; } = new HostConfigItem<float>(ModConfig.CartItemsMinPrice, requireSync: false);
internal static HostConfigItem<float> KeepMaxPrice { get; private set; } = new HostConfigItem<float>(ModConfig.CartItemsMaxPrice, requireSync: false);
internal static HostConfigItem<int> KeepItemsRarity { get; private set; } = new HostConfigItem<int>(ModConfig.CartItemRarity, requireSync: false);
internal static HostConfigItem<int> PlusCartRarity { get; private set; } = new HostConfigItem<int>(ModConfig.PlusItemRarity, requireSync: false);
internal static HostConfigItem<float> PlusCartMinPrice { get; private set; } = new HostConfigItem<float>(ModConfig.PlusItemMinPrice, requireSync: false);
internal static HostConfigItem<float> PlusCartMaxPrice { get; private set; } = new HostConfigItem<float>(ModConfig.PlusItemMaxPrice, requireSync: false);
internal static HostConfigItem<bool> PlusCartRareVariants { get; private set; } = new HostConfigItem<bool>(ModConfig.RareVariants, requireSync: false);
internal static HostConfigItem<int> VRRarity { get; private set; } = new HostConfigItem<int>(ModConfig.VoidRemoteRarity, requireSync: false);
internal static HostConfigItem<float> VRMinPrice { get; private set; } = new HostConfigItem<float>(ModConfig.VoidRemoteMinPrice, requireSync: false);
internal static HostConfigItem<float> VRMaxPrice { get; private set; } = new HostConfigItem<float>(ModConfig.VoidRemoteMaxPrice, requireSync: false);
internal static void StartGame()
{
Plugin.Spam("Checking config items!!");
HostConfigBase.namesToSync = new List<string>();
CollectionExtensions.Do<HostConfigBase>((IEnumerable<HostConfigBase>)HostConfigBase.HostConfigItems, (Action<HostConfigBase>)delegate(HostConfigBase p)
{
if (p is IValueSetter valueSetter)
{
valueSetter.SetValue(p.RequireSync);
}
});
if ((Object)(object)GlobalNetworking.Instance == (Object)null)
{
Plugin.WARNING("GlobalNetworking is null!");
}
HostConfigBase.SyncIsReady();
HostConfigBase.HostConfigInit = true;
}
internal static void UpdateValue(ConfigEntryBase configItem)
{
ConfigEntryBase configItem2 = configItem;
if (PhotonNetwork.IsMasterClient)
{
Plugin.Spam("Host updated value for " + configItem2.Definition.Key);
HostConfigBase hostConfigBase = HostConfigBase.HostConfigItems.Find((HostConfigBase c) => c.Name == configItem2.Definition.Key);
if (hostConfigBase == null)
{
Plugin.Spam(configItem2.Definition.Key + " is not a HostValue being watched");
return;
}
GlobalNetworking.Instance.HostSendIndividual(configItem2.Definition.Key, configItem2.BoxedValue);
GlobalNetworking.Instance.photonView.RPC("HostSendIndividual", (RpcTarget)1, new object[2]
{
configItem2.Definition.Key,
configItem2.BoxedValue
});
}
}
}
internal static class ModConfig
{
internal static ConfigEntry<bool> DeveloperLogging { get; private set; }
internal static ConfigEntry<bool> KeepItemsUnlockNoUpgrade { get; private set; }
internal static ConfigEntry<float> CartItemsMinPrice { get; private set; }
internal static ConfigEntry<float> CartItemsMaxPrice { get; private set; }
internal static ConfigEntry<bool> CartItemsUpgradeShared { get; private set; }
internal static ConfigEntry<bool> IgnoreEnemies { get; private set; }
internal static ConfigEntry<bool> PlayerSafetyCheck { get; private set; }
internal static ConfigEntry<float> CartStabilizationTimer { get; private set; }
internal static ConfigEntry<float> ItemSafetyTimer { get; private set; }
internal static ConfigEntry<int> CartItemRarity { get; private set; }
internal static ConfigEntry<bool> CartItemSprite { get; private set; }
internal static ConfigEntry<bool> CartItemLevels { get; private set; }
internal static ConfigEntry<bool> AllowDeposit { get; private set; }
internal static ConfigEntry<int> PlusItemRarity { get; private set; }
internal static ConfigEntry<float> PlusItemMinPrice { get; private set; }
internal static ConfigEntry<float> PlusItemMaxPrice { get; private set; }
internal static ConfigEntry<bool> RareVariants { get; private set; }
internal static ConfigEntry<int> VoidRemoteRarity { get; private set; }
internal static ConfigEntry<float> VoidRemoteMinPrice { get; private set; }
internal static ConfigEntry<float> VoidRemoteMaxPrice { get; private set; }
internal static void Init()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Expected O, but got Unknown
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Expected O, but got Unknown
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Expected O, but got Unknown
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
//IL_01fc: Expected O, but got Unknown
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Expected O, but got Unknown
//IL_028e: Unknown result type (might be due to invalid IL or missing references)
//IL_0298: Expected O, but got Unknown
//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
//IL_02d9: Expected O, but got Unknown
//IL_0310: Unknown result type (might be due to invalid IL or missing references)
//IL_031a: Expected O, but got Unknown
//IL_036b: Unknown result type (might be due to invalid IL or missing references)
//IL_0375: Expected O, but got Unknown
//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
//IL_03b6: Expected O, but got Unknown
//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
//IL_03f7: Expected O, but got Unknown
DeveloperLogging = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Debug", "Developer Logging", false, new ConfigDescription("Enable this to see developer logging output", (AcceptableValueBase)null, Array.Empty<object>()));
KeepItemsUnlockNoUpgrade = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Keep Items Upgrade", "Unlock without Upgrade", false, "Enable this if you want the upgrade enabled without having to buy it from the shop.");
CartItemsMinPrice = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Keep Items Upgrade", "Minimum Price", 6000f, new ConfigDescription("Set this as the minimum base price for this item (before multipliers)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 90000f), Array.Empty<object>()));
CartItemsMaxPrice = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Keep Items Upgrade", "Maximum Price", 11000f, new ConfigDescription("Set this as the maximum base price for this item (before multipliers)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 90000f), Array.Empty<object>()));
CartItemRarity = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Keep Items Upgrade", "Rarity Percentage (Add-on)", 75, new ConfigDescription("This is a percentage from 0-100 of how rarely this item will be added to the store.\nThis is an added-on rarity on-top of base-game's rng based spawn system.\n Set to 0 to never spawn this upgrade.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
CartItemsUpgradeShared = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Keep Items Upgrade", "Shared Unlock", false, "Enable this if you want one purchase of this upgrade to unlock the feature for all players in the lobby.\nThis should work with \"Upgrade Levels\" enabled");
IgnoreEnemies = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Keep Items Upgrade", "Ignore Enemies", true, "Disable this if you'd like the pocket cart to try to store enemies as well as items.\nNote: Storing enemies is still fairly buggy.\nThe recommended setting for this is TRUE if you wish to play with as little jank as possible.");
PlayerSafetyCheck = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Keep Items Upgrade", "Player Safety Check", false, "When enabled, ensures living players are ignored during pocket cart equip to prevent player death.\nWhen disabled, players will be sent to the void. (The void can be locked by the void remote item)");
CartItemSprite = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Keep Items Upgrade", "Show On MiniMap", true, "Disable this if you wish to hide the icon for this item on the minimap");
CartItemLevels = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Keep Items Upgrade", "Upgrade Levels", true, "When enabled, the upgrade will only apply for as many carts as the current upgrade level.\nSo upgrade level 1 will only store items for one pocket cart at a time");
CartStabilizationTimer = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Keep Items Upgrade", "Cart Stabilization Timer", 0.15f, new ConfigDescription("Set this as the amount of time the cart items remain frozen while waiting for the cart to stabilize after equipping.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>()));
ItemSafetyTimer = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Keep Items Upgrade", "Item Safety Timer", 0.2f, new ConfigDescription("Set this as the amount of time the cart items are invulnerable to damage after the cart is re-equipped.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>()));
AllowDeposit = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Keep Items Upgrade", "Allow Deposit", true, "Enable this to stop items from being stored when holding ALT");
PlusItemRarity = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Cart Plus Item", "Rarity Percentage (Add-on)", 95, new ConfigDescription("This is a percentage from 0-100 of how rarely this item will be added to the store.\nThis is an added-on rarity on-top of base-game's rng based spawn system.\n Set to 0 to never spawn this item.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
PlusItemMinPrice = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Cart Plus Item", "Minimum Price", 30000f, new ConfigDescription("Set this as the minimum base price for this item (before multipliers)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 90000f), Array.Empty<object>()));
PlusItemMaxPrice = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Cart Plus Item", "Maximum Price", 60000f, new ConfigDescription("Set this as the maximum base price for this item (before multipliers)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 90000f), Array.Empty<object>()));
RareVariants = ((BaseUnityPlugin)Plugin.instance).Config.Bind<bool>("Cart Plus Item", "Rare Variants", true, "When enabled, the pocket cart plus has a rare chance to spawn as either the PLUS2 (150% scale) or PLUS3 (175% scale)");
VoidRemoteRarity = ((BaseUnityPlugin)Plugin.instance).Config.Bind<int>("Void Remote Item", "Rarity Percentage (Add-on)", 100, new ConfigDescription("This is a percentage from 0-100 of how rarely this item will be added to the store.\nThis is an added-on rarity on-top of base-game's rng based spawn system.\n Set to 0 to never spawn this item.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
VoidRemoteMinPrice = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Void Remote Item", "Minimum Price", 100f, new ConfigDescription("Set this as the minimum base price for this item (before multipliers)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 90000f), Array.Empty<object>()));
VoidRemoteMaxPrice = ((BaseUnityPlugin)Plugin.instance).Config.Bind<float>("Void Remote Item", "Maximum Price", 2500f, new ConfigDescription("Set this as the maximum base price for this item (before multipliers)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(100f, 90000f), Array.Empty<object>()));
}
}
internal class GlobalNetworking : MonoBehaviour
{
internal PhotonView photonView;
internal static GlobalNetworking Instance
{
get
{
if ((Object)(object)((Component)RunManager.instance.runManagerPUN).gameObject.GetComponent<GlobalNetworking>() == (Object)null)
{
((Component)RunManager.instance.runManagerPUN).gameObject.AddComponent<GlobalNetworking>();
}
return ((Component)RunManager.instance.runManagerPUN).gameObject.GetComponent<GlobalNetworking>();
}
}
private void Awake()
{
Plugin.Spam("GlobalNetworking instance created!");
photonView = ((Component)this).gameObject.GetComponent<PhotonView>();
}
[PunRPC]
internal void AskHostAll(string[] names, PhotonMessageInfo info)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
Player sender = info.Sender;
Dictionary<string, bool> dictionary = new Dictionary<string, bool>();
Dictionary<string, float> dictionary2 = new Dictionary<string, float>();
Dictionary<string, int> dictionary3 = new Dictionary<string, int>();
foreach (string id in names)
{
Plugin.Spam("Host is being asked for value of " + id);
HostConfigBase hostConfigBase = HostConfigBase.HostConfigItems.Find((HostConfigBase c) => c.Name == id);
if (hostConfigBase.BoxedVal is bool)
{
bool value = HostConfigItem<bool>.GetItem(id).Value;
dictionary.Add(id, value);
}
else if (hostConfigBase.BoxedVal is float)
{
float value2 = HostConfigItem<float>.GetItem(id).Value;
dictionary2.Add(id, value2);
}
else if (hostConfigBase.BoxedVal is int)
{
int value3 = HostConfigItem<int>.GetItem(id).Value;
dictionary3.Add(id, value3);
}
else
{
Plugin.ERROR("Unexpected type in AskHostValue! " + id + "\nFrom " + sender.NickName);
}
}
photonView.RPC("HostSendAll", sender, new object[6]
{
dictionary.Keys.ToArray(),
dictionary.Values.ToArray(),
dictionary2.Keys.ToArray(),
dictionary2.Values.ToArray(),
dictionary3.Keys.ToArray(),
dictionary3.Values.ToArray()
});
}
[PunRPC]
internal void HostSendIndividual(string id, object value)
{
if (value is bool flag)
{
HostSent(new string[1] { id }, new bool[1] { flag });
}
else if (value is float num)
{
HostSent(new string[1] { id }, new float[1] { num });
}
else if (value is int num2)
{
HostSent(new string[1] { id }, new int[1] { num2 });
}
else
{
Plugin.WARNING("Invalid type at HostSendIndividual for " + id + "!");
}
}
[PunRPC]
internal void HostSendAll(string[] boolNames, bool[] boolValues, string[] floatNames, float[] floatValues, string[] intNames, int[] intValues)
{
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
HostSent(boolNames, boolValues);
HostSent(floatNames, floatValues);
HostSent(intNames, intValues);
}
}
internal void HostSent<T>(string[] names, T[] values)
{
if (names.Length != values.Length)
{
Plugin.ERROR($"Invalid value count!\nNames: {names.Length}\nValues: {values.Length}");
return;
}
for (int i = 0; i < names.Length; i++)
{
Plugin.Message($"Updating value of {names[i]} to {values[i]}");
HostConfigItem<T> item = HostConfigItem<T>.GetItem(names[i]);
item.Value = values[i];
item.ValueIsReady();
}
}
}
[BepInPlugin("com.github.darmuh.PocketCartPlus", "PocketCart Plus", "0.4.0")]
[BepInDependency("REPOLib", "2.1.0")]
public class Plugin : BaseUnityPlugin
{
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.github.darmuh.PocketCartPlus";
public const string PLUGIN_NAME = "PocketCart Plus";
public const string PLUGIN_VERSION = "0.4.0";
}
[CompilerGenerated]
private sealed class <BundleLoader>d__12 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public AssetBundle mybundle;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <BundleLoader>d__12(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;
if (((Object)mybundle).name == "upgrade_cartitems")
{
Bundle = mybundle;
<>2__current = null;
<>1__state = 1;
return true;
}
if (((Object)mybundle).name == "pocketdimension")
{
PocketDimensionBundle = mybundle;
PocketDimension = PocketDimensionBundle.LoadAsset<GameObject>("PocketDimension");
Spam("PocketDimension bundle loaded!");
}
break;
case 1:
<>1__state = -1;
Spam("Asset bundle has been loaded");
BundleLoaded = true;
break;
}
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();
}
}
public static Plugin instance = null;
internal static ManualLogSource Log = null;
internal static bool BundleLoaded = false;
internal static Random Rand = new Random();
internal static AssetBundle Bundle = null;
internal static AssetBundle PocketDimensionBundle = null;
internal static GameObject PocketDimension = null;
internal static GameObject HintPrefab = null;
private void Awake()
{
instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"PocketCart Plus is loading with version 0.4.0!");
Log.LogInfo((object)"This version of the mod has been compiled for REPO version 0.2.1 :)");
ModConfig.Init();
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text = Path.Combine(directoryName, "upgrade_cartitems");
string text2 = Path.Combine(directoryName, "pocketdimension");
BundleLoader.LoadBundle(text2, (Func<AssetBundle, IEnumerator>)BundleLoader, false);
BundleLoader.LoadBundle(text, (Func<AssetBundle, IEnumerator>)BundleLoader, true);
((BaseUnityPlugin)this).Config.ConfigReloaded += OnConfigReloaded;
((BaseUnityPlugin)this).Config.SettingChanged += OnSettingChanged;
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
Log.LogInfo((object)"PocketCart Plus load complete!");
}
public void OnConfigReloaded(object sender, EventArgs e)
{
Log.LogDebug((object)"Config has been reloaded!");
if (PhotonNetwork.MasterClient != null)
{
HostValues.StartGame();
}
}
public void OnSettingChanged(object sender, SettingChangedEventArgs settingChangedArg)
{
if (settingChangedArg.ChangedSetting != null)
{
HostValues.UpdateValue(settingChangedArg.ChangedSetting);
}
}
[IteratorStateMachine(typeof(<BundleLoader>d__12))]
private static IEnumerator BundleLoader(AssetBundle mybundle)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <BundleLoader>d__12(0)
{
mybundle = mybundle
};
}
internal static void Message(string message)
{
Log.LogMessage((object)message);
}
internal static void Spam(string message)
{
if (ModConfig.DeveloperLogging.Value)
{
Log.LogDebug((object)message);
}
}
internal static void ERROR(string message)
{
Log.LogError((object)message);
}
internal static void WARNING(string message)
{
Log.LogWarning((object)message);
}
}
public class PocketCartUpgradeItems : MonoBehaviour
{
internal static PocketCartUpgradeItems instance;
internal PhotonView photonView;
internal ItemToggle itemToggle;
internal Item itemComponent;
internal MapCustom mapCustom;
internal static Dictionary<string, int> ClientsUpgradeDictionary = new Dictionary<string, int>();
internal static List<string> ClientsUnlockedOLD = new List<string>();
internal static Value valuePreset = null;
internal static readonly float basePriceMultiplier = 4f;
internal static readonly Color blueUpgradeicon = new Color(2f / 85f, 19f / 85f, 0.4392157f);
internal static readonly Color transparent = new Color(1f, 1f, 1f, 0f);
private void Start()
{
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
instance = this;
photonView = ((Component)this).gameObject.GetComponent<PhotonView>();
itemComponent = ((Component)this).gameObject.GetComponent<Item>();
itemToggle = ((Component)this).gameObject.GetComponent<ItemToggle>();
mapCustom = ((Component)this).gameObject.GetComponent<MapCustom>();
Plugin.Spam("PocketCartUpgradeItems Start");
if ((Object)(object)mapCustom != (Object)null)
{
Plugin.Spam("got mapCustom!");
if (!ModConfig.CartItemSprite.Value)
{
mapCustom.color = transparent;
}
else
{
mapCustom.color = blueUpgradeicon;
}
}
}
internal static void ClientsUnlocked()
{
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
int clientsUnlocked = 0;
int sharedLevel = 0;
CollectionExtensions.Do<PlayerAvatar>((IEnumerable<PlayerAvatar>)GameDirector.instance.PlayerList, (Action<PlayerAvatar>)delegate(PlayerAvatar p)
{
if (!ClientsUpgradeDictionary.TryGetValue(p.steamID, out var value))
{
Plugin.Spam(p.playerName + " does not exist in listing");
}
else if (value < 1)
{
Plugin.Spam(p.playerName + " does not have this unlock!");
}
else
{
clientsUnlocked++;
if (sharedLevel < value)
{
sharedLevel = value;
}
if (!HostValues.ShareKeepUpgrade.Value)
{
Plugin.Spam($"Host has detected {p.playerName} as having CartItemsUpgrade unlocked. Telling client to enable behavior with level {value}");
CartManager.firstInstance.photonView.RPC("ReceiveItemsUpgrade", p.photonView.Owner, new object[1] { value });
}
}
});
if (HostValues.ShareKeepUpgrade.Value && clientsUnlocked > 0)
{
Plugin.Spam($"Host has shared upgrades enabled and detected [ {clientsUnlocked} ] with the upgrade unlocked. Highest upgrade level set to [ {sharedLevel} ]");
CartManager.firstInstance.photonView.RPC("ReceiveItemsUpgrade", (RpcTarget)1, new object[1] { sharedLevel });
}
}
internal static void InitDictionary()
{
Plugin.Spam("Creating dictionary listing");
ClientsUpgradeDictionary = new Dictionary<string, int>();
if (!PhotonNetwork.IsMasterClient)
{
return;
}
CollectionExtensions.Do<PlayerAvatar>((IEnumerable<PlayerAvatar>)GameDirector.instance.PlayerList, (Action<PlayerAvatar>)delegate(PlayerAvatar p)
{
if (!((Object)(object)p == (Object)null) && p.steamID != null && !ClientsUpgradeDictionary.ContainsKey(p.steamID))
{
ClientsUpgradeDictionary.Add(p.steamID, 0);
}
});
}
internal static void ResetProgress()
{
Plugin.Message("UpgradeItems progress reset, will be refreshed by next save");
CartManager.CartsStoringItems = 0;
UpgradeManager.LocalItemsUpgrade = false;
ClientsUpgradeDictionary = new Dictionary<string, int>();
}
internal static void LoadStart()
{
LoadSave();
Plugin.Spam("--- Start of Clients Unlocked List ---");
CollectionExtensions.Do<KeyValuePair<string, int>>((IEnumerable<KeyValuePair<string, int>>)ClientsUpgradeDictionary, (Action<KeyValuePair<string, int>>)delegate(KeyValuePair<string, int> d)
{
Plugin.Spam(d.Key ?? "");
});
Plugin.Spam("--- End of ClientsUnlocked List ---");
ClientsUnlocked();
}
internal static void LoadSave()
{
Plugin.Spam("Loading unlocked clients listing from statsmanager!");
if (!StatsManager.instance.dictionaryOfDictionaries.TryGetValue("playerUpgradePocketcartKeepItems", out ClientsUpgradeDictionary))
{
Plugin.WARNING("Unable to load save key!");
}
GetOldSaveData();
}
internal void UpdateSave()
{
Plugin.Spam("Updating PocketCartUpgrades_ItemsUpgrade in dictionary!");
StatsManager.instance.dictionaryOfDictionaries["playerUpgradePocketcartKeepItems"] = ClientsUpgradeDictionary;
}
private static void GetOldSaveData()
{
if (!ES3.KeyExists("PocketCartUpgrades_ItemsUpgrade", StatsManager.instance.saveFileCurrent))
{
return;
}
Plugin.Spam("Old existing save key found! Loading values");
ClientsUnlockedOLD = ES3.Load<List<string>>("PocketCartUpgrades_ItemsUpgrade", StatsManager.instance.saveFileCurrent);
if (ClientsUnlockedOLD.Count > 0)
{
ClientsUnlockedOLD.RemoveAll((string c) => c == null);
CollectionExtensions.Do<string>((IEnumerable<string>)ClientsUnlockedOLD, (Action<string>)delegate(string c)
{
if (!ClientsUpgradeDictionary.ContainsKey(c))
{
ClientsUpgradeDictionary.Add(c, 1);
}
else if (ClientsUpgradeDictionary[c] == 0)
{
ClientsUpgradeDictionary[c] = 1;
}
});
}
ES3.DeleteKey("PocketCartUpgrades_ItemsUpgrade");
ClientsUnlockedOLD = new List<string>();
}
public void Upgrade()
{
Plugin.Spam("PocketCartUpgradeItems Upgrade!");
PlayerAvatar val = SemiFunc.PlayerAvatarGetFromPhotonID(itemToggle.playerTogglePhotonID);
if (val.isLocal)
{
if (!UpgradeManager.LocalItemsUpgrade)
{
UpgradeManager.LocalItemsUpgrade = true;
}
UpgradeManager.CartItemsUpgradeLevel++;
Plugin.Spam($"Enabling PocketCart Keep Items Upgrade for local player! Level [ {UpgradeManager.CartItemsUpgradeLevel} ]");
}
if (!ClientsUpgradeDictionary.TryGetValue(val.steamID, out var _))
{
Plugin.Spam("Unable to find [ " + val.steamID + " ] in ClientsUpgradeDictionary, creating new entry at level 1!");
ClientsUpgradeDictionary.Add(val.steamID, 1);
}
else
{
ClientsUpgradeDictionary[val.steamID]++;
}
UpdateSave();
if (SemiFunc.IsMasterClientOrSingleplayer() && HostValues.ShareKeepUpgrade.Value)
{
Plugin.Spam("Sending upgrade status to all other clients!");
List<Player> list = PhotonNetwork.PlayerListOthers.ToList();
if (list.Contains(val.photonView.Owner))
{
list.Remove(val.photonView.Owner);
}
CollectionExtensions.Do<Player>((IEnumerable<Player>)list, (Action<Player>)delegate(Player o)
{
photonView.RPC("ReceiveUpgrade", o, new object[1] { UpgradeManager.CartItemsUpgradeLevel });
});
}
}
[PunRPC]
private void ReceiveUpgrade(int upgradeLevel)
{
if (!PhotonNetwork.IsMasterClient)
{
if (!UpgradeManager.LocalItemsUpgrade)
{
UpgradeManager.LocalItemsUpgrade = true;
}
if (upgradeLevel != UpgradeManager.CartItemsUpgradeLevel)
{
UpgradeManager.CartItemsUpgradeLevel = upgradeLevel;
}
}
}
internal static void ValueRef()
{
if ((Object)(object)valuePreset == (Object)null)
{
valuePreset = ScriptableObject.CreateInstance<Value>();
}
valuePreset.valueMin = HostValues.KeepMinPrice.Value / basePriceMultiplier;
valuePreset.valueMax = HostValues.KeepMaxPrice.Value / basePriceMultiplier;
((Object)valuePreset).name = "pocketcart_keepitems";
Plugin.Spam($"valuePreset created for keepItems upgrade with base min price of {HostValues.KeepMinPrice.Value} and base max price of {HostValues.KeepMaxPrice.Value}");
}
internal static void ShopPatch()
{
bool flag = false;
Item keepItems = Items.GetItemByName("Item PocketCart Items");
if ((Object)(object)keepItems == (Object)null)
{
Plugin.Spam("Item not found!");
return;
}
if (HostValues.KeepItemsRarity.Value >= Plugin.Rand.Next(0, 100))
{
flag = true;
}
if (!flag && ShopManager.instance.potentialItemUpgrades.Contains(keepItems))
{
int num = ShopManager.instance.potentialItems.Count((Item i) => i.itemAssetName == keepItems.itemAssetName);
Plugin.Spam($"Add-on rarity has determined {keepItems.itemName} should be removed from the store! Original contains {num} of this item");
ShopManager.instance.potentialItemUpgrades.RemoveAll((Item i) => i.itemAssetName == keepItems.itemAssetName);
if (num > 0 && ShopManager.instance.potentialItemUpgrades.Count > 0)
{
for (int j = 0; j < num; j++)
{
ShopManager.instance.potentialItemUpgrades.Add(ShopManager.instance.potentialItemUpgrades[Plugin.Rand.Next(0, ShopManager.instance.potentialItemUpgrades.Count)]);
Plugin.Spam("Replaced upgrade with another random valid upgrade");
}
}
}
Plugin.Spam($"Rarity determined item is a valid potential itemUpgrade in the shop {flag}");
keepItems.value = valuePreset;
Plugin.Spam("Value preset set for KeepPocketCartItems Upgrade!");
}
}
public class PocketCartUpgradeSize : MonoBehaviourPunCallbacks
{
[CompilerGenerated]
private sealed class <ReturnToSize>d__12 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public PocketCartUpgradeSize <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ReturnToSize>d__12(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
PocketCartUpgradeSize pocketCartUpgradeSize = <>4__this;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
goto IL_0042;
case 1:
<>1__state = -1;
goto IL_0042;
case 2:
{
<>1__state = -1;
Plugin.Spam($"Scale has been returned to chosen scale {pocketCartUpgradeSize.chosenScale}");
return false;
}
IL_0042:
if (((Component)pocketCartUpgradeSize).transform.localScale != Vector3.one)
{
<>2__current = null;
<>1__state = 1;
return true;
}
<>2__current = EquipPatch.ChangeSize(0.2f, pocketCartUpgradeSize.chosenVector3, ((Component)pocketCartUpgradeSize).transform.localScale, ((Component)pocketCartUpgradeSize).transform);
<>1__state = 2;
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();
}
}
internal static Value valuePreset = null;
internal static readonly float basePriceMultiplier = 4f;
public PhysGrabCart Cart;
public float chosenScale = 1.25f;
public Vector3 chosenVector3;
internal ItemAttributes itemAtts;
private void Awake()
{
itemAtts = ((Component)this).gameObject.GetComponent<ItemAttributes>();
Cart = ((Component)this).gameObject.GetComponent<PhysGrabCart>();
if (SemiFunc.IsMasterClientOrSingleplayer())
{
ChooseScale();
UpgradeManager.PlusSizeCarts.RemoveAll((PocketCartUpgradeSize c) => (Object)(object)c == (Object)null);
UpgradeManager.PlusSizeCarts.Add(this);
}
}
private void Start()
{
UpdateName();
}
private void ChooseScale()
{
Plugin.Spam("Chosing scale!");
int num = Plugin.Rand.Next(0, 100);
if (num < 75)
{
chosenScale = 1.25f;
}
else if (num > 95)
{
chosenScale = 1.75f;
}
else
{
chosenScale = 1.5f;
}
if (SemiFunc.RunIsShop() || !HostValues.PlusCartRareVariants.Value)
{
chosenScale = 1.25f;
}
if (SemiFunc.IsMultiplayer())
{
((MonoBehaviourPun)this).photonView.RPC("SyncScale", (RpcTarget)0, new object[1] { chosenScale });
}
else
{
SyncScale(chosenScale);
}
}
[PunRPC]
internal void SyncScale(float scale)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
Plugin.Spam($"Syncing scale of {scale}");
chosenScale = scale;
chosenVector3 = new Vector3(scale, scale, scale);
((Component)this).transform.localScale = chosenVector3;
}
private void UpdateName()
{
Plugin.Spam("Updating Name!");
if (chosenScale == 1.5f)
{
itemAtts.itemName = "POCKET C.A.R.T. PLUS2";
}
if (chosenScale == 1.75f)
{
itemAtts.itemName = "POCKET C.A.R.T. PLUS3";
}
}
internal void ReturnScale()
{
((MonoBehaviour)this).StartCoroutine(ReturnToSize());
}
[IteratorStateMachine(typeof(<ReturnToSize>d__12))]
private IEnumerator ReturnToSize()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ReturnToSize>d__12(0)
{
<>4__this = this
};
}
internal static void ValueRef()
{
if ((Object)(object)valuePreset == (Object)null)
{
valuePreset = ScriptableObject.CreateInstance<Value>();
}
valuePreset.valueMin = HostValues.PlusCartMinPrice.Value / basePriceMultiplier;
valuePreset.valueMax = HostValues.PlusCartMaxPrice.Value / basePriceMultiplier;
((Object)valuePreset).name = "pocketcartplus_value";
Plugin.Spam($"valuePreset created for cartPlus upgrade with base min price of {HostValues.PlusCartMinPrice.Value} and base max price of {HostValues.PlusCartMaxPrice.Value}");
}
internal static void ShopPatch()
{
bool flag = false;
Item cartPlus = Items.GetItemByName("Item PCartPlus");
if ((Object)(object)cartPlus == (Object)null)
{
Plugin.Spam("Item not found!");
return;
}
if (HostValues.PlusCartRarity.Value >= Plugin.Rand.Next(0, 100))
{
flag = true;
}
if (!flag && ShopManager.instance.potentialItems.Contains(cartPlus))
{
int num = ShopManager.instance.potentialItems.Count((Item i) => i.itemAssetName == cartPlus.itemAssetName);
Plugin.Spam($"Add-on rarity has determined {cartPlus.itemName} should be removed from the store! Original contains {num} of this item");
ShopManager.instance.potentialItems.RemoveAll((Item i) => i.itemAssetName == cartPlus.itemAssetName);
if (num > 0 && ShopManager.instance.potentialItems.Count > 0)
{
for (int j = 0; j < num; j++)
{
ShopManager.instance.potentialItems.Add(ShopManager.instance.potentialItems[Plugin.Rand.Next(0, ShopManager.instance.potentialItems.Count)]);
Plugin.Spam("Replaced item with another random valid item");
}
}
}
Plugin.Spam($"Rarity determined item is valid to be added to the shop {flag}");
cartPlus.value = valuePreset;
Plugin.Spam("Value preset set for cart small plus!");
}
}
internal class UpgradeManager
{
internal static bool LocalItemsUpgrade = false;
internal static List<PocketCartUpgradeSize> PlusSizeCarts = new List<PocketCartUpgradeSize>();
internal static int CartItemsUpgradeLevel
{
get
{
int result = 0;
if (!StatsManager.instance.FetchPlayerUpgrades(PlayerAvatar.instance.steamID).ContainsKey("Pocketcart Keep Items"))
{
Plugin.WARNING("Unable to find upgrade for CartItemsUpgradeLevel! Returning 0!");
return result;
}
return StatsManager.instance.FetchPlayerUpgrades(PlayerAvatar.instance.steamID)["Pocketcart Keep Items"];
}
set
{
StatsManager.instance.DictionaryUpdateValue("playerUpgradePocketcartKeepItems", PlayerAvatar.instance.steamID, value);
}
}
}
public class VoidController : MonoBehaviour
{
internal static float DistanceFromFace = 0.75f;
internal static Quaternion xTurn = Quaternion.Euler(0f, 0f, 0f);
internal static Quaternion yTurn = Quaternion.Euler(0f, 350f, 0f);
internal static readonly float basePriceMultiplier = 4f;
internal static Value valuePreset = null;
internal ItemAttributes itemAtts;
internal PhotonView photonView;
public Renderer panelMesh;
public TMP_Text keypadDisplayText;
private Color lockedColor = new Color(0.75f, 0f, 0f, 1f);
private Color unlockedColor = new Color(0.3f, 0.58f, 0.3f, 0f);
private ItemToggle itemToggle;
private ItemEquippable itemEquippable;
private PhysGrabObject physGrabObject;
internal static bool VoidIsLocked { get; private set; } = false;
private void Awake()
{
itemToggle = ((Component)this).GetComponent<ItemToggle>();
itemEquippable = ((Component)this).GetComponent<ItemEquippable>();
photonView = ((Component)this).GetComponent<PhotonView>();
itemAtts = ((Component)this).GetComponent<ItemAttributes>();
physGrabObject = ((Component)this).GetComponent<PhysGrabObject>();
}
private void Physics()
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
if (physGrabObject.grabbed && physGrabObject.grabbedLocal && !PhysGrabber.instance.isPulling && !PhysGrabber.instance.isPushing)
{
PhysGrabber.instance.OverrideGrabDistance(DistanceFromFace);
if (!physGrabObject.isRotating)
{
Quaternion identity = Quaternion.identity;
physGrabObject.TurnXYZ(xTurn, yTurn, identity);
}
}
}
private void Update()
{
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: 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)
Physics();
if (!SemiFunc.RunIsShop() && !itemEquippable.isEquipped && VoidIsLocked != itemToggle.toggleState)
{
VoidIsLocked = itemToggle.toggleState;
if (VoidIsLocked)
{
panelMesh.material.SetVector("_EmissionColor", Color.op_Implicit(lockedColor));
keypadDisplayText.text = "LOCKED";
}
else
{
panelMesh.material.SetVector("_EmissionColor", Color.op_Implicit(unlockedColor));
keypadDisplayText.text = "UNLOCKED";
}
photonView.RPC("SyncVoidStatus", (RpcTarget)1, new object[1] { VoidIsLocked });
}
}
[PunRPC]
private void SyncVoidStatus(bool status)
{
if (itemToggle.toggleState != status)
{
itemToggle.toggleState = status;
}
}
internal static void ValueRef()
{
if ((Object)(object)valuePreset == (Object)null)
{
valuePreset = ScriptableObject.CreateInstance<Value>();
}
valuePreset.valueMin = HostValues.VRMinPrice.Value / basePriceMultiplier;
valuePreset.valueMax = HostValues.VRMaxPrice.Value / basePriceMultiplier;
((Object)valuePreset).name = "voidRemote_value";
Plugin.Spam($"valuePreset created for voidRemote item with base min price of {HostValues.VRMinPrice.Value} and base max price of {HostValues.VRMaxPrice.Value}");
}
internal static void ShopPatch()
{
bool flag = false;
Item voidRemote = Items.GetItemByName("Item VoidRemote");
if ((Object)(object)voidRemote == (Object)null)
{
Plugin.Spam("Item not found!");
return;
}
if (HostValues.VRRarity.Value >= Plugin.Rand.Next(0, 100))
{
flag = true;
}
if (!flag && ShopManager.instance.potentialSecretItems.Any((KeyValuePair<itemSecretShopType, List<Item>> x) => x.Value.Contains(voidRemote)))
{
int num = ShopManager.instance.potentialSecretItems.Values.Sum((List<Item> x) => x.Count((Item i) => i.itemAssetName == voidRemote.itemAssetName));
Plugin.Spam($"Add-on rarity has determined {voidRemote.itemName} should be removed from the store! Original contains {num} of this item");
foreach (List<Item> value in ShopManager.instance.potentialSecretItems.Values)
{
value.RemoveAll((Item i) => i.itemAssetName == voidRemote.itemAssetName);
}
}
Plugin.Spam($"Rarity determined void remote is valid to be added to the shop {flag}");
voidRemote.value = valuePreset;
Plugin.Spam("Value preset set for void remote!");
}
}
public class VoidRef : MonoBehaviour
{
public GameObject inCart;
}
}