Decompiled source of Micro gamer v0.23.0

plugins/EntertainmentPack/EntertainmentPack.dll

Decompiled 18 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Missions.Arena.NullWard;
using EntityStates.VoidCamp;
using HG;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using On.RoR2;
using On.RoR2.CharacterAI;
using On.RoR2.Orbs;
using On.RoR2.Projectile;
using On.RoR2.UI;
using R2API;
using R2API.Utils;
using Rewired;
using RoR2;
using RoR2.Artifacts;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Networking;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.Sprites;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EntertainmentPack")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.23.0.0")]
[assembly: AssemblyInformationalVersion("0.23.0")]
[assembly: AssemblyProduct("EntertainmentPack")]
[assembly: AssemblyTitle("EntertainmentPack")]
[assembly: AssemblyVersion("0.23.0.0")]
[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 EntertainmentPack
{
	public sealed class ArcadeActor : NetworkBehaviour
	{
		internal ActionPage MenuPage;

		internal int[] OfferIcons = Array.Empty<int>();

		internal int AttackWins;

		internal int BossCompleted;

		internal int BossWins;

		internal int StageFights;

		internal bool BossAttack;

		internal bool SupportChallenge;

		internal CharacterMaster? SupportMaster;

		private List<MonoBehaviour> menuObjects = new List<MonoBehaviour>();

		private List<CharacterMaster> menuPlayers = new List<CharacterMaster>();

		internal bool BrowserShopReady;

		private RouletteChestController? roulette;

		private float rouletteAt;

		private static readonly PropertyInfo? cycling = typeof(RouletteChestController).GetProperty("isCycling", BindingFlags.Instance | BindingFlags.NonPublic);

		internal CharacterBody Body;

		internal CharacterBody? Target;

		internal ArcadePhase Phase;

		internal uint Round;

		internal int Integrity;

		internal int MaxIntegrity;

		internal int Selected = -1;

		internal bool GameResolved;

		internal bool ClippyNotice;

		internal uint NoticeId;

		internal int NoticeGame = -1;

		internal int FiledGame = -1;

		internal int CommittedChoice = -1;

		internal float GameSpeed = 1f;

		internal float ResultAge;

		internal float ResolvedElapsed;

		private float resultAt;

		internal readonly int[] Tiles = new int[6];

		internal float Remaining = 2f;

		internal float Duration = 4.5f;

		internal bool Won;

		internal bool Eliminating;

		internal Vector3 Focus;

		internal string TargetName = "";

		internal bool Exploring;

		internal bool FastForward;

		internal StartMenuBoard? StartMenu;

		internal PaintBoard? Paint;

		internal PinballBoard? Pinball;

		private Vector3 moveInput;

		private float inputAt;

		private float interactAt;

		private NetworkInstanceId targetId;

		private KinematicCharacterMotor motor;

		private MatchBoard? board;

		internal MicrogameKind Kind;

		internal int GameSeed;

		internal TombBoard? Tomb;

		internal VexBoard? Vex;

		internal BlockBoard? Blocks;

		internal FallingBlock Falling = new FallingBlock();

		internal SkiBoard? Ski;

		internal PipeBoard? Pipes;

		internal RodentBoard? Rodent;

		internal MineBoard? Mines;

		internal ChipsBoard? Chips;

		internal GolfBoard? Golf;

		internal BlackjackBoard? Blackjack;

		internal bool IsAlly;

		internal bool GiftMenu;

		internal bool IsShop;

		internal bool DamageBlocked;

		internal int ShopKeeper;

		internal int ShopGain;

		internal int PaperClips;

		internal int HiddenCount;

		internal int HideCapacity;

		internal uint ShopUpgradeCost;

		internal uint ShopPayout;

		internal uint ShopRevision;

		internal uint ShopCost;

		internal string[] OfferLabels = Array.Empty<string>();

		internal bool[] OfferEnabled = Array.Empty<bool>();

		internal uint Money;

		internal uint LunarCoins;

		internal uint VoidCoins;

		private PurchaseInteraction[] shops = Array.Empty<PurchaseInteraction>();

		private List<ItemIndex> gifts = new List<ItemIndex>();

		private float gameInputAt;

		internal bool IsInteraction;

		internal bool CanInteract;

		internal bool IsProgress;

		internal string OfferContext = "";

		private MonoBehaviour? offer;

		private MicrogameDeck deck;

		private bool menuOpen;

		private float offerStatusAt;

		private float deadline;

		private float syncAt;

		private float heldUntil;

		private bool heldWin;

		internal AuthoredRound? CustomRound;

		internal uint Debit;

		internal uint Offshore;

		internal uint FinanceRevision;

		internal bool OffshoreReady;

		internal bool ShopFromBrowser;

		internal bool BankInitialized;

		internal bool BankPending;

		internal string BankStatus = "";

		internal int[] DroneStock = Array.Empty<int>();

		internal uint[] DronePrices = Array.Empty<uint>();

		internal bool Deployed;

		internal float DeployFacing;

		internal bool DeployGrounded;

		internal Vector3 DeployAim = Vector3.forward;

		internal Vector3 DeployVelocity;

		private CharacterController? walkerMotor;

		private DeployVisual? walkerShell;

		private bool walkerStats;

		private Vector3 spawnAnchor;

		private Vector3 lastWalkerGround;

		private readonly WalkerJump walkerJump = new WalkerJump();

		private Vector3 jumpBurst;

		private bool jumpQueued;

		private bool sprintInput;

		internal uint MarketRevision;

		internal uint MarketChestPrice;

		internal MarketListing[] MarketBuying = Array.Empty<MarketListing>();

		internal MarketListing[] MarketSelling = Array.Empty<MarketListing>();

		internal bool SupportAlive
		{
			get
			{
				if (Object.op_Implicit((Object)(object)SupportMaster) && Object.op_Implicit((Object)(object)SupportMaster.GetBody()) && Object.op_Implicit((Object)(object)SupportMaster.GetBody().healthComponent))
				{
					return SupportMaster.GetBody().healthComponent.alive;
				}
				return false;
			}
		}

		private bool ShopBankLocked
		{
			get
			{
				if (ShopFromBrowser)
				{
					return ArcadeBank.For(this).Pending != null;
				}
				return false;
			}
		}

		private uint ShopFunds
		{
			get
			{
				if (!ShopFromBrowser)
				{
					return Body.master.money;
				}
				return ArcadeBank.For(this).Debit;
			}
		}

		private void ResetEncounter()
		{
			Won = false;
			Selected = -1;
			IsInteraction = (IsAlly = (GiftMenu = (IsShop = (DamageBlocked = (IsProgress = (SupportChallenge = (BossAttack = (ShopFromBrowser = false))))))));
			BossCompleted = (BossWins = 0);
			offer = null;
			SupportMaster = null;
			shops = Array.Empty<PurchaseInteraction>();
			OfferLabels = Array.Empty<string>();
			OfferEnabled = Array.Empty<bool>();
			OfferIcons = Array.Empty<int>();
			heldWin = false;
			GameResolved = false;
			SetTarget(null);
		}

		private void OpenActionMenu()
		{
			ResetEncounter();
			if (Deployed)
			{
				ChangePhase(ArcadePhase.Deployed, float.PositiveInfinity);
			}
			else if (Exploring || menuOpen)
			{
				ChangePhase(ArcadePhase.Waiting, 0.3f);
			}
			else
			{
				ShowMenu(ActionPage.Main);
			}
		}

		private void ShowMenu(ActionPage page, bool refresh = false)
		{
			string text = MenuSignature();
			MenuPage = page;
			IsInteraction = false;
			GiftMenu = false;
			OfferIcons = Array.Empty<int>();
			AttackWins = ArcadeProgress.Attacks(this).Successes;
			StageFights = ArcadeProgress.StageFights(this);
			List<string> labels = new List<string>();
			List<bool> enabled = new List<bool>();
			TargetName = ((page == ActionPage.Main) ? "CHOOSE AN ACTION" : page.ToString().ToUpperInvariant());
			switch (page)
			{
			case ActionPage.Main:
				Add("ATTACK", Object.op_Implicit((Object)(object)FindTarget()));
				Add("SUPPORT", OtherPlayers().Count > 0);
				Add("INTERACT", HasInteractables());
				Add("E-SHOP\n" + AttackWins + " / 5", ShopAllowed() && ArcadeProgress.Attacks(this).ShopReady);
				Add("DEPLOY", CanDeploy());
				Add("BROWSE");
				break;
			case ActionPage.Attack:
				if (!Object.op_Implicit((Object)(object)FindTarget(bossOnly: true)))
				{
					if (refresh)
					{
						ShowMenu(ActionPage.Main);
					}
					else
					{
						BeginAttack(boss: false);
					}
					return;
				}
				Add("BOSS");
				Add("ENEMY", Object.op_Implicit((Object)(object)FindTarget(bossOnly: false, excludeBoss: true)));
				break;
			case ActionPage.Interact:
			{
				ActionPage[] array = new ActionPage[5]
				{
					ActionPage.Chest,
					ActionPage.Item,
					ActionPage.Teleport,
					ActionPage.Shrine,
					ActionPage.Drone
				};
				for (int i = 0; i < array.Length; i++)
				{
					ActionPage actionPage = array[i];
					Add((actionPage == ActionPage.Teleport && Object.op_Implicit((Object)(object)TeleporterInteraction.instance) && TeleporterInteraction.instance.isIdle) ? ("TELEPORT\n" + StageFights + " / 10 FIGHTS") : actionPage.ToString().ToUpperInvariant(), WorldInteraction.List(this, actionPage).Count > 0);
				}
				break;
			}
			case ActionPage.Players:
				menuPlayers = OtherPlayers();
				if (menuPlayers.Count == 0)
				{
					ShowMenu(ActionPage.Main);
					return;
				}
				foreach (CharacterMaster menuPlayer in menuPlayers)
				{
					CharacterBody body = menuPlayer.GetBody();
					PlayerCharacterMasterController component = ((Component)menuPlayer).GetComponent<PlayerCharacterMasterController>();
					Add(((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.networkUser)) ? component.networkUser.userName : (Object.op_Implicit((Object)(object)body) ? Util.GetBestBodyName(((Component)body).gameObject) : "Player")) + ((Object.op_Implicit((Object)(object)body) && body.healthComponent.alive) ? "" : " (DOWN)"));
				}
				break;
			default:
				menuObjects = WorldInteraction.List(this, page);
				if (menuObjects.Count == 0)
				{
					ShowMenu(ActionPage.Interact);
					return;
				}
				foreach (MonoBehaviour menuObject in menuObjects)
				{
					WorldInteraction.Describe(this, menuObject, out string title, out string context);
					Add(title + (string.IsNullOrEmpty(context) ? "" : ("\n" + context)), WorldInteraction.Available(this, menuObject));
				}
				break;
			}
			OfferLabels = labels.ToArray();
			OfferEnabled = enabled.ToArray();
			OfferContext = ((labels.Count == 0) ? "Nothing available." : "");
			if (!refresh || text != MenuSignature())
			{
				Round++;
				ChangePhase(ArcadePhase.Menu, float.PositiveInfinity);
			}
			void Add(string label, bool available = true)
			{
				labels.Add(label);
				enabled.Add(available);
			}
		}

		private bool ShopAllowed()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			SceneDef mostRecentSceneDef = SceneCatalog.mostRecentSceneDef;
			return ActionRules.ShopAreaAllowed(WorldInteraction.Area == CycleArea.Bazaar, Object.op_Implicit((Object)(object)mostRecentSceneDef) && (int)mostRecentSceneDef.sceneType == 1, WorldInteraction.Area == CycleArea.VoidFields, Object.op_Implicit((Object)(object)FindTarget()));
		}

		private void RefreshBrowser()
		{
			RefreshBank();
			RefreshMarket();
			AttackWins = ArcadeProgress.Attacks(this).Successes;
			BrowserShopReady = ShopAllowed() && ArcadeProgress.Attacks(this).ShopReady;
			((NetworkBehaviour)this).SetDirtyBit(1u);
		}

		private bool HasInteractables()
		{
			ActionPage[] array = new ActionPage[5]
			{
				ActionPage.Chest,
				ActionPage.Item,
				ActionPage.Teleport,
				ActionPage.Shrine,
				ActionPage.Drone
			};
			foreach (ActionPage category in array)
			{
				if (WorldInteraction.List(this, category).Count > 0)
				{
					return true;
				}
			}
			return false;
		}

		private string MenuSignature()
		{
			string text = MenuPage.ToString() + "|" + string.Join("|", OfferLabels) + "|" + string.Join("|", OfferEnabled);
			foreach (MonoBehaviour menuObject in menuObjects)
			{
				text = text + "|" + (Object.op_Implicit((Object)(object)menuObject) ? ((Object)menuObject).GetInstanceID() : 0);
			}
			foreach (CharacterMaster menuPlayer in menuPlayers)
			{
				text = text + "|" + (Object.op_Implicit((Object)(object)menuPlayer) ? ((Object)menuPlayer).GetInstanceID() : 0);
			}
			return text;
		}

		private void AcceptMenu(int tile)
		{
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			if (tile == -11)
			{
				ShowMenu(ActionPage.Main);
				return;
			}
			int num = -100 - tile;
			if (num < 0 || num >= OfferEnabled.Length || !OfferEnabled[num])
			{
				return;
			}
			if (MenuPage == ActionPage.Main)
			{
				if (num == 0)
				{
					ShowMenu(ActionPage.Attack);
				}
				if (num == 1)
				{
					ShowMenu(ActionPage.Players);
				}
				if (num == 2)
				{
					ShowMenu(ActionPage.Interact);
				}
				switch (num)
				{
				case 4:
					BeginDeploy();
					break;
				case 5:
					ResetEncounter();
					RefreshBrowser();
					Round++;
					ChangePhase(ArcadePhase.Browser, float.PositiveInfinity);
					break;
				case 3:
					if (ShopAllowed() && ArcadeProgress.Attacks(this).Visit())
					{
						ResetEncounter();
						BeginShop();
					}
					break;
				}
				return;
			}
			if (MenuPage == ActionPage.Attack)
			{
				BeginAttack(num == 0);
				return;
			}
			if (MenuPage == ActionPage.Interact)
			{
				ShowMenu((ActionPage)(4 + num));
				return;
			}
			if (MenuPage == ActionPage.Players)
			{
				if (num >= menuPlayers.Count || !Object.op_Implicit((Object)(object)menuPlayers[num]))
				{
					ShowMenu(MenuPage);
					return;
				}
				CharacterMaster val = menuPlayers[num];
				ResetEncounter();
				SupportMaster = val;
				Round++;
				IsInteraction = (IsAlly = true);
				SetTarget(val.GetBody());
				TargetName = ((OfferLabels.Length > num) ? OfferLabels[num] : "PLAYER");
				PlayerCharacterMasterController component = ((Component)val).GetComponent<PlayerCharacterMasterController>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.networkUser))
				{
					TargetName = component.networkUser.userName;
				}
				RefreshOffer();
				ChangePhase(ArcadePhase.Pan, 1.85f);
				return;
			}
			if (num >= menuObjects.Count || !WorldInteraction.Available(this, menuObjects[num]))
			{
				ShowMenu(MenuPage);
				return;
			}
			MonoBehaviour val2 = menuObjects[num];
			if (MenuPage == ActionPage.Chest)
			{
				Vector3 focus = ((Component)val2).transform.position + Vector3.up;
				if (!WorldInteraction.Use(this, val2))
				{
					ShowMenu(MenuPage);
					return;
				}
				if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)((Component)val2).GetComponent<RouletteChestController>()))
				{
					BeginRoulette(val2);
					return;
				}
				ResetEncounter();
				Focus = focus;
				Round++;
				ChangePhase(ArcadePhase.Interlude, 1.8f);
			}
			else
			{
				ResetEncounter();
				offer = val2;
				BeginWorldOffer();
			}
		}

		private void BeginAttack(bool boss)
		{
			CharacterBody val = FindTarget(boss, !boss);
			if (!Object.op_Implicit((Object)(object)val))
			{
				ShowMenu(ActionPage.Main);
				return;
			}
			ResetEncounter();
			BossAttack = boss;
			Round++;
			SetTarget(val);
			ChangePhase(ArcadePhase.Pan, 1.85f);
		}

		private void NextAfterResult()
		{
			if (BossAttack && BossCompleted < 3 && Eligible(Target))
			{
				Round++;
				PrepareGame();
			}
			else
			{
				NewEncounter();
			}
		}

		private List<CharacterMaster> OtherPlayers()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			List<CharacterMaster> list = new List<CharacterMaster>();
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				if (Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.master) && (Object)(object)instance.master != (Object)(object)Body.master && instance.master.teamIndex == Body.teamComponent.teamIndex)
				{
					list.Add(instance.master);
				}
			}
			return list;
		}

		private bool TeamWiped()
		{
			List<CharacterMaster> list = OtherPlayers();
			if (list.Count == 0)
			{
				return false;
			}
			foreach (CharacterMaster item in list)
			{
				if (!item.IsDeadAndOutOfLivesServer())
				{
					return false;
				}
			}
			return true;
		}

		private bool RebootSupport()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)SupportMaster) || SupportAlive || !SupportMaster.IsDeadAndOutOfLivesServer() || MaxIntegrity <= 1)
			{
				return false;
			}
			CharacterMaster? supportMaster = SupportMaster;
			if (!Object.op_Implicit((Object)(object)supportMaster.Respawn(supportMaster.deathFootPosition, Quaternion.identity, true)))
			{
				return false;
			}
			if (!ArcadeProgress.State(this).SpendMaximum())
			{
				return false;
			}
			MaxIntegrity = ArcadeProgress.State(this).Maximum;
			Integrity = Mathf.Min(Integrity, MaxIntegrity);
			return true;
		}

		private void WriteActions(NetworkWriter writer)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			WriteBank(writer);
			writer.Write(Deployed);
			writer.Write(DeployFacing);
			writer.Write(DeployGrounded);
			writer.Write(DeployAim);
			writer.Write(DeployVelocity);
			WriteMarket(writer);
			writer.Write(StageFights);
			writer.Write(BrowserShopReady);
			writer.Write((byte)MenuPage);
			writer.Write(AttackWins);
			writer.Write(BossAttack);
			writer.Write(BossCompleted);
			writer.Write(BossWins);
			writer.Write(SupportChallenge);
			writer.Write((ushort)OfferIcons.Length);
			int[] offerIcons = OfferIcons;
			foreach (int num in offerIcons)
			{
				writer.Write(num);
			}
		}

		private void ReadActions(NetworkReader reader)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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)
			ReadBank(reader);
			Deployed = reader.ReadBoolean();
			DeployFacing = reader.ReadSingle();
			DeployGrounded = reader.ReadBoolean();
			DeployAim = reader.ReadVector3();
			DeployVelocity = reader.ReadVector3();
			ReadMarket(reader);
			StageFights = reader.ReadInt32();
			BrowserShopReady = reader.ReadBoolean();
			MenuPage = (ActionPage)reader.ReadByte();
			AttackWins = reader.ReadInt32();
			BossAttack = reader.ReadBoolean();
			BossCompleted = reader.ReadInt32();
			BossWins = reader.ReadInt32();
			SupportChallenge = reader.ReadBoolean();
			OfferIcons = new int[reader.ReadUInt16()];
			for (int i = 0; i < OfferIcons.Length; i++)
			{
				OfferIcons[i] = reader.ReadInt32();
			}
		}

		private void BeginRoulette(MonoBehaviour candidate)
		{
			//IL_0040: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//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)
			ResetEncounter();
			roulette = ((Component)candidate).GetComponent<RouletteChestController>();
			offer = candidate;
			IsInteraction = true;
			Round++;
			TargetName = "ADAPTIVE CHEST";
			Focus = ((Component)candidate).transform.position + Vector3.up * 1.2f;
			rouletteAt = Time.fixedTime;
			ChangePhase(ArcadePhase.Roulette, float.PositiveInfinity);
		}

		private void TickRoulette()
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)roulette))
			{
				if (Time.fixedTime - rouletteAt > 1f)
				{
					object obj = cycling?.GetValue(roulette);
					if (obj is bool && !(bool)obj)
					{
						goto IL_0048;
					}
				}
				Focus = ((Component)roulette).transform.position + Vector3.up * 1.2f;
				return;
			}
			goto IL_0048;
			IL_0048:
			roulette = null;
			FinishOffer();
		}

		private void StopRoulette()
		{
			if (Object.op_Implicit((Object)(object)roulette))
			{
				object obj = cycling?.GetValue(roulette);
				if (obj is bool && (bool)obj)
				{
					roulette.HandleInteractionServer(((Component)this).GetComponent<Interactor>());
					roulette = null;
					FinishOffer();
				}
			}
		}

		private void OnDestroy()
		{
			DisposeWalkerMotor();
			if (Object.op_Implicit((Object)(object)Body) && Object.op_Implicit((Object)(object)Body.healthComponent) && !Body.healthComponent.alive)
			{
				ArcadeView.NotifyDeath(this);
			}
		}

		private void Awake()
		{
			Body = ((Component)this).GetComponent<CharacterBody>();
			motor = ((Component)this).GetComponent<KinematicCharacterMotor>();
		}

		private void Start()
		{
			//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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			CharacterMotor component = ((Component)this).GetComponent<CharacterMotor>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.velocity = Vector3.zero;
				((Behaviour)component).enabled = false;
			}
			if (Object.op_Implicit((Object)(object)motor))
			{
				((Behaviour)motor).enabled = false;
				KinematicCharacterSystem.CharacterMotors.Remove(motor);
			}
			CharacterNetworkTransform component2 = ((Component)this).GetComponent<CharacterNetworkTransform>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				((Behaviour)component2).enabled = false;
			}
			InteractionDriver component3 = ((Component)this).GetComponent<InteractionDriver>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				((Behaviour)component3).enabled = false;
			}
			EquipmentSlot component4 = ((Component)this).GetComponent<EquipmentSlot>();
			if (Object.op_Implicit((Object)(object)component4))
			{
				((Behaviour)component4).enabled = false;
			}
			((Component)this).GetComponent<InvisibleAvatar>().Hide();
			Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			HurtBox[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<HurtBox>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				((Behaviour)componentsInChildren2[i]).enabled = false;
			}
			spawnAnchor = ((Component)this).transform.position;
			Focus = ((Component)this).transform.position;
			if (Object.op_Implicit((Object)(object)Body.inventory))
			{
				ItemPolicy.Refresh(Body.inventory);
			}
			if (NetworkServer.active)
			{
				FastForward = ArcadeProgress.Fast(this);
				IntegrityProgress integrityProgress = ArcadeProgress.State(this);
				MaxIntegrity = integrityProgress.Maximum;
				Integrity = MaxIntegrity;
				SyncFiling(integrityProgress);
				ClippyNotice = integrityProgress.NoticeGame.HasValue;
				NoticeGame = integrityProgress.NoticeGame ?? (-1);
				NoticeId = integrityProgress.NoticeId;
				Duration = Plugin.GameSeconds;
				Body.healthComponent.godMode = true;
				if (!Body.HasBuff(Buffs.Cloak))
				{
					Body.AddBuff(Buffs.Cloak);
				}
				int tickCount = Environment.TickCount;
				NetworkInstanceId netId = ((NetworkBehaviour)this).netId;
				deck = new MicrogameDeck(tickCount ^ (int)((NetworkInstanceId)(ref netId)).Value);
				ChangePhase(ArcadePhase.Ready, 3f);
			}
		}

		internal bool Eligible(CharacterBody? body)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			//IL_0055: 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)
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.healthComponent) || !Object.op_Implicit((Object)(object)body.teamComponent) || (int)body.teamComponent.teamIndex == 0 || (int)body.teamComponent.teamIndex == -1)
			{
				return false;
			}
			return RoundRules.CanExecute(body.healthComponent.alive, TeamManager.IsTeamEnemy(Body.teamComponent.teamIndex, body.teamComponent.teamIndex), boss: false, inRange: true);
		}

		private CharacterBody? FindTarget(bool bossOnly = false, bool excludeBoss = false)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			CharacterBody result = null;
			int num = 0;
			int num2 = -1;
			bool activeSeed = WorldPresence.ActiveVoidSeed();
			foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
			{
				if (!Eligible(readOnlyInstances) || (bossOnly && !readOnlyInstances.isBoss && !readOnlyInstances.isChampion) || (excludeBoss && (readOnlyInstances.isBoss || readOnlyInstances.isChampion)))
				{
					continue;
				}
				int num3 = WorldRules.EnemyPriority(readOnlyInstances.isBoss || readOnlyInstances.isChampion, (int)readOnlyInstances.teamComponent.teamIndex == 4, activeSeed, readOnlyInstances.HasBuff(Buffs.EliteEarth), readOnlyInstances.isElite);
				if (num3 >= num2)
				{
					if (num3 > num2)
					{
						num2 = num3;
						num = 0;
					}
					if (Random.Range(0, ++num) == 0)
					{
						result = readOnlyInstances;
					}
				}
			}
			return result;
		}

		private void SetTarget(CharacterBody? target)
		{
			//IL_0018: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			Target = target;
			targetId = (Object.op_Implicit((Object)(object)target) ? ((NetworkBehaviour)target).netId : NetworkInstanceId.Invalid);
			if (Object.op_Implicit((Object)(object)target))
			{
				Focus = target.corePosition;
				TargetName = Util.GetBestBodyName(((Component)target).gameObject);
				if (!Deployed)
				{
					MoveWorld(Focus);
				}
			}
			((NetworkBehaviour)this).SetDirtyBit(1u);
		}

		private void ChangePhase(ArcadePhase phase, float duration)
		{
			Phase = phase;
			Remaining = duration * TransitionTiming.Scale(phase, FastForward);
			deadline = Time.fixedTime + Remaining;
			((NetworkBehaviour)this).SetDirtyBit(1u);
		}

		private void NewEncounter()
		{
			OpenActionMenu();
		}

		private void BeginShop()
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			if (!ShopAllowed())
			{
				OpenActionMenu();
				return;
			}
			ArcadeProgress.For(this).OfferedShop();
			Round++;
			IsInteraction = (IsShop = true);
			Random random = ArcadeProgress.For(this).Random;
			ShopKeeper = ShopRules.Keeper(random.NextDouble());
			if (ShopKeeper == 2)
			{
				RollCorruptStock();
			}
			else
			{
				ShopGain = 1;
				ShopUpgradeCost = ShopRules.UpgradePrice(RunDifficulty.LargeChestCost);
			}
			SetTarget(null);
			Focus = ((Component)this).transform.position;
			ArcadeProgress.For(this).SelectedTurn();
			RefreshOffer();
			ChangePhase(ArcadePhase.Pan, 1.85f);
		}

		private void RollCorruptStock()
		{
			Random random = ArcadeProgress.For(this).Random;
			ShopGain = ShopRules.CorruptGain(random.Next(3));
			ShopUpgradeCost = ShopRules.Scale(ShopRules.UpgradePrice(RunDifficulty.LargeChestCost), ShopRules.CorruptMultiplier(random.NextDouble()));
			ShopPayout = ShopRules.Scale(RunDifficulty.LargeChestCost, ShopRules.CorruptMultiplier(random.NextDouble()));
			ShopRevision++;
		}

		private void BeginWorldOffer()
		{
			//IL_006d: 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)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			Round++;
			ArcadeProgress.For(this).SelectedTurn();
			IsInteraction = true;
			SetTarget(null);
			IsProgress = offer is ProgressZoneOffer;
			Focus = ((offer is ProgressZoneOffer progressZoneOffer) ? ProgressZones.Center(progressZoneOffer.Source) : (((Component)offer).transform.position + Vector3.up));
			if (!IsProgress)
			{
				MoveWorld(Focus);
			}
			RefreshOffer();
			ChangePhase(ArcadePhase.Pan, 1.85f);
		}

		private void RefreshOffer()
		{
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			if (IsShop)
			{
				IntegrityProgress integrityProgress = ArcadeProgress.State(this);
				SyncFiling(integrityProgress);
				ShopCost = RunDifficulty.NormalChestCost;
				if (ShopKeeper == 0)
				{
					TargetName = "Clippy's Shop";
					OfferContext = "PAPER CLIPS  " + PaperClips + "     HIDDEN  " + HiddenCount + " / " + HideCapacity;
					OfferLabels = new string[1] { "1 PAPER CLIP\nCOST: 1 MAX INTEGRITY" };
					OfferEnabled = new bool[1] { integrityProgress.CanBuyPaperClip };
				}
				else if (ShopKeeper == 2)
				{
					TargetName = "Corrupted BonziBUDDY";
					OfferContext = "";
					OfferLabels = new string[2]
					{
						"MAX INTEGRITY +" + ShopGain + "\n$" + ShopUpgradeCost,
						"GAIN $" + ShopPayout + "\nLOSE 1 INTEGRITY" + ((Integrity == 1) ? " (LETHAL)" : "")
					};
					OfferEnabled = new bool[2]
					{
						Object.op_Implicit((Object)(object)Body.master) && ShopFunds >= ShopUpgradeCost && MaxIntegrity + ShopGain <= 10,
						Integrity > 0 && CanShopPayout(ShopPayout)
					};
				}
				else
				{
					TargetName = "BonziBUDDY's Shop";
					OfferContext = "Patch things up, or make room for one more mistake.";
					OfferLabels = new string[2]
					{
						"INTEGRITY HEAL\n$" + ShopCost,
						"INCREASE TOTAL +1\n$" + ShopUpgradeCost
					};
					OfferEnabled = new bool[2]
					{
						Object.op_Implicit((Object)(object)Body.master) && ShopFunds >= ShopCost && Integrity < MaxIntegrity,
						Object.op_Implicit((Object)(object)Body.master) && ShopFunds >= ShopUpgradeCost && MaxIntegrity < 10 && !integrityProgress.NormalUpgradeBought
					};
				}
				if (ShopBankLocked)
				{
					for (int i = 0; i < OfferEnabled.Length; i++)
					{
						OfferEnabled[i] = false;
					}
				}
				CanInteract = Array.Exists(OfferEnabled, (bool enabled) => enabled);
				((NetworkBehaviour)this).SetDirtyBit(1u);
			}
			else if (IsAlly)
			{
				CanInteract = Object.op_Implicit((Object)(object)SupportMaster) && (Object)(object)SupportMaster != (Object)(object)Body.master;
				OfferContext = ((!CanInteract) ? "Player is no longer available." : (GiftMenu ? "Choose one item to transfer one copy." : "Heal through a microgame, give an item, or reboot a fallen player."));
				if (GiftMenu)
				{
					OfferLabels = new string[gifts.Count];
					OfferEnabled = new bool[gifts.Count];
					for (int num = 0; num < gifts.Count; num++)
					{
						OfferLabels[num] = Language.GetString(ItemCatalog.GetItemDef(gifts[num]).nameToken) + " x" + Body.inventory.GetItemCountPermanent(gifts[num]);
						OfferEnabled[num] = CanInteract && SupportAlive && Body.inventory.GetItemCountPermanent(gifts[num]) > 0;
					}
				}
				else
				{
					OfferLabels = new string[3] { "FULL HEAL", "GIVE ITEM", "REBOOT\nCOST: 1 MAX INTEGRITY" };
					OfferEnabled = new bool[3]
					{
						SupportAlive,
						SupportAlive && PlayerSupport.GiftItems(this).Count > 0,
						CanInteract && !SupportAlive && MaxIntegrity > 1 && SupportMaster.IsDeadAndOutOfLivesServer()
					};
				}
				OfferIcons = (GiftMenu ? gifts.ConvertAll((ItemIndex item) => (int)item).ToArray() : Array.Empty<int>());
				((NetworkBehaviour)this).SetDirtyBit(1u);
			}
			else if (!Object.op_Implicit((Object)(object)offer))
			{
				CanInteract = false;
			}
			else
			{
				WorldInteraction.Describe(this, offer, out TargetName, out OfferContext);
				CanInteract = WorldInteraction.Available(this, offer);
				if (shops.Length == 0)
				{
					shops = WorldInteraction.ShopChoices(offer);
				}
				OfferLabels = new string[shops.Length];
				OfferEnabled = new bool[shops.Length];
				for (int num2 = 0; num2 < shops.Length; num2++)
				{
					OfferLabels[num2] = (Object.op_Implicit((Object)(object)shops[num2]) ? WorldInteraction.ShopLabel(this, shops[num2]) : "UNAVAILABLE");
					OfferEnabled[num2] = WorldInteraction.Available(this, (MonoBehaviour?)(object)shops[num2]);
				}
				if (shops.Length != 0)
				{
					TargetName = "Multi-shop";
					OfferContext = "Choose one terminal. Native prices and shop rules apply.";
				}
				((NetworkBehaviour)this).SetDirtyBit(1u);
			}
		}

		private void PrepareGame()
		{
			//IL_016d: 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)
			IntegrityProgress integrityProgress = ArcadeProgress.State(this);
			SyncFiling(integrityProgress);
			Kind = deck.NextHidden(integrityProgress.HiddenGames);
			float num = ((Kind == MicrogameKind.Tetris || Kind == MicrogameKind.Rodent || Kind == MicrogameKind.Minesweeper || Kind == MicrogameKind.SkiFree || Kind == MicrogameKind.Chips || Kind == MicrogameKind.Golf) ? Mathf.Max(7f, Plugin.GameSeconds) : Plugin.GameSeconds);
			bool flag = Kind == MicrogameKind.SkiFree || Kind == MicrogameKind.Tetris || Kind == MicrogameKind.Pinball;
			if (Kind == MicrogameKind.Pinball)
			{
				num = Mathf.Max(9f, Plugin.GameSeconds);
			}
			if (Kind == MicrogameKind.Paint)
			{
				num = Mathf.Max(7f, Plugin.GameSeconds);
			}
			int tier = RunDifficulty.Tier();
			GameSpeed = (flag ? DifficultyRules.SurvivalSpeed(RunDifficulty.Mode, tier) : 1f);
			AuthorGame authorGame = AuthoredCatalog.Game((int)Kind);
			if (authorGame != null)
			{
				num = authorGame.seconds;
				flag = authorGame.mode == "survive";
				GameSpeed = (flag ? DifficultyRules.SurvivalSpeed(RunDifficulty.Mode, tier) : 1f);
			}
			Duration = (flag ? num : DifficultyRules.PuzzleSeconds(num, RunDifficulty.Mode, tier));
			GameResolved = false;
			CommittedChoice = -1;
			ResultAge = 0f;
			uint num2 = Round * 1103515245;
			NetworkInstanceId netId = ((NetworkBehaviour)this).netId;
			GameSeed = (int)(num2 + ((NetworkInstanceId)(ref netId)).Value * 12345);
			CreateBoard();
			Selected = -1;
			ChangePhase(ArcadePhase.Prompt, 1.15f);
		}

		private void CreateBoard()
		{
			AuthorGame authorGame = AuthoredCatalog.Game((int)Kind);
			CustomRound = ((authorGame != null) ? new AuthoredRound(authorGame) : null);
			StartMenu = new StartMenuBoard(GameSeed);
			Paint = new PaintBoard(GameSeed);
			Pinball = new PinballBoard(GameSeed);
			Chips = new ChipsBoard(GameSeed);
			Golf = new GolfBoard(GameSeed);
			Blackjack = new BlackjackBoard(GameSeed);
			Falling = new FallingBlock();
			Ski = new SkiBoard(GameSeed);
			Pipes = new PipeBoard(GameSeed);
			Rodent = new RodentBoard(GameSeed);
			Mines = new MineBoard(GameSeed);
			board = new MatchBoard(GameSeed);
			Tomb = new TombBoard(GameSeed);
			Vex = new VexBoard(GameSeed);
			Blocks = new BlockBoard(GameSeed);
			Array.Copy(board.Tiles, Tiles, Tiles.Length);
		}

		internal void AcceptClick(uint round, int tile, uint notice = 0u, uint shopRevision = 0u, uint marketRevision = 0u)
		{
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || !Body.healthComponent.alive || Eliminating)
			{
				return;
			}
			if (tile == -41 && round == Round)
			{
				float num = TransitionTiming.Scale(Phase, FastForward);
				FastForward = !FastForward;
				ArcadeProgress.SetFast(this, FastForward);
				float num2 = Mathf.Max(0f, deadline - Time.fixedTime);
				deadline = Time.fixedTime + num2 * TransitionTiming.Scale(Phase, FastForward) / num;
				Remaining = deadline - Time.fixedTime;
				if (FastForward && GameResolved && Phase == ArcadePhase.Playing)
				{
					EndPreview();
				}
				((NetworkBehaviour)this).SetDirtyBit(1u);
			}
			else if ((tile == -30 || tile == -31) && ClippyNotice && notice == NoticeId)
			{
				if (tile == -30)
				{
					IntegrityProgress integrityProgress = ArcadeProgress.State(this);
					integrityProgress.File(NoticeGame);
					SyncFiling(integrityProgress);
				}
				ArcadeProgress.State(this).ClearNotice();
				ClippyNotice = false;
				((NetworkBehaviour)this).SetDirtyBit(1u);
			}
			else if (Phase == ArcadePhase.Roulette && round == Round)
			{
				if (tile == -42)
				{
					StopRoulette();
				}
			}
			else if (Phase == ArcadePhase.Browser && round == Round)
			{
				if (tile <= -1000)
				{
					AcceptMarket(tile, marketRevision);
					return;
				}
				switch (tile)
				{
				case -11:
					OpenActionMenu();
					break;
				case -50:
					if (ShopAllowed() && ArcadeProgress.Attacks(this).Visit())
					{
						ResetEncounter();
						ShopFromBrowser = true;
						RefreshBank();
						BeginShop();
					}
					break;
				}
			}
			else if (Phase == ArcadePhase.Menu && round == Round)
			{
				AcceptMenu(tile);
			}
			else if (Phase == ArcadePhase.Offer && round == Round && deadline > Time.fixedTime)
			{
				if (tile == -11)
				{
					FinishOffer();
				}
				else if (tile <= -100)
				{
					if (IsShop && ShopKeeper == 2 && shopRevision != ShopRevision)
					{
						return;
					}
					int num3 = -100 - tile;
					if (IsShop)
					{
						RefreshOffer();
						IntegrityProgress integrityProgress2 = ArcadeProgress.State(this);
						if (num3 < 0 || num3 >= OfferEnabled.Length || !OfferEnabled[num3])
						{
							return;
						}
						if (ShopKeeper == 0)
						{
							if (num3 == 0 && integrityProgress2.TradeForPaperClip())
							{
								Body.inventory.GiveItemPermanent(Plugin.PaperClip.itemIndex, 1);
								MaxIntegrity = integrityProgress2.Maximum;
								Integrity = Mathf.Min(Integrity, MaxIntegrity);
								SyncFiling(integrityProgress2);
								FinishOffer();
							}
							return;
						}
						if (ShopKeeper == 2)
						{
							if (num3 == 0 && integrityProgress2.IncreaseTotal(ShopGain))
							{
								PayShop(ShopUpgradeCost);
								MaxIntegrity = integrityProgress2.Maximum;
								Integrity = Mathf.Min(MaxIntegrity, Integrity + ShopGain);
								RollCorruptStock();
								RefreshOffer();
							}
							else if (num3 == 1)
							{
								ShopCredit(ShopPayout);
								Integrity = Mathf.Max(0, Integrity - 1);
								integrityProgress2.LoseIntegrity();
								if (Integrity <= 0)
								{
									FinishOffer();
									Eliminate();
								}
								else
								{
									RollCorruptStock();
									RefreshOffer();
								}
							}
							return;
						}
						switch (num3)
						{
						case 0:
							PayShop(ShopCost);
							Integrity = Mathf.Min(MaxIntegrity, Integrity + 1);
							FinishOffer();
							break;
						case 1:
							if (integrityProgress2.BuyNormalUpgrade())
							{
								PayShop(ShopUpgradeCost);
								MaxIntegrity = integrityProgress2.Maximum;
								Integrity = Mathf.Min(MaxIntegrity, Integrity + 1);
								FinishOffer();
							}
							break;
						}
					}
					else if (IsAlly)
					{
						if (!Object.op_Implicit((Object)(object)SupportMaster))
						{
							FinishOffer();
						}
						else if (GiftMenu)
						{
							if (num3 >= 0 && num3 < gifts.Count && PlayerSupport.Give(this, gifts[num3]))
							{
								FinishOffer();
							}
							else
							{
								RefreshOffer();
							}
						}
						else if (num3 == 0 && SupportAlive)
						{
							SupportChallenge = true;
							IsInteraction = false;
							Round++;
							PrepareGame();
						}
						else if (num3 == 1 && SupportAlive)
						{
							gifts = PlayerSupport.GiftItems(this);
							GiftMenu = true;
							Round++;
							RefreshOffer();
						}
						else if (num3 == 2 && RebootSupport())
						{
							FinishOffer();
						}
						else
						{
							RefreshOffer();
						}
					}
					else if (num3 >= 0 && num3 < shops.Length)
					{
						if (WorldInteraction.Use(this, (MonoBehaviour?)(object)shops[num3]))
						{
							FinishOffer();
						}
						else
						{
							RefreshOffer();
						}
					}
				}
				else if (tile == -10 && !IsAlly && !IsShop && shops.Length == 0)
				{
					if (WorldInteraction.Use(this, offer))
					{
						FinishOffer();
					}
					else
					{
						RefreshOffer();
					}
				}
			}
			else
			{
				if (GameResolved || board == null || !RoundRules.AcceptClick(Phase, Round, round, deadline - Time.fixedTime, Eliminating))
				{
					return;
				}
				if (CustomRound != null)
				{
					int num4 = CustomRound.Click(tile);
					((NetworkBehaviour)this).SetDirtyBit(1u);
					if (num4 != 0)
					{
						FinishGame(num4 > 0);
					}
					return;
				}
				CommittedChoice = tile;
				int num5;
				switch (Kind)
				{
				case MicrogameKind.StartMenu:
					num5 = StartMenu.Click(tile);
					break;
				case MicrogameKind.Paint:
					num5 = Paint.Click(tile);
					break;
				case MicrogameKind.Pinball:
					num5 = Pinball.Flippers(tile);
					break;
				case MicrogameKind.Chips:
					if (Time.fixedTime < gameInputAt)
					{
						return;
					}
					gameInputAt = Time.fixedTime + 0.075f;
					num5 = Chips.Move(tile);
					break;
				case MicrogameKind.Golf:
					num5 = Golf.Click(tile);
					break;
				case MicrogameKind.Blackjack:
					num5 = Blackjack.Click(tile);
					break;
				case MicrogameKind.Tut:
					num5 = Tomb.Click(tile);
					Selected = Tomb.Selected;
					break;
				case MicrogameKind.TetraVex:
					num5 = Vex.Click(tile);
					break;
				case MicrogameKind.Tetris:
					if (Time.fixedTime < gameInputAt)
					{
						return;
					}
					gameInputAt = Time.fixedTime + 0.055f;
					num5 = 0;
					switch (tile)
					{
					case 0:
						Falling.Move(Blocks, -1, 0);
						break;
					case 1:
						Falling.Move(Blocks, 1, 0);
						break;
					case 2:
						Falling.Move(Blocks, 0, -1);
						break;
					case 3:
						Falling.Move(Blocks, 0, 1);
						break;
					case 4:
						num5 = Falling.Step(Blocks, 0.07f, soft: true);
						break;
					case 5:
						num5 = Falling.Drop(Blocks);
						break;
					}
					break;
				case MicrogameKind.SkiFree:
					if (tile == 0 || tile == 1)
					{
						Ski.Move((tile != 0) ? 1 : (-1));
					}
					num5 = 0;
					break;
				case MicrogameKind.PipeDream:
					num5 = Pipes.Click(tile);
					break;
				case MicrogameKind.Rodent:
					num5 = Rodent.Move(tile);
					break;
				case MicrogameKind.Minesweeper:
					num5 = Mines.Click(tile);
					break;
				default:
					num5 = board.Click(tile);
					Selected = board.Selected;
					break;
				}
				((NetworkBehaviour)this).SetDirtyBit(1u);
				if (num5 != 0)
				{
					FinishGame(num5 > 0);
				}
			}
		}

		private void FinishOffer()
		{
			offer = null;
			IsInteraction = (IsAlly = (GiftMenu = (IsShop = (IsProgress = false))));
			OfferLabels = Array.Empty<string>();
			OfferEnabled = Array.Empty<bool>();
			SetTarget(null);
			ChangePhase(ArcadePhase.Interlude, 1.8f);
		}

		private void FinishGame(bool win)
		{
			if (!GameResolved)
			{
				Won = win;
				GameResolved = true;
				ResolvedElapsed = Duration - Remaining;
				resultAt = Time.fixedTime;
				ResultAge = 0f;
				((NetworkBehaviour)this).SetDirtyBit(1u);
				if (FastForward)
				{
					EndPreview();
				}
			}
		}

		private void EndPreview()
		{
			if (Won && !SupportChallenge && !BossAttack)
			{
				heldWin = true;
				heldUntil = Time.fixedTime + 5f;
			}
			Resolve();
		}

		private void Resolve()
		{
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: 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)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			if (BossAttack)
			{
				BossCompleted++;
				if (Won)
				{
					BossWins++;
				}
			}
			if (Won)
			{
				if (SupportChallenge)
				{
					PlayerSupport.Heal(this);
					ChangePhase(ArcadePhase.Won, 1.8f);
					return;
				}
				if (BossAttack && !ActionRules.BossDamage(BossCompleted, BossWins))
				{
					ChangePhase(ArcadePhase.Won, 1.8f);
					return;
				}
				if (!Eligible(Target))
				{
					if (BossAttack)
					{
						heldWin = false;
						ChangePhase(ArcadePhase.Won, 1.8f);
						return;
					}
					SetTarget(FindTarget(bossOnly: false, excludeBoss: true));
					if (!Object.op_Implicit((Object)(object)Target))
					{
						ChangePhase(ArcadePhase.Waiting, 0.3f);
						return;
					}
				}
				heldWin = false;
				HealthComponent healthComponent = Target.healthComponent;
				bool flag = Target.isBoss || Target.isChampion;
				bool critical = false;
				ItemPolicy.InCombat(this, Target.corePosition, delegate
				{
					critical = Util.CheckRoll(Body.crit, Body.master);
				});
				DamageInfo val = new DamageInfo
				{
					attacker = ((Component)Body).gameObject,
					inflictor = ((Component)Body).gameObject,
					damage = healthComponent.fullCombinedHealth * (flag ? 0.2f : 1.01f),
					procCoefficient = 1f,
					crit = critical,
					position = Target.corePosition,
					damageType = DamageTypeCombo.op_Implicit((DamageType)((!flag) ? 262146 : 0))
				};
				healthComponent.TakeDamage(val);
				if (Object.op_Implicit((Object)(object)GlobalEventManager.instance))
				{
					GlobalEventManager.instance.OnHitEnemy(val, ((Component)Target).gameObject);
					GlobalEventManager.instance.OnHitAll(val, ((Component)Target).gameObject);
				}
				ArcadeProgress.WonFight(this);
				ChangePhase(ArcadePhase.Won, 1.8f);
			}
			else
			{
				DamageBlocked = ItemPolicy.BlocksFailure(this);
				if (!DamageBlocked)
				{
					Integrity = Mathf.Max(0, Integrity - 1);
					ArcadeProgress.State(this).LoseIntegrity((int)Kind);
					NoticeGame = (int)Kind;
					NoticeId = ArcadeProgress.State(this).NoticeId;
					ClippyNotice = true;
				}
				ChangePhase(ArcadePhase.Lost, 1.95f);
			}
		}

		private void Eliminate()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			DisposeWalkerMotor();
			Eliminating = true;
			heldWin = false;
			ChangePhase(ArcadePhase.Eliminated, 0f);
			Body.healthComponent.godMode = false;
			Body.healthComponent.Suicide((GameObject)null, (GameObject)null, DamageTypeCombo.op_Implicit((DamageType)0));
		}

		private void FixedUpdate()
		{
			//IL_0087: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: 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_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)Body) || !Object.op_Implicit((Object)(object)Body.healthComponent) || !Body.healthComponent.alive)
			{
				return;
			}
			UpdateWalker();
			EquipmentSlot component = ((Component)this).GetComponent<EquipmentSlot>();
			if (Object.op_Implicit((Object)(object)component))
			{
				((Behaviour)component).enabled = Object.op_Implicit((Object)(object)Body.inventory) && Body.inventory.currentEquipmentIndex == Equipment.MultiShopCard.equipmentIndex;
			}
			if (!NetworkServer.active)
			{
				Target = ResolveBody(targetId);
				Remaining = Mathf.Max(0f, Remaining - Time.fixedDeltaTime);
				if (GameResolved)
				{
					ResultAge += Time.fixedDeltaTime;
				}
			}
			else
			{
				if (Eliminating || !Object.op_Implicit((Object)(object)Run.instance) || Run.instance.isGameOverServer)
				{
					return;
				}
				if (TeamWiped())
				{
					Eliminate();
					return;
				}
				TickBank();
				SyncCurrency();
				if (Phase == ArcadePhase.Deployed)
				{
					TickDeployed();
					return;
				}
				if (Phase == ArcadePhase.Roulette)
				{
					TickRoulette();
					return;
				}
				if (Time.fixedTime - inputAt < 0.3f && Exploring && Phase == ArcadePhase.Waiting)
				{
					Vector3 position = ((Component)this).transform.position + moveInput * 25f * Time.fixedDeltaTime;
					MoveWorld(position);
				}
				if (Phase == ArcadePhase.Browser && Time.fixedTime >= offerStatusAt)
				{
					offerStatusAt = Time.fixedTime + 0.5f;
					RefreshBrowser();
				}
				if (Phase == ArcadePhase.Menu && Time.fixedTime >= offerStatusAt)
				{
					offerStatusAt = Time.fixedTime + 0.5f;
					ShowMenu(MenuPage, refresh: true);
				}
				if (IsShop)
				{
					if (Time.fixedTime >= offerStatusAt)
					{
						offerStatusAt = Time.fixedTime + 0.3f;
						RefreshOffer();
					}
				}
				else if (IsAlly && (Phase == ArcadePhase.Pan || Phase == ArcadePhase.Offer))
				{
					if (!Object.op_Implicit((Object)(object)SupportMaster))
					{
						FinishOffer();
						return;
					}
					Target = SupportMaster.GetBody();
					if (Object.op_Implicit((Object)(object)Target))
					{
						Focus = Target.corePosition;
					}
					if (Time.fixedTime >= offerStatusAt)
					{
						offerStatusAt = Time.fixedTime + 0.3f;
						RefreshOffer();
					}
				}
				else if (IsInteraction && Object.op_Implicit((Object)(object)offer))
				{
					Focus = ((offer is ProgressZoneOffer progressZoneOffer) ? ProgressZones.Center(progressZoneOffer.Source) : (((Component)offer).transform.position + Vector3.up));
					if (Time.fixedTime >= offerStatusAt)
					{
						offerStatusAt = Time.fixedTime + 0.3f;
						RefreshOffer();
					}
				}
				else if (Object.op_Implicit((Object)(object)Target) && Target.healthComponent.alive)
				{
					Focus = Target.corePosition;
				}
				else if (Phase == ArcadePhase.Waiting || Phase == ArcadePhase.Ready)
				{
					Focus = ((Component)this).transform.position;
				}
				Remaining = Mathf.Max(0f, deadline - Time.fixedTime);
				if (Phase == ArcadePhase.Playing && !GameResolved)
				{
					int num = 0;
					if (CustomRound != null)
					{
						num = CustomRound.Step(Time.fixedDeltaTime, GameSpeed, Duration, (Time.fixedTime - inputAt < 0.3f) ? moveInput.x : 0f, (Time.fixedTime - inputAt < 0.3f) ? (0f - moveInput.z) : 0f);
					}
					if (Kind == MicrogameKind.Pinball)
					{
						num = Pinball.Step(Time.fixedDeltaTime, GameSpeed);
					}
					if (Kind == MicrogameKind.Tetris)
					{
						num = Falling.Step(Blocks, Time.fixedDeltaTime, soft: false, GameSpeed);
					}
					if (Kind == MicrogameKind.SkiFree)
					{
						num = Ski.Advance(DifficultyRules.SkiProgress(Duration - Remaining, Duration, GameSpeed));
					}
					if (num != 0)
					{
						FinishGame(num > 0);
					}
				}
				if (GameResolved && Phase == ArcadePhase.Playing)
				{
					if (Kind == MicrogameKind.Pinball)
					{
						Pinball.AdvancePreview(Time.fixedDeltaTime);
					}
					ResultAge = Time.fixedTime - resultAt;
					if (WorldRules.PreviewFinished(ResultAge, FastForward))
					{
						EndPreview();
					}
				}
				if (heldWin && Time.fixedTime >= heldUntil)
				{
					heldWin = (Won = false);
					NewEncounter();
				}
				else
				{
					if (!RoundRules.IsExpired(Time.fixedTime, deadline))
					{
						return;
					}
					switch (Phase)
					{
					case ArcadePhase.Ready:
						NewEncounter();
						break;
					case ArcadePhase.Waiting:
						if (heldWin)
						{
							SetTarget(FindTarget(bossOnly: false, excludeBoss: true));
							if (Object.op_Implicit((Object)(object)Target))
							{
								Resolve();
							}
							else
							{
								ChangePhase(ArcadePhase.Waiting, 0.3f);
							}
						}
						else
						{
							NewEncounter();
						}
						break;
					case ArcadePhase.Pan:
						if (IsInteraction)
						{
							if (!Object.op_Implicit((Object)(object)offer) && !IsAlly && !IsShop)
							{
								NewEncounter();
							}
							else
							{
								ChangePhase(ArcadePhase.Offer, Plugin.OfferSeconds);
							}
						}
						else if (!Eligible(Target))
						{
							NewEncounter();
						}
						else
						{
							PrepareGame();
						}
						break;
					case ArcadePhase.Prompt:
						if (SupportChallenge ? (!SupportAlive) : (!Eligible(Target)))
						{
							NewEncounter();
						}
						else
						{
							ChangePhase(ArcadePhase.Playing, Duration);
						}
						break;
					case ArcadePhase.Offer:
						FinishOffer();
						break;
					case ArcadePhase.Interlude:
						NewEncounter();
						break;
					case ArcadePhase.Playing:
						if (!GameResolved)
						{
							FinishGame(CustomRound?.Game.mode == "survive");
						}
						break;
					case ArcadePhase.Reveal:
						Resolve();
						break;
					case ArcadePhase.Won:
						NextAfterResult();
						break;
					case ArcadePhase.Lost:
						if (Integrity <= 0)
						{
							Eliminate();
						}
						else
						{
							NextAfterResult();
						}
						break;
					case ArcadePhase.Eliminated:
						break;
					}
				}
			}
		}

		private void SyncFiling(IntegrityProgress state)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Plugin.PaperClip) && Object.op_Implicit((Object)(object)Body.inventory))
			{
				state.SetPaperClips(Body.inventory.GetItemCountPermanent(Plugin.PaperClip.itemIndex));
			}
			FiledGame = state.FiledGame ?? (-1);
			PaperClips = state.PaperClips;
			HiddenCount = state.HiddenGames.Count;
			HideCapacity = state.HideCapacity;
		}

		private void SyncCurrency()
		{
			if (!(Time.fixedTime < syncAt))
			{
				SyncFiling(ArcadeProgress.State(this));
				Money = (Object.op_Implicit((Object)(object)Body.master) ? Body.master.money : 0u);
				NetworkUser val = PlayerSupport.User(Body);
				LunarCoins = (Object.op_Implicit((Object)(object)val) ? val.lunarCoins : 0u);
				VoidCoins = (Object.op_Implicit((Object)(object)Body.master) ? Body.master.voidCoins : 0u);
				syncAt = Time.fixedTime + 0.1f;
				((NetworkBehaviour)this).SetDirtyBit(1u);
			}
		}

		internal void AcceptControl(CursorControl input)
		{
			//IL_0023: 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_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: 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)
			if (!NetworkServer.active || !Body.healthComponent.alive || Eliminating || !Finite(input.Move) || !Finite(input.Origin) || !Finite(input.Direction))
			{
				return;
			}
			menuOpen = input.MenuOpen;
			if (Phase == ArcadePhase.Playing && CustomRound != null)
			{
				moveInput = (input.MenuOpen ? Vector3.zero : Vector3.ClampMagnitude(input.Move, 1f));
				inputAt = Time.fixedTime;
				return;
			}
			if (Deployed)
			{
				AcceptDeployed(input);
				return;
			}
			if (input.ToggleExplore)
			{
				Exploring = !Exploring;
			}
			moveInput = Vector3.ClampMagnitude(input.Move, 1f);
			inputAt = Time.fixedTime;
			if (input.Click && Exploring && Phase == ArcadePhase.Waiting && Time.fixedTime >= interactAt)
			{
				Vector3 val = input.Origin - ((Component)this).transform.position;
				if (((Vector3)(ref val)).sqrMagnitude < 10000f && ((Vector3)(ref input.Direction)).sqrMagnitude > 0.9f && ((Vector3)(ref input.Direction)).sqrMagnitude < 1.1f)
				{
					interactAt = Time.fixedTime + 0.3f;
					WorldInteraction.Click(this, new Ray(input.Origin, ((Vector3)(ref input.Direction)).normalized));
				}
			}
			((NetworkBehaviour)this).SetDirtyBit(1u);
		}

		internal void MoveWorld(Vector3 position)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)motor))
			{
				motor.SetPosition(position, true);
			}
			else
			{
				((Component)this).transform.position = position;
			}
		}

		private static bool Finite(Vector3 value)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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)
			if (!float.IsNaN(value.x) && !float.IsNaN(value.y) && !float.IsNaN(value.z) && !float.IsInfinity(value.x) && !float.IsInfinity(value.y))
			{
				return !float.IsInfinity(value.z);
			}
			return false;
		}

		private static CharacterBody? ResolveBody(NetworkInstanceId id)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Util.FindNetworkObject(id);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return null;
			}
			return val.GetComponent<CharacterBody>();
		}

		public override bool OnSerialize(NetworkWriter writer, bool initialState)
		{
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			writer.Write(CustomRound?.Mask ?? 0);
			writer.Write(CustomRound?.X ?? 0f);
			writer.Write(CustomRound?.Y ?? 0f);
			WriteActions(writer);
			writer.Write(FastForward);
			writer.Write(IsProgress);
			writer.Write(StartMenu?.Open ?? false);
			writer.Write(StartMenu?.Chosen ?? (-1));
			writer.Write(Paint?.Bucket ?? false);
			writer.Write(Paint?.Selected ?? (-1));
			writer.Write(Paint?.Fill ?? (-1));
			writer.Write(Pinball?.X ?? 0.5f);
			writer.Write(Pinball?.Y ?? 0.86f);
			writer.Write(Pinball?.Outcome ?? 0);
			writer.Write(Pinball?.Left ?? 0f);
			writer.Write(Pinball?.Right ?? 0f);
			writer.Write((byte)Phase);
			writer.Write(Round);
			writer.Write(targetId);
			writer.Write(IsShop);
			writer.Write(ShopKeeper);
			writer.Write(ShopRevision);
			writer.Write(ShopCost);
			writer.Write(PaperClips);
			writer.Write(HiddenCount);
			writer.Write(HideCapacity);
			writer.Write(DamageBlocked);
			writer.Write(IsAlly);
			writer.Write(GiftMenu);
			writer.Write(Money);
			writer.Write(LunarCoins);
			writer.Write(VoidCoins);
			writer.Write((ushort)OfferLabels.Length);
			for (int i = 0; i < OfferLabels.Length; i++)
			{
				writer.Write(OfferLabels[i]);
				writer.Write(OfferEnabled[i]);
			}
			writer.Write(Falling.Column);
			writer.Write(Falling.Rotation);
			writer.Write(Falling.Row);
			writer.Write(Ski?.Lane ?? 1);
			writer.Write(Ski?.Passed ?? 0);
			writer.Write(Rodent?.X ?? 0);
			writer.Write(Rodent?.Y ?? 0);
			writer.Write(Rodent?.BoxX ?? 0);
			writer.Write(Rodent?.BoxY ?? 0);
			writer.Write(Chips?.X ?? 0);
			writer.Write(Chips?.Y ?? 0);
			writer.Write(Chips?.Facing ?? 2);
			writer.Write(Chips?.HasKey ?? false);
			writer.Write(Chips?.DoorOpen ?? false);
			writer.Write(Golf?.TopCard ?? 0);
			writer.Write(Golf?.Mask ?? 0);
			writer.Write(Golf?.Cleared ?? 0);
			writer.Write((byte)Kind);
			writer.Write(GameSeed);
			writer.Write(IsInteraction);
			writer.Write(CanInteract);
			writer.Write(OfferContext);
			writer.Write(MaxIntegrity);
			writer.Write(GameResolved);
			writer.Write(GameSpeed);
			writer.Write(ResultAge);
			writer.Write(ResolvedElapsed);
			writer.Write(CommittedChoice);
			writer.Write(ClippyNotice);
			writer.Write(NoticeId);
			writer.Write(NoticeGame);
			writer.Write(FiledGame);
			writer.Write(Integrity);
			writer.Write(Selected);
			writer.Write(Remaining);
			writer.Write(Duration);
			writer.Write(Won);
			writer.Write(Exploring);
			writer.Write(((Component)this).transform.position);
			writer.Write(Focus);
			writer.Write(TargetName);
			for (int j = 0; j < Tiles.Length; j++)
			{
				writer.Write((byte)Tiles[j]);
			}
			return true;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_052c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0531: Unknown result type (might be due to invalid IL or missing references)
			//IL_0556: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			uint round = Round;
			int gameSeed = GameSeed;
			MicrogameKind kind = Kind;
			ulong mask = reader.ReadUInt64();
			float x = reader.ReadSingle();
			float y = reader.ReadSingle();
			ReadActions(reader);
			FastForward = reader.ReadBoolean();
			IsProgress = reader.ReadBoolean();
			bool open = reader.ReadBoolean();
			int chosen = reader.ReadInt32();
			bool bucket = reader.ReadBoolean();
			int selected = reader.ReadInt32();
			int fill = reader.ReadInt32();
			float x2 = reader.ReadSingle();
			float y2 = reader.ReadSingle();
			int outcome = reader.ReadInt32();
			float left = reader.ReadSingle();
			float right = reader.ReadSingle();
			Phase = (ArcadePhase)reader.ReadByte();
			Round = reader.ReadUInt32();
			targetId = reader.ReadNetworkId();
			IsShop = reader.ReadBoolean();
			ShopKeeper = reader.ReadInt32();
			ShopRevision = reader.ReadUInt32();
			ShopCost = reader.ReadUInt32();
			PaperClips = reader.ReadInt32();
			HiddenCount = reader.ReadInt32();
			HideCapacity = reader.ReadInt32();
			DamageBlocked = reader.ReadBoolean();
			IsAlly = reader.ReadBoolean();
			GiftMenu = reader.ReadBoolean();
			Money = reader.ReadUInt32();
			LunarCoins = reader.ReadUInt32();
			VoidCoins = reader.ReadUInt32();
			int num = reader.ReadUInt16();
			OfferLabels = new string[num];
			OfferEnabled = new bool[num];
			for (int i = 0; i < num; i++)
			{
				OfferLabels[i] = reader.ReadString();
				OfferEnabled[i] = reader.ReadBoolean();
			}
			int column = reader.ReadInt32();
			int rotation = reader.ReadInt32();
			int row = reader.ReadInt32();
			int lane = reader.ReadInt32();
			int passed = reader.ReadInt32();
			int x3 = reader.ReadInt32();
			int y3 = reader.ReadInt32();
			int boxX = reader.ReadInt32();
			int boxY = reader.ReadInt32();
			int x4 = reader.ReadInt32();
			int y4 = reader.ReadInt32();
			int facing = reader.ReadInt32();
			bool hasKey = reader.ReadBoolean();
			bool doorOpen = reader.ReadBoolean();
			int num2 = reader.ReadInt32();
			int mask2 = reader.ReadInt32();
			int cleared = reader.ReadInt32();
			Kind = (MicrogameKind)reader.ReadByte();
			GameSeed = reader.ReadInt32();
			IsInteraction = reader.ReadBoolean();
			CanInteract = reader.ReadBoolean();
			OfferContext = reader.ReadString();
			if (initialState || round != Round || gameSeed != GameSeed || kind != Kind)
			{
				CreateBoard();
			}
			if (CustomRound != null)
			{
				CustomRound.Mask = mask;
				CustomRound.X = x;
				CustomRound.Y = y;
			}
			if (StartMenu != null)
			{
				StartMenu.Open = open;
				StartMenu.Chosen = chosen;
			}
			if (Paint != null)
			{
				Paint.Bucket = bucket;
				Paint.Selected = selected;
				Paint.Fill = fill;
			}
			if (Pinball != null)
			{
				Pinball.X = x2;
				Pinball.Y = y2;
				Pinball.Outcome = outcome;
				Pinball.Left = left;
				Pinball.Right = right;
			}
			if (Chips != null)
			{
				Chips.X = x4;
				Chips.Y = y4;
				Chips.Facing = facing;
				Chips.HasKey = hasKey;
				Chips.DoorOpen = doorOpen;
			}
			if (Golf != null)
			{
				Golf.TopCard = num2;
				Golf.Top = GolfBoard.Rank(num2);
				Golf.Mask = mask2;
				Golf.Cleared = cleared;
			}
			Falling.Column = column;
			Falling.Rotation = rotation;
			Falling.Row = row;
			if (Ski != null)
			{
				Ski.Lane = lane;
				Ski.Passed = passed;
			}
			if (Rodent != null)
			{
				Rodent.X = x3;
				Rodent.Y = y3;
				Rodent.BoxX = boxX;
				Rodent.BoxY = boxY;
			}
			MaxIntegrity = reader.ReadInt32();
			GameResolved = reader.ReadBoolean();
			GameSpeed = reader.ReadSingle();
			ResultAge = reader.ReadSingle();
			ResolvedElapsed = reader.ReadSingle();
			CommittedChoice = reader.ReadInt32();
			ClippyNotice = reader.ReadBoolean();
			NoticeId = reader.ReadUInt32();
			NoticeGame = reader.ReadInt32();
			FiledGame = reader.ReadInt32();
			Integrity = reader.ReadInt32();
			Selected = reader.ReadInt32();
			Remaining = reader.ReadSingle();
			Duration = reader.ReadSingle();
			Won = reader.ReadBoolean();
			Exploring = reader.ReadBoolean();
			Vector3 val = reader.ReadVector3();
			if (Object.op_Implicit((Object)(object)motor))
			{
				motor.SetPosition(val, true);
			}
			else
			{
				((Component)this).transform.position = val;
			}
			Focus = reader.ReadVector3();
			TargetName = reader.ReadString();
			for (int j = 0; j < Tiles.Length; j++)
			{
				Tiles[j] = reader.ReadByte();
			}
		}

		private void RefreshBank()
		{
			ArcadeBank arcadeBank = ArcadeBank.For(this);
			Debit = arcadeBank.Debit;
			Offshore = arcadeBank.Offshore;
			FinanceRevision = arcadeBank.Revision;
			OffshoreReady = arcadeBank.OffshoreReady;
			BankInitialized = arcadeBank.Initialized;
			BankPending = arcadeBank.Pending != null;
			BankStatus = arcadeBank.Error;
			DroneStock = arcadeBank.Drones;
			DronePrices = new uint[DroneStock.Length];
			for (int i = 0; i < DroneStock.Length; i++)
			{
				DronePrices[i] = DroneStore.Price(DroneStock[i]);
			}
		}

		private void PayShop(uint amount)
		{
			if (ShopFromBrowser)
			{
				ArcadeBank arcadeBank = ArcadeBank.For(this);
				arcadeBank.Debit -= amount;
				arcadeBank.Revision++;
				RefreshBank();
			}
			else
			{
				CharacterMaster master = Body.master;
				master.money -= amount;
			}
		}

		private bool CanShopPayout(uint amount)
		{
			return amount <= (uint)(-1 - (int)ShopFunds);
		}

		private void ShopCredit(uint amount)
		{
			if (ShopFromBrowser)
			{
				ArcadeBank arcadeBank = ArcadeBank.For(this);
				arcadeBank.Debit += amount;
				arcadeBank.Revision++;
				RefreshBank();
			}
			else
			{
				CharacterMaster master = Body.master;
				master.money += amount;
			}
		}

		internal void AcceptFinance(uint round, uint revision, byte operation, uint amount)
		{
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Body) || !Object.op_Implicit((Object)(object)Body.master) || !Body.healthComponent.alive || Eliminating || Phase != ArcadePhase.Browser || Round != round)
			{
				return;
			}
			ArcadeBank arcadeBank = ArcadeBank.For(this);
			if (arcadeBank.Pending != null || revision != arcadeBank.Revision)
			{
				RefreshBank();
				((NetworkBehaviour)this).SetDirtyBit(1u);
				return;
			}
			if (operation <= 4)
			{
				arcadeBank.Transfer(this, (BankTransfer)operation, amount);
			}
			else
			{
				if (operation < 10 || operation >= 14)
				{
					return;
				}
				int num = operation - 10;
				if (num >= arcadeBank.Drones.Length)
				{
					return;
				}
				int index = arcadeBank.Drones[num];
				uint num2 = DroneStore.Price(index);
				if (arcadeBank.Debit < num2)
				{
					arcadeBank.Error = "INSUFFICIENT DEBIT FUNDS";
					RefreshBank();
					((NetworkBehaviour)this).SetDirtyBit(1u);
					return;
				}
				try
				{
					if (!DroneStore.Deliver(this, index))
					{
						arcadeBank.Error = "DRONE DELIVERY UNAVAILABLE";
					}
					else
					{
						arcadeBank.Debit -= num2;
						arcadeBank.Revision++;
						arcadeBank.Error = "DRONE DELIVERED";
					}
				}
				catch (Exception ex)
				{
					arcadeBank.Error = "DRONE DELIVERY UNAVAILABLE";
					Debug.LogError((object)("MICRO-GAMER drones: " + ex.Message));
				}
			}
			arcadeBank.Tick(this);
			Money = Body.master.money;
			RefreshBank();
			((NetworkBehaviour)this).SetDirtyBit(1u);
		}

		private void TickBank()
		{
			ArcadeBank arcadeBank = ArcadeBank.For(this);
			arcadeBank.Tick(this);
			if (FinanceRevision != arcadeBank.Revision)
			{
				RefreshBank();
				((NetworkBehaviour)this).SetDirtyBit(1u);
			}
		}

		internal void AcceptBankSync(FinanceMessage input)
		{
			if (!NetworkServer.active || !Object.op_Implicit((Object)(object)Body) || !Object.op_Implicit((Object)(object)Body.master))
			{
				return;
			}
			ArcadeBank arcadeBank = ArcadeBank.For(this);
			if (input.Operation == 200 && !arcadeBank.Initialized)
			{
				arcadeBank.Initialized = true;
				arcadeBank.OffshoreReady = input.Success;
				arcadeBank.Offshore = (input.Success ? input.Amount : 0u);
				arcadeBank.Generation = input.Generation;
				arcadeBank.Revision++;
				if (!input.Success)
				{
					arcadeBank.Error = "OFF-SHORE SAVE UNAVAILABLE";
				}
			}
			else if (input.Operation == 202 || input.Operation == 203)
			{
				arcadeBank.Acknowledge(this, input);
			}
			RefreshBank();
			Money = Body.master.money;
			((NetworkBehaviour)this).SetDirtyBit(1u);
		}

		private void WriteBank(NetworkWriter writer)
		{
			writer.Write(Debit);
			writer.Write(Offshore);
			writer.Write(FinanceRevision);
			writer.Write(OffshoreReady);
			writer.Write(BankInitialized);
			writer.Write(BankPending);
			writer.Write(BankStatus);
			writer.Write(ShopFromBrowser);
			writer.Write((byte)DroneStock.Length);
			for (int i = 0; i < DroneStock.Length; i++)
			{
				writer.Write(DroneStock[i]);
				writer.Write(DronePrices[i]);
			}
		}

		private void ReadBank(NetworkReader reader)
		{
			Debit = reader.ReadUInt32();
			Offshore = reader.ReadUInt32();
			FinanceRevision = reader.ReadUInt32();
			OffshoreReady = reader.ReadBoolean();
			BankInitialized = reader.ReadBoolean();
			BankPending = reader.ReadBoolean();
			BankStatus = reader.ReadString();
			ShopFromBrowser = reader.ReadBoolean();
			int num = reader.ReadByte();
			DroneStock = new int[num];
			DronePrices = new uint[num];
			for (int i = 0; i < num; i++)
			{
				DroneStock[i] = reader.ReadInt32();
				DronePrices[i] = reader.ReadUInt32();
			}
		}

		private bool FindDeployGround(out Vector3 point)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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)
			//IL_0070: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[2]
			{
				((Component)this).transform.position,
				spawnAnchor
			};
			RaycastHit val = default(RaycastHit);
			for (int i = 0; i < array.Length; i++)
			{
				if (Physics.Raycast(array[i] + Vector3.up * 5f, Vector3.down, ref val, 1000f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1))
				{
					point = ((RaycastHit)(ref val)).point + Vector3.up * 1.1f;
					return true;
				}
			}
			point = ((Component)this).transform.position;
			return false;
		}

		private bool CanDeploy()
		{
			Vector3 point;
			if (Object.op_Implicit((Object)(object)Plugin.DeployModel))
			{
				return FindDeployGround(out point);
			}
			return false;
		}

		private void BeginDeploy()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			if (!CanDeploy() || !FindDeployGround(out var point))
			{
				ShowMenu(ActionPage.Main);
				return;
			}
			ResetEncounter();
			Exploring = false;
			DeployFacing = ((Component)this).transform.eulerAngles.y;
			Deployed = true;
			Round++;
			GameObject val = new GameObject("MICRO-GAMER Walking Motor");
			val.layer = LayerIndex.defaultLayer.intVal;
			val.transform.position = point;
			walkerMotor = val.AddComponent<CharacterController>();
			walkerMotor.height = 2f;
			walkerMotor.radius = 0.5f;
			walkerMotor.center = Vector3.zero;
			walkerMotor.stepOffset = 0.35f;
			walkerMotor.slopeLimit = 55f;
			walkerMotor.skinWidth = 0.05f;
			lastWalkerGround = point;
			walkerJump.Reset();
			jumpBurst = Vector3.zero;
			moveInput = Vector3.zero;
			jumpQueued = false;
			MoveWorld(point);
			UpdateWalker();
			Focus = point;
			ChangePhase(ArcadePhase.Deployed, float.PositiveInfinity);
		}

		private void RecallWalker()
		{
			Deployed = false;
			DisposeWalkerMotor();
			UpdateWalker();
			Round++;
			OpenActionMenu();
		}

		private void DisposeWalkerMotor()
		{
			if (Object.op_Implicit((Object)(object)walkerMotor))
			{
				Object.Destroy((Object)(object)((Component)walkerMotor).gameObject);
			}
			walkerMotor = null;
			if (Object.op_Implicit((Object)(object)walkerShell))
			{
				Object.Destroy((Object)(object)((Component)walkerShell).gameObject);
			}
			walkerShell = null;
		}

		private void UpdateWalker()
		{
			if (walkerStats != Deployed)
			{
				walkerStats = Deployed;
				Body.baseMoveSpeed = (Deployed ? Plugin.DeployMoveSpeed : 0f);
				Body.baseJumpPower = (Deployed ? Plugin.DeployJumpPower : 0f);
				if (!Deployed)
				{
					Body.isSprinting = false;
				}
				ItemPolicy.RefreshMovement(Body);
				Body.RecalculateStats();
				Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].enabled = false;
				}
				HurtBox[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<HurtBox>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					((Behaviour)componentsInChildren2[i]).enabled = false;
				}
			}
			if (Deployed && !Object.op_Implicit((Object)(object)walkerShell) && Object.op_Implicit((Object)(object)Plugin.DeployModel))
			{
				walkerShell = DeployVisual.Create(this, Plugin.DeployModel);
			}
			if (Object.op_Implicit((Object)(object)walkerShell))
			{
				((Component)walkerShell).gameObject.SetActive(Deployed);
			}
		}

		private void AcceptDeployed(CursorControl input)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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)
			//IL_002e: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: 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_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			if (Phase != ArcadePhase.Deployed)
			{
				return;
			}
			if (input.Recall)
			{
				RecallWalker();
				return;
			}
			if (input.MenuOpen)
			{
				moveInput = Vector3.zero;
				DeployVelocity = Vector3.zero;
				return;
			}
			moveInput = Vector3.ClampMagnitude(new Vector3(input.Move.x, 0f, input.Move.z), 1f);
			inputAt = Time.fixedTime;
			jumpQueued |= input.Jump;
			sprintInput = input.Sprint;
			if (((Vector3)(ref input.Direction)).sqrMagnitude > 0.9f && ((Vector3)(ref input.Direction)).sqrMagnitude < 1.1f)
			{
				DeployAim = ((Vector3)(ref input.Direction)).normalized;
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(DeployAim.x, 0f, DeployAim.z);
				if (((Vector3)(ref val)).sqrMagnitude > 0.0001f)
				{
					Quaternion val2 = Quaternion.LookRotation(val);
					DeployFacing = ((Quaternion)(ref val2)).eulerAngles.y;
				}
			}
			Vector3 val3;
			if (input.Interact && Time.fixedTime >= interactAt)
			{
				val3 = input.Origin - ((Component)this).transform.position;
				if (((Vector3)(ref val3)).sqrMagnitude <= 1225f && ((Vector3)(ref input.Direction)).sqrMagnitude > 0.9f && ((Vector3)(ref input.Direction)).sqrMagnitude < 1.1f)
				{
					interactAt = Time.fixedTime + 0.25f;
					WorldInteraction.Use(this, WorldInteraction.Nearby(this, new Ray(input.Origin, input.Direction)));
					return;
				}
			}
			if (!input.Attack || Time.fixedTime < interactAt)
			{
				return;
			}
			val3 = input.Origin - ((Component)this).transform.position;
			if (((Vector3)(ref val3)).sqrMagnitude > 1225f || ((Vector3)(ref input.Direction)).sqrMagnitude < 0.9f || ((Vector3)(ref input.Direction)).sqrMagnitude > 1.1f)
			{
				return;
			}
			interactAt = Time.fixedTime + 0.25f;
			MonoBehaviour val4 = WorldInteraction.Aimed(this, new Ray(input.Origin, input.Direction));
			if (Object.op_Implicit((Object)(object)val4))
			{
				WorldInteraction.Use(this, val4);
				return;
			}
			RaycastHit val5 = default(RaycastHit);
			float num = (Physics.Raycast(input.Origin, input.Direction, ref val5, 300f, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask), (QueryTriggerInteraction)1) ? ((RaycastHit)(ref val5)).distance : 300f);
			RaycastHit[] array = Physics.SphereCastAll(new Ray(input.Origin, input.Direction), 0.4f, num, LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.entityPrecise)).mask), (QueryTriggerInteraction)2);
			Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
			RaycastHit[] array2 = array;
			for (int num2 = 0; num2 < array2.Length; num2++)
			{
				RaycastHit val6 = array2[num2];
				HurtBox component = ((Component)((RaycastHit)(ref val6)).collider).GetComponent<HurtBox>();
				CharacterBody val7 = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.healthComponent)) ? component.healthComponent.body : ((Component)((RaycastHit)(ref val6)).collider).GetComponentInParent<CharacterBody>());
				if (Eligible(val7))
				{
					ResetEncounter();
					BossAttack = val7.isBoss || val7.isChampion;
					Round++;
					SetTarget(val7);
					ChangePhase(ArcadePhase.Pan, 1.85f);
					break;
				}
			}
		}

		private void TickDeployed()
		{
			//IL_001d: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)walkerMotor))
			{
				RecallWalker();
				return;
			}
			if (menuOpen)
			{
				DeployVelocity = Vector3.zero;
				((NetworkBehaviour)this).SetDirtyBit(1u);
				return;
			}
			if (Time.fixedTime - inputAt > 0.3f)
			{
				moveInput = Vector3.zero;
				sprintInput = false;
				jumpQueued = false;
			}
			Body.isSprinting = sprintInput && ((Vector3)(ref moveInput)).sqrMagnitude > 0.01f;
			bool flag = (DeployGrounded = walkerMotor.isGrounded);
			if (flag && walkerJump.Velocity <= 0f)
			{
				lastWalkerGround = ((Component)walkerMotor).transform.position;
				jumpBurst = Vector3.zero;
			}
			if (walkerJump.Step(Time.fixedDeltaTime, flag, jumpQueued, Body.maxJumpCount, Body.jumpPower, Physics.gravity.y) && flag && Body.isSprinting)
			{
				int itemCountEffective = Body.inventory.GetItemCountEffective(Items.JumpBoost);
				jumpBurst = moveInput * (float)(10 * itemCountEffective);
			}
			jumpQueued = false;
			Vector3 position = ((Component)walkerMotor).transform.position;
			walkerMotor.Move((moveInput * Mathf.Max(0f, Body.moveSpeed) + jumpBurst + Vector3.up * walkerJump.Velocity) * Time.fixedDeltaTime);
			if (((Component)walkerMotor).transform.position.y < lastWalkerGround.y - 150f)
			{
				((Collider)walkerMotor).enabled = false;
				((Component)walkerMotor).transform.position = lastWalkerGround;
				((Collider)walkerMotor).enabled = true;
				walkerJump.Reset();
				jumpBurst = Vector3.zero;
			}
			DeployVelocity = (((Component)walkerMotor).transform.position - position) / Time.fixedDeltaTime;
			MoveWorld(((Component)walkerMotor).transform.position);
			Focus = ((Component)this).transform.position;
			((NetworkBehaviour)this).SetDirtyBit(1u);
		}

		private void RefreshMarket()
		{
			ArcadeMarket arcadeMarket = ArcadeMarket.For(this);
			MarketRevision = arcadeMarket.Revision;
			MarketChestPrice = arcadeMarket.ChestPrice;
			MarketBuying = arcadeMarket.Buying;
			MarketSelling = arcadeMarket.Selling;
		}

		private void AcceptMarket(int tile, uint revision)
		{
			//IL_00b6: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || Phase != ArcadePhase.Browser || !Object.op_Implicit((Object)(object)Body.inventory) || !Object.op_Implicit((Object)(object)Body.master))
			{
				return;
			}
			ArcadeMarket arcadeMarket = ArcadeMarket.For(this);
			if (revision != arcadeMarket.Revision)
			{
				return;
			}
			bool flag = tile <= -1000 && tile > -1020;
			bool flag2 = tile <= -1100 && tile > -1105;
			if (!flag && !flag2)
			{
				return;
			}
			int num = (flag ? (-1000 - tile) : (-1100 - tile));
			MarketListing[] array = (flag ? arcadeMarket.Buying : arcadeMarket.Selling);
			if (num < 0 || num >= array.Length)
			{
				return;
			}
			MarketListing marketListing = array[num];
			ItemIndex val = (ItemIndex)marketListing.Item;
			if (!Object.op_Implicit((Object)(object)ItemCatalog.GetItemDef(val)))
			{
				return;
			}
			int itemCountPermanent = Body.inventory.GetItemCountPermanent(val);
			ArcadeBank arcadeBank = ArcadeBank.For(this);
			if (arcadeBank.Pending == null && marketListing.TryTrade(flag, arcadeBank.Debit, itemCountPermanent, out var balance))
			{
				arcadeBank.Debit = balance;
				arcadeBank.Revision++;
				if (flag)
				{
					Body.inventory.RemoveItemPermanent(val, 1);
				}
				else
				{
					Body.inventory.GiveItemPermanent(val, 1);
				}
				RefreshBank();
				RefreshMarket();
				((NetworkBehaviour)this).SetDirtyBit(1u);
			}
		}

		private void WriteMarket(NetworkWriter writer)
		{
			writer.Write(MarketRevision);
			writer.Write(MarketChestPrice);
			Listings(MarketBuying);
			Listings(MarketSelling);
			void Listings(MarketListing[] rows)
			{
				writer.Write((byte)rows.Length);
				foreach (MarketListing marketListing in rows)
				{
					writer.Write(marketListing.Item);
					writer.Write((byte)marketListing.Rarity);
					writer.Write(marketListing.Price);
					writer.Write(marketListing.Completed);
				}
			}
		}

		private void ReadMarket(NetworkReader reader)
		{
			MarketRevision = reader.ReadUInt32();
			MarketChestPrice = reader.ReadUInt32();
			MarketBuying = Listings();
			MarketSelling = Listings();
			MarketListing[] Listings()
			{
				MarketListing[] array = new MarketListing[reader.ReadByte()];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = new MarketListing(reader.ReadInt32(), (MarketRarity)reader.ReadByte(), reader.ReadUInt32(), reader.ReadBoolean());
				}
				return array;
			}
		}
	}
	public enum ActionPage
	{
		Main,
		Attack,
		Interact,
		Players,
		Chest,
		Item,
		Teleport,
		Shrine,
		Drone
	}
	public sealed class AttackProgress
	{
		public int Successes { get; private set; }

		public bool ShopReady => Successes >= 5;

		public void Succeed()
		{
			Successes = Math.Min(5, Successes + 1);
		}

		public bool Visit()
		{
			if (!ShopReady)
			{
				return false;
			}
			Successes = 0;
			return true;
		}
	}
	public static class ActionRules
	{
		public static int ChoiceRows(int options, int columns)
		{
			return Math.Max(1, (Math.Min(6, Math.Max(0, options)) + columns - 1) / columns);
		}

		public static float ChoiceHeight(int options, int columns, float header, float rowHeight, bool footer)
		{
			return header + (float)ChoiceRows(options, columns) * rowHeight + (float)(footer ? 40 : 0) + 10f;
		}

		public static float ChoiceTop(float height)
		{
			return 530f - height;
		}

		public static string DisplayName(string name)
		{
			if (!string.Equals(name, "Barrel1", StringComparison.OrdinalIgnoreCase))
			{
				return name;
			}
			return "Barrel";
		}

		public static bool ShopAreaAllowed(bool bazaar, bool normalStage, bool voidFields, bool enemyPresent)
		{
			if (!bazaar)
			{
				return normalStage || voidFields || enemyPresent;
			}
			return false;
		}

		public static ActionPage Category(bool portal, bool pickup, bool drone, bool itemReward)
		{
			if (!portal)
			{
				if (!pickup)
				{
					if (!drone)
					{
						if (!itemReward)
						{
							return ActionPage.Shrine;
						}
						return ActionPage.Chest;
					}
					return ActionPage.Drone;
				}
				return ActionPage.Item;
			}
			return ActionPage.Teleport;
		}

		public static bool DroneName(string name)
		{
			name = name.ToLowerInvariant();
			if (!name.Contains("drone") && !name.Contains("turret") && !name.Contains("sentry"))
			{
				return name.Contains("tc280");
			}
			return true;
		}

		public static bool ItemRewardName(string name)
		{
			name = name.ToLowerInvariant();
			string[] array = new string[11]
			{
				"chest", "shrinechance", "shrinecleanse", "shrinedread", "halcyoniteshrine", "cleansingpool", "duplicator", "scrapper", "lockbox", "cauldron",
				"lunarshopterminal"
			};
			foreach (string value in array)
			{
				if (name.Contains(value))
				{
					return true;
				}
			}
			return false;
		}

		public static int ChestRank(string name)
		{
			name = name.ToLowerInvariant();
			if (name.Contains("goldbarrel") || name == "barrel1" || name.StartsWith("barrel1(") || name.Contains("money"))
			{
				return 0;
			}
			if (name.Contains("chest1") || name.Contains("normalchest") || name == "chest")
			{
				return 1;
			}
			if (name.Contains("multishop") || name.Contains("triple"))
			{
				return 2;
			}
			if (name.Contains("chest2") || name.Contains("largechest"))
			{
				return 3;
			}
			return 4;
		}

		public static int ItemRank(string tier, bool equipment, bool temporary, bool ethereal)
		{
			tier = tier.ToLowerInvariant();
			int num = ((!tier.Contains("boss")) ? (tier.Contains("tier3") ? 1 : (tier.Contains("tier2") ? 2 : (tier.Contains("tier1") ? 3 : (equipment ? 4 : 5)))) : 0);
			return (ethereal ? 200 : (temporary ? 100 : 0)) + num;
		}

		public static bool BossDamage(int completed, int wins)
		{
			if (completed == 3)
			{
				return wins == 3;
			}
			return false;
		}
	}
	public sealed class FightProgress
	{
		public const int Required = 10;

		public int Successes { get; private set; }

		public bool Ready => Successes >= 10;

		public void Succeed()
		{
			Successes = Math.Min(10, Successes + 1);
		}

		public void Reset()
		{
			Successes = 0;
		}
	}
	internal static class ArcadeNetwork
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static NetworkMessageDelegate <0>__Receive;

			public static NetworkMessageDelegate <1>__ReceiveControl;

			public static NetworkMessageDelegate <2>__ReceiveFinance;

			public static NetworkMessageDelegate <3>__ReceiveBankSave;
		}

		private const short ClickMessageId = 29123;

		private const short ControlMessageId = 29124;

		private const short FinanceMessageId = 29125;

		private static bool registered;

		private static NetworkClient? financeClient;

		internal static void Tick