Decompiled source of REPO PVP v1.0.0

Celling.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using RepoMods.PVP;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+bf6bd61ad1cd75a34f8c445711a37e032a8fe412")]
[assembly: AssemblyProduct("Celling")]
[assembly: AssemblyTitle("Celling")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Empress.RepoMods
{
	[BepInPlugin("com.empress.repo.logo-replacer", "REPO Logo Replacer", "1.0.0")]
	public sealed class RepoLogoReplacer : BaseUnityPlugin
	{
		[HarmonyPatch]
		internal static class ResourcesLoadPatch
		{
			private static MethodBase TargetMethod()
			{
				return AccessTools.Method(typeof(Resources), "Load", new Type[2]
				{
					typeof(string),
					typeof(Type)
				}, (Type[])null);
			}

			private static void Postfix(string path, Type systemTypeInstance, ref Object __result)
			{
				if (__result == (Object)null)
				{
					return;
				}
				try
				{
					bool flag = false;
					if (!string.IsNullOrEmpty(path))
					{
						string text = path.Replace('\\', '/').Split('/')?.LastOrDefault();
						if (!string.IsNullOrEmpty(text))
						{
							flag = string.Equals(text, "repo_logo_shadow_alpha", StringComparison.OrdinalIgnoreCase) || string.Equals(text, "repo_logo_shadow_alpha.png", StringComparison.OrdinalIgnoreCase);
						}
					}
					if (systemTypeInstance == typeof(Sprite) || __result is Sprite)
					{
						Object obj = __result;
						Sprite val = (Sprite)(object)((obj is Sprite) ? obj : null);
						if ((flag || ((Object)(object)val != (Object)null && string.Equals(((Object)val).name, "repo_logo_shadow_alpha", StringComparison.OrdinalIgnoreCase))) && (Object)(object)ReplacementSprite != (Object)null)
						{
							__result = (Object)(object)ReplacementSprite;
						}
					}
					else if (systemTypeInstance == typeof(Texture2D) || __result is Texture2D)
					{
						Object obj2 = __result;
						Texture2D val2 = (Texture2D)(object)((obj2 is Texture2D) ? obj2 : null);
						if ((flag || ((Object)(object)val2 != (Object)null && string.Equals(((Object)val2).name, "repo_logo_shadow_alpha", StringComparison.OrdinalIgnoreCase))) && (Object)(object)ReplacementTexture != (Object)null)
						{
							__result = (Object)(object)ReplacementTexture;
						}
					}
				}
				catch (Exception arg)
				{
					ManualLogSource logS = LogS;
					if (logS != null)
					{
						logS.LogError((object)$"Resources.Load Postfix error: {arg}");
					}
				}
			}
		}

		[CompilerGenerated]
		private sealed class <DelayedSweep>d__10 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float delay;

			public RepoLogoReplacer <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DelayedSweep>d__10(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					TryReplaceInAll();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <RepeatedSweep>d__11 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float duration;

			public float interval;

			public RepoLogoReplacer <>4__this;

			private float <t>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <RepeatedSweep>d__11(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0045: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<t>5__1 = 0f;
					break;
				case 1:
					<>1__state = -1;
					<t>5__1 += interval;
					break;
				}
				if (<t>5__1 < duration)
				{
					TryReplaceInAll();
					<>2__current = (object)new WaitForSeconds(interval);
					<>1__state = 1;
					return true;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public const string PluginGuid = "com.empress.repo.logo-replacer";

		public const string PluginName = "REPO Logo Replacer";

		public const string PluginVersion = "1.0.0";

		private const string TargetSpriteName = "repo_logo_shadow_alpha";

		private const string TargetPngFileName = "repo_logo_shadow_alpha.png";

		internal static ManualLogSource LogS;

		internal static Sprite ReplacementSprite;

		internal static Texture2D ReplacementTexture;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			LogS = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("com.empress.repo.logo-replacer");
			try
			{
				LoadReplacementFromDisk();
			}
			catch (Exception arg)
			{
				LogS.LogError((object)$"Failed to load replacement PNG: {arg}");
			}
			try
			{
				_harmony.PatchAll(typeof(ResourcesLoadPatch));
			}
			catch (Exception arg2)
			{
				LogS.LogError((object)$"Failed to patch Resources.Load: {arg2}");
			}
			SceneManager.sceneLoaded += OnSceneLoaded;
			((MonoBehaviour)this).StartCoroutine(DelayedSweep(0.25f));
		}

		[IteratorStateMachine(typeof(<DelayedSweep>d__10))]
		private IEnumerator DelayedSweep(float delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DelayedSweep>d__10(0)
			{
				<>4__this = this,
				delay = delay
			};
		}

		[IteratorStateMachine(typeof(<RepeatedSweep>d__11))]
		private IEnumerator RepeatedSweep(float duration, float interval)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <RepeatedSweep>d__11(0)
			{
				<>4__this = this,
				duration = duration,
				interval = interval
			};
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			((MonoBehaviour)this).StartCoroutine(RepeatedSweep(2f, 0.15f));
		}

		private static void TryReplaceInAll()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//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)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ReplacementSprite == (Object)null)
			{
				Sprite val = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).FirstOrDefault((Func<Sprite, bool>)((Sprite s) => Object.op_Implicit((Object)(object)s) && string.Equals(((Object)s).name, "repo_logo_shadow_alpha", StringComparison.OrdinalIgnoreCase)));
				if ((Object)(object)val != (Object)null && (Object)(object)ReplacementTexture != (Object)null)
				{
					Texture2D replacementTexture = ReplacementTexture;
					Rect val2 = new Rect(0f, 0f, (float)((Texture)ReplacementTexture).width, (float)((Texture)ReplacementTexture).height);
					Vector2 pivot = val.pivot;
					Rect rect = val.rect;
					ReplacementSprite = Sprite.Create(replacementTexture, val2, pivot / ((Rect)(ref rect)).size, val.pixelsPerUnit, 0u, (SpriteMeshType)1);
					((Object)ReplacementSprite).name = "repo_logo_shadow_alpha";
				}
			}
			int num = 0;
			if ((Object)(object)ReplacementSprite != (Object)null)
			{
				Image[] array = Resources.FindObjectsOfTypeAll<Image>();
				foreach (Image val3 in array)
				{
					if (!((Object)(object)val3 == (Object)null))
					{
						Sprite sprite = val3.sprite;
						if ((Object)(object)sprite != (Object)null && string.Equals(((Object)sprite).name, "repo_logo_shadow_alpha", StringComparison.OrdinalIgnoreCase))
						{
							val3.sprite = ReplacementSprite;
							((Graphic)val3).SetAllDirty();
							num++;
						}
					}
				}
				SpriteRenderer[] array2 = Resources.FindObjectsOfTypeAll<SpriteRenderer>();
				foreach (SpriteRenderer val4 in array2)
				{
					if (!((Object)(object)val4 == (Object)null))
					{
						Sprite sprite2 = val4.sprite;
						if ((Object)(object)sprite2 != (Object)null && string.Equals(((Object)sprite2).name, "repo_logo_shadow_alpha", StringComparison.OrdinalIgnoreCase))
						{
							val4.sprite = ReplacementSprite;
							num++;
						}
					}
				}
			}
			if (!((Object)(object)ReplacementTexture != (Object)null))
			{
				return;
			}
			RawImage[] array3 = Resources.FindObjectsOfTypeAll<RawImage>();
			foreach (RawImage val5 in array3)
			{
				if (!((Object)(object)val5 == (Object)null))
				{
					Texture texture = val5.texture;
					Texture2D val6 = (Texture2D)(object)((texture is Texture2D) ? texture : null);
					if ((Object)(object)val6 != (Object)null && string.Equals(((Object)val6).name, "repo_logo_shadow_alpha", StringComparison.OrdinalIgnoreCase))
					{
						val5.texture = (Texture)(object)ReplacementTexture;
						((Graphic)val5).SetAllDirty();
						num++;
					}
				}
			}
		}

		private void OnDestroy()
		{
			if (_harmony != null)
			{
				try
				{
					_harmony.UnpatchSelf();
				}
				catch
				{
				}
			}
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}

		private static void LoadReplacementFromDisk()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			string directoryName = Path.GetDirectoryName(typeof(RepoLogoReplacer).Assembly.Location);
			if (string.IsNullOrEmpty(directoryName))
			{
				ManualLogSource logS = LogS;
				if (logS != null)
				{
					logS.LogWarning((object)"Assembly location unknown; cannot load replacement image.");
				}
				return;
			}
			string text = Path.Combine(directoryName, "repo_logo_shadow_alpha.png");
			if (!File.Exists(text))
			{
				ManualLogSource logS2 = LogS;
				if (logS2 != null)
				{
					logS2.LogWarning((object)("Replacement PNG not found: " + text));
				}
				return;
			}
			byte[] array = File.ReadAllBytes(text);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false, true);
			if (!ImageConversion.LoadImage(val, array, false))
			{
				ManualLogSource logS3 = LogS;
				if (logS3 != null)
				{
					logS3.LogError((object)"Texture2D.LoadImage returned false for replacement PNG.");
				}
				Object.Destroy((Object)(object)val);
			}
			else
			{
				((Object)val).name = "repo_logo_shadow_alpha";
				((Texture)val).wrapMode = (TextureWrapMode)1;
				((Texture)val).filterMode = (FilterMode)1;
				ReplacementTexture = val;
				ReplacementSprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)1);
				((Object)ReplacementSprite).name = "repo_logo_shadow_alpha";
			}
		}
	}
}
namespace RepoMods.PVP
{
	public class PvpBullet : MonoBehaviour
	{
		public PvpManager Manager;

		public bool VisualOnly;

		public int Damage = 10;

		public float Life = 3f;

		public int OwnerActor = -1;

		public bool Explosive = false;

		public float ArmingTime = 0.1f;

		public Collider[] IgnoreOwnerColliders;

