Decompiled source of REPO Multiplayer Plus v1.1.11

plugins/REPOMultiplayerPlus.dll

Decompiled 41 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using Photon.Voice.Unity;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: AssemblyTitle("REPO Multiplayer Plus")]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyCompany("WAURESY")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("1.1.11.0")]
namespace Wauresy.MultiplayerPlus;

[HarmonyPatch(typeof(MenuPageEsc), "Start")]
internal static class AdminInstall
{
	private static void Postfix(MenuPageEsc __instance)
	{
		if (Session.Host)
		{
			((Component)__instance).gameObject.AddComponent<AdminScreen>().Init(__instance);
		}
	}
}
public sealed class AdminScreen : MonoBehaviour
{
	private enum Page
	{
		Home,
		Cosmetics,
		Spawn,
		Gift,
		Status,
		Players,
		Detail,
		Bans,
		Confirm
	}

	private const float PanelWidth = 440f;

	private const float RowWidth = 400f;

	private Page page;

	private string action;

	private string targetId;

	private int target;

	private GameObject entry;

	private GameObject overlay;

	private GameObject content;

	private TMP_FontAsset font;

	private float y;

	private float nextRefresh;

	private string lastSignature;

	private int banPage;

	private static readonly FieldInfo Disabled = AccessTools.Field(typeof(PlayerAvatar), "isDisabled");

	private static readonly FieldInfo HP = AccessTools.Field(typeof(PlayerHealth), "health");

	private static readonly FieldInfo MaxHP = AccessTools.Field(typeof(PlayerHealth), "maxHealth");

	private static readonly FieldInfo PageActive = AccessTools.Field(typeof(MenuPage), "pageActive");

	private MenuPage esc;

	private TextMeshProUGUI statusLabel;

	private string lastButton;

	private GameObject stage;

	private MenuButton template;

	private readonly List<GameObject> hidden = new List<GameObject>();

