Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of PocketCartPlusFixed v0.5.6
plugins/com.github.darmuh.PocketCartPlus.dll
Decompiled 13 hours agousing 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.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 REPOLib; 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: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("darmuh")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.5.6")] [assembly: AssemblyInformationalVersion("0.5.6+248bdb4d0b7367c1324896b9c093ffa78a472495")] [assembly: AssemblyProduct("com.github.darmuh.PocketCartPlus")] [assembly: AssemblyTitle("PocketCartPlus")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.5.6.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace PocketCartPlus { internal class CartItem : MonoBehaviour { 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_0143: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_017b: 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) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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 = itemLights.Distinct().ToList(); 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()); } internal IEnumerator EquipToVoid() { bool flag = (Object)(object)playerRef != (Object)null; if (flag && HostValues.PlayerSafety.Value) { Plugin.Spam("Skipping player!"); yield break; } if (grabObj.isEnemy && HostValues.KeepIgnoreEnemies.Value) { Plugin.Spam("Ignoring Enemy!"); yield break; } if (flag) { playerRef.tumble.TumbleSet(true, false); yield return null; photonTransformView.Teleport(PocketDimension.ThePocket.transform.position + new Vector3(0f, 5f * ((Component)playerRef).transform.localScale.y - Random.Range(0f, 2f), 0f), PocketDimension.ThePocket.transform.rotation); Plugin.Spam($"Teleporting player to pocket dimension {PocketDimension.ThePocket.transform}"); IsStored = true; yield break; } grabObj.rb.isKinematic = true; grabObj.isActive = false; ((Behaviour)grabObj.impactDetector).enabled = false; grabObj.impactDetector.isIndestructible = true; List<Collider> coll = ((Component)baseTransform).gameObject.GetComponentsInChildren<Collider>().ToList(); CollectionExtensions.Do<Collider>((IEnumerable<Collider>)coll, (Action<Collider>)delegate(Collider c) { c.enabled = false; }); if ((Object)(object)EnemyBody != (Object)null && EnemyBody.enemy.MasterClient) { if (EnemyBody.enemy.HasNavMeshAgent && SemiFunc.IsMasterClientOrSingleplayer()) { EnemyBody.enemy.NavMeshAgent.Stop(9999999f); } EnemyBody.frozen = true; } yield return EquipPatch.ChangeSize(0.2f, baseTransform.localScale * 0.01f, baseTransform.localScale, baseTransform); if (itemLights.Count > 0) { CollectionExtensions.Do<Light>((IEnumerable<Light>)itemLights, (Action<Light>)delegate(Light i) { ((Behaviour)i).enabled = false; }); } if ((Object)(object)EnemyBody != (Object)null) { IsStored = true; Plugin.Spam(((Object)((Component)this).gameObject).name + " has been equipped with the cart!"); yield break; } PocketCartUpgradeSize component = ((Component)MyCart).gameObject.GetComponent<PocketCartUpgradeSize>(); Vector3 posOffset = PosOffset; if ((Object)(object)component != (Object)null) { _ = posOffset / component.chosenScale; } Vector3 val = PosOffset * 40f; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(1f, 1f, 1f); photonTransformView.Teleport(PocketDimension.voidRef.inCart.transform.position + val + val2, baseTransform.rotation); yield return null; if (!Object.op_Implicit((Object)(object)((Component)this).gameObject.GetComponent<PlayerDeathHead>())) { yield return EquipPatch.ChangeSize(0.2f, OriginalScale * 40f, baseTransform.localScale, baseTransform); } CollectionExtensions.Do<Collider>((IEnumerable<Collider>)coll, (Action<Collider>)delegate(Collider c) { c.enabled = true; }); if (itemLights.Count > 0) { CollectionExtensions.Do<Light>((IEnumerable<Light>)itemLights, (Action<Light>)delegate(Light i) { ((Behaviour)i).enabled = true; }); } IsStored = true; Plugin.Spam(((Object)((Component)this).gameObject).name + " has been equipped with the cart!"); } 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); } internal IEnumerator RestoreItem(PhysGrabCart cart) { Plugin.Spam($"{((Object)((Component)this).gameObject).name} position: {baseTransform.position}"); bool isPlayer = (Object)(object)playerRef != (Object)null; List<Collider> coll = ((Component)baseTransform).gameObject.GetComponentsInChildren<Collider>().ToList(); if (!isPlayer) { CollectionExtensions.Do<Collider>((IEnumerable<Collider>)coll, (Action<Collider>)delegate(Collider c) { c.enabled = false; }); } yield return null; if (isPlayer) { if (VoidController.VoidIsLocked) { Plugin.Log.LogMessage((object)("The void is locked! " + playerRef.playerName + " will not be returned to play area!!")); if (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(); } yield break; } if (!playerRef.isDisabled) { playerRef.tumble.TumbleSet(true, false); yield return null; photonTransformView.Teleport(cart.inCart.position + new Vector3(0f, 1f, 0f), cart.inCart.rotation); Plugin.Spam($"Teleporting player back to level {cart.inCart.position}"); IsStored = false; yield break; } baseTransform = ((Component)playerRef.playerDeathHead).transform; } baseTransform.localScale = OriginalScale * 0.1f; grabObj.isActive = true; IsStored = false; baseTransform.localScale = ((Component)this).transform.localScale; photonTransformView.Teleport(ClampToCartBounds(cart), baseTransform.rotation); float timer = 0f; while (timer < HostValues.StabilzeTimer.Value) { timer += Time.deltaTime; LerpItem(cart, timer); yield return null; } if (!isPlayer) { CollectionExtensions.Do<Collider>((IEnumerable<Collider>)coll, (Action<Collider>)delegate(Collider c) { c.enabled = true; }); } baseTransform.localScale = OriginalScale; if ((Object)(object)EnemyBody != (Object)null && EnemyBody.enemy.MasterClient) { ((Behaviour)EnemyBody).enabled = true; if (EnemyBody.enemy.HasNavMeshAgent && SemiFunc.IsMasterClientOrSingleplayer()) { Plugin.Spam("Enabling navmesh"); EnemyBody.enemy.NavMeshAgent.StopTimer = 0f; EnemyBody.frozen = false; EnemyBody.enemy.EnemyTeleported(baseTransform.position); } yield return null; Plugin.Spam("Returning enemy state"); EnemyBody.enemy.CurrentState = OriginalState; } ((Behaviour)grabObj.impactDetector).enabled = true; grabObj.rb.isKinematic = false; yield return (object)new WaitForSeconds(HostValues.SafetyTimer.Value); grabObj.impactDetector.isIndestructible = false; Plugin.Spam("RestoreItem complete!"); } } 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 = null; 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)); } } [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 { internal 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.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>(); } Plugin.Spam("RunManagerPUN.Start"); HostConfigCheck(); } internal static void HostConfigCheck() { if (!HostConfigBase.HostConfigInit && IsValidState() && !InvalidScene()) { HostValues.StartGame(); } } private static bool IsValidState() { if (GameManager.Multiplayer()) { return PhotonNetwork.MasterClient != null; } return true; } private static bool InvalidScene() { if (!SemiFunc.IsCurrentLevel(RunManager.instance.levelCurrent, RunManager.instance.levelMainMenu)) { return SemiFunc.IsCurrentLevel(RunManager.instance.levelCurrent, RunManager.instance.levelSplashScreen); } return true; } } [HarmonyPatch(typeof(StatsManager), "Start")] public class StatsManagerStart { public static void Postfix(StatsManager __instance) { PocketCartUpgradeItems.InitDictionary(); Plugin.Spam("Updating statsmanager with our save keys!"); __instance.dictionaryOfDictionaries.TryAdd("playerUpgradePocketcartKeepItems", PocketCartUpgradeItems.ClientsUpgradeDictionary); } } [HarmonyPatch(typeof(SemiFunc), "OnSceneSwitch")] public class LeaveToMainReset { public static void Postfix(bool _gameOver, bool _leaveGame) { if (_gameOver || _leaveGame) { PocketCartUpgradeItems.ResetProgress(); } Plugin.Spam("SemiFunc.OnSceneSwitch"); if (!SemiFunc.RunIsLobby() && !SemiFunc.RunIsLobbyMenu()) { NetworkingInstance.HostConfigCheck(); } if (HostConfigBase.HostConfigInit) { HostConfigBase.HostConfigInit = !_leaveGame; } } } [HarmonyPatch(typeof(ShopManager), "GetAllItemsFromStatsManager")] public class ModifyItemRarity { public static void Postfix(ShopManager __instance) { if (SemiFunc.IsMasterClientOrSingleplayer()) { Plugin.Log.LogDebug((object)"Value reference patches"); PocketCartUpgradeItems.ValueRef(); PocketCartUpgradeSize.ValueRef(); VoidController.ValueRef(); Plugin.Log.LogDebug((object)"Add-on rarity patches"); ShopPatch(HostValues.KeepItemsRarity.Value, "Item PocketCart Items", PocketCartUpgradeItems.valuePreset, ref __instance.potentialItemUpgrades); ShopPatch(HostValues.PlusCartRarity.Value, "Item PCartPlus", PocketCartUpgradeSize.valuePreset, ref __instance.potentialItems); ShopPatch(HostValues.VRRarity.Value, "Item VoidRemote", VoidController.valuePreset, ref __instance.potentialSecretItems); } } private static void ShopPatch(int config, string prefabName, Value valuePreset, ref List<Item> RefItemList) { bool flag = false; Item itemName = ((IEnumerable<Item>)RefItemList).FirstOrDefault((Func<Item, bool>)((Item i) => ((PrefabRef<GameObject>)(object)i.prefab).prefabName == prefabName)); if ((Object)(object)itemName == (Object)null) { Plugin.Spam("Item [" + prefabName + "] not found!"); return; } if (config >= Plugin.Rand.Next(0, 100)) { flag = true; } if (!flag) { int num = RefItemList.Count((Item i) => i.itemName == itemName.itemName); Plugin.Spam($"Add-on rarity has determined {itemName.itemName} should be removed from the store! Original contains {num} of this item"); RefItemList.RemoveAll((Item i) => i.itemName == itemName.itemName); if (num > 0 && RefItemList.Count > 0) { for (int num2 = 0; num2 < num; num2++) { RefItemList.Add(RefItemList[Plugin.Rand.Next(0, RefItemList.Count)]); Plugin.Spam("Replaced item with another random item of same type"); } } } Plugin.Spam($"Rarity determined Item [{prefabName}] can be added in the shop {flag}"); itemName.value = valuePreset; Plugin.Spam("Value preset set for Item [" + prefabName + "]"); } private static void ShopPatch(int config, string prefabName, Value valuePreset, ref Dictionary<itemSecretShopType, List<Item>> secretShopDict) { //IL_0017: 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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Item itemName = null; itemSecretShopType key = (itemSecretShopType)0; foreach (itemSecretShopType key2 in secretShopDict.Keys) { List<Item> source = secretShopDict[key2]; itemName = ((IEnumerable<Item>)source).FirstOrDefault((Func<Item, bool>)((Item x) => ((PrefabRef<GameObject>)(object)x.prefab).prefabName == prefabName)); if ((Object)(object)itemName != (Object)null) { key = key2; break; } } if ((Object)(object)itemName == (Object)null) { Plugin.Spam("Item [" + prefabName + "] not found in secret shop!"); return; } int num = Plugin.Rand.Next(0, 100); if (config >= num) { flag = true; } else { Plugin.Spam($"Config {config} is less than {num}"); } if (!flag) { int num2 = secretShopDict[key].Count((Item i) => i.itemName == itemName.itemName); Plugin.Spam($"Add-on rarity has determined {itemName.itemName} should be removed from the store! Original contains {num2} of this item"); secretShopDict[key].RemoveAll((Item i) => i.itemName == itemName.itemName); if (num2 > 0 && secretShopDict.Count > 0) { for (int num3 = 0; num3 < num2; num3++) { secretShopDict[key].Add(secretShopDict[key][Plugin.Rand.Next(0, secretShopDict.Count)]); Plugin.Spam("Replaced secret shop item with another random valid secret shop item"); } } } Plugin.Spam($"Rarity determined Item [{prefabName}] can be added in the secret shop {flag}"); itemName.value = valuePreset; Plugin.Spam("Value preset set for Item [" + prefabName + "]"); } } [HarmonyPatch(typeof(PhysGrabCart), "Start")] public class GetPocketCarts { internal static List<PhysGrabCart> AllSmallCarts = new List<PhysGrabCart>(); public static void Postfix(PhysGrabCart __instance) { if (((Object)((Component)__instance).gameObject).name.StartsWith("Item PCartPlus")) { __instance.isSmallCart = true; } if ((Object)(object)__instance.valueScreen == (Object)null) { __instance.valueScreen = ((Component)__instance).GetComponentInChildren<ValueScreen>(true); if ((Object)(object)__instance.valueScreen == (Object)null) { Plugin.Spam("PhysGrabCart on '" + ((Object)((Component)__instance).gameObject).name + "' has no ValueScreen!"); } } 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(PhysGrabCart), "ObjectsInCart")] public class FixObjectsInCartNRE { public static Exception? Finalizer(Exception __exception, PhysGrabCart __instance) { if (__exception != null && (Object)(object)__instance.valueScreen == (Object)null) { return null; } return __exception; } } [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 { internal static List<CartItem> AllCartItems = new List<CartItem>(); public static void Postfix(ItemEquippable __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)__instance)) { return; } PhysGrabCart val = ((IEnumerable<PhysGrabCart>)GetPocketCarts.AllSmallCarts).FirstOrDefault((Func<PhysGrabCart, bool>)((PhysGrabCart c) => (Object)(object)c.itemEquippable == (Object)(object)__instance)); if ((Object)(object)val == (Object)null) { return; } try { CatchMissedItems(val); } catch (Exception arg) { Plugin.ERROR($"CatchMissedItems failed: {arg}"); } if (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)3, new object[1] { PlayerAvatar.instance.steamID }); } else { component.HideCartItems(PlayerAvatar.instance.steamID); } Plugin.Spam("Pocket cart equip detected!\nHiding all cart items with cart!"); } 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) float elapsed = 0f; while (elapsed < duration) { float num = elapsed / duration; transform.localScale = Vector3.Lerp(originalScale, targetScale, num); elapsed += Time.deltaTime; yield return null; } transform.localScale = targetScale; Plugin.Spam($"All items size set to targetscale [ {targetScale} ] in transform!"); } private static void CatchMissedItems(PhysGrabCart cart) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0010: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) Vector3 val = cart.inCart.lossyScale / 2f; Collider[] array = Physics.OverlapBox(cart.inCart.position, val, cart.inCart.rotation); foreach (Collider val2 in array) { if (((Component)val2).gameObject.layer == LayerMask.NameToLayer("PhysGrabObject") && !((Component)val2).transform.IsChildOf(((Component)cart).transform)) { PhysGrabObject componentInParent = ((Component)val2).GetComponentInParent<PhysGrabObject>(); if ((Object)(object)componentInParent != (Object)null && !cart.itemsInCart.Contains(componentInParent)) { Plugin.Spam("Catching item outside of base cart detection box: " + ((Object)((Component)componentInParent).gameObject).name); cart.itemsInCart.Add(componentInParent); } } } } } [HarmonyPatch(typeof(ItemEquippable), "UpdateVisuals")] public class UpdateVisualsPatch { 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 if ((int)__instance.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)__instance)) { 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)__instance)); 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)3, Array.Empty<object>()); } else { component.ShowCartItems(); } } } internal static IEnumerator WaitToDisplay(CartManager cartManager) { if (cartManager.isShowingItems) { yield break; } cartManager.isShowingItems = true; PhysGrabCart cart = cartManager.MyCart; Plugin.Spam("Waiting to Display object group for cart!"); yield return null; while (((Component)cart).transform.localScale != Vector3.one) { yield return null; if (cartManager.isStoringItems) { Plugin.WARNING("Ending display early! Cart is equiping!"); cartManager.isShowingItems = false; yield break; } } 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)cart), (Action<CartItem>)delegate(CartItem x) { ((MonoBehaviour)cart).StartCoroutine(x.RestoreItem(cart)); }); yield return null; cartManager.isShowingItems = false; if (cartManager.storedBy == PlayerAvatar.instance.steamID) { CartManager.CartsStoringItems = Mathf.Clamp(CartManager.CartsStoringItems - 1, 0, 99); } } } 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } 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 " + info.Sender.NickName); } } photonView.RPC("HostSendAll", info.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(); } } [PunRPC] internal void ReceiveItemsUpgrade(int upgradeLevel) { if (!UpgradeManager.LocalItemsUpgrade) { UpgradeManager.LocalItemsUpgrade = true; } if (upgradeLevel != UpgradeManager.CartItemsUpgradeLevel) { UpgradeManager.CartItemsUpgradeLevel = upgradeLevel; } } } public class HintUI : SemiUI { public TextMeshProUGUI Text; internal static HintUI instance; public string messagePrev = "prev"; public float messageTimer; public Color textColor; internal Transform normalParent; internal bool grabHint; public override void Start() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) base.doNotDisable = new List<GameObject>(); ((SemiUI)this).Start(); Text = ((Component)this).GetComponent<TextMeshProUGUI>(); if ((Object)(object)Text == (Object)null) { Plugin.Log.LogError((object)"NULL HINTER TEXT!!"); return; } 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_0052: 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), 0.2f); 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 { 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) { HostConfigBase hostConfigBase = HostConfigBase.HostConfigItems.Find((HostConfigBase c) => c.Name == id); 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) { if (SemiFunc.IsMainMenu() || !sync) { Plugin.Spam("Setting value of " + Name); Value = configItem.Value; } else if (SemiFunc.IsMasterClientOrSingleplayer()) { Plugin.Spam("HOST: Setting value of " + Name); Value = configItem.Value; } else { Plugin.Spam("CLIENT: Awaiting value of " + Name + " from host!"); 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 && GameManager.Multiplayer()) { Plugin.WARNING("GlobalNetworking is null!"); } HostConfigBase.SyncIsReady(); HostConfigBase.HostConfigInit = true; } internal static void UpdateValue(ConfigEntryBase configItem) { if (PhotonNetwork.IsMasterClient) { Plugin.Spam("Host updated value for " + configItem.Definition.Key); HostConfigBase hostConfigBase = HostConfigBase.HostConfigItems.Find((HostConfigBase c) => c.Name == configItem.Definition.Key); if (hostConfigBase == null) { Plugin.Spam(configItem.Definition.Key + " is not a HostValue being watched"); return; } GlobalNetworking.Instance.HostSendIndividual(configItem.Definition.Key, configItem.BoxedValue); GlobalNetworking.Instance.photonView.RPC("HostSendIndividual", (RpcTarget)4, new object[2] { configItem.Definition.Key, configItem.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>())); } } [BepInDependency("REPOLib", "4.2.0")] [BepInPlugin("com.github.darmuh.PocketCartPlus", "PocketCartPlus", "0.5.6")] public class Plugin : BaseUnityPlugin { internal 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; public const string Id = "com.github.darmuh.PocketCartPlus"; public static string Name => "PocketCartPlus"; public static string Version => "0.5.6"; private void Awake() { instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)(Name + " is loading with version " + Version + "!")); Log.LogInfo((object)"This version of the mod has been compiled for REPO version 0.4.4 :)"); 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)(Name + " 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); } } private static IEnumerator BundleLoader(AssetBundle mybundle) { if (((Object)mybundle).name == "upgrade_cartitems") { Bundle = mybundle; yield return null; Spam("Asset bundle has been loaded"); BundleLoaded = true; } else if (((Object)mybundle).name == "pocketdimension") { PocketDimensionBundle = mybundle; PocketDimension = PocketDimensionBundle.LoadAsset<GameObject>("PocketDimension"); Spam("PocketDimension bundle loaded!"); } } 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 = null; 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}"); if (p.isLocal) { GlobalNetworking.Instance.ReceiveItemsUpgrade(value); } else { GlobalNetworking.Instance.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} ]"); GlobalNetworking.Instance.photonView.RPC("ReceiveItemsUpgrade", (RpcTarget)4, 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.TryAdd(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 static 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 && !UpgradeManager.LocalItemsUpgrade) { UpgradeManager.LocalItemsUpgrade = true; } if (!ClientsUpgradeDictionary.TryGetValue(val.steamID, out var value)) { Plugin.Spam("Unable to find [ " + val.steamID + " ] in ClientsUpgradeDictionary, creating new entry at level 1!"); ClientsUpgradeDictionary.Add(val.steamID, 1); } else { Plugin.Spam($"Found [{val.steamID}] in ClientsUpgradeDictionary, adding to current upgradeLevel - [{value}]"); ClientsUpgradeDictionary[val.steamID]++; } UpdateSave(); if (SemiFunc.IsMasterClientOrSingleplayer() && HostValues.ShareKeepUpgrade.Value) { Plugin.Spam("Sending upgrade status to all other clients!"); photonView.RPC("ReceiveUpgrade", (RpcTarget)4, 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}"); } } public class PocketCartUpgradeSize : MonoBehaviourPunCallbacks { 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)3, 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()); } private IEnumerator ReturnToSize() { while (((Component)this).transform.localScale != Vector3.one) { yield return null; } yield return EquipPatch.ChangeSize(0.2f, chosenVector3, ((Component)this).transform.localScale, ((Component)this).transform); Plugin.Spam($"Scale has been returned to chosen scale {chosenScale}"); } 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 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("playerUpgradePocketcartKeepItems")) { Plugin.WARNING("Unable to find upgrade for CartItemsUpgradeLevel! Returning 0!"); return result; } return StatsManager.instance.FetchPlayerUpgrades(PlayerAvatar.instance.steamID)["playerUpgradePocketcartKeepItems"]; } 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)4, 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}"); } } public class VoidRef : MonoBehaviour { public GameObject inCart; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }