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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using REPOLib;
using UnityEngine;
[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.2.2")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.2.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 <RestoreItem>d__16 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public CartItem <>4__this;
public PhysGrabCart cart;
private float <timer>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RestoreItem>d__16(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0043: 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)
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_0291: Expected O, but got Unknown
//IL_016b: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
int num = <>1__state;
CartItem cartItem = <>4__this;
List<Collider> list;
switch (num)
{
default:
return false;
case 0:
<>1__state = -1;
Plugin.Spam($"{((Object)((Component)cartItem).gameObject).name} position: {cartItem.baseTransform.position}");
cartItem.grabObj.isActive = true;
cartItem.isStored = false;
cartItem.baseTransform.localScale = ((Component)cartItem).transform.localScale;
cartItem.baseTransform.position = cartItem.ClampToCartBounds(cart);
if (cartItem.itemLights.Count > 0)
{
CollectionExtensions.Do<Light>((IEnumerable<Light>)cartItem.itemLights, (Action<Light>)delegate(Light i)
{
((Behaviour)i).enabled = true;
});
}
<timer>5__2 = 0f;
goto IL_0117;
case 1:
<>1__state = -1;
goto IL_0117;
case 2:
<>1__state = -1;
Plugin.Spam("Returning enemy state");
cartItem.EnemyBody.enemy.CurrentState = cartItem.OriginalState;
goto IL_021c;
case 3:
{
<>1__state = -1;
cartItem.grabObj.impactDetector.isIndestructible = false;
Plugin.Spam("RestoreItem complete!");
return false;
}
IL_0117:
if (<timer>5__2 < ModConfig.CartStabilizationTimer.Value)
{
<timer>5__2 += Time.deltaTime;
cartItem.LerpItem(cart, <timer>5__2);
<>2__current = null;
<>1__state = 1;
return true;
}
list = ((Component)cartItem.grabObj).gameObject.GetComponentsInChildren<Collider>().ToList();
CollectionExtensions.Do<Collider>((IEnumerable<Collider>)list, (Action<Collider>)delegate(Collider c)
{
c.enabled = true;
});
cartItem.baseTransform.localScale = cartItem.OriginalScale;
if ((Object)(object)cartItem.EnemyBody != (Object)null)
{
((Behaviour)cartItem.EnemyBody).enabled = true;
if (cartItem.EnemyBody.enemy.HasNavMeshAgent && SemiFunc.IsMasterClientOrSingleplayer())
{
Plugin.Spam("Enabling navmesh");
cartItem.EnemyBody.enemy.NavMeshAgent.Enable();
cartItem.EnemyBody.enemy.EnemyTeleported(cartItem.baseTransform.position);
}
<>2__current = null;
<>1__state = 2;
return true;
}
goto IL_021c;
IL_021c:
((Behaviour)cartItem.grabObj.impactDetector).enabled = true;
cartItem.grabObj.rb.isKinematic = false;
if (cartItem.hasMapIcon)
{
if ((Object)(object)cartItem.mapIcon != (Object)null)
{
((Renderer)cartItem.mapIcon).enabled = true;
}
else
{
Plugin.WARNING("Unable to show map icon for " + ((Object)((Component)cartItem).gameObject).name);
}
}
<>2__current = (object)new WaitForSeconds(ModConfig.ItemSafetyTimer.Value);
<>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();
}
}
internal Vector3 PosOffset;
internal PhysGrabObject grabObj;
internal bool isStored;
internal Transform baseTransform;
internal Vector3 OriginalScale;
internal EnemyRigidbody EnemyBody;
internal EnemyState OriginalState;
internal List<Light> itemLights = new List<Light>();
internal PhysGrabCart MyCart;
internal SpriteRenderer mapIcon;
internal bool hasMapIcon;
internal void UpdateItem(PhysGrabObject item, PhysGrabCart cart)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: 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);
PosOffset = baseTransform.position - cart.inCart.position;
OriginalScale = baseTransform.localScale;
MyCart = cart;
grabObj = item;
hasMapIcon = (Object)(object)mapIcon != (Object)null;
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)
{
if (item.isEnemy)
{
return ((Component)((Component)item).gameObject.gameObject.GetComponent<EnemyRigidbody>().enemyParent).gameObject.transform;
}
if (item.isPlayer)
{
return ((Component)((Component)item).gameObject.GetComponent<PlayerAvatar>()).gameObject.transform;
}
return ((Component)item).gameObject.transform;
}
internal static void AddToEquip(PhysGrabObject item, PhysGrabCart cart)
{
//IL_011b: 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_0130: Unknown result type (might be due to invalid IL or missing references)
if (item.isPlayer && ModConfig.PlayerSafetyCheck.Value)
{
Plugin.Spam("Skipping player!");
return;
}
if (item.isEnemy && ModConfig.IgnoreEnemies.Value)
{
Plugin.Spam("Ignoring Enemy!");
return;
}
item.rb.isKinematic = true;
item.isActive = false;
((Behaviour)item.impactDetector).enabled = false;
item.impactDetector.isIndestructible = true;
CartItem cartItem = ((Component)item).gameObject.GetComponent<CartItem>() ?? ((Component)item).gameObject.AddComponent<CartItem>();
cartItem.UpdateItem(item, cart);
List<Collider> list = ((Component)item).gameObject.GetComponentsInChildren<Collider>().ToList();
CollectionExtensions.Do<Collider>((IEnumerable<Collider>)list, (Action<Collider>)delegate(Collider c)
{
c.enabled = false;
});
if ((Object)(object)cartItem.EnemyBody != (Object)null)
{
((Behaviour)cartItem.EnemyBody).enabled = false;
if (cartItem.EnemyBody.enemy.HasNavMeshAgent && SemiFunc.IsMasterClientOrSingleplayer())
{
cartItem.EnemyBody.enemy.NavMeshAgent.Disable(9999999f);
}
}
((MonoBehaviour)cart).StartCoroutine(EquipPatch.ChangeSize(0.2f, cartItem.baseTransform.localScale * 0.01f, cartItem.baseTransform.localScale, cartItem.baseTransform));
if (cartItem.itemLights.Count > 0)
{
CollectionExtensions.Do<Light>((IEnumerable<Light>)cartItem.itemLights, (Action<Light>)delegate(Light i)
{
((Behaviour)i).enabled = false;
});
}
cartItem.isStored = true;
if (cartItem.hasMapIcon)
{
if ((Object)(object)cartItem.mapIcon != (Object)null)
{
((Renderer)cartItem.mapIcon).enabled = false;
}
else
{
Plugin.WARNING("Unable to hide map icon for " + ((Object)((Component)item).gameObject).name);
}
}
Plugin.Spam(((Object)((Component)item).gameObject).name + " has been equipped with the cart!");
Plugin.Spam($"cartItem.grabObj is null [ {(Object)(object)cartItem.grabObj == (Object)null} ]");
}
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.2f, 0.2f);
ref Bounds reference2 = ref combinedBounds;
((Bounds)(ref reference2)).max = ((Bounds)(ref reference2)).max - new Vector3(0.2f, -1f, 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__16))]
internal IEnumerator RestoreItem(PhysGrabCart cart)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RestoreItem>d__16(0)
{
<>4__this = this,
cart = cart
};
}
}
internal class CartManager : MonoBehaviour
{
internal PhotonView photonView;
internal bool hasItems;
internal bool isStoringItems;
internal bool isShowingItems;
internal static int CartsStoringItems;
internal PhysGrabCart MyCart;
internal string storedBy = string.Empty;
private void Start()
{
Plugin.Spam("CartManager instance created!");
photonView = ((Component)this).gameObject.GetComponent<PhotonView>();
MyCart = ((Component)this).gameObject.GetComponent<PhysGrabCart>();
}
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;
hasItems = true;
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));
}
}
[HarmonyPatch(typeof(Map), "CustomPositionSet")]
public class MapFixPatch
{
public static void Postfix(Transform transformTarget, Transform transformSource)
{
if (!SemiFunc.RunIsShop())
{
CartItem cartItem = ((Component)transformSource).gameObject.GetComponent<CartItem>() ?? ((Component)transformSource).gameObject.AddComponent<CartItem>();
if (!((Object)(object)cartItem.mapIcon != (Object)null))
{
Plugin.Spam("Assigning mapIcon for game object " + ((Object)((Component)transformSource).gameObject).name);
cartItem.mapIcon = ((Component)transformTarget).gameObject.GetComponentInChildren<SpriteRenderer>();
}
}
}
}
[HarmonyPatch(typeof(PlayerAvatar), "Spawn")]
public class SpawnPlayerStuff
{
public static void Postfix()
{
if (AreWeInGame())
{
Plugin.Message("Player Spawned: CartsStoringItems set to 0");
CartManager.CartsStoringItems = 0;
}
}
private static bool AreWeInGame()
{
if (SemiFunc.RunIsLobbyMenu())
{
return false;
}
if ((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelMainMenu)
{
return false;
}
return true;
}
}
[HarmonyPatch(typeof(StatsManager), "Awake")]
public class StatsManagerAwake
{
public static void Postfix()
{
PocketCartUpgradeItems.InitDictionary();
}
}
[HarmonyPatch(typeof(StatsManager), "Start")]
public class StatsManagerStart
{
public static void Postfix(StatsManager __instance)
{
Plugin.Spam("Updating statsmanager with our save keys!");
if (!__instance.dictionaryOfDictionaries.ContainsKey("playerUpgradePocketcartKeepItems"))
{
__instance.dictionaryOfDictionaries.Add("playerUpgradePocketcartKeepItems", PocketCartUpgradeItems.dictionaryOfClients);
}
}
}
[HarmonyPatch(typeof(RunManager), "ResetProgress")]
public class ResetStuff
{
public static void Postfix()
{
PocketCartUpgradeItems.ResetProgress();
}
}
[HarmonyPatch(typeof(SemiFunc), "ShopPopulateItemVolumes")]
public class ModifyItemRarity
{
public static void Prefix()
{
if (SemiFunc.IsMasterClientOrSingleplayer())
{
PocketCartUpgradeItems.ValueRef();
PocketCartUpgradeSize.ValueRef();
PocketCartUpgradeItems.ShopPatch();
PocketCartUpgradeSize.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 && !ModConfig.KeepItemsUnlockNoUpgrade.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 (!ModConfig.KeepItemsUnlockNoUpgrade.Value && ModConfig.CartItemLevels.Value && UpgradeManager.CartItemsUpgradeLevel <= CartManager.CartsStoringItems)
{
Plugin.Message($"Unable to store items with this cart, already storing items in [ {CartManager.CartsStoringItems} ] carts!");
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;
cartManager.hasItems = 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 && !ModConfig.KeepItemsUnlockNoUpgrade.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
};
}
}
internal static class ModConfig
{
internal static ConfigEntry<bool> DeveloperLogging;
internal static ConfigEntry<bool> KeepItemsUnlockNoUpgrade;
internal static ConfigEntry<float> CartItemsMinPrice;
internal static ConfigEntry<float> CartItemsMaxPrice;
internal static ConfigEntry<bool> CartItemsUpgradeShared;
internal static ConfigEntry<bool> IgnoreEnemies;
internal static ConfigEntry<bool> PlayerSafetyCheck;
internal static ConfigEntry<float> CartStabilizationTimer;
internal static ConfigEntry<float> ItemSafetyTimer;
internal static ConfigEntry<int> CartItemRarity;
internal static ConfigEntry<bool> CartItemSprite;
internal static ConfigEntry<bool> CartItemLevels;
internal static ConfigEntry<int> PlusItemRarity;
internal static ConfigEntry<float> PlusItemMinPrice;
internal static ConfigEntry<float> PlusItemMaxPrice;
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_026a: Unknown result type (might be due to invalid IL or missing references)
//IL_0274: Expected O, but got Unknown
//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Expected O, but got Unknown
//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: 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", true, "When enabled, ensures living players are ignored during pocket cart equip to prevent player death.\nDisabling this will result in a more buggy experience but it can be funny.");
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>()));
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>()));
}
}
[BepInPlugin("com.github.darmuh.PocketCartPlus", "PocketCart Plus", "0.2.2")]
[BepInDependency("REPOLib", "2.0.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.2.2";
}
[CompilerGenerated]
private sealed class <BundleLoader>d__7 : 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__7(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;
Bundle = mybundle;
<>2__current = null;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
Spam("Asset bundle has been loaded");
BundleLoaded = true;
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;
private void Awake()
{
instance = this;
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"PocketCart Plus is loading with version 0.2.2!");
ModConfig.Init();
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text = Path.Combine(directoryName, "pocketcartplus");
BundleLoader.LoadBundle(text, (Func<AssetBundle, IEnumerator>)BundleLoader, true);
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
Log.LogInfo((object)"PocketCart Plus load complete!");
}
[IteratorStateMachine(typeof(<BundleLoader>d__7))]
private static IEnumerator BundleLoader(AssetBundle mybundle)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <BundleLoader>d__7(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 PhotonView photonView;
internal ItemToggle itemToggle;
internal Item itemComponent;
internal MapCustom mapCustom;
internal static bool SaveLoaded = false;
internal static Dictionary<string, int> dictionaryOfClients = 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_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: 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)
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;
}
}
if (!SaveLoaded)
{
LoadStart();
SaveLoaded = true;
}
}
internal static void InitDictionary()
{
Plugin.Spam("Creating dictionary listing");
dictionaryOfClients = 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 && !dictionaryOfClients.ContainsKey(p.steamID))
{
dictionaryOfClients.Add(p.steamID, 0);
}
});
}
internal static void ResetProgress()
{
SaveLoaded = false;
CartManager.CartsStoringItems = 0;
UpgradeManager.CartItemsUpgradeLevel = 0;
UpgradeManager.LocalItemsUpgrade = false;
dictionaryOfClients = new Dictionary<string, int>();
}
internal void LoadStart()
{
LoadSave();
Plugin.Spam("--- Start of Clients Unlocked List ---");
CollectionExtensions.Do<KeyValuePair<string, int>>((IEnumerable<KeyValuePair<string, int>>)dictionaryOfClients, (Action<KeyValuePair<string, int>>)delegate(KeyValuePair<string, int> d)
{
Plugin.Spam(d.Key ?? "");
});
Plugin.Spam("--- End of ClientsUnlocked List ---");
if (!SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
int clientsUnlocked = 0;
int sharedLevel = 0;
CollectionExtensions.Do<PlayerAvatar>((IEnumerable<PlayerAvatar>)GameDirector.instance.PlayerList, (Action<PlayerAvatar>)delegate(PlayerAvatar p)
{
if (!dictionaryOfClients.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 (!ModConfig.CartItemsUpgradeShared.Value)
{
Plugin.Spam($"Host has detected {p.playerName} as having CartItemsUpgrade unlocked. Telling client to enable behavior with level {value}");
photonView.RPC("ReceiveUpgrade", p.photonView.Owner, new object[1] { value });
}
}
});
if (ModConfig.CartItemsUpgradeShared.Value && clientsUnlocked > 0)
{
Plugin.Spam($"Host has shared upgrades enabled and detected [ {clientsUnlocked} ] with the upgrade unlocked. Highest upgrade level set to [ {sharedLevel} ]");
photonView.RPC("ReceiveUpgrade", (RpcTarget)1, new object[1] { sharedLevel });
}
}
internal void LoadSave()
{
Plugin.Spam("Loading unlocked clients listing from statsmanager!");
if (!StatsManager.instance.dictionaryOfDictionaries.TryGetValue("playerUpgradePocketcartKeepItems", out dictionaryOfClients))
{
Plugin.WARNING("Unable to load save key!");
}
GetOldSaveData();
}
internal void UpdateSave()
{
Plugin.Spam("Updating PocketCartUpgrades_ItemsUpgrade in dictionary!");
StatsManager.instance.dictionaryOfDictionaries["playerUpgradePocketcartKeepItems"] = dictionaryOfClients;
}
private 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 (!dictionaryOfClients.ContainsKey(c))
{
dictionaryOfClients.Add(c, 1);
}
else if (dictionaryOfClients[c] == 0)
{
dictionaryOfClients[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 (!dictionaryOfClients.TryGetValue(val.steamID, out var _))
{
Plugin.WARNING("Unable to find [ " + val.steamID + " ] in dictionaryOfClients, creating new entry at level 1!");
dictionaryOfClients.Add(val.steamID, 1);
}
else
{
dictionaryOfClients[val.steamID]++;
}
UpdateSave();
if (SemiFunc.IsMasterClientOrSingleplayer() && ModConfig.CartItemsUpgradeShared.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 = ModConfig.CartItemsMinPrice.Value / basePriceMultiplier;
valuePreset.valueMax = ModConfig.CartItemsMaxPrice.Value / basePriceMultiplier;
((Object)valuePreset).name = "pocketcart_keepitems";
Plugin.Spam($"valuePreset created for keepItems upgrade with base min price of {ModConfig.CartItemsMinPrice.Value} and base max price of {ModConfig.CartItemsMaxPrice.Value}");
}
internal static void ShopPatch()
{
bool flag = false;
Item val = ((IEnumerable<Item>)ShopManager.instance.potentialItemUpgrades).FirstOrDefault((Func<Item, bool>)((Item i) => i.itemAssetName == "Item PocketCart Items"));
if ((Object)(object)val == (Object)null)
{
Plugin.Spam($"Item not found in potentialItemUpgrades ({ShopManager.instance.potentialItemUpgrades.Count})!");
return;
}
if (ModConfig.CartItemRarity.Value >= Plugin.Rand.Next(0, 100))
{
flag = true;
}
if (!flag)
{
ShopManager.instance.potentialItemUpgrades.Remove(val);
}
Plugin.Spam($"Rarity determined item is a valid potential itemUpgrade in the shop {flag}");
val.value = valuePreset;
Plugin.Spam("Value preset set for KeepPocketCartItems Upgrade!");
}
}
public class PocketCartUpgradeSize : MonoBehaviourPunCallbacks
{
[CompilerGenerated]
private sealed class <ReturnToSize>d__11 : 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__11(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 float chosenScale = 1.25f;
public Vector3 chosenVector3;
internal ItemAttributes itemAtts;
private void Awake()
{
itemAtts = ((Component)this).gameObject.GetComponent<ItemAttributes>();
if (SemiFunc.IsMasterClientOrSingleplayer())
{
ChooseScale();
}
}
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())
{
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__11))]
private IEnumerator ReturnToSize()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ReturnToSize>d__11(0)
{
<>4__this = this
};
}
internal static void ValueRef()
{
if ((Object)(object)valuePreset == (Object)null)
{
valuePreset = ScriptableObject.CreateInstance<Value>();
}
valuePreset.valueMin = ModConfig.PlusItemMinPrice.Value / basePriceMultiplier;
valuePreset.valueMax = ModConfig.PlusItemMaxPrice.Value / basePriceMultiplier;
((Object)valuePreset).name = "pocketcartplus_value";
Plugin.Spam($"valuePreset created for cartPlus upgrade with base min price of {ModConfig.PlusItemMinPrice.Value} and base max price of {ModConfig.PlusItemMaxPrice.Value}");
}
internal static void ShopPatch()
{
bool flag = false;
Item val = ((IEnumerable<Item>)ShopManager.instance.potentialItems).FirstOrDefault((Func<Item, bool>)((Item i) => i.itemAssetName == "Item Cart Small Plus"));
if ((Object)(object)val == (Object)null)
{
Plugin.Spam($"Item not found in potentialItems ({ShopManager.instance.potentialItems.Count})!");
return;
}
if (ModConfig.PlusItemRarity.Value >= Plugin.Rand.Next(0, 100))
{
flag = true;
}
if (!flag)
{
ShopManager.instance.potentialItems.Remove(val);
}
Plugin.Spam($"Rarity determined item is a valid potential itemUpgrade in the shop {flag}");
val.value = valuePreset;
Plugin.Spam("Value preset set for cart small plus!");
}
}
internal class UpgradeManager
{
internal static bool LocalItemsUpgrade = false;
internal static int CartItemsUpgradeLevel = 0;
internal static List<int> PlusSizesChosen = new List<int>();
}
}