	public void Init(MenuPageEsc menu)
	{
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Expected O, but got Unknown
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Expected O, but got Unknown
		esc = ((Component)menu).GetComponent<MenuPage>();
		TextMeshProUGUI componentInChildren = ((Component)menu.customizeButton).GetComponentInChildren<TextMeshProUGUI>(true);
		if (!Object.op_Implicit((Object)(object)componentInChildren))
		{
			return;
		}
		font = ((TMP_Text)componentInChildren).font;
		MenuButton[] componentsInChildren = ((Component)menu).GetComponentsInChildren<MenuButton>(true);
		template = ((IEnumerable<MenuButton>)componentsInChildren).FirstOrDefault((Func<MenuButton, bool>)((MenuButton b) => Calls(b, "ButtonEventSettings"))) ?? ((IEnumerable<MenuButton>)componentsInChildren).FirstOrDefault((Func<MenuButton, bool>)((MenuButton b) => ((Object)b).name.IndexOf("Settings", StringComparison.OrdinalIgnoreCase) >= 0)) ?? menu.customizeButton;
		RectTransform main = (RectTransform)AccessTools.Field(typeof(MenuPageEsc), "mainMenuRectTransform").GetValue(menu);
		if (Object.op_Implicit((Object)(object)main))
		{
			stage = new GameObject("Admin button staging", new Type[1] { typeof(RectTransform) });
			stage.SetActive(false);
			stage.transform.SetParent(((Component)esc).transform, false);
			entry = NativeButton(((Transform)main).parent, "ADMIN", Open, enabled: true, delegate(GameObject clone)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Expected O, but got Unknown
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				RectTransform val = (RectTransform)clone.transform;
				val.anchorMin = main.anchorMin;
				val.anchorMax = main.anchorMax;
				val.pivot = main.pivot;
				val.anchoredPosition3D = main.anchoredPosition3D + Vector3.down * 32f;
				((Transform)val).SetSiblingIndex(((Transform)main).GetSiblingIndex() + 1);
			});
		}
	}

	private static bool Calls(MenuButton item, string method)
	{
		Button component = ((Component)item).GetComponent<Button>();
		if (!Object.op_Implicit((Object)(object)component))
		{
			return false;
		}
		for (int i = 0; i < ((UnityEventBase)component.onClick).GetPersistentEventCount(); i++)
		{
			if (((UnityEventBase)component.onClick).GetPersistentMethodName(i) == method)
			{
				return true;
			}
		}
		return false;
	}

	private GameObject NativeButton(Transform parent, string title, Action click, bool enabled, Action<GameObject> place)
	{
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Expected O, but got Unknown
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Expected O, but got Unknown
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Expected O, but got Unknown
		GameObject clone = Object.Instantiate<GameObject>(((Component)template).gameObject, stage.transform, false);
		clone.SetActive(false);
		((Object)clone).name = title;
		clone.transform.SetParent(parent, false);
		MenuButton component = clone.GetComponent<MenuButton>();
		component.buttonTextString = title;
		component.holdLogic = false;
		component.hasHold = false;
		component.doButtonEffect = false;
		MenuButtonPopUp component2 = clone.GetComponent<MenuButtonPopUp>();
		if (Object.op_Implicit((Object)(object)component2))
		{
			AccessTools.Field(typeof(MenuButtonPopUp), "disabled").SetValue(component2, true);
		}
		MonoBehaviour[] componentsInChildren = clone.GetComponentsInChildren<MonoBehaviour>(true);
		foreach (MonoBehaviour val in componentsInChildren)
		{
			if (Object.op_Implicit((Object)(object)val) && ((object)val).GetType().Name.IndexOf("Localiz", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				((Behaviour)val).enabled = false;
			}
		}
		TextMeshProUGUI componentInChildren = clone.GetComponentInChildren<TextMeshProUGUI>(true);
		((TMP_Text)componentInChildren).text = title;
		((TMP_Text)componentInChildren).richText = false;
		Button component3 = clone.GetComponent<Button>();
		component3.onClick = new ButtonClickedEvent();
		int clickedFrame = -1;
		((UnityEvent)component3.onClick).AddListener((UnityAction)delegate
		{
			if (Session.Host && enabled && clone.activeInHierarchy && clickedFrame != Time.frameCount)
			{
				clickedFrame = Time.frameCount;
				click();
			}
		});
		AccessTools.Field(typeof(MenuButton), "disabled").SetValue(component, !enabled);
		((Selectable)component3).interactable = enabled;
		RectTransform rectTransformSelection = component.rectTransformSelection;
		if (!Object.op_Implicit((Object)(object)rectTransformSelection) || !Object.op_Implicit((Object)(object)((Component)rectTransformSelection).GetComponent<MenuSelectableElement>()))
		{
			rectTransformSelection = (RectTransform)new GameObject("Selection", new Type[1] { typeof(RectTransform) }).transform;
			((Transform)rectTransformSelection).SetParent(clone.transform, false);
			Stretch(rectTransformSelection);
			((Component)rectTransformSelection).gameObject.AddComponent<MenuSelectableElement>();
			component.rectTransformSelection = rectTransformSelection;
		}
		place(clone);
		clone.SetActive(true);
		return clone;
	}

	private void Forget(GameObject subtree)
	{
		List<MenuSelectableElement> list = (List<MenuSelectableElement>)AccessTools.Field(typeof(MenuPage), "selectableElements").GetValue(esc);
		list.RemoveAll((MenuSelectableElement e) => !Object.op_Implicit((Object)(object)e) || ((Component)e).transform.IsChildOf(subtree.transform));
	}

	private static RectTransform Rect(GameObject obj, Transform parent, Vector2 anchor, Vector2 pos, float w, float h)
	{
		//IL_0012: 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_0014: 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_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: 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)
		RectTransform component = obj.GetComponent<RectTransform>();
		((Transform)component).SetParent(parent, false);
		Vector2 val = (component.pivot = anchor);
		Vector2 anchorMin = (component.anchorMax = val);
		component.anchorMin = anchorMin;
		component.anchoredPosition = pos;
		component.sizeDelta = new Vector2(w, h);
		return component;
	}

	private TextMeshProUGUI TextAt(Transform parent, string s, Vector2 anchor, Vector2 pos, float w, float h, int size)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		//IL_002f: 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)
		GameObject val = new GameObject("Label", new Type[2]
		{
			typeof(RectTransform),
			typeof(TextMeshProUGUI)
		});
		Rect(val, parent, anchor, pos, w, h);
		TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
		((TMP_Text)component).font = font;
		((TMP_Text)component).fontSize = size;
		((TMP_Text)component).text = s;
		((TMP_Text)component).richText = false;
		((Graphic)component).raycastTarget = false;
		((TMP_Text)component).alignment = (TextAlignmentOptions)514;
		((TMP_Text)component).overflowMode = (TextOverflowModes)1;
		return component;
	}

	private static void Stretch(RectTransform rect)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: 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_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		rect.anchorMin = Vector2.zero;
		rect.anchorMax = Vector2.one;
		Vector2 offsetMin = (rect.offsetMax = Vector2.zero);
		rect.offsetMin = offsetMin;
	}

	private GameObject ButtonAt(string title, float height, Action callback, bool enabled, string id)
	{
		return NativeButton(content.transform, title, callback, enabled, delegate(GameObject g)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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)
			//IL_0052: 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_005f: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			if (id != null)
			{
				((Object)g).name = id;
			}
			MenuButton component = g.GetComponent<MenuButton>();
			component.resizeButton = false;
			component.customHoverArea = true;
			RectTransform val = (RectTransform)g.transform;
			((Transform)val).localScale = Vector3.one;
			Vector2 anchorMin = (val.anchorMax = new Vector2(0f, 1f));
			val.anchorMin = anchorMin;
			val.pivot = Vector2.zero;
			val.anchoredPosition = new Vector2(20f, 0f - y - height);
			val.sizeDelta = new Vector2(400f, height);
			if (Object.op_Implicit((Object)(object)component.rectTransformSelection) && (Object)(object)component.rectTransformSelection != (Object)(object)val)
			{
				Stretch(component.rectTransformSelection);
			}
			TextMeshProUGUI componentInChildren = g.GetComponentInChildren<TextMeshProUGUI>(true);
			Stretch(((TMP_Text)componentInChildren).rectTransform);
			((TMP_Text)componentInChildren).margin = new Vector4(8f, 0f, 8f, 0f);
			((TMP_Text)componentInChildren).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)componentInChildren).enableAutoSizing = true;
			((TMP_Text)componentInChildren).fontSizeMin = 22f;
			((TMP_Text)componentInChildren).fontSizeMax = 33f;
			((TMP_Text)componentInChildren).fontSize = 33f;
			((TMP_Text)componentInChildren).overflowMode = (TextOverflowModes)1;
		});
	}

	private void Open()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Expected O, but got Unknown
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Expected O, but got Unknown
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: 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_0174: 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_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: 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_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: 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_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)overlay) || !Session.Host)
		{
			return;
		}
		Canvas rootCanvas = ((Component)esc).GetComponentInParent<Canvas>().rootCanvas;
		RectTransform val = (RectTransform)((Component)rootCanvas).transform;
		MenuSelectableElement[] componentsInChildren = ((Component)esc).GetComponentsInChildren<MenuSelectableElement>(false);
		foreach (MenuSelectableElement val2 in componentsInChildren)
		{
			MenuButton componentInParent = ((Component)val2).GetComponentInParent<MenuButton>();
			GameObject val3 = (Object.op_Implicit((Object)(object)componentInParent) ? ((Component)componentInParent).gameObject : ((Component)val2).gameObject);
			if ((Object)(object)val3 != (Object)(object)((Component)esc).gameObject && val3.activeSelf && !hidden.Contains(val3))
			{
				hidden.Add(val3);
			}
		}
		foreach (GameObject item in hidden)
		{
			item.SetActive(false);
		}
		overlay = new GameObject("Administration", new Type[2]
		{
			typeof(RectTransform),
			typeof(Image)
		});
		RectTransform component = overlay.GetComponent<RectTransform>();
		((Transform)component).SetParent(((Component)esc).transform, false);
		Rect rect = val.rect;
		float num = ((Rect)(ref rect)).height / 720f;
		((Transform)component).localScale = Vector3.one * (((Transform)val).lossyScale.y / ((Component)esc).transform.lossyScale.y) * num;
		Rect rect2 = val.rect;
		float num2 = Mathf.Min(((Rect)(ref rect2)).width / num, 440f);
		component.sizeDelta = new Vector2(num2, 720f);
		Rect rect3 = val.rect;
		float num3 = ((Rect)(ref rect3)).xMin + num2 * num * 0.5f;
		Rect rect4 = val.rect;
		((Transform)component).position = ((Transform)val).TransformPoint(Vector2.op_Implicit(new Vector2(num3, ((Rect)(ref rect4)).center.y)));
		((Transform)component).SetAsLastSibling();
		((Graphic)overlay.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.92f);
		Go(Page.Home);
	}

	private void OnDisable()
	{
		Close();
	}

	private void OnDestroy()
	{
		Close();
		if (Object.op_Implicit((Object)(object)entry))
		{
			Object.Destroy((Object)(object)entry);
		}
	}

	private void Close()
	{
		if (Object.op_Implicit((Object)(object)overlay))
		{
			if (Object.op_Implicit((Object)(object)esc))
			{
				Forget(overlay);
			}
			overlay.SetActive(false);
			Object.Destroy((Object)(object)overlay);
			overlay = null;
		}
		foreach (GameObject item in hidden)
		{
			if (Object.op_Implicit((Object)(object)item))
			{
				item.SetActive(true);
			}
		}
		hidden.Clear();
	}

	private void Update()
	{
		if (!Object.op_Implicit((Object)(object)overlay))
		{
			return;
		}
		if (!Session.Host || !Object.op_Implicit((Object)(object)esc) || !(bool)PageActive.GetValue(esc))
		{
			Close();
			return;
		}
		if (Object.op_Implicit((Object)(object)statusLabel))
		{
			((TMP_Text)statusLabel).text = Session.Current.Status;
		}
		if (!(Time.unscaledTime < nextRefresh))
		{
			nextRefresh = Time.unscaledTime + 0.4f;
			string text = Signature();
			if (text != lastSignature)
			{
				Draw();
			}
		}
	}

	private static PlayerAvatar Avatar(Player p)
	{
		if (p != null)
		{
			return SemiFunc.PlayerAvatarGetFromPhotonPlayer(p);
		}
		return null;
	}

	private static bool Dead(PlayerAvatar a)
	{
		return (bool)Disabled.GetValue(a);
	}

	private static string HealthColor(int hp)
	{
		if (hp >= 30)
		{
			if (hp >= 50)
			{
				return "#8DED91";
			}
			return "#FFA329";
		}
		return "#FF625B";
	}

	private static string State(Player p)
	{
		PlayerAvatar val = (p.IsLocal ? PlayerAvatar.instance : Avatar(p));
		if (!Object.op_Implicit((Object)(object)val) || (!p.IsLocal && (!Object.op_Implicit((Object)(object)val.photonView) || val.photonView.Owner != p)))
		{
			return "Joining";
		}
		string text = (Dead(val) ? "<color=#FF625B>Dead</color>" : "<color=#8DED91>Alive</color>");
		if (!Object.op_Implicit((Object)(object)val.playerHealth))
		{
			return text + "     HP —";
		}
		int num = (int)HP.GetValue(val.playerHealth);
		return text + "     <color=" + HealthColor(num) + ">HP " + num + "</color>";
	}

	private string Signature()
	{
		return string.Join("|", PhotonNetwork.PlayerList.Select((Player p) => p.ActorNumber + ":" + p.NickName + ":" + State(p) + ":" + Session.Compatible(p) + ":" + Session.SupportsSingle(p) + ":" + Session.Current.Muted(p)).ToArray());
	}

	private Player Selected()
	{
		Player val = ((PhotonNetwork.CurrentRoom == null) ? null : PhotonNetwork.CurrentRoom.GetPlayer(target, false));
		if (val == null || !(val.UserId == targetId))
		{
			return null;
		}
		return val;
	}

	private void Go(Page p)
	{
		page = p;
		lastButton = null;
		Draw();
	}

	private GameObject Row(string s, Action callback, bool enabled = true, string id = null)
	{
		float num = ((page == Page.Players || page == Page.Cosmetics || page == Page.Status) ? 38f : 48f);
		GameObject val = ButtonAt(s, num, callback, enabled, id);
		if (enabled && Object.op_Implicit((Object)(object)EventSystem.current) && (lastButton == s || !Object.op_Implicit((Object)(object)EventSystem.current.currentSelectedGameObject)))
		{
			EventSystem.current.SetSelectedGameObject(val);
		}
		y += num + 6f;
		return val;
	}

	private void BoxChoices()
	{
		//IL_001b: 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_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		TextMeshProUGUI val = TextAt(content.transform, "SPAWN ALL BOXES", new Vector2(0f, 1f), new Vector2(20f, 0f - y), 214f, 38f, 26);
		((TMP_Text)val).alignment = (TextAlignmentOptions)513;
		BoxChoice(value: true, 234f);
		TextAt(content.transform, "|", new Vector2(0f, 1f), new Vector2(312f, 0f - y), 16f, 38f, 26);
		BoxChoice(value: false, 330f);
		y += 44f;
	}

	private void BoxChoice(bool value, float x)
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Expected O, but got Unknown
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		string text = (value ? "ON" : "OFF");
		GameObject val = ButtonAt(text, 38f, delegate
		{
			Plugin.AllBoxes.Value = value;
			Session.Current.Status = "Applies to the next level.";
			Draw();
		}, enabled: true, null);
		RectTransform val2 = (RectTransform)val.transform;
		val2.anchoredPosition = new Vector2(x, val2.anchoredPosition.y);
		val2.sizeDelta = new Vector2(76f, 38f);
		TextMeshProUGUI componentInChildren = val.GetComponentInChildren<TextMeshProUGUI>(true);
		((TMP_Text)componentInChildren).alignment = (TextAlignmentOptions)514;
		((TMP_Text)componentInChildren).richText = true;
		((TMP_Text)componentInChildren).text = ((value == Plugin.AllBoxes.Value) ? ("<color=#FFA329>" + text + "</color>") : text);
	}

	private void Draw()
	{
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Expected O, but got Unknown
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: 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_012a: 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_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0691: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_08d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0568: Unknown result type (might be due to invalid IL or missing references)
		//IL_0590: Unknown result type (might be due to invalid IL or missing references)
		//IL_059f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b92: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ba3: Unknown result type (might be due to invalid IL or missing references)
		//IL_082b: Unknown result type (might be due to invalid IL or missing references)
		//IL_083c: Unknown result type (might be due to invalid IL or missing references)
		if (!Session.Host || !Object.op_Implicit((Object)(object)overlay))
		{
			return;
		}
		if (Object.op_Implicit((Object)(object)content))
		{
			GameObject val = (Object.op_Implicit((Object)(object)EventSystem.current) ? EventSystem.current.currentSelectedGameObject : null);
			if (Object.op_Implicit((Object)(object)val) && val.transform.IsChildOf(content.transform))
			{
				lastButton = ((Object)val).name;
			}
			Forget(content);
			content.SetActive(false);
			Object.Destroy((Object)(object)content);
		}
		content = new GameObject("Administration", new Type[1] { typeof(RectTransform) });
		RectTransform component = content.GetComponent<RectTransform>();
		((Transform)component).SetParent(overlay.transform, false);
		component.anchorMin = Vector2.zero;
		component.anchorMax = Vector2.one;
		Vector2 offsetMin = (component.offsetMax = Vector2.zero);
		component.offsetMin = offsetMin;
		if (Object.op_Implicit((Object)(object)EventSystem.current))
		{
			EventSystem.current.SetSelectedGameObject((GameObject)null);
		}
		y = 92f;
		lastSignature = Signature();
		Player val2 = Selected();
		string s = ((page == Page.Home) ? "R.E.P.O. ADMIN MENU" : ((page == Page.Detail && val2 != null) ? ("ADMIN - " + val2.NickName) : ((page == Page.Cosmetics) ? "GIVE COSMETICS" : ((page == Page.Gift) ? "GIVE COSMETIC TOKENS" : ((page == Page.Status) ? "PLAYERS STATUS" : ("ADMIN - " + page.ToString().ToUpperInvariant()))))));
		TextMeshProUGUI val3 = TextAt(content.transform, s, new Vector2(0.5f, 1f), new Vector2(0f, -22f), 400f, 50f, 38);
		((Graphic)val3).color = new Color(1f, 0.65f, 0.06f);
		((TMP_Text)val3).alignment = (TextAlignmentOptions)513;
		statusLabel = TextAt(content.transform, Session.Current.Status, new Vector2(0.5f, 0f), new Vector2(0f, 16f), 400f, 40f, 21);
		if (page == Page.Home)
		{
			Row("GIVE COSMETICS", delegate
			{
				Go(Page.Cosmetics);
			});
			Row("SPAWN", delegate
			{
				Go(Page.Spawn);
			});
			Row("PLAYERS STATUS", delegate
			{
				Go(Page.Status);
			});
			Row("PLAYERS", delegate
			{
				Go(Page.Players);
			});
			Row("BAN LIST", delegate
			{
				Go(Page.Bans);
			});
			Row("BACK TO PAUSE MENU", Close);
			return;
		}
		if (page == Page.Cosmetics || page == Page.Status || page == Page.Players)
		{
			if (page == Page.Cosmetics)
			{
				BoxChoices();
				bool flag = PhotonNetwork.PlayerList.All(Session.Compatible) && Object.op_Implicit((Object)(object)MetaManager.instance) && Object.op_Implicit((Object)(object)CosmeticTokenUI.instance);
				Row("GIVE ALL: 1 OF EACH TOKEN", Session.Current.GiveEveryone, flag);
				if (!flag)
				{
					((TMP_Text)statusLabel).text = (Session.Current.Status = "Group gifts require compatible players and a ready inventory.");
				}
			}
			if (page == Page.Players)
			{
				Row("REVIVE ALL", delegate
				{
					All(revive: true);
				});
				Row("HEAL ALL", delegate
				{
					All(revive: false);
				});
			}
			foreach (Player item in PhotonNetwork.PlayerList.OrderBy((Player val10) => val10.ActorNumber))
			{
				Player p = item;
				string text = (string.IsNullOrEmpty(p.NickName) ? ("Player " + p.ActorNumber) : p.NickName);
				if (page == Page.Cosmetics && !Session.SupportsSingle(p))
				{
					text += "   [GIFTS UNAVAILABLE]";
				}
				GameObject val4 = Row(text, delegate
				{
					target = p.ActorNumber;
					targetId = p.UserId;
					Go((page == Page.Cosmetics) ? Page.Gift : Page.Detail);
				}, enabled: true, "Player " + p.ActorNumber);
				if (page == Page.Status)
				{
					TextMeshProUGUI componentInChildren = val4.GetComponentInChildren<TextMeshProUGUI>(true);
					((TMP_Text)componentInChildren).rectTransform.offsetMax = new Vector2(-188f, 0f);
					TextMeshProUGUI val5 = TextAt(val4.transform, State(p), new Vector2(1f, 0.5f), new Vector2(-8f, 0f), 180f, 38f, 23);
					((TMP_Text)val5).richText = true;
					((TMP_Text)val5).alignment = (TextAlignmentOptions)513;
				}
			}
			y = 622f;
			Row("BACK", delegate
			{
				Go(Page.Home);
			});
			return;
		}
		if (page == Page.Gift || page == Page.Spawn)
		{
			bool spawning = page == Page.Spawn;
			Player val6 = Selected();
			if (!spawning && val6 == null)
			{
				Go(Page.Cosmetics);
				return;
			}
			TextAt(content.transform, spawning ? "COSMETIC BOXES · TRUCK" : val6.NickName, new Vector2(0.5f, 1f), new Vector2(0f, 0f - y), 400f, 38f, 28);
			y += 50f;
			string[] names = new string[4] { "COMMON · GREEN", "UNCOMMON · BLUE", "RARE · PURPLE", "ULTRA RARE · GOLD" };
			string[] array = new string[4] { "#8DED91", "#68B8FF", "#CF96FF", "#FFCA54" };
			bool flag2 = (spawning ? LevelBoxes.ManualAvailable() : Session.SupportsSingle(val6));
			for (int num = 0; num < names.Length; num++)
			{
				int tier = num;
				GameObject val7 = Row(names[num], delegate
				{
					if (spawning)
					{
						Session.Current.Status = (LevelBoxes.SpawnManual(tier) ? (names[tier] + " box spawned in the truck.") : "Could not spawn box.");
					}
					else
					{
						Session.Current.GiveSingle(Selected(), tier);
					}
				}, flag2);
				TextMeshProUGUI componentInChildren2 = val7.GetComponentInChildren<TextMeshProUGUI>(true);
				((TMP_Text)componentInChildren2).richText = true;
				((TMP_Text)componentInChildren2).text = "<color=" + array[num] + ">" + names[num] + "</color>";
			}
			if (!flag2)
			{
				TextAt(content.transform, spawning ? "Available on a loaded level with a truck." : "Direct gifts require Multiplayer Plus 1.1.4+ on this player. Without it, extract cosmetic boxes to earn tokens.", new Vector2(0.5f, 1f), new Vector2(0f, 0f - y), 400f, 55f, 21);
			}
			y = 614f;
			Row("BACK", delegate
			{
				Go((!spawning) ? Page.Cosmetics : Page.Home);
			});
			return;
		}
		if (page == Page.Detail || page == Page.Confirm)
		{
			Player val8 = Selected();
			if (val8 == null)
			{
				Go(Page.Players);
				return;
			}
			TextMeshProUGUI val9 = TextAt(content.transform, State(val8), new Vector2(0.5f, 1f), new Vector2(0f, 0f - y), 400f, 32f, 26);
			((TMP_Text)val9).richText = true;
			((TMP_Text)val9).alignment = (TextAlignmentOptions)513;
			y += 41f;
			if (page == Page.Confirm)
			{
				Row("CONFIRM " + action, delegate
				{
					Session.Current.Remove(Selected(), action == "BAN");
					Go(Page.Players);
				});
				Row("CANCEL", delegate
				{
					Go(Page.Detail);
				});
				return;
			}
			Row("HEAL", delegate
			{
				Apply(Selected(), "HEAL");
			});
			Row("REVIVE", delegate
			{
				Apply(Selected(), "REVIVE");
			});
			Row("KILL", delegate
			{
				Apply(Selected(), "KILL");
			});
			Row(Session.Current.Muted(val8) ? "UNMUTE" : "MUTE", delegate
			{
				Session.Current.ToggleMute(Selected());
				Draw();
			}, !val8.IsLocal && Session.Compatible(val8));
			Row("KICK", delegate
			{
				action = "KICK";
				Go(Page.Confirm);
			}, !val8.IsLocal);
			Row("BAN", delegate
			{
				action = "BAN";
				Go(Page.Confirm);
			}, !val8.IsLocal);
			Row("BACK", delegate
			{
				Go(Page.Players);
			});
			return;
		}
		List<KeyValuePair<string, string>> list = (from x in Session.Bans()
			orderby x.Key
			select x).ToList();
		banPage = Math.Min(banPage, Math.Max(0, (list.Count - 1) / 8));
		foreach (KeyValuePair<string, string> item2 in list.Skip(8 * banPage).Take(8))
		{
			string id = item2.Key;
			Row("UNBAN   " + item2.Value + "   " + id, delegate
			{
				Session.Current.Unban(id);
				Draw();
			});
		}
		if (list.Count == 0)
		{
			TextAt(content.transform, "No banned players", new Vector2(0.5f, 1f), new Vector2(0f, 0f - y), 400f, 36f, 24);
			y += 42f;
		}
		if (banPage > 0)
		{
			Row("PREVIOUS", delegate
			{
				banPage--;
				Draw();
			});
		}
		if ((banPage + 1) * 8 < list.Count)
		{
			Row("NEXT", delegate
			{
				banPage++;
				Draw();
			});
		}
		Row("BACK", delegate
		{
			Go(Page.Home);
		});
	}

	private void All(bool revive)
	{
		Player[] playerList = PhotonNetwork.PlayerList;
		foreach (Player p in playerList)
		{
			Apply(p, revive ? "REVIVE" : "HEAL");
		}
	}

	private static void Apply(Player p, string op)
	{
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		if (!Session.Host || p == null || PhotonNetwork.CurrentRoom.GetPlayer(p.ActorNumber, false) != p)
		{
			return;
		}
		PlayerAvatar val = (p.IsLocal ? PlayerAvatar.instance : Avatar(p));
		if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.playerHealth) || (!p.IsLocal && (!Object.op_Implicit((Object)(object)val.photonView) || val.photonView.Owner != p)))
		{
			return;
		}
		if (op == "REVIVE")
		{
			if (Dead(val))
			{
				val.Revive(false);
			}
			return;
		}
		if (Dead(val))
		{
			Session.Current.Status = "PLAYER IS ALREADY DEAD";
			return;
		}
		int num = (int)MaxHP.GetValue(val.playerHealth);
		if (op == "HEAL")
		{
			val.playerHealth.HealOther(Math.Max(0, num - (int)HP.GetValue(val.playerHealth)), true);
		}
		if (op == "KILL" && p.IsLocal)
		{
			val.PlayerDeath(-1);
		}
		else if (op == "KILL")
		{
			val.playerHealth.HurtOther(Math.Max(1, num + 1), Vector3.zero, false, -1, false);
		}
	}
}
[HarmonyPatch(typeof(CosmeticWorldObject), "ExtractRPC")]
internal static class BoxExtraction
{
	private static readonly ConditionalWeakTable<CosmeticWorldObject, object> done = new ConditionalWeakTable<CosmeticWorldObject, object>();

	private static readonly FieldInfo Extracted = AccessTools.Field(typeof(RoundDirector), "cosmeticWorldObjectsExtracted");

	private static bool AdjustExtraction
	{
		get
		{
			if (!Session.ManagedRoom)
			{
				if (!PhotonNetwork.InRoom)
				{
					return LevelBoxes.SpawnAllThisLevel;
				}
				return false;
			}
			return true;
		}
	}

	private static int Count()
	{
		return ((List<Rarity>)Extracted.GetValue(RoundDirector.instance)).Count;
	}

	private static bool Prefix(CosmeticWorldObject __instance, out int __state)
	{
		if (!AdjustExtraction)
		{
			__state = -1;
			return true;
		}
		__state = (Object.op_Implicit((Object)(object)RoundDirector.instance) ? Count() : (-1));
		object value;
		return !done.TryGetValue(__instance, out value);
	}

	private static void Postfix(CosmeticWorldObject __instance, int __state)
	{
		if (__state >= 0 && Count() > __state)
		{
			done.GetOrCreateValue(__instance);
		}
	}

	private static int ExtractionLimit(int native)
	{
		if (!AdjustExtraction)
		{
			return native;
		}
		return Math.Max(3, native);
	}

	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> code)
	{
		MethodInfo getter = AccessTools.Method(typeof(ValuableDirector), "CosmeticWorldObjectLevelLoopsClampedGet", (Type[])null, (Type[])null);
		bool found = false;
		foreach (CodeInstruction instruction in code)
		{
			if (CodeInstructionExtensions.Calls(instruction, getter))
			{
				found = true;
				yield return instruction;
				yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(BoxExtraction), "ExtractionLimit", (Type[])null, (Type[])null));
			}
			else
			{
				yield return instruction;
			}
		}
		if (!found)
		{
			throw new InvalidOperationException("Unsupported extraction routine.");
		}
	}
}
[HarmonyPatch(typeof(HaulUI), "Start")]
internal static class HudInstall
{
	private static void Postfix(HaulUI __instance)
	{
		Create(((Component)__instance).GetComponent<TextMeshProUGUI>());
	}

	internal static void Create(TextMeshProUGUI sample)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Expected O, but got Unknown
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Expected O, but got Unknown
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: 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_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)sample) && Object.op_Implicit((Object)(object)((Graphic)sample).canvas) && !Object.op_Implicit((Object)(object)CountHud.Instance))
		{
			GameObject val = new GameObject("WAURESY Session HUD", new Type[3]
			{
				typeof(RectTransform),
				typeof(Canvas),
				typeof(CanvasScaler)
			});
			Object.DontDestroyOnLoad((Object)(object)val);
			Canvas component = val.GetComponent<Canvas>();
			component.renderMode = (RenderMode)0;
			component.sortingOrder = 9000;
			CanvasScaler component2 = val.GetComponent<CanvasScaler>();
			component2.uiScaleMode = (ScaleMode)1;
			component2.referenceResolution = new Vector2(1920f, 1080f);
			component2.matchWidthOrHeight = 0.5f;
			GameObject val2 = new GameObject("WAURESY Player Counter", new Type[2]
			{
				typeof(RectTransform),
				typeof(TextMeshProUGUI)
			});
			val2.transform.SetParent(val.transform, false);
			TextMeshProUGUI component3 = val2.GetComponent<TextMeshProUGUI>();
			RectTransform rectTransform = ((TMP_Text)component3).rectTransform;
			Vector2 val3 = (rectTransform.pivot = Vector2.zero);
			Vector2 anchorMin = (rectTransform.anchorMax = val3);
			rectTransform.anchorMin = anchorMin;
			rectTransform.anchoredPosition = new Vector2(12f, 10f);
			((TMP_Text)component3).font = ((TMP_Text)sample).font;
			((TMP_Text)component3).fontSharedMaterial = ((TMP_Text)sample).fontSharedMaterial;
			((Graphic)component3).color = ((Graphic)sample).color;
			((TMP_Text)component3).fontSize = Plugin.HudSize.Value;
			rectTransform.sizeDelta = new Vector2(((TMP_Text)component3).fontSize * 28f, ((TMP_Text)component3).fontSize * 17f);
			((TMP_Text)component3).richText = true;
			((TMP_Text)component3).alignment = (TextAlignmentOptions)1025;
			((Graphic)component3).raycastTarget = false;
			val2.AddComponent<CountHud>();
		}
	}
}
[HarmonyPatch(typeof(MenuPageLobby), "Start")]
internal static class LobbyHud
{
	private static void Postfix(MenuPageLobby __instance)
	{
		HudInstall.Create(((Component)__instance).GetComponentInChildren<TextMeshProUGUI>(true));
	}
}
public sealed class CountHud : MonoBehaviourPunCallbacks
{
	private sealed class Arrival
	{
		internal string name;

		internal float hideAt;
	}

	private TextMeshProUGUI label;

	internal static CountHud Instance;

	private bool online;

	private int previousCount = -1;

	private int previousMax = -1;

	private float nextPoll;

	private readonly SortedDictionary<int, Arrival> arrivals = new SortedDictionary<int, Arrival>();

	private bool dirty;

	private readonly List<int> expired = new List<int>();

	internal void Ready(int actor)
	{
		if (arrivals.TryGetValue(actor, out var value) && value.hideAt == 0f)
		{
			value.hideAt = Time.unscaledTime + 5f;
			dirty = true;
			Refresh();
		}
	}

	private void Awake()
	{
		Instance = this;
		label = ((Component)this).GetComponent<TextMeshProUGUI>();
		Refresh();
	}

	private void Update()
	{
		if (!(Time.unscaledTime < nextPoll))
		{
			nextPoll = Time.unscaledTime + 0.2f;
			Refresh();
		}
	}

	private void Refresh()
	{
		Room currentRoom = PhotonNetwork.CurrentRoom;
		((Behaviour)label).enabled = currentRoom != null;
		if (currentRoom == null)
		{
			arrivals.Clear();
			previousCount = -1;
			return;
		}
		bool flag = Listed(currentRoom.IsVisible, currentRoom.IsOpen, currentRoom.PlayerCount, currentRoom.MaxPlayers);
		expired.Clear();
		foreach (KeyValuePair<int, Arrival> arrival in arrivals)
		{
			if (arrival.Value.hideAt > 0f && arrival.Value.hideAt <= Time.unscaledTime)
			{
				expired.Add(arrival.Key);
			}
		}
		foreach (int item in expired)
		{
			arrivals.Remove(item);
			dirty = true;
		}
		if (!dirty && online == flag && previousCount == currentRoom.PlayerCount && previousMax == currentRoom.MaxPlayers)
		{
			return;
		}
		online = flag;
		previousCount = currentRoom.PlayerCount;
		previousMax = currentRoom.MaxPlayers;
		dirty = false;
		StringBuilder stringBuilder = new StringBuilder();
		foreach (Arrival value in arrivals.Values)
		{
			stringBuilder.Append(value.name).AppendLine((value.hideAt == 0f) ? " Joining" : " Joined");
		}
		((TMP_Text)label).text = stringBuilder.ToString() + "PLAYER COUNT: " + SlotText.Format(previousCount, previousMax) + "\nSTATUS: " + (online ? "<color=#8DED91>ONLINE</color>" : "<color=#F19B83>OFFLINE</color>");
	}

	internal static bool Listed(bool visible, bool open, int count, int maximum)
	{
		if (visible && open)
		{
			return count < maximum;
		}
		return false;
	}

	public override void OnJoinedRoom()
	{
		Refresh();
	}

	public override void OnLeftRoom()
	{
		Refresh();
	}

	public override void OnPlayerEnteredRoom(Player p)
	{
		string name = (p.NickName ?? "Player").Replace('<', '<').Replace('>', '>').Replace('\n', ' ')
			.Replace('\r', ' ');
		arrivals[p.ActorNumber] = new Arrival
		{
			name = name
		};
		dirty = true;
		Refresh();
	}

	public override void OnPlayerLeftRoom(Player p)
	{
		arrivals.Remove(p.ActorNumber);
		dirty = true;
		Refresh();
	}
}
[HarmonyPatch(typeof(PlayerAvatar), "LoadingLevelAnimationCompletedRPC")]
internal static class ArrivalReady
{
	private static void Postfix(PlayerAvatar __instance, PhotonMessageInfo __0, bool ___levelAnimationCompleted)
	{
		if (___levelAnimationCompleted && __0.Sender != null && Object.op_Implicit((Object)(object)__instance.photonView) && __instance.photonView.Owner == __0.Sender)
		{
			if (Object.op_Implicit((Object)(object)CountHud.Instance))
			{
				CountHud.Instance.Ready(__0.Sender.ActorNumber);
			}
			NewListener.Ready(__instance, __0.Sender);
		}
	}
}
[HarmonyPatch(typeof(MenuPageServerList), "CreateServerElement")]
internal static class SlotText
{
	internal static string Format(int count, int max)
	{
		return "<color=#FFA329>" + count + "</color>/" + max;
	}

	private static void SetSlots(TMP_Text label, string value)
	{
		string[] array = value.Split('/');
		if (array.Length == 2 && int.TryParse(array[0], out var result) && int.TryParse(array[1], out var result2) && result2 == 10)
		{
			label.richText = true;
			label.text = Format(result, result2);
		}
		else
		{
			label.text = value;
		}
	}

	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> code)
	{
		FieldInfo field = AccessTools.Field(typeof(MenuElementServer), "textPlayers");
		MethodInfo setter = AccessTools.PropertySetter(typeof(TMP_Text), "text");
		bool pending = false;
		bool replaced = false;
		foreach (CodeInstruction ins in code)
		{
			if (CodeInstructionExtensions.LoadsField(ins, field, false))
			{
				pending = true;
			}
			if (pending && CodeInstructionExtensions.Calls(ins, setter))
			{
				ins.opcode = OpCodes.Call;
				ins.operand = AccessTools.Method(typeof(SlotText), "SetSlots", (Type[])null, (Type[])null);
				pending = false;
				replaced = true;
			}
			yield return ins;
		}
		if (!replaced)
		{
			throw new InvalidOperationException("Unsupported server list text layout");
		}
	}
}
internal static class NewListener
{
	private static readonly HashSet<int> readyActors = new HashSet<int>();

	private static LevelGenerator scene;

	internal static void Ready(PlayerAvatar avatar, Player recipient)
	{
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		if (!Session.Host || recipient == null || recipient.IsLocal || !Object.op_Implicit((Object)(object)avatar) || !Object.op_Implicit((Object)(object)avatar.photonView) || avatar.photonView.Owner != recipient || PhotonNetwork.CurrentRoom.GetPlayer(recipient.ActorNumber, false) != recipient)
		{
			return;
		}
		LevelGenerator instance = LevelGenerator.Instance;
		if (!Object.op_Implicit((Object)(object)instance))
		{
			return;
		}
		if ((Object)(object)scene != (Object)(object)instance)
		{
			scene = instance;
			readyActors.Clear();
		}
		if (!readyActors.Add(recipient.ActorNumber))
		{
			return;
		}
		PhysGrabCart[] array = Object.FindObjectsByType<PhysGrabCart>((FindObjectsSortMode)0);
		foreach (PhysGrabCart val in array)
		{
			PhysGrabObject componentInParent = ((Component)val).GetComponentInParent<PhysGrabObject>();
			if (Object.op_Implicit((Object)(object)componentInParent) && Object.op_Implicit((Object)(object)componentInParent.rb))
			{
				PhotonView component = ((Component)componentInParent).GetComponent<PhotonView>();
				if (Object.op_Implicit((Object)(object)component) && component.ViewID > 0)
				{
					component.RPC("SetPositionRPC", recipient, new object[2]
					{
						componentInParent.rb.position,
						componentInParent.rb.rotation
					});
				}
			}
		}
		((MonoBehaviour)instance).StartCoroutine(RefreshVoice(instance, recipient, PhotonNetwork.CurrentRoom));
	}

	private static IEnumerator RefreshVoice(LevelGenerator level, Player recipient, Room room)
	{
		float until = Time.unscaledTime + 10f;
		while (Object.op_Implicit((Object)(object)level) && (Object)(object)LevelGenerator.Instance == (Object)(object)level && Session.Host && room == PhotonNetwork.CurrentRoom && room.GetPlayer(recipient.ActorNumber, false) == recipient && Time.unscaledTime < until)
		{
			PlayerAvatar local = PlayerAvatar.instance;
			PlayerVoiceChat voice = PlayerVoiceChat.instance;
			PhotonView view = (Object.op_Implicit((Object)(object)voice) ? ((Component)voice).GetComponent<PhotonView>() : null);
			if (Object.op_Implicit((Object)(object)local) && Object.op_Implicit((Object)(object)local.photonView) && local.photonView.IsMine && Object.op_Implicit((Object)(object)view) && view.IsMine && view.ViewID > 0)
			{
				local.photonView.RPC("UpdateMyPlayerVoiceChat", recipient, new object[1] { view.ViewID });
				PlayerVoiceChat.VoiceTargetPlayersInvalidate();
				Plugin.Log.LogInfo((object)("Host voice binding sent to ready actor " + recipient.ActorNumber));
				break;
			}
			yield return (object)new WaitForSecondsRealtime(0.25f);
		}
	}
}
[HarmonyPatch]
internal static class LateJoin
{
	private static Room hosted;

	private static bool listed;

	private static bool steamPublic;

	private static bool transitioning;

	private static LevelGenerator closingLevel;

	private static readonly FieldInfo AnimationDone = AccessTools.Field(typeof(PlayerAvatar), "levelAnimationCompleted");

	private static readonly FieldInfo ModuleTarget = AccessTools.Field(typeof(LevelGenerator), "ModulesSpawnedTarget");

	private static readonly FieldInfo ModuleReady = AccessTools.Field(typeof(LevelGenerator), "ModulesReadyPlayerList");

	private static readonly HashSet<int> syncing = new HashSet<int>();

	private static readonly FieldInfo SteamPrivate = AccessTools.Field(typeof(SteamLobbyManager), "privateLobby");

	private static readonly FieldInfo ActivePoint = AccessTools.Field(typeof(RoundDirector), "extractionPointCurrent");

	private static readonly FieldInfo Active = AccessTools.Field(typeof(RoundDirector), "extractionPointActive");

	private static readonly FieldInfo Head = AccessTools.Field(typeof(PlayerAvatar), "playerDeathHead");

	private static readonly FieldInfo Tumble = AccessTools.Field(typeof(PlayerAvatar), "tumble");

	private static readonly FieldInfo Park = AccessTools.Field(typeof(AssetManager), "physDisabledPosition");

	internal static bool Accepting
	{
		get
		{
			if (!transitioning && hosted != null && hosted == PhotonNetwork.CurrentRoom)
			{
				return hosted.IsOpen;
			}
			return false;
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(NetworkConnect), "OnCreatedRoom")]
	private static void RememberRoom()
	{
		if (Session.Host)
		{
			transitioning = false;
			closingLevel = null;
			syncing.Clear();
			hosted = PhotonNetwork.CurrentRoom;
			listed = hosted.IsVisible;
			steamPublic = listed;
		}
	}

	[HarmonyPriority(800)]
	[HarmonyPrefix]
	[HarmonyPatch(typeof(MenuPageLobby), "ButtonStart")]
	private static void RememberAccess()
	{
		if (PhotonNetwork.IsMasterClient && PhotonNetwork.InRoom)
		{
			if (hosted != PhotonNetwork.CurrentRoom)
			{
				hosted = PhotonNetwork.CurrentRoom;
				listed = hosted.IsVisible;
			}
			SteamLobbyManager instance = SteamLobbyManager.instance;
			steamPublic = Object.op_Implicit((Object)(object)instance) && !(bool)SteamPrivate.GetValue(instance);
		}
	}

	[HarmonyPatch(typeof(RunManager), "ChangeLevel")]
	[HarmonyPrefix]
	private static void Transition()
	{
		if (hosted != null && PhotonNetwork.CurrentRoom == hosted && PhotonNetwork.IsMasterClient && !transitioning)
		{
			transitioning = true;
			closingLevel = LevelGenerator.Instance;
			TruckArrivals.Pending.Clear();
			if (hosted.IsOpen)
			{
				PhotonNetwork.SetRoomOpen(false);
			}
			if (hosted.IsVisible)
			{
				hosted.IsVisible = false;
			}
			if (Object.op_Implicit((Object)(object)SteamLobbyManager.instance))
			{
				SteamLobbyManager.instance.LockLobby();
			}
			syncing.Clear();
		}
	}

	[HarmonyPatch(typeof(GameDirector), "OutroStart")]
	[HarmonyPostfix]
	private static void LeavingMap()
	{
		Transition();
	}

	[HarmonyPatch(typeof(LevelGenerator), "GenerateDoneApply")]
	[HarmonyPostfix]
	private static void OpenLoadedLevel()
	{
		if (hosted != null && PhotonNetwork.CurrentRoom == hosted && PhotonNetwork.IsMasterClient && (SemiFunc.RunIsLevel() || SemiFunc.RunIsShop() || SemiFunc.RunIsLobby()) && (!transitioning || !Object.op_Implicit((Object)(object)closingLevel) || !((Object)(object)closingLevel == (Object)(object)LevelGenerator.Instance)))
		{
			transitioning = false;
			closingLevel = null;
			PhotonNetwork.SetRoomOpen(true);
			hosted.IsVisible = listed;
			Plugin.Log.LogInfo((object)("Late join open. Public listing: " + listed + ", players: " + hosted.PlayerCount));
			if (Object.op_Implicit((Object)(object)SteamLobbyManager.instance))
			{
				SteamLobbyManager.instance.UnlockLobby(steamPublic);
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(NetworkManager), "OnPlayerLeftRoom")]
	private static void Cancel(Player __0)
	{
		syncing.Remove(__0.ActorNumber);
	}

	[HarmonyPatch(typeof(NetworkManager), "PlayerSpawnedRPC")]
	[HarmonyPostfix]
	private static void AvatarReady(NetworkManager __instance, PhotonMessageInfo __0)
	{
		Player sender = __0.Sender;
		if (PhotonNetwork.IsMasterClient && sender != null && !sender.IsLocal && hosted != null && hosted == PhotonNetwork.CurrentRoom && hosted.GetPlayer(sender.ActorNumber, false) == sender && Accepting && TruckArrivals.Pending.Contains(sender.ActorNumber) && syncing.Add(sender.ActorNumber))
		{
			((MonoBehaviourPun)__instance).photonView.RPC("AllPlayerSpawnedRPC", sender, new object[0]);
			LevelGenerator instance = LevelGenerator.Instance;
			if (!Object.op_Implicit((Object)(object)instance))
			{
				syncing.Remove(sender.ActorNumber);
				return;
			}
			instance.PhotonView.RPC("ModuleAmountRPC", sender, new object[1] { (int)ModuleTarget.GetValue(instance) });
			((MonoBehaviour)__instance).StartCoroutine(FinishJoin(sender, instance));
		}
	}

	private static IEnumerator FinishJoin(Player player, LevelGenerator level)
	{
		float reportAt = Time.unscaledTime + 12f;
		while (Accepting && Object.op_Implicit((Object)(object)level) && (Object)(object)LevelGenerator.Instance == (Object)(object)level && hosted == PhotonNetwork.CurrentRoom && PhotonNetwork.IsMasterClient && syncing.Contains(player.ActorNumber) && hosted.GetPlayer(player.ActorNumber, false) == player)
		{
			PlayerAvatar avatar = SemiFunc.PlayerAvatarGetFromPhotonPlayer(player);
			List<Player> ready = (List<Player>)ModuleReady.GetValue(level);
			if (ready != null && ready.Contains(player) && Object.op_Implicit((Object)(object)avatar) && (Object)(object)avatar != (Object)(object)PlayerAvatar.instance && Object.op_Implicit((Object)(object)avatar.photonView) && !avatar.photonView.IsMine && avatar.photonView.Owner == player && Object.op_Implicit((Object)(object)StatsManager.instance) && !string.IsNullOrEmpty(SemiFunc.PlayerGetSteamID(avatar)) && Object.op_Implicit((Object)(object)TruckSafetySpawnPoint.instance) && Object.op_Implicit((Object)(object)ValuableDirector.instance) && Object.op_Implicit((Object)(object)PunManager.instance))
			{
				syncing.Remove(player.ActorNumber);
				ValuableDirector instance = ValuableDirector.instance;
				PhotonView component = ((Component)instance).GetComponent<PhotonView>();
				component.RPC("ValuablesTargetSetRPC", player, new object[1] { instance.valuableList.Count((ValuableObject v) => Object.op_Implicit((Object)(object)v)) });
				component.RPC("CosmeticWorldObjectTargetSetRPC", player, new object[1] { RoundDirector.instance.cosmeticWorldObjects.Count((CosmeticWorldObject v) => Object.op_Implicit((Object)(object)v)) });
				component.RPC("VolumesAndSwitchSetupRPC", player, new object[0]);
				Upgrades.CatchUp(avatar);
				PunManager.instance.SyncAllDictionaries();
				foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
				{
					if (Object.op_Implicit((Object)(object)item) && !((Object)(object)item == (Object)(object)avatar) && Object.op_Implicit((Object)(object)item.photonView))
					{
						item.photonView.RPC("SpawnRPC", player, new object[3]
						{
							((Component)item).transform.position,
							((Component)item).transform.rotation,
							false
						});
					}
				}
				Transform transform = ((Component)TruckSafetySpawnPoint.instance).transform;
				avatar.Spawn(transform.position, transform.rotation, false);
				AttachBodies(avatar, level);
				ExtractionPoint val = (ExtractionPoint)ActivePoint.GetValue(RoundDirector.instance);
				if (Object.op_Implicit((Object)(object)val) && !ExtractionLocks.Completed(val) && (bool)Active.GetValue(RoundDirector.instance))
				{
					((Component)RoundDirector.instance).GetComponent<PhotonView>().RPC("ExtractionPointActivateRPC", player, new object[1] { ((Component)val).GetComponent<PhotonView>().ViewID });
				}
				PlayerAvatar instance2 = PlayerAvatar.instance;
				if (Object.op_Implicit((Object)(object)instance2) && Object.op_Implicit((Object)(object)instance2.photonView) && instance2.photonView.Owner == PhotonNetwork.LocalPlayer && (bool)AnimationDone.GetValue(instance2))
				{
					instance2.photonView.RPC("LoadingLevelAnimationCompletedRPC", player, new object[0]);
					Plugin.Log.LogInfo((object)("Host loading confirmation sent to actor " + player.ActorNumber));
				}
				level.PhotonView.RPC("GenerateDone", player, new object[0]);
				Plugin.Log.LogInfo((object)("Truck spawn and level snapshot sent to actor " + player.ActorNumber));
				break;
			}
			if (Time.unscaledTime >= reportAt)
			{
				Plugin.Log.LogInfo((object)("Waiting for late join actor " + player.ActorNumber + "; modules ready=" + (ready?.Contains(player) ?? false) + ", avatar registered=" + Object.op_Implicit((Object)(object)avatar)));
				reportAt = float.PositiveInfinity;
			}
			yield return (object)new WaitForSecondsRealtime(0.1f);
		}
	}

	private static void AttachBodies(PlayerAvatar avatar, LevelGenerator level)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: 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_002a: Expected O, but got Unknown
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: 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)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = (Vector3)Park.GetValue(AssetManager.instance);
		if (!Object.op_Implicit((Object)(PlayerDeathHead)Head.GetValue(avatar)))
		{
			GameObject val2 = PhotonNetwork.Instantiate(((Object)level.PlayerDeathHeadPrefab).name, val, Quaternion.identity, (byte)0, (object[])null);
			PlayerDeathHead component = val2.GetComponent<PlayerDeathHead>();
			component.playerAvatar = avatar;
			Head.SetValue(avatar, component);
		}
		if (!Object.op_Implicit((Object)(PlayerTumble)Tumble.GetValue(avatar)))
		{
			GameObject val3 = PhotonNetwork.Instantiate(((Object)level.PlayerTumblePrefab).name, val, Quaternion.identity, (byte)0, (object[])null);
			PlayerTumble component2 = val3.GetComponent<PlayerTumble>();
			component2.playerAvatar = avatar;
			Tumble.SetValue(avatar, component2);
		}
	}
}
[HarmonyPatch]
internal static class ExtractionLocks
{
	private static readonly FieldInfo State = AccessTools.Field(typeof(ExtractionPoint), "currentState");

	private static readonly FieldInfo Next = AccessTools.Field(typeof(ExtractionPoint), "stateSetTo");

	private static readonly FieldInfo Locked = AccessTools.Field(typeof(ExtractionPoint), "isLocked");

	private static readonly FieldInfo Points = AccessTools.Field(typeof(RoundDirector), "extractionPointList");

	private static readonly FieldInfo Current = AccessTools.Field(typeof(RoundDirector), "extractionPointCurrent");

	private static readonly FieldInfo Active = AccessTools.Field(typeof(RoundDirector), "extractionPointActive");

	private static readonly FieldInfo Total = AccessTools.Field(typeof(RoundDirector), "extractionPoints");

	private static readonly FieldInfo Done = AccessTools.Field(typeof(RoundDirector), "extractionPointsCompleted");

	private static float nextCheck;

	internal static bool Completed(ExtractionPoint p)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Invalid comparison between Unknown and I4
		return (int)(State)State.GetValue(p) == 7;
	}

	[HarmonyPatch(typeof(RoundDirector), "RequestExtractionPointActivationRPC")]
	[HarmonyPrefix]
	private static bool CheckRequest(int __0)
	{
		if (!Session.Host)
		{
			return true;
		}
		PhotonView val = PhotonView.Find(__0);
		ExtractionPoint val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<ExtractionPoint>() : null);
		if (Object.op_Implicit((Object)(object)val2))
		{
			return !Completed(val2);
		}
		return false;
	}

	[HarmonyPatch(typeof(RoundDirector), "Update")]
	[HarmonyPostfix]
	private static void CheckLocks(RoundDirector __instance)
	{
		if (Time.unscaledTime < nextCheck || !Session.Host)
		{
			return;
		}
		nextCheck = Time.unscaledTime + 1f;
		if (Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.Generated && SemiFunc.RunIsLevel())
		{
			int num = (int)Done.GetValue(__instance);
			if (num > 0 && num < (int)Total.GetValue(__instance) && NeedsUnlock(__instance))
			{
				Active.SetValue(__instance, false);
				__instance.ExtractionPointsUnlock();
				Plugin.Log.LogInfo((object)("Released stale extraction lock after " + num + " completed."));
			}
		}
	}

	private static bool NeedsUnlock(RoundDirector round)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		//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_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Invalid comparison between Unknown and I4
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Invalid comparison between Unknown and I4
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Invalid comparison between Unknown and I4
		ExtractionPoint val = (ExtractionPoint)Current.GetValue(round);
		if (Object.op_Implicit((Object)(object)val) && !Completed(val))
		{
			return false;
		}
		List<GameObject> list = (List<GameObject>)Points.GetValue(round);
		if (list == null)
		{
			return false;
		}
		bool result = false;
		foreach (GameObject item in list)
		{
			ExtractionPoint val2 = (Object.op_Implicit((Object)(object)item) ? item.GetComponent<ExtractionPoint>() : null);
			if (!Object.op_Implicit((Object)(object)val2))
			{
				return false;
			}
			State val3 = (State)State.GetValue(val2);
			State val4 = (State)Next.GetValue(val2);
			if ((int)val4 != 0 || ((int)val3 != 1 && (int)val3 != 7))
			{
				return false;
			}
			if ((int)val3 == 1 && (bool)Locked.GetValue(val2))
			{
				result = true;
			}
		}
		return result;
	}
}
[HarmonyPatch(typeof(PhotonView), "RPC", new Type[]
{
	typeof(string),
	typeof(RpcTarget),
	typeof(object[])
})]
internal static class SceneInitialization
{
	private static readonly HashSet<string> Initial = new HashSet<string> { "ModuleConnectionSetRPC", "ModuleConnectionSetMegaRPC", "StartRoundRPC", "HaulGoalSetRPC", "SetItemNameRPC" };

	private static void Prefix(string __0, ref RpcTarget __1)
	{
		if (Session.ManagedRoom)
		{
			if ((int)__1 == 0 && __0 == "LoadingLevelAnimationCompletedRPC")
			{
				__1 = (RpcTarget)3;
			}
			else if ((int)__1 == 0 && Initial.Contains(__0) && PhotonNetwork.IsMasterClient)
			{
				__1 = (RpcTarget)3;
			}
			else if ((int)__1 == 1 && (__0 == "PrefabsLoadRPC" || __0 == "DollarValueSetRPC") && PhotonNetwork.IsMasterClient)
			{
				__1 = (RpcTarget)4;
			}
			else if ((int)__1 == 3 && __0 == "GenerateDone" && PhotonNetwork.IsMasterClient)
			{
				__1 = (RpcTarget)0;
			}
		}
	}
}
[HarmonyPatch]
internal static class Upgrades
{
	private static readonly Dictionary<string, string> Fields = new Dictionary<string, string>
	{
		{ "UpgradePlayerHealth", "playerUpgradeHealth" },
		{ "UpgradePlayerEnergy", "playerUpgradeStamina" },
		{ "UpgradePlayerExtraJump", "playerUpgradeExtraJump" },
		{ "UpgradeMapPlayerCount", "playerUpgradeMapPlayerCount" },
		{ "UpgradePlayerTumbleLaunch", "playerUpgradeLaunch" },
		{ "UpgradePlayerTumbleClimb", "playerUpgradeTumbleClimb" },
		{ "UpgradeDeathHeadBattery", "playerUpgradeDeathHeadBattery" },
		{ "UpgradePlayerTumbleWings", "playerUpgradeTumbleWings" },
		{ "UpgradePlayerSprintSpeed", "playerUpgradeSpeed" },
		{ "UpgradePlayerCrouchRest", "playerUpgradeCrouchRest" },
		{ "UpgradePlayerGrabStrength", "playerUpgradeStrength" },
		{ "UpgradePlayerThrowStrength", "playerUpgradeThrow" },
		{ "UpgradePlayerGrabRange", "playerUpgradeRange" }
	};

	private static readonly Dictionary<MethodInfo, FieldInfo> Types = Fields.ToDictionary((KeyValuePair<string, string> e) => AccessTools.Method(typeof(PunManager), e.Key, new Type[2]
	{
		typeof(string),
		typeof(int)
	}, (Type[])null), (KeyValuePair<string, string> e) => AccessTools.Field(typeof(StatsManager), e.Value));

	private static bool distributing;

	internal static bool UsingItem;

	private static IEnumerable<MethodBase> TargetMethods()
	{
		return Types.Keys.Cast<MethodBase>();
	}

	private static void Postfix(MethodBase __originalMethod, PunManager __instance, string __0, int __1)
	{
		if (!UsingItem || distributing || __1 <= 0 || !PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient || string.IsNullOrEmpty(__0))
		{
			return;
		}
		distributing = true;
		try
		{
			IEnumerable<string> team = (from a in SemiFunc.PlayerGetList()
				where Object.op_Implicit((Object)(object)a)
				select a).Select((Func<PlayerAvatar, string>)SemiFunc.PlayerGetSteamID);
			string name = Types[(MethodInfo)__originalMethod].Name;
			foreach (string item in Recipients(__0, team))
			{
				__originalMethod.Invoke(__instance, new object[2] { item, __1 });
				((Component)__instance).GetComponent<PhotonView>().RPC("TesterUpgradeCommandRPC", (RpcTarget)1, new object[3]
				{
					item,
					name.Substring("playerUpgrade".Length),
					__1
				});
			}
		}
		finally
		{
			distributing = false;
		}
	}

	internal static IEnumerable<string> Recipients(string buyer, IEnumerable<string> team)
	{
		HashSet<string> seen = new HashSet<string> { buyer };
		foreach (string id in team)
		{
			if (!string.IsNullOrEmpty(id) && seen.Add(id))
			{
				yield return id;
			}
		}
	}

	internal static int Missing(Dictionary<string, int> values, string id)
	{
		values.TryGetValue(id, out var value);
		if (values.Count != 0)
		{
			return Math.Max(0, values.Values.Max() - value);
		}
		return 0;
	}

	internal static bool CatchUp(PlayerAvatar avatar)
	{
		string text = SemiFunc.PlayerGetSteamID(avatar);
		if (string.IsNullOrEmpty(text) || !Object.op_Implicit((Object)(object)StatsManager.instance) || !Object.op_Implicit((Object)(object)PunManager.instance))
		{
			return false;
		}
		bool result = false;
		foreach (KeyValuePair<MethodInfo, FieldInfo> type in Types)
		{
			Dictionary<string, int> dictionary = (Dictionary<string, int>)type.Value.GetValue(StatsManager.instance);
			if (dictionary != null)
			{
				int num = Missing(dictionary, text);
				if (num > 0)
				{
					type.Key.Invoke(PunManager.instance, new object[2] { text, num });
					result = true;
				}
			}
		}
		return result;
	}
}
[HarmonyPatch(typeof(LevelGenerator), "PlayerSpawn")]
internal static class TeamAtLevelStart
{
	private static bool Prefix(LevelGenerator __instance)
	{
		if (!PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient)
		{
			return true;
		}
		if (__instance.Generated)
		{
			return false;
		}
		bool flag = false;
		foreach (PlayerAvatar item in SemiFunc.PlayerGetList())
		{
			if (Object.op_Implicit((Object)(object)item))
			{
				flag |= Upgrades.CatchUp(item);
			}
		}
		if (flag)
		{
			PunManager.instance.SyncAllDictionaries();
		}
		return true;
	}
}
[HarmonyPatch(typeof(ItemUpgrade), "PlayerUpgrade")]
internal static class ItemUse
{
	private static void Prefix(out bool __state)
	{
		__state = Upgrades.UsingItem;
		Upgrades.UsingItem = true;
	}

	private static void Finalizer(bool __state)
	{
		Upgrades.UsingItem = __state;
	}
}
[BepInPlugin("wauresy.repo.multiplayerplus", "REPO Multiplayer Plus", "1.1.11")]
public sealed class Plugin : BaseUnityPlugin
{
	public const string Id = "wauresy.repo.multiplayerplus";

	internal const int Limit = 10;

	internal const string Marker = "[MP+LateJoin]";

	internal static ManualLogSource Log;

	internal static ConfigEntry<int> HudSize;

	internal static ConfigEntry<bool> AllBoxes;

	internal static ConfigEntry<string> BanData;

	private void Awake()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		Log = ((BaseUnityPlugin)this).Logger;
		AllBoxes = ((BaseUnityPlugin)this).Config.Bind<bool>("Cosmetics", "Guarantee four boxes", false, "Generate one cosmetic box of each rarity on each level. Disable for normal game generation.");
		HudSize = ((BaseUnityPlugin)this).Config.Bind<int>("HUD", "Counter size", 22, new ConfigDescription("HUD text size in canvas units.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(16, 36), new object[0]));
		BanData = ((BaseUnityPlugin)this).Config.Bind<string>("Administration", "Bans", "", "Permanent SteamID64 and encoded display name, one entry per comma.");
		((Component)this).gameObject.AddComponent<Session>();
		new Harmony("wauresy.repo.multiplayerplus").PatchAll(typeof(Plugin).Assembly);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"REPO Multiplayer Plus 1.1.11 ready");
	}

	internal static string Title(string value)
	{
		string suffix = (value ?? "").Trim();
		string[] array = new string[6] { "LAST JOIN |", "LAST JOIN ", "->LAST JOIN<-", "[MP+LateJoin]", "[Late Join]", "[中途加入]" };
		while (true)
		{
			string text = Array.Find(array, (string s) => suffix.StartsWith(s, StringComparison.OrdinalIgnoreCase));
			if (text == null)
			{
				break;
			}
			suffix = suffix.Substring(text.Length).TrimStart();
		}
		if (suffix.Length != 0 && !suffix.Equals("LAST JOIN", StringComparison.OrdinalIgnoreCase))
		{
			return "[MP+LateJoin] " + suffix;
		}
		return "[MP+LateJoin]";
	}
}
[HarmonyPatch(typeof(GameManager), "SetMaxPlayers")]
internal static class CapacityChange
{
	private static void Prefix(GameManager __instance, ref int __0)
	{
		if (!PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient)
		{
			__instance.maxPlayersPhoton = 10;
			__0 = 10;
		}
	}
}
[HarmonyPatch(typeof(SteamLobbyManager), "HostLobby")]
internal static class SteamCapacity
{
	private static void Prefix()
	{
		GameManager.instance.maxPlayers = 10;
	}
}
[HarmonyPatch(typeof(NetworkConnect), "OnConnectedToMaster")]
internal static class PhotonCapacity
{
	private static void Prefix()
	{
		GameManager.instance.maxPlayers = 10;
	}
}
[HarmonyPatch]
internal static class RoomCreation
{
	private static IEnumerable<MethodBase> TargetMethods()
	{
		yield return AccessTools.Method(typeof(PhotonNetwork), "CreateRoom", (Type[])null, (Type[])null);
		yield return AccessTools.Method(typeof(PhotonNetwork), "JoinRandomOrCreateRoom", (Type[])null, (Type[])null);
	}

	private static void Prefix(RoomOptions roomOptions)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		if (roomOptions != null)
		{
			roomOptions.MaxPlayers = 10;
			if (roomOptions.CustomRoomProperties == null)
			{
				roomOptions.CustomRoomProperties = new Hashtable();
			}
			roomOptions.CustomRoomProperties[(object)"server_name"] = Plugin.Title(roomOptions.CustomRoomProperties[(object)"server_name"] as string);
			string[] array = roomOptions.CustomRoomPropertiesForLobby ?? new string[0];
			if (!array.Contains("server_name"))
			{
				roomOptions.CustomRoomPropertiesForLobby = array.Concat(new string[1] { "server_name" }).ToArray();
			}
		}
	}
}
[HarmonyPatch(typeof(Room), "SetCustomProperties")]
internal static class KeepRoomTitle
{
	private static void Prefix(Room __instance, Hashtable __0)
	{
		if (__instance == PhotonNetwork.CurrentRoom && PhotonNetwork.IsMasterClient && __0 != null && ((Dictionary<object, object>)(object)__0).ContainsKey((object)"server_name"))
		{
			__0[(object)"server_name"] = Plugin.Title(__0[(object)"server_name"] as string);
		}
	}
}
[HarmonyPatch(typeof(NetworkConnect), "OnCreatedRoom")]
internal static class AdvertisedName
{
	private static void Postfix()
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		Room currentRoom = PhotonNetwork.CurrentRoom;
		if (currentRoom != null && PhotonNetwork.IsMasterClient)
		{
			string text = ((RoomInfo)currentRoom).CustomProperties[(object)"server_name"] as string;
			string text2 = Plugin.Title(text);
			if (text != text2)
			{
				Hashtable val = new Hashtable();
				((Dictionary<object, object>)(object)val).Add((object)"server_name", (object)text2);
				currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
			}
		}
	}
}
[HarmonyPatch]
internal static class TruckArrivals
{
	internal static readonly HashSet<int> Pending = new HashSet<int>();

	[HarmonyPatch(typeof(LevelGenerator), "Start")]
	[HarmonyPrefix]
	private static void NewScene()
	{
		Pending.Clear();
		LevelBoxes.BeginLevel();
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(NetworkManager), "OnPlayerEnteredRoom")]
	private static void Joined(Player __0)
	{
		if (LateJoin.Accepting && __0 != null && !__0.IsLocal && PhotonNetwork.IsMasterClient && Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.Generated)
		{
			Pending.Add(__0.ActorNumber);
		}
	}

	[HarmonyPatch(typeof(NetworkManager), "OnPlayerLeftRoom")]
	[HarmonyPrefix]
	private static void Left(Player __0)
	{
		Pending.Remove(__0.ActorNumber);
	}

	[HarmonyPatch(typeof(PlayerAvatar), "Spawn")]
	[HarmonyPrefix]
	private static void Spawn(PlayerAvatar __instance, ref Vector3 __0, ref Quaternion __1)
	{
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: 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)
		if (PhotonNetwork.IsMasterClient && !((Object)(object)__instance == (Object)(object)PlayerAvatar.instance) && Object.op_Implicit((Object)(object)__instance.photonView) && !__instance.photonView.IsMine && Pending.Remove(__instance.photonView.OwnerActorNr))
		{
			TruckSafetySpawnPoint instance = TruckSafetySpawnPoint.instance;
			if (Object.op_Implicit((Object)(object)instance))
			{
				__0 = ((Component)instance).transform.position;
				__1 = ((Component)instance).transform.rotation;
			}
		}
	}
}
[HarmonyPatch]
internal static class LevelBoxes
{
	private static readonly MethodInfo LoopCount = AccessTools.Method(typeof(ValuableDirector), "CosmeticWorldObjectLevelLoopsClampedGet", (Type[])null, (Type[])null);

	private static readonly MethodInfo SpawnNative = AccessTools.Method(typeof(ValuableDirector), "SpawnCosmeticWorldObject", (Type[])null, (Type[])null);

	private static readonly FieldInfo TargetCount = AccessTools.Field(typeof(ValuableDirector), "cosmeticWorldObjectTargetAmount");

	internal static bool SpawnAllThisLevel { get; private set; }

	internal static void BeginLevel()
	{
		SpawnAllThisLevel = Plugin.AllBoxes.Value;
	}

	private static MethodBase TargetMethod()
	{
		return AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(ValuableDirector), "SetupHost", (Type[])null, (Type[])null));
	}

	private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> input, MethodBase original)
	{
		Type iterator = original.DeclaringType;
		FieldInfo indexes = iterator.GetFields(AccessTools.all).Single((FieldInfo f) => f.FieldType == typeof(int[]) && f.Name.Contains("volumeIndex"));
		FieldInfo volumes = iterator.GetFields(AccessTools.all).Single((FieldInfo f) => f.FieldType == typeof(List<ValuableVolume>[]));
		int matches = 0;
		foreach (CodeInstruction instruction in input)
		{
			if (!CodeInstructionExtensions.Calls(instruction, LoopCount))
			{
				yield return instruction;
				continue;
			}
			matches++;
			yield return CodeInstructionExtensions.MoveLabelsFrom(new CodeInstruction(OpCodes.Ldarg_0, (object)null), instruction);
			yield return new CodeInstruction(OpCodes.Ldfld, (object)indexes);
			yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
			yield return new CodeInstruction(OpCodes.Ldfld, (object)volumes);
			yield return new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LevelBoxes), "SpawnFour", (Type[])null, (Type[])null));
		}
		if (matches != 1)
		{
			throw new InvalidOperationException("Unsupported cosmetic generation layout");
		}
	}

	internal static bool ManualAvailable()
	{
		if (Session.Host && Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.Generated && SemiFunc.RunIsLevel() && Object.op_Implicit((Object)(object)TruckSafetySpawnPoint.instance))
		{
			return Object.op_Implicit((Object)(object)ValuableDirector.instance);
		}
		return false;
	}

	internal static bool SpawnManual(int tier)
	{
		if (tier < 0 || tier > 3 || !ManualAvailable())
		{
			return false;
		}
		return SpawnAtTruck(ValuableDirector.instance, tier);
	}

	private static bool SpawnAtTruck(ValuableDirector director, int tier)
	{
		//IL_005a: 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_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		TruckSafetySpawnPoint instance = TruckSafetySpawnPoint.instance;
		if (!Object.op_Implicit((Object)(object)instance) || director.cosmeticWorldObjectSetups == null || tier >= director.cosmeticWorldObjectSetups.Count)
		{
			return false;
		}
		CosmeticWorldObjectSetup val = director.cosmeticWorldObjectSetups[tier];
		if (val == null || val.prefab == null || string.IsNullOrEmpty(((PrefabRef<GameObject>)(object)val.prefab).ResourcePath))
		{
			return false;
		}
		Transform transform = ((Component)instance).transform;
		Vector3 val2 = transform.position + transform.right * (((float)tier - 1.5f) * 0.65f) + Vector3.up * 0.3f;
		GameObject val3 = ((SemiFunc.IsMultiplayer() || Session.Host) ? PhotonNetwork.InstantiateRoomObject(((PrefabRef<GameObject>)(object)val.prefab).ResourcePath, val2, transform.rotation, (byte)0, (object[])null) : Object.Instantiate<GameObject>(((PrefabRef<GameObject>)(object)val.prefab).Prefab, val2, transform.rotation));
		if (!Object.op_Implicit((Object)(object)val3))
		{
			return false;
		}
		TargetCount.SetValue(director, (int)TargetCount.GetValue(director) + 1);
		return true;
	}

	private static int SpawnFour(ValuableDirector director, int[] indexes, List<ValuableVolume>[] volumes)
	{
		if (!SpawnAllThisLevel)
		{
			return director.CosmeticWorldObjectLevelLoopsClampedGet();
		}
		for (int i = 0; i < 4; i++)
		{
			int num = (int)TargetCount.GetValue(director);
			SpawnNative.Invoke(director, new object[3]
			{
				(object)(Rarity)i,
				indexes,
				volumes
			});
			if ((int)TargetCount.GetValue(director) == num && !SpawnAtTruck(director, i))
			{
				Plugin.Log.LogError((object)("Could not spawn fallback box tier " + i));
			}
		}
		return -1;
	}
}
public sealed class Session : MonoBehaviourPunCallbacks, IOnEventCallback
{
	private const byte Channel = 176;

	private const string Key = "wauresy.rmp/1.1";