		private float _dieAt;

		private float _bornAt;

		private Collider _col;

		private void Start()
		{
			_bornAt = Time.time;
			_dieAt = Time.time + Mathf.Max(0.2f, Life);
			_col = ((Component)this).GetComponent<Collider>();
			if (!((Object)(object)_col != (Object)null) || IgnoreOwnerColliders == null)
			{
				return;
			}
			Collider[] ignoreOwnerColliders = IgnoreOwnerColliders;
			foreach (Collider val in ignoreOwnerColliders)
			{
				if ((Object)(object)val != (Object)null)
				{
					Physics.IgnoreCollision(_col, val, true);
				}
			}
		}

		private void Update()
		{
			if (Time.time >= _dieAt)
			{
				TryVanish();
			}
		}

		private void OnTriggerEnter(Collider other)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: 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_0186: Unknown result type (might be due to invalid IL or missing references)
			if (VisualOnly || Time.time < _bornAt + ArmingTime)
			{
				return;
			}
			try
			{
				PvpShield componentInParent = ((Component)other).GetComponentInParent<PvpShield>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					if (componentInParent.OwnerActor != OwnerActor)
					{
						if (Explosive)
						{
							SpawnExpandingHazard(((Component)this).transform.position);
						}
						TryVanish();
					}
					return;
				}
				PlayerAvatar val = (Object.op_Implicit((Object)(object)other) ? ((Component)other).GetComponentInParent<PlayerAvatar>() : null);
				if ((Object)(object)val != (Object)null && (Object)(object)val.photonView != (Object)null && val.photonView.Owner != null)
				{
					int ownerActorNr = val.photonView.OwnerActorNr;
					if (OwnerActor >= 0 && ownerActorNr == OwnerActor)
					{
						return;
					}
					int num = Damage;
					if ((Object)(object)Manager != (Object)null && Manager.HasPowerup(ownerActorNr, PvpManager.PvpPowerupType.Shield))
					{
						num = Mathf.RoundToInt((float)num * 0.6f);
					}
					Vector3 position = ((Component)this).transform.position;
					if (PhotonNetwork.IsMasterClient)
					{
						PlayerHealth component = ((Component)val).GetComponent<PlayerHealth>();
						if ((Object)(object)component != (Object)null)
						{
							component.HurtOther(Mathf.Max(1, num), position, false, -1);
						}
						if (Explosive)
						{
							SpawnExpandingHazard(position);
						}
					}
					else
					{
						PvpEvt.SendMaster(15, OwnerActor, ownerActorNr, Mathf.Max(1, num), position.x, position.y, position.z, Explosive ? 1 : 0);
					}
					TryVanish();
				}
				else if (Explosive)
				{
					SpawnExpandingHazard(((Component)this).transform.position);
					TryVanish();
				}
			}
			catch (Exception ex)
			{
				PvpPlugin.Logger.LogWarning((object)("[PVP] Bullet trigger: " + ex.Message));
				TryVanish();
			}
		}

		private void SpawnExpandingHazard(Vector3 pos)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Manager != (Object)null)
			{
				Manager.SpawnExplosionHazard(pos, Damage, OwnerActor);
			}
		}

		private void TryVanish()
		{
			try
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar))]
	internal static class PvpDeathHook
	{
		[HarmonyPostfix]
		[HarmonyPatch("PlayerDeathRPC")]
		private static void Post_PlayerDeathRPC(PlayerAvatar __instance)
		{
			if (PhotonNetwork.IsMasterClient && !((Object)(object)PvpManager.Instance == (Object)null) && PvpManager.Instance.IsArmed && !((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.photonView == (Object)null))
			{
				PvpManager.Instance.MasterOnPlayerDeath(__instance);
			}
		}
	}
	public class PvpEventManager : MonoBehaviourPunCallbacks, IOnEventCallback
	{
		public static PvpEventManager Instance { get; private set; }

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}

		private void OnEnable()
		{
			if (PhotonNetwork.NetworkingClient != null)
			{
				PhotonNetwork.AddCallbackTarget((object)this);
			}
		}

		private void OnDisable()
		{
			PhotonNetwork.RemoveCallbackTarget((object)this);
		}

		public void OnEvent(EventData photonEvent)
		{
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0548: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_055c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (photonEvent.Code != 45 || !(photonEvent.CustomData is object[] array) || array.Length < 2 || !(array[0] is string text) || text != "PVP1")
				{
					return;
				}
				switch ((byte)array[1])
				{
				case 1:
					if (array.Length >= 3 && array[2] is float[] packed)
					{
						PvpManager.Instance?.ApplySpawnPointsFromMaster(packed);
					}
					break;
				case 2:
				{
					if (array.Length < 6 || !ToInt(array[2], out var val3))
					{
						break;
					}
					object obj = array[3];
					if (!(obj is float))
					{
						break;
					}
					float num2 = (float)obj;
					if (1 == 0)
					{
						break;
					}
					obj = array[4];
					if (!(obj is float))
					{
						break;
					}
					float num3 = (float)obj;
					if (1 == 0)
					{
						break;
					}
					obj = array[5];
					if (obj is float)
					{
						float num4 = (float)obj;
						if (true)
						{
							PvpManager.Instance?.SpawnPowerupVisual(val3, new Vector3(num2, num3, num4));
						}
					}
					break;
				}
				case 5:
					if (array.Length >= 3 && array[2] is float[] packed2)
					{
						PvpManager.Instance?.ApplyPortalsFromMaster(packed2);
					}
					break;
				case 3:
				{
					if (array.Length < 7 || !ToInt(array[2], out var val4) || !ToInt(array[3], out var val5))
					{
						break;
					}
					float num5 = Convert.ToSingle(array[4]);
					float num6 = Convert.ToSingle(array[5]);
					float num7 = Convert.ToSingle(array[6]);
					Vector3 val6 = default(Vector3);
					((Vector3)(ref val6))..ctor(num5, num6, num7);
					if (PhotonNetwork.IsMasterClient)
					{
						int sender = photonEvent.Sender;
						Player localPlayer = PhotonNetwork.LocalPlayer;
						if (sender != ((localPlayer != null) ? localPlayer.ActorNumber : (-1)))
						{
							PvpManager.Instance?.ApplyPowerup(val4, (PvpManager.PvpPowerupType)val5, broadcast: false);
							PvpManager.Instance?.HandlePowerupPickedAt((PvpManager.PvpPowerupType)val5, val6);
							PvpEvt.SendAll(3, val4, val5, val6.x, val6.y, val6.z);
							break;
						}
					}
					PvpManager.Instance?.ApplyPowerup(val4, (PvpManager.PvpPowerupType)val5, broadcast: false);
					PvpManager.Instance?.HandlePowerupPickedAt((PvpManager.PvpPowerupType)val5, val6);
					break;
				}
				case 4:
					if (array.Length >= 6)
					{
						Vector3 pos = (Vector3)array[2];
						Vector3 dir = (Vector3)array[3];
						float speed = Convert.ToSingle(array[4]);
						float life = Convert.ToSingle(array[5]);
						PvpManager.Instance?.SpawnBulletVisual(pos, dir, speed, life, visualOnly: true, null, -1);
					}
					break;
				case 10:
				{
					int[] actors = (int[])array[2];
					int[] lives = (int[])array[3];
					int[] wins = (int[])array[4];
					int[] rounds = null;
					if (array.Length >= 6 && array[5] is int[])
					{
						rounds = (int[])array[5];
					}
					PvpManager.Instance?.ApplyRoundSync(actors, lives, wins, rounds);
					break;
				}
				case 11:
				{
					int winnerActor = Convert.ToInt32(array[2]);
					PvpManager.Instance?.AnnounceWinner(winnerActor);
					break;
				}
				case 12:
					PvpManager.Instance?.OnRoundResetAnnounce();
					break;
				case 15:
				{
					if (!PhotonNetwork.IsMasterClient)
					{
						break;
					}
					int ownerActor = Convert.ToInt32(array[2]);
					int actor2 = Convert.ToInt32(array[3]);
					int num = Convert.ToInt32(array[4]);
					Vector3 val = default(Vector3);
					((Vector3)(ref val))..ctor(Convert.ToSingle(array[5]), Convert.ToSingle(array[6]), Convert.ToSingle(array[7]));
					bool flag = array.Length >= 9 && Convert.ToInt32(array[8]) != 0;
					PvpManager instance = PvpManager.Instance;
					if ((Object)(object)instance == (Object)null)
					{
						break;
					}
					PlayerAvatar val2 = instance.FindAvatarByActor(actor2);
					if (!((Object)(object)val2 == (Object)null))
					{
						if (instance.HasPowerup(actor2, PvpManager.PvpPowerupType.Shield))
						{
							num = Mathf.RoundToInt((float)num * 0.6f);
						}
						PlayerHealth component = ((Component)val2).GetComponent<PlayerHealth>();
						if ((Object)(object)component != (Object)null && num > 0)
						{
							component.HurtOther(Mathf.Max(1, num), val, false, -1);
						}
						if (flag)
						{
							instance.SpawnExplosionHazard(val, Mathf.Max(1, num), ownerActor);
						}
					}
					break;
				}
				case 16:
					if (array.Length >= 4)
					{
						int actor = Convert.ToInt32(array[2]);
						int typeOrMinus = Convert.ToInt32(array[3]);
						PvpManager.Instance?.ShowGunFlash(actor, typeOrMinus, 0.2f);
					}
					break;
				case 6:
				case 7:
				case 8:
				case 9:
				case 13:
				case 14:
					break;
				}
			}
			catch (Exception ex)
			{
				PvpPlugin.Logger.LogWarning((object)("[PVP] OnEvent guarded: " + ex.Message));
			}
		}

		private static bool ToInt(object o, out int val)
		{
			try
			{
				if (o is int num)
				{
					val = num;
					return true;
				}
				if (o is byte b)
				{
					val = b;
					return true;
				}
				if (o is short num2)
				{
					val = num2;
					return true;
				}
				if (o is long num3)
				{
					val = (int)num3;
					return true;
				}
				if (o is float num4)
				{
					val = (int)num4;
					return true;
				}
				if (o is double num5)
				{
					val = (int)num5;
					return true;
				}
				if (o is string s && int.TryParse(s, out var result))
				{
					val = result;
					return true;
				}
			}
			catch
			{
			}
			val = -1;
			return false;
		}
	}
	internal static class PvpEvt
	{
		internal const byte EVT_CODE = 45;

		internal const string TAG = "PVP1";

		internal const byte SPAWN_POINTS = 1;

		internal const byte SPAWN_POWERUPS = 2;

		internal const byte PICKUP_POWERUP = 3;

		internal const byte BULLET_VISUAL = 4;

		internal const byte SPAWN_PORTALS = 5;

		internal const byte GUN_SHOT = 16;

		internal const byte ROUND_SYNC = 10;

		internal const byte ROUND_WIN = 11;

		internal const byte ROUND_RESET = 12;

		internal const byte DAMAGE_HIT = 15;

		internal static readonly RaiseEventOptions ToAll = new RaiseEventOptions
		{
			Receivers = (ReceiverGroup)1
		};

		internal static readonly RaiseEventOptions ToOthers = new RaiseEventOptions
		{
			Receivers = (ReceiverGroup)0
		};

		internal static readonly RaiseEventOptions ToMaster = new RaiseEventOptions
		{
			Receivers = (ReceiverGroup)2
		};

		internal static readonly SendOptions Reliable;

		internal static readonly SendOptions Unreliable;

		internal static void SendAll(byte innerId, params object[] args)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			PhotonNetwork.RaiseEvent((byte)45, (object)Build(innerId, args), ToAll, Reliable);
		}

		internal static void SendOthers(byte innerId, params object[] args)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			PhotonNetwork.RaiseEvent((byte)45, (object)Build(innerId, args), ToOthers, Unreliable);
		}

		internal static void SendMaster(byte innerId, params object[] args)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			PhotonNetwork.RaiseEvent((byte)45, (object)Build(innerId, args), ToMaster, Reliable);
		}

		private static object[] Build(byte innerId, object[] args)
		{
			object[] array = new object[2 + ((args != null) ? args.Length : 0)];
			array[0] = "PVP1";
			array[1] = innerId;
			if (args != null && args.Length != 0)
			{
				Array.Copy(args, 0, array, 2, args.Length);
			}
			return array;
		}

		static PvpEvt()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0022: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_004c: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			SendOptions val = default(SendOptions);
			((SendOptions)(ref val)).Reliability = true;
			Reliable = val;
			val = default(SendOptions);
			((SendOptions)(ref val)).Reliability = false;
			Unreliable = val;
		}
	}
	public class PvpExplosionHazard : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <CoGrow>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float dur;

			public PvpExplosionHazard <>4__this;

			private float <t>5__1;

			private float <k>5__2;

			private float <radius>5__3;

			private Color <c>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <CoGrow>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0096: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_012d: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<t>5__1 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<t>5__1 < dur)
				{
					<t>5__1 += Time.deltaTime;
					<k>5__2 = <t>5__1 / dur;
					<radius>5__3 = Mathf.Lerp(0.1f, 2.2f, <k>5__2);
					<>4__this._col.radius = <radius>5__3;
					((Component)<>4__this).transform.localScale = Vector3.one * <radius>5__3;
					if ((Object)(object)<>4__this._mr != (Object)null && ((Renderer)<>4__this._mr).material.HasProperty("_Color"))
					{
						<c>5__4 = ((Renderer)<>4__this._mr).material.color;
						<c>5__4.a = Mathf.Lerp(0.35f, 0f, <k>5__2);
						((Renderer)<>4__this._mr).material.color = <c>5__4;
					}
					<>4__this._touchedThisFrame.Clear();
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				try
				{
					Object.Destroy((Object)(object)((Component)<>4__this).gameObject);
				}
				catch
				{
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private SphereCollider _col;

		private MeshRenderer _mr;

		private int _ownerActor;

		private int _baseDamage;

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

		public void Init(float duration, int damage, int ownerActor)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			float dur = Mathf.Max(0.1f, duration);
			_ownerActor = ownerActor;
			_baseDamage = Mathf.Max(1, damage);
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)val).name = "Visual";
			val.transform.SetParent(((Component)this).transform, false);
			val.transform.localPosition = Vector3.zero;
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
			_mr = val.GetComponent<MeshRenderer>();
			if ((Object)(object)_mr != (Object)null)
			{
				((Renderer)_mr).material = PvpManager.BuildTranslucentMat(new Color(1f, 0.5f, 0.1f, 0.35f));
			}
			_col = ((Component)this).gameObject.AddComponent<SphereCollider>();
			((Collider)_col).isTrigger = true;
			_col.radius = 0.1f;
			((MonoBehaviour)this).StartCoroutine(CoGrow(dur));
		}

		[IteratorStateMachine(typeof(<CoGrow>d__6))]
		private IEnumerator CoGrow(float dur)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <CoGrow>d__6(0)
			{
				<>4__this = this,
				dur = dur
			};
		}

		private void OnTriggerStay(Collider other)
		{
			TryDamage(other);
		}

		private void OnTriggerEnter(Collider other)
		{
			TryDamage(other);
		}

		private void TryDamage(Collider other)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				PlayerAvatar componentInParent = ((Component)other).GetComponentInParent<PlayerAvatar>();
				if ((Object)(object)componentInParent == (Object)null || (Object)(object)componentInParent.photonView == (Object)null)
				{
					return;
				}
				int ownerActorNr = componentInParent.photonView.OwnerActorNr;
				if (ownerActorNr != _ownerActor && !_touchedThisFrame.Contains(ownerActorNr))
				{
					PlayerHealth component = ((Component)componentInParent).GetComponent<PlayerHealth>();
					if ((Object)(object)component != (Object)null)
					{
						int num = Mathf.Max(1, Mathf.RoundToInt((float)_baseDamage * 0.35f));
						component.HurtOther(num, Vector3.zero, false, -1);
						_touchedThisFrame.Add(ownerActorNr);
					}
				}
			}
			catch
			{
			}
		}
	}
	public class PvpGun : MonoBehaviour
	{
		public static readonly HashSet<int> PlayersShootingGuns = new HashSet<int>();

		public static readonly Vector3 ShootingArmPose = new Vector3(0f, -90f, 0f);

		private PvpManager _mgr;

		private int _actor;

		private Transform _root;

		private MeshRenderer _barrelMr;

		private MeshRenderer _gripMr;

		private float _hideAt;

		private int _lastType = int.MinValue;

		private bool _isLocalPlayer;

		private int _avatarViewId = -1;

		public void Setup(PvpManager mgr, int actor)
		{
			_mgr = mgr;
			_actor = actor;
			Player localPlayer = PhotonNetwork.LocalPlayer;
			_isLocalPlayer = localPlayer != null && localPlayer.ActorNumber == actor;
			PlayerAvatar val = _mgr.FindAvatarByActor(_actor);
			if ((Object)(object)val != (Object)null && (Object)(object)val.photonView != (Object)null)
			{
				_avatarViewId = val.photonView.ViewID;
			}
			if ((Object)(object)_root == (Object)null)
			{
				Build();
			}
		}

		private void Build()
		{
			//IL_0007: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			_root = new GameObject("GunVisual").transform;
			_root.SetParent(((Component)this).transform, false);
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val).name = "Barrel";
			val.transform.SetParent(_root, false);
			val.transform.localScale = new Vector3(0.28f, 0.08f, 0.08f);
			val.transform.localPosition = new Vector3(0.12f, 0.02f, 0f);
			_barrelMr = val.GetComponent<MeshRenderer>();
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
			GameObject val2 = GameObject.CreatePrimitive((PrimitiveType)3);
			((Object)val2).name = "Grip";
			val2.transform.SetParent(_root, false);
			val2.transform.localScale = new Vector3(0.08f, 0.15f, 0.06f);
			val2.transform.localPosition = new Vector3(-0.02f, -0.06f, -0.02f);
			val2.transform.localRotation = Quaternion.Euler(0f, 0f, -15f);
			_gripMr = val2.GetComponent<MeshRenderer>();
			Object.Destroy((Object)(object)val2.GetComponent<Collider>());
			((Component)_root).gameObject.SetActive(false);
		}

		public void Show(int typeOrMinus1, float duration)
		{
			if ((Object)(object)_root == (Object)null)
			{
				Build();
			}
			ApplyStyle(typeOrMinus1);
			((Component)_root).gameObject.SetActive(true);
			_hideAt = Time.time + Mathf.Max(0.05f, duration);
			if (_avatarViewId >= 0)
			{
				PlayersShootingGuns.Add(_avatarViewId);
			}
		}

		private void LateUpdate()
		{
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_mgr == (Object)null)
			{
				return;
			}
			PlayerAvatar val = _mgr.FindAvatarByActor(_actor);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			if (_isLocalPlayer)
			{
				Transform val2 = (((Object)(object)((Component)val).transform.parent != (Object)null) ? ((Component)val).transform.parent.Find("Local Camera") : null);
				if ((Object)(object)val2 != (Object)null && (Object)(object)((Component)this).transform.parent != (Object)(object)val2)
				{
					((Component)this).transform.SetParent(val2, false);
					((Component)this).transform.localPosition = new Vector3(0.2f, -0.15f, 0.265f);
					((Component)this).transform.localRotation = Quaternion.Euler(17f, 17f, 5f);
					((Component)this).transform.localScale = Vector3.one;
				}
			}
			else
			{
				PlayerAvatarRightArm val3 = (((Object)(object)((Component)val).transform.parent != (Object)null) ? ((Component)((Component)val).transform.parent).GetComponentInChildren<PlayerAvatarRightArm>() : null);
				if ((Object)(object)val3 != (Object)null && (Object)(object)val3.rightArmTransform != (Object)null && (Object)(object)((Component)this).transform.parent != (Object)(object)val3.rightArmTransform)
				{
					((Component)this).transform.SetParent(val3.rightArmTransform, false);
					((Component)this).transform.localPosition = new Vector3(0.05f, -0.034f, 0.479f);
					((Component)this).transform.localRotation = Quaternion.Euler(-17.5f, 52.7f, 81f);
					((Component)this).transform.localScale = Vector3.one;
				}
			}
			if ((Object)(object)_root != (Object)null && ((Component)_root).gameObject.activeSelf && Time.time >= _hideAt)
			{
				((Component)_root).gameObject.SetActive(false);
				if (_avatarViewId >= 0)
				{
					PlayersShootingGuns.Remove(_avatarViewId);
				}
			}
		}

		private void ApplyStyle(int typeOrMinus1)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if (typeOrMinus1 != _lastType || !((Object)(object)_barrelMr != (Object)null) || !((Object)(object)_gripMr != (Object)null))
			{
				_lastType = typeOrMinus1;
				Color tint = default(Color);
				((Color)(ref tint))..ctor(0.7f, 0.7f, 0.7f, 0.85f);
				if (typeOrMinus1 >= 0)
				{
					tint = PvpManager.ColorFor((PvpManager.PvpPowerupType)typeOrMinus1, 0.85f);
				}
				Material material = PvpManager.BuildTranslucentMat(tint);
				if ((Object)(object)_barrelMr != (Object)null)
				{
					((Renderer)_barrelMr).material = material;
				}
				if ((Object)(object)_gripMr != (Object)null)
				{
					((Renderer)_gripMr).material = material;
				}
			}
		}
	}
	internal static class PvpHideVanillaUI
	{
		[HarmonyPatch(typeof(HealthUI), "Start")]
		private static class Patch_HealthUI_Start
		{
			private static void Postfix(HealthUI __instance)
			{
				if (PvpActive)
				{
					try
					{
						((Component)__instance).gameObject.SetActive(false);
					}
					catch
					{
					}
				}
			}
		}

		[HarmonyPatch(typeof(HealthUI), "Update")]
		private static class Patch_HealthUI_Update
		{
			private static bool Prefix(HealthUI __instance)
			{
				if (PvpActive)
				{
					try
					{
						if (((Component)__instance).gameObject.activeSelf)
						{
							((Component)__instance).gameObject.SetActive(false);
						}
					}
					catch
					{
					}
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(EnergyUI), "Start")]
		private static class Patch_EnergyUI_Start
		{
			private static void Postfix(EnergyUI __instance)
			{
				if (PvpActive)
				{
					try
					{
						((Component)__instance).gameObject.SetActive(false);
					}
					catch
					{
					}
				}
			}
		}

		[HarmonyPatch(typeof(EnergyUI), "Update")]
		private static class Patch_EnergyUI_Update
		{
			private static bool Prefix(EnergyUI __instance)
			{
				if (PvpActive)
				{
					try
					{
						if (((Component)__instance).gameObject.activeSelf)
						{
							((Component)__instance).gameObject.SetActive(false);
						}
					}
					catch
					{
					}
					return false;
				}
				return true;
			}
		}

		private static bool PvpActive => (Object)(object)PvpManager.Instance != (Object)null && PvpManager.Instance.IsArmed;
	}
	public class PvpManager : MonoBehaviourPunCallbacks
	{
		public enum PvpPowerupType
		{
			RapidFire,
			DoubleShot,
			HeavyRounds,
			Shield,
			Explosive
		}

		[CompilerGenerated]
		private sealed class <ArmRoundSequence>d__36 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PvpManager <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ArmRoundSequence>d__36(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					PvpPlugin.Logger.LogInfo((object)"[PVP] Starting arm sequence...");
					<>2__current = (object)new WaitForSeconds(0.25f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this._preArmed = true;
					<>4__this._preUntil = Time.time + Mathf.Max(0.5f, PvpPlugin.PreRoundSeconds.Value);
					<>4__this._armed = false;
					if (PhotonNetwork.IsMasterClient)
					{
						<>4__this.SuppressEnemiesLocal();
						<>4__this.DistributeSpawnsMaster();
						<>4__this.ChooseAndBroadcastPortalsMaster();
						<>4__this.SpawnPowerupsMaster();
						<>4__this.InitializeLivesAndSync();
						<>4__this._subRoundActive = true;
						<>4__this._respawnDueAt.Clear();
						<>4__this._respawnPos.Clear();
					}
					<>4__this._nextShootReady = Time.time + 0.5f;
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if (<>4__this._preArmed && Time.time < <>4__this._preUntil)
				{
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
				<>4__this._armed = true;
				<>4__this._armingInProgress = false;
				PvpPlugin.Logger.LogInfo((object)"[PVP] Round armed and active!");
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <CoFinalWinAndTruck>d__51 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public int winnerActor;

			public PvpManager <>4__this;

			private string <name>5__1;

			private Player <p>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <CoFinalWinAndTruck>d__51(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<name>5__1 = null;
				<p>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0125: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						<>1__state = -3;
						Room currentRoom = PhotonNetwork.CurrentRoom;
						<name>5__1 = ((currentRoom != null && currentRoom.Players.TryGetValue(winnerActor, out <p>5__2)) ? <p>5__2.NickName : $"Player {winnerActor}");
						<>4__this._winBanner = <name>5__1 + " wins the match!";
						<>4__this._winBannerUntil = Time.time + 5f;
						if (!<>4__this._roundsWon.ContainsKey(winnerActor))
						{
							<>4__this._roundsWon[winnerActor] = 0;
						}
						<>4__this._roundsWon[winnerActor]++;
						<>4__this.SendLivesSync();
						<>2__current = (object)new WaitForSeconds(5f);
						<>1__state = 1;
						return true;
					}
					case 1:
						<>1__state = -3;
						<>4__this.TryStartTruck();
						<name>5__1 = null;
						<p>5__2 = null;
						<>m__Finally1();
						return false;
					}
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			private void <>m__Finally1()
			{
				<>1__state = -1;
				<>4__this._winBanner = null;
				<>4__this._winBannerUntil = 0f;
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <CoResetSubRound>d__45 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PvpManager <>4__this;

			private float <when>5__1;

			private List<int>.Enumerator <>s__2;

			private int <a>5__3;

			private List<KeyValuePair<int, PvpShield>>.Enumerator <>s__4;

			private KeyValuePair<int, PvpShield> <kv>5__5;

			private Dictionary<int, PvpExplosionHazard>.ValueCollection.Enumerator <>s__6;

			private PvpExplosionHazard <hz>5__7;

			private List<PlayerAvatar>.Enumerator <>s__8;

			private PlayerAvatar <p>5__9;

			private int <actor>5__10;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <CoResetSubRound>d__45(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>s__2 = default(List<int>.Enumerator);
				<>s__4 = default(List<KeyValuePair<int, PvpShield>>.Enumerator);
				<kv>5__5 = default(KeyValuePair<int, PvpShield>);
				<>s__6 = default(Dictionary<int, PvpExplosionHazard>.ValueCollection.Enumerator);
				<hz>5__7 = null;
				<>s__8 = default(List<PlayerAvatar>.Enumerator);
				<p>5__9 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Expected O, but got Unknown
				//IL_0288: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>s__2 = <>4__this._powerupsByActor.Keys.ToList().GetEnumerator();
					try
					{
						while (<>s__2.MoveNext())
						{
							<a>5__3 = <>s__2.Current;
							<>4__this.ClearAllPowerups(<a>5__3);
						}
					}
					finally
					{
						((IDisposable)<>s__2).Dispose();
					}
					<>s__2 = default(List<int>.Enumerator);
					<>s__4 = <>4__this._shieldByActor.ToList().GetEnumerator();
					try
					{
						while (<>s__4.MoveNext())
						{
							<kv>5__5 = <>s__4.Current;
							<>4__this.DestroyShield(<kv>5__5.Key);
							<kv>5__5 = default(KeyValuePair<int, PvpShield>);
						}
					}
					finally
					{
						((IDisposable)<>s__4).Dispose();
					}
					<>s__4 = default(List<KeyValuePair<int, PvpShield>>.Enumerator);
					<>s__6 = <>4__this._activeExplosionByActor.Values.GetEnumerator();
					try
					{
						while (<>s__6.MoveNext())
						{
							<hz>5__7 = <>s__6.Current;
							try
							{
								if (Object.op_Implicit((Object)(object)<hz>5__7))
								{
									Object.Destroy((Object)(object)((Component)<hz>5__7).gameObject);
								}
							}
							catch
							{
							}
							<hz>5__7 = null;
						}
					}
					finally
					{
						((IDisposable)<>s__6).Dispose();
					}
					<>s__6 = default(Dictionary<int, PvpExplosionHazard>.ValueCollection.Enumerator);
					<>4__this._activeExplosionByActor.Clear();
					<>4__this.InitializeLivesAndSync();
					<>4__this._respawnDueAt.Clear();
					<>4__this._respawnPos.Clear();
					<when>5__1 = Time.realtimeSinceStartup + 1f;
					<>s__8 = <>4__this.SafePlayers().GetEnumerator();
					try
					{
						while (<>s__8.MoveNext())
						{
							<p>5__9 = <>s__8.Current;
							<actor>5__10 = <p>5__9.photonView.OwnerActorNr;
							<>4__this._respawnDueAt[<actor>5__10] = <when>5__1;
							<>4__this._respawnPos[<actor>5__10] = <>4__this.PickRandomRespawnPointFarFromTruck();
							<p>5__9 = null;
						}
					}
					finally
					{
						((IDisposable)<>s__8).Dispose();
					}
					<>s__8 = default(List<PlayerAvatar>.Enumerator);
					<>4__this._subRoundActive = true;
					PvpEvt.SendAll(12);
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <CoRotateArmLocalY>d__70 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public Transform armTf;

			public float yAngle;

			public float holdSeconds;

			public PvpManager <>4__this;

			private Vector3 <orig>5__1;

			private float <until>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <CoRotateArmLocalY>d__70(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if ((Object)(object)armTf == (Object)null)
					{
						return false;
					}
					<orig>5__1 = armTf.localEulerAngles;
					armTf.localEulerAngles = new Vector3(<orig>5__1.x, yAngle, <orig>5__1.z);
					<until>5__2 = Time.time + Mathf.Max(0.05f, holdSeconds);
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (Time.time < <until>5__2)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				if (Object.op_Implicit((Object)(object)armTf))
				{
					armTf.localEulerAngles = <orig>5__1;
				}
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private readonly Dictionary<int, HashSet<PvpPowerupType>> _powerupsByActor = new Dictionary<int, HashSet<PvpPowerupType>>();

		private readonly Dictionary<int, Dictionary<PvpPowerupType, float>> _powerupExpireAt = new Dictionary<int, Dictionary<PvpPowerupType, float>>();

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

		private readonly Dictionary<int, PvpShield> _shieldByActor = new Dictionary<int, PvpShield>();

		private readonly Dictionary<int, PvpExplosionHazard> _activeExplosionByActor = new Dictionary<int, PvpExplosionHazard>();

		private readonly Dictionary<int, PvpGun> _guns = new Dictionary<int, PvpGun>();

		private readonly List<Vector3> _portalPositions = new List<Vector3>();

		private readonly List<PvpPortal> _portals = new List<PvpPortal>();

		private bool _armed;

		private bool _preArmed;

		private float _preUntil;

		private bool _armingInProgress;

		private float _nextShootReady;

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

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

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

		private const int START_LIVES = 3;

		private const int WINS_TO_END = 3;

		private bool _subRoundActive;

		private readonly Dictionary<int, float> _respawnDueAt = new Dictionary<int, float>();

		private readonly Dictionary<int, Vector3> _respawnPos = new Dictionary<int, Vector3>();

		private string _winBanner = null;

		private float _winBannerUntil = 0f;

		public static PvpManager Instance { get; private set; }

		public bool IsArmed => _armed || _preArmed;

		private void Awake()
		{
			if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		public override void OnJoinedRoom()
		{
			try
			{
				PvpPlugin.Logger.LogInfo((object)"[PVP] Joined room, waiting for level to be ready...");
			}
			catch (Exception ex)
			{
				PvpPlugin.Logger.LogError((object)("[PVP] OnJoinedRoom: " + ex));
			}
		}

		public override void OnLeftRoom()
		{
			_armed = (_preArmed = false);
			_armingInProgress = false;
			_powerupsByActor.Clear();
			_powerupExpireAt.Clear();
			CleanupPowerups();
			foreach (PvpShield value in _shieldByActor.Values)
			{
				try
				{
					if (Object.op_Implicit((Object)(object)value))
					{
						Object.Destroy((Object)(object)((Component)value).gameObject);
					}
				}
				catch
				{
				}
			}
			_shieldByActor.Clear();
			foreach (PvpExplosionHazard value2 in _activeExplosionByActor.Values)
			{
				try
				{
					if (Object.op_Implicit((Object)(object)value2))
					{
						Object.Destroy((Object)(object)((Component)value2).gameObject);
					}
				}
				catch
				{
				}
			}
			_activeExplosionByActor.Clear();
			CleanupPortals();
			_lives.Clear();
			_wins.Clear();
			_roundsWon.Clear();
			_subRoundActive = false;
			_respawnDueAt.Clear();
			_respawnPos.Clear();
			_winBanner = null;
			_winBannerUntil = 0f;
		}

		public void OnNewLevelSceneLoaded()
		{
			try
			{
				_armed = (_preArmed = false);
				_armingInProgress = false;
				CleanupPowerups();
				CleanupPortals();
				foreach (KeyValuePair<int, PvpShield> item in _shieldByActor.ToList())
				{
					DestroyShield(item.Key);
				}
				foreach (PvpExplosionHazard value in _activeExplosionByActor.Values)
				{
					try
					{
						if (Object.op_Implicit((Object)(object)value))
						{
							Object.Destroy((Object)(object)((Component)value).gameObject);
						}
					}
					catch
					{
					}
				}
				_activeExplosionByActor.Clear();
				_wins.Clear();
				_lives.Clear();
				_subRoundActive = false;
				_respawnDueAt.Clear();
				_respawnPos.Clear();
			}
			catch (Exception ex)
			{
				PvpPlugin.Logger.LogWarning((object)("[PVP] OnNewLevelSceneLoaded: " + ex.Message));
			}
		}

		public void TryArmRound()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Invalid comparison between Unknown and I4
			if (!_armingInProgress && !_preArmed && !_armed)
			{
				if (SemiFunc.MenuLevel() || (Object)(object)LevelGenerator.Instance == (Object)null || (Object)(object)GameDirector.instance == (Object)null)
				{
					PvpPlugin.Logger.LogWarning((object)"[PVP] TryArmRound called but conditions not met.");
					return;
				}
				if ((int)GameDirector.instance.currentState != 2)
				{
					PvpPlugin.Logger.LogWarning((object)"[PVP] TryArmRound called but not in Main state.");
					return;
				}
				if (GameDirector.instance.PlayerList == null || GameDirector.instance.PlayerList.Count == 0)
				{
					PvpPlugin.Logger.LogWarning((object)"[PVP] TryArmRound called but no players present.");
					return;
				}
				_armingInProgress = true;
				((MonoBehaviour)this).StartCoroutine(ArmRoundSequence());
			}
		}

		[IteratorStateMachine(typeof(<ArmRoundSequence>d__36))]
		private IEnumerator ArmRoundSequence()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ArmRoundSequence>d__36(0)
			{
				<>4__this = this
			};
		}

		private void Update()
		{
			if (!_armed || SemiFunc.MenuLevel() || (Object)(object)LevelGenerator.Instance == (Object)null || (Object)(object)GameDirector.instance == (Object)null || !PhotonNetwork.InRoom)
			{
				return;
			}
			Player localPlayer = PhotonNetwork.LocalPlayer;
			if (localPlayer != null)
			{
				if (HasPowerup(localPlayer.ActorNumber, PvpPowerupType.RapidFire))
				{
					if (Input.GetMouseButton(1) && Time.time >= _nextShootReady)
					{
						Fire();
					}
				}
				else if (Input.GetMouseButtonDown(1) && Time.time >= _nextShootReady)
				{
					Fire();
				}
			}
			if (_powerupExpireAt.Count > 0)
			{
				float time = Time.time;
				foreach (KeyValuePair<int, Dictionary<PvpPowerupType, float>> item in _powerupExpireAt.ToList())
				{
					int key = item.Key;
					Dictionary<PvpPowerupType, float> value = item.Value;
					foreach (PvpPowerupType item2 in value.Keys.ToList())
					{
						if (value[item2] <= time)
						{
							value.Remove(item2);
							if (_powerupsByActor.TryGetValue(key, out HashSet<PvpPowerupType> value2))
							{
								value2.Remove(item2);
							}
							if (item2 == PvpPowerupType.Shield)
							{
								DestroyShield(key);
							}
						}
					}
					if (value.Count == 0)
					{
						_powerupExpireAt.Remove(key);
					}
				}
			}
			if (PhotonNetwork.IsMasterClient && _subRoundActive)
			{
				MasterTickRound();
				MasterPollRespawns();
			}
			if (Input.GetKeyDown((KeyCode)101))
			{
				TryUseInteractable();
			}
		}

		public static Transform FindChildDeep(Transform root, string name)
		{
			if ((Object)(object)root == (Object)null)
			{
				return null;
			}
			if (((Object)root).name == name)
			{
				return root;
			}
			for (int i = 0; i < root.childCount; i++)
			{
				Transform child = root.GetChild(i);
				Transform val = FindChildDeep(child, name);
				if ((Object)(object)val != (Object)null)
				{
					return val;
				}
			}
			return null;
		}

		private Transform EnsureGrabberPivot(Transform avatarRoot, out Transform grabber)
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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)
			grabber = FindChildDeep(avatarRoot, "Grabber Target");
			if ((Object)(object)grabber == (Object)null)
			{
				return null;
			}
			Transform val = (((Object)(object)grabber.parent != (Object)null) ? grabber.parent.Find("PVP_GrabberParent") : null);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			Transform parent = grabber.parent;
			int siblingIndex = (((Object)(object)parent != (Object)null) ? grabber.GetSiblingIndex() : 0);
			GameObject val2 = new GameObject("PVP_GrabberParent");
			Transform transform = val2.transform;
			transform.SetParent(parent, false);
			transform.SetSiblingIndex(siblingIndex);
			transform.position = grabber.position;
			transform.rotation = grabber.rotation;
			transform.localScale = Vector3.one;
			grabber.SetParent(transform, true);
			return transform;
		}

		private void InitializeLivesAndSync()
		{
			_lives.Clear();
			List<PlayerAvatar> list = SafePlayers();
			foreach (PlayerAvatar item in list)
			{
				int ownerActorNr = item.photonView.OwnerActorNr;
				if (!_wins.ContainsKey(ownerActorNr))
				{
					_wins[ownerActorNr] = 0;
				}
				if (!_roundsWon.ContainsKey(ownerActorNr))
				{
					_roundsWon[ownerActorNr] = 0;
				}
				_lives[ownerActorNr] = 3;
			}
			SendLivesSync();
		}

		private void MasterTickRound()
		{
			List<int> list = (from kv in _lives
				where kv.Value > 0
				select kv.Key).ToList();
			if (list.Count > 1 || _respawnDueAt.Count != 0)
			{
				return;
			}
			_respawnDueAt.Clear();
			_respawnPos.Clear();
			int num = ((list.Count == 1) ? list[0] : (-1));
			if (num >= 0)
			{
				if (!_wins.ContainsKey(num))
				{
					_wins[num] = 0;
				}
				_wins[num]++;
				PvpEvt.SendAll(11, num);
				SendLivesSync();
				if (_wins[num] >= 3)
				{
					_subRoundActive = false;
					((MonoBehaviour)this).StartCoroutine(CoFinalWinAndTruck(num));
					return;
				}
			}
			_subRoundActive = false;
			((MonoBehaviour)this).StartCoroutine(CoResetSubRound());
		}

		public void MasterOnPlayerDeath(PlayerAvatar avatar)
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			if (!PhotonNetwork.IsMasterClient || (Object)(object)avatar == (Object)null || (Object)(object)avatar.photonView == (Object)null)
			{
				return;
			}
			int ownerActorNr = avatar.photonView.OwnerActorNr;
			if (_respawnDueAt.ContainsKey(ownerActorNr))
			{
				return;
			}
			if (!_lives.ContainsKey(ownerActorNr))
			{
				_lives[ownerActorNr] = 3;
			}
			if (_lives[ownerActorNr] <= 0)
			{
				return;
			}
			_lives[ownerActorNr]--;
			SendLivesSync();
			if (_lives[ownerActorNr] > 0)
			{
				_respawnDueAt[ownerActorNr] = Time.realtimeSinceStartup + 5f;
				_respawnPos[ownerActorNr] = PickRandomRespawnPointFarFromTruck();
				_subRoundActive = true;
				return;
			}
			try
			{
				ClearAllPowerups(ownerActorNr);
			}
			catch
			{
			}
			try
			{
				DestroyShield(ownerActorNr);
			}
			catch
			{
			}
			if (_activeExplosionByActor.TryGetValue(ownerActorNr, out PvpExplosionHazard value) && Object.op_Implicit((Object)(object)value))
			{
				try
				{
					Object.Destroy((Object)(object)((Component)value).gameObject);
				}
				catch
				{
				}
			}
			_activeExplosionByActor.Remove(ownerActorNr);
		}

		private Vector3 PickRandomRespawnPointFarFromTruck()
		{
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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_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_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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: 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_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				List<LevelPoint> list = Object.FindObjectsOfType<LevelPoint>(true).ToList();
				if (list == null || list.Count == 0)
				{
					PlayerController instance = PlayerController.instance;
					Vector3? val = ((instance != null) ? new Vector3?(((Component)instance).transform.position) : null);
					Vector3 val2 = Vector3.up * 0.3f;
					return (Vector3)(((??)(val.HasValue ? new Vector3?(val.GetValueOrDefault() + val2) : null)) ?? (Vector3.up * 0.3f));
				}
				Vector3 truck = (((Object)(object)TruckSafetySpawnPoint.instance != (Object)null) ? ((Component)TruckSafetySpawnPoint.instance).transform.position : Vector3.zero);
				float minD = Mathf.Max(0f, PvpPlugin.SpreadMinMetersFromTruck.Value);
				List<Vector3> list2 = list.Select((LevelPoint p) => ((Component)p).transform.position).ToList();
				List<Vector3> list3 = list2.Where((Vector3 p) => Vector3.Distance(p, truck) >= minD).ToList();
				if (list3.Count == 0)
				{
					list3 = list2;
				}
				if (_portalPositions.Count > 0)
				{
					list3 = list3.Where((Vector3 pos) => !_portalPositions.Any((Vector3 pp) => Vector2.Distance(new Vector2(pp.x, pp.z), new Vector2(pos.x, pos.z)) < 3.5f)).ToList();
					if (list3.Count == 0)
					{
						list3 = list2.Where((Vector3 pos) => !_portalPositions.Any((Vector3 pp) => Vector2.Distance(new Vector2(pp.x, pp.z), new Vector2(pos.x, pos.z)) < 3.5f)).ToList();
					}
					if (list3.Count == 0)
					{
						list3 = list2;
					}
				}
				int tickCount = Environment.TickCount;
				Room currentRoom = PhotonNetwork.CurrentRoom;
				Random random = new Random(tickCount ^ ((currentRoom != null) ? currentRoom.Name.GetHashCode() : 0));
				return list3[random.Next(list3.Count)] + Vector3.up * 0.2f;
			}
			catch
			{
				return Vector3.up * 0.3f;
			}
		}

		private void MasterPollRespawns()
		{
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_0146: 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_015a: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			if (_respawnDueAt.Count == 0)
			{
				return;
			}
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			foreach (KeyValuePair<int, float> item in _respawnDueAt.ToList())
			{
				if (realtimeSinceStartup < item.Value)
				{
					continue;
				}
				int key = item.Key;
				PlayerAvatar val = FindAvatarByActor(key);
				_respawnDueAt.Remove(key);
				if ((Object)(object)val == (Object)null)
				{
					_respawnPos.Remove(key);
					continue;
				}
				try
				{
					val.Revive(false);
				}
				catch
				{
				}
				try
				{
					PlayerHealth component = ((Component)val).GetComponent<PlayerHealth>();
					if ((Object)(object)component != (Object)null)
					{
						component.HealOther(999, true);
					}
				}
				catch (Exception ex)
				{
					PvpPlugin.Logger.LogWarning((object)("[PVP] Heal on revive warn: " + ex.Message));
				}
				Vector3 value;
				Vector3 val2 = (_respawnPos.TryGetValue(key, out value) ? value : (((Component)val).transform.position + Vector3.up * 0.3f));
				_respawnPos.Remove(key);
				Quaternion val3 = Quaternion.Euler(0f, ((Component)val).transform.eulerAngles.y, 0f);
				try
				{
					val.Spawn(val2, val3);
				}
				catch
				{
				}
				try
				{
					PlayerAvatarVisuals field = GetField<PlayerAvatarVisuals>(val, "playerAvatarVisuals", null);
					if ((Object)(object)field != (Object)null)
					{
						((Component)field).gameObject.SetActive(true);
					}
					((Component)val).gameObject.SetActive(true);
				}
				catch
				{
				}
			}
		}

		[IteratorStateMachine(typeof(<CoResetSubRound>d__45))]
		private IEnumerator CoResetSubRound()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <CoResetSubRound>d__45(0)
			{
				<>4__this = this
			};
		}

		private List<PlayerAvatar> SafePlayers()
		{
			try
			{
				return GameDirector.instance?.PlayerList?.Where((PlayerAvatar p) => (Object)(object)p != (Object)null && (Object)(object)p.photonView != (Object)null && p.photonView.Owner != null).ToList() ?? new List<PlayerAvatar>();
			}
			catch
			{
				return new List<PlayerAvatar>();
			}
		}

		private void SendLivesSync()
		{
			try
			{
				int[] array = _lives.Keys.OrderBy((int a) => a).ToArray();
				int value3;
				int[] array2 = array.Select((int a) => _lives.TryGetValue(a, out value3) ? value3 : 0).ToArray();
				int value2;
				int[] array3 = array.Select((int a) => _wins.TryGetValue(a, out value2) ? value2 : 0).ToArray();
				int value;
				int[] array4 = array.Select((int a) => _roundsWon.TryGetValue(a, out value) ? value : 0).ToArray();
				PvpEvt.SendAll(10, array, array2, array3, array4);
			}
			catch (Exception ex)
			{
				PvpPlugin.Logger.LogWarning((object)("[PVP] SendLivesSync: " + ex.Message));
			}
		}

		public void ApplyRoundSync(int[] actors, int[] lives, int[] wins, int[] rounds = null)
		{
			try
			{
				_lives.Clear();
				_wins.Clear();
				if (rounds == null)
				{
					_roundsWon.Clear();
				}
				for (int i = 0; i < actors.Length; i++)
				{
					int key = actors[i];
					_lives[key] = lives[Mathf.Clamp(i, 0, lives.Length - 1)];
					_wins[key] = wins[Mathf.Clamp(i, 0, wins.Length - 1)];
					if (rounds != null)
					{
						_roundsWon[key] = rounds[Mathf.Clamp(i, 0, rounds.Length - 1)];
					}
				}
			}
			catch
			{
			}
		}

		public void AnnounceWinner(int winnerActor)
		{
			try
			{
				Room currentRoom = PhotonNetwork.CurrentRoom;
				Player value;
				string text = ((currentRoom != null && currentRoom.Players.TryGetValue(winnerActor, out value)) ? value.NickName : $"Player {winnerActor}");
				_winBanner = text + " wins the round!";
				_winBannerUntil = Time.time + 5f;
				PvpPlugin.Logger.LogInfo((object)("[PVP] Round won by " + text));
			}
			catch
			{
			}
		}

		public void OnRoundResetAnnounce()
		{
		}

		[IteratorStateMachine(typeof(<CoFinalWinAndTruck>d__51))]
		private IEnumerator CoFinalWinAndTruck(int winnerActor)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <CoFinalWinAndTruck>d__51(0)
			{
				<>4__this = this,
				winnerActor = winnerActor
			};
		}

		private void TryStartTruck()
		{
			try
			{
				if ((Object)(object)RunManager.instance != (Object)null)
				{
					RunManager.instance.ChangeLevel(true, false, (ChangeLevelType)1);
					PvpPlugin.Logger.LogInfo((object)"[PVP] Called RunManager.ChangeLevel (match end).");
					return;
				}
				MonoBehaviour val = ((IEnumerable<MonoBehaviour>)Object.FindObjectsOfType<MonoBehaviour>(true)).FirstOrDefault((Func<MonoBehaviour, bool>)((MonoBehaviour mb) => ((Object)mb).name.Contains("Truck", StringComparison.OrdinalIgnoreCase) || ((object)mb).GetType().Name.Contains("Truck", StringComparison.OrdinalIgnoreCase) || ((object)mb).GetType().Name.Contains("Vehicle", StringComparison.OrdinalIgnoreCase)));
				(((object)val)?.GetType().GetMethods().FirstOrDefault((MethodInfo x) => x.Name.ToLower().Contains("start") || x.Name.ToLower().Contains("drive")))?.Invoke(val, null);
				PvpPlugin.Logger.LogInfo((object)"[PVP] Fallback: attempted to start the truck.");
			}
			catch (Exception ex)
			{
				PvpPlugin.Logger.LogWarning((object)("[PVP] Could not start truck automatically: " + ex.Message));
			}
		}

		private void DistributeSpawnsMaster()
		{
			//IL_0059: 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_005e: 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_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: 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_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: 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_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: 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)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				List<PlayerAvatar> list = SafePlayers();
				List<LevelPoint> list2 = Object.FindObjectsOfType<LevelPoint>(true).ToList();
				if (list.Count == 0 || list2.Count == 0)
				{
					return;
				}
				Vector3 truck = (((Object)(object)TruckSafetySpawnPoint.instance != (Object)null) ? ((Component)TruckSafetySpawnPoint.instance).transform.position : Vector3.zero);
				float minD = Mathf.Max(0f, PvpPlugin.SpreadMinMetersFromTruck.Value);
				List<Vector3> eligible = (from p in list2
					where Vector3.Distance(((Component)p).transform.position, truck) >= minD
					select ((Component)p).transform.position).ToList();
				if (eligible.Count == 0)
				{
					eligible = list2.Select((LevelPoint p) => ((Component)p).transform.position).ToList();
				}
				List<Vector3> list3 = new List<Vector3>();
				Random rnd = new Random((PhotonNetwork.CurrentRoom != null) ? PhotonNetwork.CurrentRoom.Name.GetHashCode() : Environment.TickCount);
				list3.Add(PickRandom());
				while (list3.Count < list.Count && eligible.Count > 0)
				{
					Vector3 item = eligible[0];
					float num = -1f;
					foreach (Vector3 item2 in eligible)
					{
						float num2 = float.MaxValue;
						foreach (Vector3 item3 in list3)
						{
							num2 = Mathf.Min(num2, Vector3.Distance(item2, item3));
						}
						if (num2 > num)
						{
							num = num2;
							item = item2;
						}
					}
					list3.Add(item);
				}
				List<int> list4 = list.Select((PlayerAvatar p) => p.photonView.Owner.ActorNumber).ToList();
				list4.Sort();
				List<float> list5 = new List<float>(list4.Count * 3);
				for (int i = 0; i < list4.Count; i++)
				{
					Vector3 val = ((i < list3.Count) ? list3[i] : list3.Last());
					val += Vector3.up * 0.2f;
					list5.Add(val.x);
					list5.Add(val.y);
					list5.Add(val.z);
				}
				PvpEvt.SendAll(1, list5.ToArray());
				Vector3 val4 = default(Vector3);
				for (int j = 0; j < list4.Count; j++)
				{
					int actor = list4[j];
					PlayerAvatar val2 = ((IEnumerable<PlayerAvatar>)list).FirstOrDefault((Func<PlayerAvatar, bool>)((PlayerAvatar p) => p.photonView.OwnerActorNr == actor));
					if ((Object)(object)val2 != (Object)null)
					{
						Camera main = Camera.main;
						Quaternion val3 = (((Object)(object)main != (Object)null) ? Quaternion.Euler(0f, ((Component)main).transform.eulerAngles.y, 0f) : Quaternion.identity);
						((Vector3)(ref val4))..ctor(list5[j * 3], list5[j * 3 + 1], list5[j * 3 + 2]);
						val2.Spawn(val4, val3);
					}
				}
				Vector3 PickRandom()
				{
					//IL_001c: Unknown result type (might be due to invalid IL or missing references)
					return eligible[rnd.Next(eligible.Count)];
				}
			}
			catch (Exception ex)
			{
				PvpPlugin.Logger.LogWarning((object)("[PVP] DistributeSpawnsMaster: " + ex.Message));
			}
		}

		public void ApplySpawnPointsFromMaster(float[] packed)
		{
		}

		private void ChooseAndBroadcastPortalsMaster()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_0139: 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_0154: 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_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: 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_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: 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_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: 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_0175: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_portalPositions.Clear();
				CleanupPortals();
				List<LevelPoint> list = Object.FindObjectsOfType<LevelPoint>(true).ToList();
				if (list.Count == 0)
				{
					return;
				}
				Vector3 truck = (((Object)(object)TruckSafetySpawnPoint.instance != (Object)null) ? ((Component)TruckSafetySpawnPoint.instance).transform.position : Vector3.zero);
				float minD = Mathf.Max(0f, PvpPlugin.SpreadMinMetersFromTruck.Value);
				List<Vector3> list2 = (from p in list
					where Vector3.Distance(((Component)p).transform.position, truck) >= minD
					select ((Component)p).transform.position).ToList();
				if (list2.Count < 4)
				{
					list2 = list.Select((LevelPoint p) => ((Component)p).transform.position).ToList();
				}
				if (list2.Count == 0)
				{
					return;
				}
				List<Vector3> list3 = new List<Vector3>();
				int tickCount = Environment.TickCount;
				Room currentRoom = PhotonNetwork.CurrentRoom;
				Random random = new Random(tickCount ^ ((currentRoom != null) ? currentRoom.Name.GetHashCode() : 0));
				while (list3.Count < 4 && list2.Count > 0)
				{
					Vector3 item = list2[0];
					float num = -1f;
					foreach (Vector3 item2 in list2)
					{
						float num2 = float.MaxValue;
						foreach (Vector3 item3 in list3)
						{
							num2 = Mathf.Min(num2, Vector3.Distance(item2, item3));
						}
						if (num2 > num)
						{
							num = num2;
							item = item2;
						}
					}
					list3.Add(item);
					list2.Remove(item);
				}
				_portalPositions.Clear();
				List<float> list4 = new List<float>(12);
				foreach (Vector3 item4 in list3)
				{
					Vector3 val = item4 + Vector3.up * 0.2f;
					_portalPositions.Add(val);
					list4.Add(val.x);
					list4.Add(val.y);
					list4.Add(val.z);
				}
				PvpEvt.SendAll(5, list4.ToArray());
			}
			catch (Exception ex)
			{
				PvpPlugin.Logger.LogWarning((object)("[PVP] ChooseAndBroadcastPortalsMaster: " + ex.Message));
			}
		}

		public void ApplyPortalsFromMaster(float[] packed)
		{
			//IL_002c: 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_006b: Expected O, but got Unknown
			//IL_0078: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CleanupPortals();
				_portalPositions.Clear();
				for (int i = 0; i + 2 < packed.Length; i += 3)
				{
					if (_portalPositions.Count >= 4)
					{
						break;
					}
					_portalPositions.Add(new Vector3(packed[i], packed[i + 1], packed[i + 2]));
				}
				for (int j = 0; j < _portalPositions.Count; j++)
				{
					GameObject val = new GameObject("PVP_PortalRoot");
					val.transform.position = _portalPositions[j];
					PvpPortal pvpPortal = val.AddComponent<PvpPortal>();
					pvpPortal.PairIndex = ((j >= 2) ? 1 : 0);
					Color tint = ((pvpPortal.PairIndex == 0) ? new Color(1f, 0.25f, 0.25f, 0.5f) : new Color(0.25f, 0.45f, 1f, 0.5f));
					pvpPortal.InitVisual(tint);
					_portals.Add(pvpPortal);
				}
				if (_portals.Count >= 4)
				{
					_portals[0].Linked = _portals[1];
					_portals[1].Linked = _portals[0];
					_portals[2].Linked = _portals[3];
					_portals[3].Linked = _portals[2];
				}
			}
			catch (Exception ex)
			{
				PvpPlugin.Logger.LogWarning((object)("[PVP] ApplyPortalsFromMaster: " + ex.Message));
			}
		}

		private void CleanupPortals()
		{
			foreach (PvpPortal portal in _portals)
			{
				try
				{
					if (Object.op_Implicit((Object)(object)portal))
					{
						Object.Destroy((Object)(object)((Component)portal).gameObject);
					}
				}
				catch
				{
				}
			}
			_portals.Clear();
		}

		private void SpawnPowerupsMaster()
		{
			//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_0074: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CleanupPowerups();
				List<LevelPoint> list = Object.FindObjectsOfType<LevelPoint>(true).ToList();
				if (list.Count == 0)
				{
					return;
				}
				for (int i = 0; i < list.Count; i++)
				{
					LevelPoint val = list[i];
					Vector3 posBase = ((Component)val).transform.position;
					if (!_portalPositions.Any((Vector3 pp) => Vector2.Distance(new Vector2(pp.x, pp.z), new Vector2(posBase.x, posBase.z)) < 3.5f))
					{
						Vector3 val2 = posBase + new Vector3(0f, PvpPlugin.PowerupHoverYOffset.Value, 0f);
						int num = i % 5;
						PvpEvt.SendAll(2, num, val2.x, val2.y, val2.z);
					}
				}
			}
			catch (Exception ex)
			{
				PvpPlugin.Logger.LogWarning((object)("[PVP] SpawnPowerupsMaster: " + ex.Message));
			}
		}

		public void SpawnPowerupVisual(int type, Vector3 pos)
		{
			//IL_002f: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_0102: 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_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)3);
			PvpPowerupType pvpPowerupType = (PvpPowerupType)type;
			((Object)val).name = "PVP_Powerup_" + pvpPowerupType;
			val.transform.position = pos;
			val.transform.localScale = new Vector3(0.25f, 0.25f, 0.25f);
			Collider component = val.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				component.isTrigger = true;
			}
			Rigidbody val2 = val.AddComponent<Rigidbody>();
			val2.isKinematic = true;
			val2.useGravity = false;
			MeshRenderer component2 = val.GetComponent<MeshRenderer>();
			if ((Object)(object)component2 != (Object)null)
			{
				((Renderer)component2).material = BuildTranslucentMat(ColorFor((PvpPowerupType)type, 0.6f));
			}
			PvpPowerup pvpPowerup = val.AddComponent<PvpPowerup>();
			pvpPowerup.Manager = this;
			pvpPowerup.Type = (PvpPowerupType)type;
			GameObject val3 = new GameObject("Label");
			val3.transform.SetParent(val.transform, false);
			val3.transform.localPosition = new Vector3(0f, 1.05f, 0f);
			TextMeshPro val4 = val3.AddComponent<TextMeshPro>();
			((TMP_Text)val4).fontSize = 1.25f;
			((TMP_Text)val4).alignment = (TextAlignmentOptions)514;
			((Graphic)val4).color = new Color(0.95f, 1f, 1f, 0.95f);
			((TMP_Text)val4).text = LabelFor((PvpPowerupType)type);
			((TMP_Text)val4).enableAutoSizing = false;
			pvpPowerup.InitHover(pos, PvpPlugin.PowerupBobAmplitude.Value, PvpPlugin.PowerupBobSpeed.Value, PvpPlugin.PowerupRotateSpeed.Value);
			_powerupObjects.Add(val);
		}

		public static Material BuildTranslucentMat(Color tint)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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)
			Material val = null;
			Shader val2 = Shader.Find("Standard");
			if ((Object)(object)val2 != (Object)null)
			{
				val = new Material(val2);
				if (val.HasProperty("_Mode"))
				{
					val.SetFloat("_Mode", 3f);
				}
				val.SetInt("_SrcBlend", 5);
				val.SetInt("_DstBlend", 10);
				val.SetInt("_ZWrite", 0);
				val.DisableKeyword("_ALPHATEST_ON");
				val.EnableKeyword("_ALPHABLEND_ON");
				val.DisableKeyword("_ALPHAPREMULTIPLY_ON");
				val.renderQueue = 3000;
				if (val.HasProperty("_Color"))
				{
					val.color = tint;
				}
				return val;
			}
			Shader val3 = Shader.Find("Unlit/Color");
			if ((Object)(object)val3 != (Object)null)
			{
				val = new Material(val3);
				if (val.HasProperty("_Color"))
				{
					val.color = tint;
				}
				return val;
			}
			val = new Material(Shader.Find("Sprites/Default") ?? Shader.Find("UI/Default"));
			if (val.HasProperty("_Color"))
			{
				val.color = tint;
			}
			val.renderQueue = 3000;
			return val;
		}

		private static string LabelFor(PvpPowerupType t)
		{
			if (1 == 0)
			{
			}
			string result = t switch
			{
				PvpPowerupType.RapidFire => "Rapid Fire", 
				PvpPowerupType.DoubleShot => "Double Shot", 
				PvpPowerupType.HeavyRounds => "Heavy Rounds", 
				PvpPowerupType.Shield => "Shield", 
				_ => "Explosive", 
			};
			if (1 == 0)
			{
			}
			return result;
		}

		public static Color ColorFor(PvpPowerupType t, float a = 1f)
		{
			//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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			if (1 == 0)
			{
			}
			Color result = (Color)(t switch
			{
				PvpPowerupType.RapidFire => new Color(1f, 0.55f, 0.1f, a), 
				PvpPowerupType.DoubleShot => new Color(0.3f, 0.8f, 1f, a), 
				PvpPowerupType.HeavyRounds => new Color(0.9f, 0.2f, 0.3f, a), 
				PvpPowerupType.Shield => new Color(0.45f, 1f, 0.45f, a), 
				_ => new Color(0.8f, 0.6f, 1f, a), 
			});
			if (1 == 0)
			{
			}
			return result;
		}

		private void CleanupPowerups()
		{
			foreach (GameObject powerupObject in _powerupObjects)
			{
				try
				{
					if (Object.op_Implicit((Object)(object)powerupObject))
					{
						Object.Destroy((Object)(object)powerupObject);
					}
				}
				catch
				{
				}
			}
			_powerupObjects.Clear();
		}

		private void TryUseInteractable()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_01c3: 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_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: 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_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: 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_027a: Unknown result type (might be due to invalid IL or missing references)
			PlayerController instance = PlayerController.instance;
			PlayerAvatar val = (((Object)(object)instance != (Object)null) ? instance.playerAvatarScript : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Vector3 position = ((Component)val).transform.position;
			float value = PvpPlugin.PowerupInteractRadius.Value;
			PvpPortal pvpPortal = null;
			float num = float.MaxValue;
			foreach (PvpPortal portal in _portals)
			{
				if (Object.op_Implicit((Object)(object)portal))
				{
					float num2 = Vector3.Distance(((Component)portal).transform.position, position);
					if (num2 <= value && num2 < num)
					{
						num = num2;
						pvpPortal = portal;
					}
				}
			}
			if ((Object)(object)pvpPortal != (Object)null)
			{
				return;
			}
			PvpPowerup pvpPowerup = null;
			num = float.MaxValue;
			foreach (GameObject powerupObject in _powerupObjects)
			{
				if (!Object.op_Implicit((Object)(object)powerupObject))
				{
					continue;
				}
				PvpPowerup component = powerupObject.GetComponent<PvpPowerup>();
				if (!((Object)(object)component == (Object)null) && component.CanBePicked)
				{
					float num3 = Vector3.Distance(powerupObject.transform.position, position);
					if (num3 <= value && num3 < num)
					{
						num = num3;
						pvpPowerup = component;
					}
				}
			}
			if ((Object)(object)pvpPowerup == (Object)null)
			{
				return;
			}
			Player localPlayer = PhotonNetwork.LocalPlayer;
			if (localPlayer != null)
			{
				int actorNumber = localPlayer.ActorNumber;
				Vector3 position2 = ((Component)pvpPowerup).transform.position;
				int type = (int)pvpPowerup.Type;
				if (!PhotonNetwork.IsMasterClient)
				{
					PvpEvt.SendMaster(3, actorNumber, type, position2.x, position2.y, position2.z);
				}
				else
				{
					PvpEvt.SendAll(3, actorNumber, type, position2.x, position2.y, position2.z);
				}
				Sfx.PlayAt(position2, PvpPlugin.SfxPickup, PvpPlugin.SfxVolume.Value);
			}
		}

		public void ApplyPowerup(int actor, PvpPowerupType type, bool broadcast)
		{
			ClearAllPowerups(actor);
			HashSet<PvpPowerupType> value = new HashSet<PvpPowerupType> { type };
			_powerupsByActor[actor] = value;
			float num = ((type == PvpPowerupType.Shield) ? 10f : 30f);
			_powerupExpireAt[actor] = new Dictionary<PvpPowerupType, float> { [type] = Time.time + num };
			if (type == PvpPowerupType.Shield)
			{
				EnsureShield(actor);
			}
		}

		private void ClearAllPowerups(int actor)
		{
			if (_powerupsByActor.ContainsKey(actor))
			{
				_powerupsByActor[actor].Clear();
			}
			if (_powerupExpireAt.ContainsKey(actor))
			{
				_powerupExpireAt[actor].Clear();
			}
			DestroyShield(actor);
		}

		public void HandlePowerupPickedAt(PvpPowerupType type, Vector3 pos)
		{
			//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_0068: Unknown result type (might be due to invalid IL or missing references)
			PvpPowerup pvpPowerup = null;
			float num = float.MaxValue;
			foreach (GameObject powerupObject in _powerupObjects)
			{
				if (!Object.op_Implicit((Object)(object)powerupObject))
				{
					continue;
				}
				PvpPowerup component = powerupObject.GetComponent<PvpPowerup>();
				if (!((Object)(object)component == (Object)null) && component.Type == type)
				{
					float num2 = Vector3.SqrMagnitude(powerupObject.transform.position - pos);
					if (num2 < num)
					{
						num = num2;
						pvpPowerup = component;
					}
				}
			}
			pvpPowerup?.PlayPickupAndHide(PvpPlugin.PowerupPickupHideSeconds.Value);
		}

		public bool HasPowerup(int actor, PvpPowerupType t)
		{
			HashSet<PvpPowerupType> value;
			return _powerupsByActor.TryGetValue(actor, out value) && value.Contains(t);
		}

		public void ShowGunFlash(int actor, int typeOrMinus1, float duration)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			try
			{
				PlayerAvatar val = FindAvatarByActor(actor);
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				Transform val2 = FindChildDeep(((Component)val).transform, "ANIM ARM R");
				Transform grabber;
				Transform val3 = EnsureGrabberPivot(((Component)val).transform, out grabber);
				if (!_guns.TryGetValue(actor, out PvpGun value) || (Object)(object)value == (Object)null)
				{
					GameObject val4 = new GameObject("PVP_Gun");
					Transform val5 = (((Object)(object)val3 != (Object)null) ? val3 : (((Object)(object)grabber != (Object)null) ? grabber : ((Component)val).transform));
					val4.transform.SetParent(val5, false);
					value = val4.AddComponent<PvpGun>();
					_guns[actor] = value;
				}
				else
				{
					Transform val6 = val3 ?? grabber ?? ((Component)val).transform;
					if ((Object)(object)((Component)value).transform.parent != (Object)(object)val6)
					{
						((Component)value).transform.SetParent(val6, false);
					}
				}
				value.Setup(this, actor);
				value.Show(typeOrMinus1, duration);
				if ((Object)(object)val2 != (Object)null)
				{
					((MonoBehaviour)this).StartCoroutine(CoRotateArmLocalY(val2, -90f, duration));
				}
			}
			catch
			{
			}
		}

		[IteratorStateMachine(typeof(<CoRotateArmLocalY>d__70))]
		private IEnumerator CoRotateArmLocalY(Transform armTf, float yAngle, float holdSeconds)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <CoRotateArmLocalY>d__70(0)
			{
				<>4__this = this,
				armTf = armTf,
				yAngle = yAngle,