	private const string SingleTokenKey = "wauresy.rmp/single-token";

	internal static Session Current;

	internal bool microphoneBlocked;

	private readonly HashSet<int> muted = new HashSet<int>();

	private readonly Dictionary<string, int> pendingTokens = new Dictionary<string, int>();

	private readonly HashSet<string> received = new HashSet<string>();

	private bool incomplete;

	internal string Status = "";

	internal static bool Host
	{
		get
		{
			if (PhotonNetwork.InRoom)
			{
				return PhotonNetwork.IsMasterClient;
			}
			return false;
		}
	}

	internal static bool ManagedRoom
	{
		get
		{
			if (PhotonNetwork.InRoom)
			{
				if (!Host)
				{
					return Compatible(PhotonNetwork.MasterClient);
				}
				return true;
			}
			return false;
		}
	}

	private void Awake()
	{
		Current = this;
	}

	public override void OnJoinedRoom()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Expected O, but got Unknown
		Reset();
		Player localPlayer = PhotonNetwork.LocalPlayer;
		Hashtable val = new Hashtable();
		((Dictionary<object, object>)(object)val).Add((object)"wauresy.rmp/1.1", (object)true);
		((Dictionary<object, object>)(object)val).Add((object)"wauresy.rmp/single-token", (object)true);
		localPlayer.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
	}

	public override void OnLeftRoom()
	{
		Reset();
	}

	public override void OnMasterClientSwitched(Player next)
	{
		Reset();
	}

	private void Reset()
	{
		muted.Clear();
		received.Clear();
		pendingTokens.Clear();
		incomplete = false;
		microphoneBlocked = false;
		Status = "";
	}

	public override void OnPlayerLeftRoom(Player p)
	{
		muted.Remove(p.ActorNumber);
		string[] array = (from x in pendingTokens
			where x.Value == p.ActorNumber
			select x.Key).ToArray();
		foreach (string key in array)
		{
			pendingTokens.Remove(key);
			incomplete = true;
			Status = "Player left before confirming tokens.";
		}
	}

	internal static bool Compatible(Player p)
	{
		if (p != null)
		{
			if (!p.IsLocal)
			{
				return object.Equals(p.CustomProperties[(object)"wauresy.rmp/1.1"], true);
			}
			return true;
		}
		return false;
	}

	internal static bool Valid(Player p)
	{
		if (p != null && PhotonNetwork.CurrentRoom != null && PhotonNetwork.CurrentRoom.GetPlayer(p.ActorNumber, false) == p && ulong.TryParse(p.UserId, out var result))
		{
			return result >> 32 == 17825793;
		}
		return false;
	}

	private static bool Send(Player p, string op, string nonce, string value, int number)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Expected O, but got Unknown
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		object[] obj = new object[5] { "wauresy.rmp/1.1", op, nonce, value, number };
		RaiseEventOptions val = new RaiseEventOptions();
		val.TargetActors = new int[1] { p.ActorNumber };
		return PhotonNetwork.RaiseEvent((byte)176, (object)obj, val, SendOptions.SendReliable);
	}

	public void OnEvent(EventData e)
	{
		if (e.Code != 176 || !PhotonNetwork.InRoom || !(e.CustomData is object[] array) || array.Length != 5 || !object.Equals(array[0], "wauresy.rmp/1.1") || !(array[4] is int))
		{
			return;
		}
		string text = array[1] as string;
		string text2 = array[2] as string;
		if (text == "receipt")
		{
			if (Host && text2 != null && pendingTokens.TryGetValue(text2, out var value) && value == e.Sender && pendingTokens.Remove(text2))
			{
				Status = ((pendingTokens.Count != 0) ? ("Waiting for " + pendingTokens.Count + " token receipts.") : (incomplete ? "Some tokens were not confirmed." : "Token delivery confirmed."));
			}
		}
		else if (e.Sender == PhotonNetwork.MasterClient.ActorNumber && !PhotonNetwork.IsMasterClient)
		{
			if (text == "mute")
			{
				microphoneBlocked = (int)array[4] != 0;
			}
			int num = (int)array[4];
			if ((text == "tokens" || (text == "singleToken" && num >= 0 && num < 4)) && !string.IsNullOrEmpty(text2) && received.Add(text2))
			{
				((MonoBehaviour)this).StartCoroutine(GrantWhenReady(PhotonNetwork.CurrentRoom, PhotonNetwork.MasterClient, text2, (text == "tokens") ? (-1) : num));
			}
		}
	}

	private IEnumerator GrantWhenReady(Room room, Player host, string nonce, int tier)
	{
		while (room == PhotonNetwork.CurrentRoom && host == PhotonNetwork.MasterClient)
		{
			if (Object.op_Implicit((Object)(object)MetaManager.instance) && Object.op_Implicit((Object)(object)CosmeticTokenUI.instance))
			{
				GiveLocal(tier);
				Send(host, "receipt", nonce, "", 0);
				break;
			}
			yield return (object)new WaitForSecondsRealtime(0.25f);
		}
	}

	private static void GiveLocal(int tier)
	{
		if (tier >= 0)
		{
			MetaManager.instance.CosmeticTokenAdd((Rarity)tier);
			return;
		}
		for (int i = 0; i < 4; i++)
		{
			MetaManager.instance.CosmeticTokenAdd((Rarity)i);
		}
	}

	internal static bool SupportsSingle(Player p)
	{
		if (p != null)
		{
			if (!p.IsLocal)
			{
				return object.Equals(p.CustomProperties[(object)"wauresy.rmp/single-token"], true);
			}
			return true;
		}
		return false;
	}

	private void Deliver(Player p, int tier)
	{
		if (p.IsLocal)
		{
			GiveLocal(tier);
			return;
		}
		string text = Guid.NewGuid().ToString("N");
		if (Send(p, (tier < 0) ? "tokens" : "singleToken", text, "", Math.Max(0, tier)))
		{
			pendingTokens.Add(text, p.ActorNumber);
			Status = "Waiting for token delivery.";
		}
		else
		{
			incomplete = true;
			Status = "Token delivery failed.";
		}
	}

	internal void GiveSingle(Player p, int tier)
	{
		if (!Host || !SupportsSingle(p) || PhotonNetwork.CurrentRoom.GetPlayer(p.ActorNumber, false) != p || tier < 0 || tier > 3)
		{
			return;
		}
		if (p.IsLocal && (!Object.op_Implicit((Object)(object)MetaManager.instance) || !Object.op_Implicit((Object)(object)CosmeticTokenUI.instance)))
		{
			Status = "Token inventory is loading.";
			return;
		}
		if (pendingTokens.Count == 0)
		{
			incomplete = false;
		}
		Status = "Added one token to " + p.NickName + ".";
		Deliver(p, tier);
	}

	internal void GiveEveryone()
	{
		if (!Host || !Object.op_Implicit((Object)(object)MetaManager.instance) || !Object.op_Implicit((Object)(object)CosmeticTokenUI.instance) || !PhotonNetwork.PlayerList.All(Compatible))
		{
			return;
		}
		if (pendingTokens.Count > 0)
		{
			Status = "Waiting for previous token receipts.";
			return;
		}
		incomplete = false;
		Status = "Added one of each token.";
		Player[] playerList = PhotonNetwork.PlayerList;
		foreach (Player p in playerList)
		{
			Deliver(p, -1);
		}
	}

	internal bool Muted(Player p)
	{
		return muted.Contains(p.ActorNumber);
	}

	internal void ToggleMute(Player p)
	{
		if (!Host || !Valid(p) || p.IsLocal || !Compatible(p))
		{
			return;
		}
		bool flag = !Muted(p);
		if (Send(p, "mute", "", "", flag ? 1 : 0))
		{
			if (flag)
			{
				muted.Add(p.ActorNumber);
			}
			else
			{
				muted.Remove(p.ActorNumber);
			}
		}
	}

	internal static Dictionary<string, string> Bans()
	{
		Dictionary<string, string> dictionary = new Dictionary<string, string>();
		string[] array = Plugin.BanData.Value.Split(',');
		foreach (string text in array)
		{
			string[] array2 = text.Split(':');
			if (array2.Length == 2)
			{
				try
				{
					dictionary[array2[0]] = Encoding.UTF8.GetString(Convert.FromBase64String(array2[1]));
				}
				catch (FormatException)
				{
					dictionary[array2[0]] = "Unknown";
				}
			}
		}
		return dictionary;
	}

	private static void Save(Dictionary<string, string> bans)
	{
		Plugin.BanData.Value = string.Join(",", bans.Select((KeyValuePair<string, string> x) => x.Key + ":" + Convert.ToBase64String(Encoding.UTF8.GetBytes(x.Value))).ToArray());
		((ConfigEntryBase)Plugin.BanData).ConfigFile.Save();
	}

	internal void Unban(string id)
	{
		if (Host)
		{
			Dictionary<string, string> dictionary = Bans();
			if (dictionary.Remove(id))
			{
				Save(dictionary);
			}
		}
	}

	internal void Remove(Player p, bool ban)
	{
		if (Host && Valid(p) && !p.IsLocal && Object.op_Implicit((Object)(object)NetworkManager.instance))
		{
			if (ban)
			{
				Dictionary<string, string> dictionary = Bans();
				dictionary[p.UserId] = p.NickName ?? "";
				Save(dictionary);
			}
			Plugin.Log.LogInfo((object)("Host moderation disconnect, actor " + p.ActorNumber));
			NetworkManager.instance.KickPlayer(p);
		}
	}

	public override void OnPlayerEnteredRoom(Player p)
	{
		if (Host && Valid(p) && Bans().ContainsKey(p.UserId))
		{
			((MonoBehaviour)this).StartCoroutine(EnforceBan(p));
		}
	}

	private IEnumerator EnforceBan(Player p)
	{
		while (Host && Valid(p))
		{
			if (Object.op_Implicit((Object)(object)NetworkManager.instance))
			{
				if (Bans().ContainsKey(p.UserId))
				{
					Plugin.Log.LogInfo((object)("Host ban disconnect, actor " + p.ActorNumber));
					NetworkManager.instance.KickPlayer(p);
				}
				break;
			}
			yield return (object)new WaitForSecondsRealtime(0.2f);
		}
	}
}
[HarmonyPatch(typeof(PlayerVoiceChat), "TransmitEnabledTick")]
internal static class MutedMicrophone
{
	private static bool Prefix(PlayerVoiceChat __instance, Recorder ___recorder)
	{
		if (!Object.op_Implicit((Object)(object)Session.Current) || !Session.Current.microphoneBlocked || !Object.op_Implicit((Object)(object)___recorder))
		{
			return true;
		}
		PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
		if (!Object.op_Implicit((Object)(object)component) || !component.IsMine)
		{
			return true;
		}
		if (___recorder.TransmitEnabled)
		{
			___recorder.TransmitEnabled = false;
		}
		return false;
	}
}