Decompiled source of PEAK Tag v1.1.0

tony4twentys-PEAK Tag.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.SceneManagement;
using Zorro.Core.Serizalization;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PEAK Tag")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PEAK Tag")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a79f76bb-595e-4baf-a566-700e65990610")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PEAKTag;

[BepInPlugin("tony4twentys.PEAK_Tag", "PEAK Tag", "1.1.0")]
public class PEAKTagPlugin : BaseUnityPlugin, IInRoomCallbacks
{
	private struct GiftDef
	{
		public ushort id;

		public string name;
	}

	private enum PowerType
	{
		None,
		PlayerStun,
		PlayerWarp,
		PlayerItemDrop
	}

	[HarmonyPatch(typeof(RunManager), "StartRun")]
	private static class StartRunPatch
	{
		private static void Postfix()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.IsMasterClient)
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (!string.Equals(((Scene)(ref activeScene)).name, "Airport", StringComparison.OrdinalIgnoreCase))
				{
					Instance?.StartRunHostFlow();
				}
			}
		}
	}

	[HarmonyPatch(typeof(Campfire), "Light_Rpc")]
	private static class CampfireLightPost
	{
		private static void Postfix(Campfire __instance)
		{
			if (!PhotonNetwork.IsMasterClient || (Object)(object)Instance == (Object)null)
			{
				return;
			}
			Instance._campfireItCooldownUntil = PhotonNetwork.Time + (double)((Instance._campfireCooldownSec != null) ? Instance._campfireCooldownSec.Value : 60f);
			Character val = FindCharacterByViewID(Instance._itViewId);
			if ((Object)(object)val != (Object)null)
			{
				float seconds = ((Instance._campfireRagdollSec != null) ? Instance._campfireRagdollSec.Value : 5f);
				Instance.RagdollWithGrayscale(val, seconds);
				return;
			}
			List<Character> allCharacters = Character.AllCharacters;
			int count = allCharacters.Count;
			List<Character> list = new List<Character>();
			for (int i = 0; i < count; i++)
			{
				Character val2 = allCharacters[i];
				if (IsAlive(val2) && !val2.isBot)
				{
					list.Add(val2);
				}
			}
			if (list.Count > 0)
			{
				Character who = list[Random.Range(0, list.Count)];
				((BaseUnityPlugin)Instance).Logger.LogInfo((object)"[Tag] Campfire lit but no IT in room; choosing a new IT immediately.");
				Instance.SetItNow(who, 1.5);
				float seconds2 = Instance._campfireRagdollSec?.Value ?? 5f;
				Instance.RagdollWithGrayscale(who, seconds2);
			}
		}
	}

	[HarmonyPatch(typeof(ScoutmasterSpawner), "SpawnScoutmaster")]
	private static class BlockScoutmasterSpawn
	{
		private static bool Prefix()
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				return true;
			}
			PEAKTagPlugin instance = Instance;
			if (instance != null)
			{
				ManualLogSource logger = ((BaseUnityPlugin)instance).Logger;
				if (logger != null)
				{
					logger.LogInfo((object)"[Tag] Blocked Scoutmaster spawn (host-only).");
				}
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(Item))]
	private static class ItemCarryWeightZeroPatch
	{
		[HarmonyPatch("get_CarryWeight")]
		[HarmonyPostfix]
		private static void CarryWeightPostfix(ref int __result)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				__result = 0;
			}
		}
	}

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

		private object <>2__current;

		public PEAKTagPlugin <>4__this;

		private float <wait>5__1;

		private Character <itChar>5__2;

		private bool <doLolli>5__3;

		private bool <doEnergy>5__4;

		private bool <doBonus>5__5;

		private int <times>5__6;

		private int <times>5__7;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				<itChar>5__2 = FindCharacterByViewID(<>4__this._itViewId);
				if (!IsAlive(<itChar>5__2))
				{
					break;
				}
				<>4__this.PickBoostSet(out <doLolli>5__3, out <doEnergy>5__4, out <doBonus>5__5);
				if (<doLolli>5__3)
				{
					if (<>4__this._lolliChainCo != null)
					{
						((MonoBehaviour)<>4__this).StopCoroutine(<>4__this._lolliChainCo);
					}
					<times>5__6 = Mathf.Max(1, (<>4__this._infiniteMultiplier != null) ? <>4__this._infiniteMultiplier.Value : 3);
					<>4__this._lolliChainCo = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.ChainFeed(<itChar>5__2, 44, <times>5__6, "Lollipop"));
				}
				if (<doEnergy>5__4)
				{
					if (<>4__this._drinkChainCo != null)
					{
						((MonoBehaviour)<>4__this).StopCoroutine(<>4__this._drinkChainCo);
					}
					<times>5__7 = Mathf.Max(1, (<>4__this._boostMultiplier != null) ? <>4__this._boostMultiplier.Value : 3);
					<>4__this._drinkChainCo = ((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.ChainFeed(<itChar>5__2, 27, <times>5__7, "Energy Drink"));
				}
				if (<doBonus>5__5)
				{
					<>4__this.GiveFullBonusStamina(<itChar>5__2);
				}
				<>4__this.GivePowerGiftToIt(<itChar>5__2);
				<itChar>5__2 = null;
				break;
			}
			if (PhotonNetwork.IsMasterClient && PhotonNetwork.InRoom)
			{
				<wait>5__1 = ((<>4__this._boostGiftIntervalSec != null) ? Mathf.Max(5f, <>4__this._boostGiftIntervalSec.Value) : 90f);
				<>2__current = (object)new WaitForSecondsRealtime(<wait>5__1);
				<>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();
		}
	}

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

		private object <>2__current;

		public Character receiver;

		public ushort itemID;

		public int times;

		public string label;

		public PEAKTagPlugin <>4__this;

		private int <i>5__1;

		private Item <spawned>5__2;

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

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

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

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

		private bool MoveNext()
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Expected O, but got Unknown
			int num = <>1__state;
			if (num != 0)
			{
				if (num != 1)
				{
					return false;
				}
				<>1__state = -1;
				goto IL_00d7;
			}
			<>1__state = -1;
			if ((Object)(object)receiver?.refs?.view == (Object)null)
			{
				return false;
			}
			<i>5__1 = 0;
			goto IL_00f1;
			IL_00f1:
			if (<i>5__1 < times)
			{
				if (!<>4__this.ForceFeedOnce(receiver, itemID, label, out <spawned>5__2))
				{
					return false;
				}
				((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.CleanupAfter(<spawned>5__2));
				if (<i>5__1 < times - 1)
				{
					<>2__current = (object)new WaitForSeconds(13f);
					<>1__state = 1;
					return true;
				}
				goto IL_00d7;
			}
			return false;
			IL_00d7:
			<spawned>5__2 = null;
			<i>5__1++;
			goto IL_00f1;
		}

		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 <CleanupAfter>d__106 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Item item;

		public PEAKTagPlugin <>4__this;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>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
			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;
				if (Object.op_Implicit((Object)(object)item) && Object.op_Implicit((Object)(object)((MonoBehaviourPun)item).photonView))
				{
					PhotonNetwork.Destroy(((MonoBehaviourPun)item).photonView);
				}
				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 <DeferRefreshItEyes>d__146 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public int guardItViewId;

		public PEAKTagPlugin <>4__this;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>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
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(0.25f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if (<>4__this._itViewId == guardItViewId)
				{
					<>4__this.RefreshItEyes();
				}
				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 <DeferRefreshItEyesAfterRagdoll>d__147 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Character itChar;

		public float ragdollDuration;

		public PEAKTagPlugin <>4__this;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>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
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(0.5f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>4__this.RefreshItEyes();
				((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"[Tag] Eyes refreshed for initial IT after ragdoll application.");
				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 <EquipBackpacksAfterDelay>d__77 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public PEAKTagPlugin <>4__this;

		private float <timeout>5__1;

		private float <t>5__2;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(15f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<timeout>5__1 = 45f;
				<t>5__2 = 0f;
				break;
			case 2:
				<>1__state = -1;
				<t>5__2 += 2f;
				break;
			}
			if (PhotonNetwork.IsMasterClient && <t>5__2 < <timeout>5__1)
			{
				<>4__this.GiveBackpacksNow();
				if (AllHumansHaveBackpacks())
				{
					return false;
				}
				<>2__current = (object)new WaitForSeconds(2f);
				<>1__state = 2;
				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();
		}
	}

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

		private object <>2__current;

		public PEAKTagPlugin <>4__this;

		private int <statusCount>5__1;

		private float[] <snapshot>5__2;

		private List<Character> <characters>5__3;

		private int <count>5__4;

		private int <i>5__5;

		private int <i>5__6;

		private Character <c>5__7;

		private PhotonView <view>5__8;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<snapshot>5__2 = null;
			<characters>5__3 = null;
			<c>5__7 = null;
			<view>5__8 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<statusCount>5__1 = Enum.GetNames(typeof(STATUSTYPE)).Length;
				<snapshot>5__2 = new float[<statusCount>5__1];
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (PhotonNetwork.IsMasterClient && PhotonNetwork.InRoom)
			{
				try
				{
					<i>5__5 = 0;
					while (<i>5__5 < <statusCount>5__1)
					{
						<snapshot>5__2[<i>5__5] = 0f;
						<i>5__5++;
					}
					<characters>5__3 = Character.AllCharacters;
					<count>5__4 = <characters>5__3.Count;
					<i>5__6 = 0;
					while (<i>5__6 < <count>5__4)
					{
						<c>5__7 = <characters>5__3[<i>5__6];
						if (IsAlive(<c>5__7))
						{
							<view>5__8 = <c>5__7.refs?.view;
							if (<view>5__8 != null)
							{
								<view>5__8.RPC("ApplyStatusesFromFloatArrayRPC", (RpcTarget)0, new object[1] { <snapshot>5__2 });
							}
						}
						<c>5__7 = null;
						<view>5__8 = null;
						<i>5__6++;
					}
					<characters>5__3 = null;
				}
				catch
				{
				}
				<>2__current = (object)new WaitForSeconds(1f);
				<>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();
		}
	}

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

		private object <>2__current;

		public PEAKTagPlugin <>4__this;

		private float <secs>5__1;

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

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

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

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

		private bool MoveNext()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				<>4__this.TryGiveRandomGiftsToAll();
				break;
			}
			if (PhotonNetwork.IsMasterClient && PhotonNetwork.InRoom && (<>4__this._giftEnabled == null || <>4__this._giftEnabled.Value))
			{
				<secs>5__1 = ((<>4__this._giftIntervalSec != null) ? Mathf.Max(10f, <>4__this._giftIntervalSec.Value) : 300f);
				<>2__current = (object)new WaitForSecondsRealtime(<secs>5__1);
				<>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();
		}
	}

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

		private object <>2__current;

		public Character who;

		public float seconds;

		public PEAKTagPlugin <>4__this;

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

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

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

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

		private bool MoveNext()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				if ((Object)(object)who?.refs?.view == (Object)null)
				{
					return false;
				}
				<>2__current = (object)new WaitForSeconds(seconds);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				try
				{
					who.refs.view.RPC("OnRevive_RPC", (RpcTarget)3, Array.Empty<object>());
				}
				catch
				{
				}
				if ((Object)(object)who.refs?.view != (Object)null && who.refs.view.ViewID == <>4__this._itViewId)
				{
					TryMarkEyes(who, makePassedOut: 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();
		}
	}

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

		private object <>2__current;

		public PEAKTagPlugin <>4__this;

		private float <delaySeconds>5__1;

		private float <waited>5__2;

		private List<Character> <characters>5__3;

		private int <count>5__4;

		private List<Character> <list>5__5;

		private Character <chosen>5__6;

		private int <viewId>5__7;

		private float <rag>5__8;

		private int <i>5__9;

		private Character <c>5__10;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<characters>5__3 = null;
			<list>5__5 = null;
			<chosen>5__6 = null;
			<c>5__10 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: 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_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Expected O, but got Unknown
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Expected O, but got Unknown
			//IL_0331: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>4__this.StopItWatcher();
				<>4__this.StopGiftLoop();
				<>4__this.StopBoostGiftLoop();
				<>4__this.StopNonItDistanceWatch();
				<>4__this.StopFreezeAfflictions();
				<>4__this.ResetScoreboardStats();
				<>4__this.ClearPlayerPowers();
				<>4__this.StartFreezeAfflictions();
				((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.EquipBackpacksAfterDelay());
				<delaySeconds>5__1 = ((<>4__this._initialItDelaySec != null) ? <>4__this._initialItDelaySec.Value : 60f);
				((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)$"[Tag] Waiting {<delaySeconds>5__1} seconds before picking initial IT...");
				<waited>5__2 = 0f;
				break;
			case 1:
				<>1__state = -1;
				<waited>5__2 += 1f;
				break;
			}
			if (<waited>5__2 < <delaySeconds>5__1)
			{
				if (!PhotonNetwork.IsMasterClient || !PhotonNetwork.InRoom)
				{
					return false;
				}
				Scene activeScene = SceneManager.GetActiveScene();
				if (string.Equals(((Scene)(ref activeScene)).name, "Airport", StringComparison.OrdinalIgnoreCase))
				{
					return false;
				}
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			}
			<characters>5__3 = Character.AllCharacters;
			<count>5__4 = <characters>5__3.Count;
			<list>5__5 = new List<Character>();
			<i>5__9 = 0;
			while (<i>5__9 < <count>5__4)
			{
				<c>5__10 = <characters>5__3[<i>5__9];
				if ((Object)(object)<c>5__10 != (Object)null && !<c>5__10.isBot && (Object)(object)<c>5__10.refs?.view != (Object)null && !<c>5__10.data.dead)
				{
					<list>5__5.Add(<c>5__10);
				}
				<c>5__10 = null;
				<i>5__9++;
			}
			if (<list>5__5.Count == 0)
			{
				return false;
			}
			<chosen>5__6 = <list>5__5[Random.Range(0, <list>5__5.Count)];
			<viewId>5__7 = <chosen>5__6.refs.view.ViewID;
			<>4__this._prevItViewId = <>4__this._itViewId;
			<>4__this._itViewId = <viewId>5__7;
			<>4__this._graceUntil = PhotonNetwork.Time + 1.5;
			Room currentRoom = PhotonNetwork.CurrentRoom;
			Hashtable val = new Hashtable();
			((Dictionary<object, object>)val).Add((object)"tag_itViewId", (object)<viewId>5__7);
			((Dictionary<object, object>)val).Add((object)"tag_graceUntil", (object)<>4__this._graceUntil);
			currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
			((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)$"[Tag] Initial IT chosen: {SafeName(<chosen>5__6)} (ViewID {<viewId>5__7}).");
			<rag>5__8 = ((<>4__this._initialItRagdollSec != null) ? <>4__this._initialItRagdollSec.Value : 10f);
			((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)$"[Tag] Ragdolling initial IT for {<rag>5__8} seconds...");
			<>4__this.RagdollWithGrayscale(<chosen>5__6, <rag>5__8);
			((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.DeferRefreshItEyesAfterRagdoll(<chosen>5__6, <rag>5__8));
			<>4__this.StartGiftLoop();
			<>4__this.StartBoostGiftLoop();
			<>4__this.PreOpenAllLuggageNoLoot();
			<>4__this.StartNonItDistanceWatch();
			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 <ItWatch>d__86 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Character it;

		public PEAKTagPlugin <>4__this;

		private PlayerEyeLook <eye>5__1;

		private CharacterData <data>5__2;

		private double <now>5__3;

		private Character <target>5__4;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<eye>5__1 = null;
			<data>5__2 = null;
			<target>5__4 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Expected O, but got Unknown
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
			{
				<>1__state = -1;
				Character obj = it;
				<eye>5__1 = ((obj != null) ? ((Component)obj).GetComponent<PlayerEyeLook>() : null);
				<data>5__2 = it?.data;
				if ((Object)(object)<eye>5__1 == (Object)null || (Object)(object)<data>5__2 == (Object)null)
				{
					return false;
				}
				break;
			}
			case 1:
				<>1__state = -1;
				break;
			case 2:
				<>1__state = -1;
				break;
			case 3:
				<>1__state = -1;
				break;
			}
			if (PhotonNetwork.IsMasterClient && (Object)(object)it != (Object)null && <data>5__2.isReaching && <>4__this._itViewId == it.refs.view.ViewID)
			{
				<now>5__3 = PhotonNetwork.Time;
				if (<now>5__3 < <>4__this._graceUntil)
				{
					<>2__current = (object)new WaitForSeconds(0.05f);
					<>1__state = 1;
					return true;
				}
				if (<eye>5__1.lookingAtCharacter && (Object)(object)<eye>5__1.character != (Object)null && <eye>5__1.distance <= 1.5f)
				{
					if (TaggingBlockedByCampfire(it, <eye>5__1.character))
					{
						<>2__current = (object)new WaitForSeconds(0.05f);
						<>1__state = 2;
						return true;
					}
					<target>5__4 = <eye>5__1.character;
					if (IsAlive(<target>5__4) && (Object)(object)<target>5__4 != (Object)(object)it)
					{
						<>4__this.HostPerformTag(it, <target>5__4);
						return false;
					}
					<target>5__4 = null;
				}
				<>2__current = (object)new WaitForSeconds(0.05f);
				<>1__state = 3;
				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();
		}
	}

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

		private object <>2__current;

		public PEAKTagPlugin <>4__this;

		private float <wait>5__1;

		private Character <itChar>5__2;

		private float <gap>5__3;

		private Vector3 <itPos>5__4;

		private List<Character> <characters>5__5;

		private int <count>5__6;

		private int <i>5__7;

		private Character <c>5__8;

		private float <dy>5__9;

		private Vector3 <near>5__10;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<itChar>5__2 = null;
			<characters>5__5 = null;
			<c>5__8 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: 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_01c8: 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_01f1: Unknown result type (might be due to invalid IL or missing references)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				<itChar>5__2 = FindCharacterByViewID(<>4__this._itViewId);
				if (!IsAlive(<itChar>5__2))
				{
					break;
				}
				<gap>5__3 = ((<>4__this._nonItWarpVerticalGapMeters != null) ? Mathf.Max(5f, <>4__this._nonItWarpVerticalGapMeters.Value) : 80f);
				<itPos>5__4 = <itChar>5__2.Center;
				<characters>5__5 = Character.AllCharacters;
				<count>5__6 = <characters>5__5.Count;
				<i>5__7 = 0;
				while (<i>5__7 < <count>5__6)
				{
					<c>5__8 = <characters>5__5[<i>5__7];
					if (IsAlive(<c>5__8) && !<c>5__8.isBot && (Object)(object)<c>5__8 != (Object)(object)<itChar>5__2)
					{
						<dy>5__9 = <itPos>5__4.y - <c>5__8.Center.y;
						if (<dy>5__9 > <gap>5__3)
						{
							try
							{
								<near>5__10 = <itPos>5__4 + new Vector3(Random.Range(-2f, 2f), 0f, Random.Range(-2f, 2f));
								<c>5__8.refs.view.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { <near>5__10, true });
							}
							catch
							{
							}
						}
					}
					<c>5__8 = null;
					<i>5__7++;
				}
				<itChar>5__2 = null;
				<characters>5__5 = null;
				break;
			}
			if (PhotonNetwork.IsMasterClient && PhotonNetwork.InRoom)
			{
				<wait>5__1 = ((<>4__this._nonItWarpCheckIntervalSec != null) ? Mathf.Max(1f, <>4__this._nonItWarpCheckIntervalSec.Value) : 5f);
				<>2__current = (object)new WaitForSeconds(<wait>5__1);
				<>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();
		}
	}

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

		private object <>2__current;

		public int itViewId;

		public PEAKTagPlugin <>4__this;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>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
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(0.25f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if (<>4__this._itViewId == itViewId)
				{
					<>4__this.RefreshItEyes();
				}
				return false;
			}
		}

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

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

	public static PEAKTagPlugin Instance;

	private const string PROP_IT = "tag_itViewId";

	private const string PROP_GRACE_UNTIL = "tag_graceUntil";

	private const float TAG_DISTANCE = 1.5f;

	private const double NEW_IT_GRACE = 1.5;

	private const float TAG_TICK_SEC = 0.05f;

	private const float BACKPACK_DELAY_SEC = 15f;

	private const float INITIAL_IT_DELAY_SEC = 60f;

	private const float FALL_SECONDS_ON_TAG = 5f;

	private const float CAMPFIRE_SAFE_RADIUS = 15f;

	private const float EYE_REASSERT_DELAY = 0.25f;

	private bool _scoreboardVisible = false;

	private ConfigEntry<KeyCode> _scoreboardKey;

	private ConfigEntry<KeyCode> _scoreboardModifierKey;

	private ConfigEntry<bool> _scoreboardRequireModifier;

	private ConfigEntry<bool> _scoreboardShowOnStart;

	private ConfigEntry<Color> _scoreboardBackgroundColor;

	private ConfigEntry<Color> _scoreboardTextColor;

	private ConfigEntry<Color> _scoreboardHeaderColor;

	private ConfigEntry<int> _scoreboardFontSize;

	private ConfigEntry<float> _scoreboardWidth;

	private ConfigEntry<float> _scoreboardHeight;

	private ConfigEntry<float> _scoreboardX;

	private ConfigEntry<float> _scoreboardY;

	private const float IT_WARP_CHECK_INTERVAL = 5f;

	private const float NONIT_WARP_VERTICAL_GAP = 80f;

	private const float FREEZE_TICK_SEC = 1f;

	private Coroutine _giftCo;

	private ConfigEntry<bool> _giftEnabled;

	private ConfigEntry<float> _giftIntervalSec;

	private ConfigEntry<bool> _giftExcludeRescueHook;

	private readonly GiftDef[] _giftPool = new GiftDef[12]
	{
		new GiftDef
		{
			id = 1,
			name = "Anti-Rope Spool"
		},
		new GiftDef
		{
			id = 37,
			name = "Balloon Bunch"
		},
		new GiftDef
		{
			id = 79,
			name = "Bounce Shroom"
		},
		new GiftDef
		{
			id = 17,
			name = "Chain Launcher"
		},
		new GiftDef
		{
			id = 18,
			name = "Piton"
		},
		new GiftDef
		{
			id = 36,
			name = "Coconut"
		},
		new GiftDef
		{
			id = 45,
			name = "Magic Bean"
		},
		new GiftDef
		{
			id = 100,
			name = "Rescue Hook"
		},
		new GiftDef
		{
			id = 63,
			name = "Rope Cannon"
		},
		new GiftDef
		{
			id = 64,
			name = "Anti-Rope Cannon"
		},
		new GiftDef
		{
			id = 107,
			name = "Scout Cannon"
		},
		new GiftDef
		{
			id = 68,
			name = "Shelf Shroom"
		}
	};

	private ConfigEntry<float> _campfireCooldownSec;

	private ConfigEntry<float> _campfireRagdollSec;

	private ConfigEntry<float> _initialItDelaySec;

	private ConfigEntry<float> _initialItRagdollSec;

	private ConfigEntry<float> _nonItWarpCheckIntervalSec;

	private ConfigEntry<float> _nonItWarpVerticalGapMeters;

	private ConfigEntry<float> _playerStunPowerChance;

	private ConfigEntry<float> _playerStunPowerTime;

	private ConfigEntry<float> _playerWarpPowerChance;

	private ConfigEntry<float> _playerItemDropChance;

	private const float BUFF_BASE_SECONDS = 13f;

	private const ushort LOLLIPOP_ID = 44;

	private const ushort ENERGY_ID = 27;

	private ConfigEntry<int> _infiniteMultiplier;

	private ConfigEntry<int> _boostMultiplier;

	private ConfigEntry<float> _boostGiftIntervalSec;

	private Coroutine _boostGiftCo;

	private Coroutine _lolliChainCo;

	private Coroutine _drinkChainCo;

	private int _itViewId = -1;

	private int _prevItViewId = -1;

	private double _graceUntil = 0.0;

	private double _campfireItCooldownUntil = 0.0;

	private Coroutine _itWatcherCo;

	private int _itWatcherViewId = -1;

	private Coroutine _runStartCo;

	private Coroutine _nonItDistanceWatchCo;

	private Coroutine _freezeAfflictionsCo;

	private static readonly List<Campfire> _campfires = new List<Campfire>(32);

	private float _campfireCacheNextRebuildTime = 0f;

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

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

	private Dictionary<int, PowerType> _playerPowers = new Dictionary<int, PowerType>();

	private Dictionary<int, bool> _powerAvailable = new Dictionary<int, bool>();

	private Harmony _harmony;

	private void Awake()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_0379: Unknown result type (might be due to invalid IL or missing references)
		//IL_039e: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		_harmony = new Harmony("tony4twentys.PEAK_Tag");
		_harmony.PatchAll();
		TryPatchReachingRpcs();
		TryPatchEyePersistence();
		TryPatchLuggageNoLoot();
		TryPatchLuggageSpawnRoutineBlock();
		TryPatchLuggageAwakeAutoOpen();
		TryPatchHostAfflictions();
		PhotonNetwork.AddCallbackTarget((object)this);
		SceneManager.activeSceneChanged += OnSceneChanged;
		_giftEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Gifts", "Enabled", true, "Give players a random helpful item periodically (host-only)");
		_giftIntervalSec = ((BaseUnityPlugin)this).Config.Bind<float>("Gifts", "IntervalSeconds", 120f, "Seconds between random gifts to each player");
		_giftExcludeRescueHook = ((BaseUnityPlugin)this).Config.Bind<bool>("Gifts", "ExcludeRescueHook", true, "Exclude Rescue Hook (id 100) from the random gift pool");
		_campfireCooldownSec = ((BaseUnityPlugin)this).Config.Bind<float>("Campfires", "ItCooldownSeconds", 60f, "Seconds after a campfire lights during which IT cannot tag (host-only)");
		_campfireRagdollSec = ((BaseUnityPlugin)this).Config.Bind<float>("Campfires", "ItRagdollSecondsOnLight", 5f, "Seconds to ragdoll the current IT when a campfire lights");
		_initialItDelaySec = ((BaseUnityPlugin)this).Config.Bind<float>("IT", "InitialItDelaySeconds", 20f, "Seconds to wait before picking the initial IT (default: 20s)");
		_initialItRagdollSec = ((BaseUnityPlugin)this).Config.Bind<float>("IT", "InitialRagdollSeconds", 10f, "Seconds to ragdoll the initial IT (also grayscale duration)");
		_nonItWarpCheckIntervalSec = ((BaseUnityPlugin)this).Config.Bind<float>("IT", "WarpCheckInterval", 5f, "Seconds between non-IT vertical distance checks");
		_nonItWarpVerticalGapMeters = ((BaseUnityPlugin)this).Config.Bind<float>("IT", "WarpDistanceMeters", 80f, "Vertical gap (meters) below IT that will trigger a warp for non-IT players");
		_playerStunPowerChance = ((BaseUnityPlugin)this).Config.Bind<float>("PlayerPowers", "PlayerStunPowerChance", 0.05f, "Chance (0.0-1.0) for Player Stun power (global ragdoll)");
		_playerStunPowerTime = ((BaseUnityPlugin)this).Config.Bind<float>("PlayerPowers", "PlayerStunPowerTime", 5f, "Duration in seconds for Player Stun power ragdoll effect");
		_playerWarpPowerChance = ((BaseUnityPlugin)this).Config.Bind<float>("PlayerPowers", "PlayerWarpPowerChance", 0.05f, "Chance (0.0-1.0) for Player Warp power (warp non-IT to lowest Y)");
		_playerItemDropChance = ((BaseUnityPlugin)this).Config.Bind<float>("PlayerPowers", "PlayerItemDropChance", 0.05f, "Chance (0.0-1.0) for Player Item Drop power (drop all items)");
		_infiniteMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("Chains", "InfiniteStaminaTimeMultiplier", 3, "Base ~13s x this value");
		_boostMultiplier = ((BaseUnityPlugin)this).Config.Bind<int>("Chains", "BoostSprintAndClimbMultiplier", 3, "Base ~13s x this value");
		_boostGiftIntervalSec = ((BaseUnityPlugin)this).Config.Bind<float>("BoostGifts", "IntervalSeconds", 90f, "Seconds between boost rolls for the current IT (50/30/20 split).");
		_scoreboardKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Scoreboard", "Key", (KeyCode)115, "Key to toggle scoreboard visibility");
		_scoreboardModifierKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Scoreboard", "ModifierKey", (KeyCode)308, "Modifier key for scoreboard (default: Alt+S)");
		_scoreboardRequireModifier = ((BaseUnityPlugin)this).Config.Bind<bool>("Scoreboard", "RequireModifier", true, "Require modifier key to toggle scoreboard (set to false to use just the key)");
		_scoreboardShowOnStart = ((BaseUnityPlugin)this).Config.Bind<bool>("Scoreboard", "ShowOnStart", false, "Show scoreboard when the game starts");
		_scoreboardBackgroundColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Scoreboard", "BackgroundColor", new Color(0f, 0f, 0f, 0.8f), "Background color of the scoreboard");
		_scoreboardTextColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Scoreboard", "TextColor", Color.white, "Text color of the scoreboard");
		_scoreboardHeaderColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Scoreboard", "HeaderColor", Color.white, "Header color of the scoreboard");
		_scoreboardFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Scoreboard", "FontSize", 16, "Font size of the scoreboard text");
		_scoreboardWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Scoreboard", "Width", 350f, "Width of the scoreboard");
		_scoreboardHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Scoreboard", "Height", 250f, "Height of the scoreboard");
		_scoreboardX = ((BaseUnityPlugin)this).Config.Bind<float>("Scoreboard", "X", 10f, "X position of the scoreboard");
		_scoreboardY = ((BaseUnityPlugin)this).Config.Bind<float>("Scoreboard", "Y", 10f, "Y position of the scoreboard");
		_scoreboardVisible = _scoreboardShowOnStart.Value;
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[Tag] Loaded v1.1.0 (OPTIMIZED + Player Powers System + freeze @ run start, centralized eyes, no SFX/VFX patches).");
	}

	private void OnDestroy()
	{
		PhotonNetwork.RemoveCallbackTarget((object)this);
		SceneManager.activeSceneChanged -= OnSceneChanged;
		try
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
		catch
		{
		}
	}

	private void OnSceneChanged(Scene oldScene, Scene newScene)
	{
		if (((Scene)(ref newScene)).name == "Airport")
		{
			StopItWatcher();
			StopGiftLoop();
			StopBoostGiftLoop();
			StopNonItDistanceWatch();
			StopFreezeAfflictions();
			_prevItViewId = -1;
			_itViewId = -1;
			_graceUntil = 0.0;
			_runStartCo = null;
			ClearPlayerPowers();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[Tag] Reset at Airport.");
		}
		else if (PhotonNetwork.IsMasterClient && PhotonNetwork.InRoom)
		{
			RefreshItEyes();
		}
	}

	private void StartRunHostFlow()
	{
		if (_runStartCo != null)
		{
			((MonoBehaviour)this).StopCoroutine(_runStartCo);
		}
		_runStartCo = ((MonoBehaviour)this).StartCoroutine(HostRunStartFlowCo());
	}

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

	private void SetItNow(Character who, double grace)
	{
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Expected O, but got Unknown
		//IL_0093: Expected O, but got Unknown
		if (!((Object)(object)who?.refs?.view == (Object)null))
		{
			int viewID = who.refs.view.ViewID;
			_prevItViewId = _itViewId;
			_itViewId = viewID;
			_graceUntil = PhotonNetwork.Time + grace;
			Room currentRoom = PhotonNetwork.CurrentRoom;
			Hashtable val = new Hashtable();
			((Dictionary<object, object>)val).Add((object)"tag_itViewId", (object)viewID);
			((Dictionary<object, object>)val).Add((object)"tag_graceUntil", (object)_graceUntil);
			currentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
			RefreshItEyes();
			((MonoBehaviour)this).StartCoroutine(DeferRefreshItEyes(_itViewId));
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Current IT: {SafeName(who)} (ViewID {viewID}).");
		}
	}

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

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

	private int GiveBackpacksNow()
	{
		if (!PhotonNetwork.IsMasterClient)
		{
			return 0;
		}
		int num = 0;
		List<Character> allCharacters = Character.AllCharacters;
		int count = allCharacters.Count;
		for (int i = 0; i < count; i++)
		{
			Character c = allCharacters[i];
			if (IsAlive(c) && EquipBackpackOnCharacter(c))
			{
				num++;
			}
		}
		return num;
	}

	private bool EquipBackpackOnCharacter(Character c)
	{
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Player val = ((c != null) ? c.player : null);
			if ((Object)(object)val == (Object)null || val.backpackSlot == null || val.backpackSlot.hasBackpack)
			{
				return false;
			}
			if (((ItemSlot)val.backpackSlot).data == null)
			{
				ItemInstanceData val2 = new ItemInstanceData(Guid.NewGuid());
				ItemInstanceDataHandler.AddInstanceData(val2);
				((ItemSlot)val.backpackSlot).data = val2;
			}
			BackpackData val3 = default(BackpackData);
			if (!((ItemSlot)val.backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val3) || val3 == null)
			{
				((ItemSlot)val.backpackSlot).data.RegisterNewEntry<BackpackData>((DataEntryKey)7);
				((ItemSlot)val.backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val3);
			}
			val.backpackSlot.hasBackpack = true;
			InventorySyncData val4 = default(InventorySyncData);
			((InventorySyncData)(ref val4))..ctor(val.itemSlots, val.backpackSlot, val.tempFullSlot);
			((MonoBehaviourPun)val).photonView.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2]
			{
				IBinarySerializable.ToManagedArray<InventorySyncData>(val4),
				false
			});
			return true;
		}
		catch
		{
			return false;
		}
	}

	private static bool AllHumansHaveBackpacks()
	{
		List<Character> allCharacters = Character.AllCharacters;
		int count = allCharacters.Count;
		for (int i = 0; i < count; i++)
		{
			Character val = allCharacters[i];
			if (IsAlive(val) && !val.isBot)
			{
				Player player = val.player;
				if (player == null || !(player.backpackSlot?.hasBackpack).GetValueOrDefault())
				{
					return false;
				}
			}
		}
		return true;
	}

	private void TryPatchReachingRpcs()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Expected O, but got Unknown
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Expected O, but got Unknown
		try
		{
			_harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterGrabbing), "RPCA_StartReaching", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PEAKTagPlugin).GetMethod("ReachStartPostfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			_harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterGrabbing), "RPCA_StopReaching", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PEAKTagPlugin).GetMethod("ReachStopPostfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("[Tag] Reach RPC patch failed: " + ex.Message));
		}
	}

	private static void ReachStartPostfix(object __instance)
	{
		if (PhotonNetwork.IsMasterClient)
		{
			Character value = Traverse.Create(__instance).Field("character").GetValue<Character>();
			if (!((Object)(object)value?.refs?.view == (Object)null) && Instance._itViewId == value.refs.view.ViewID)
			{
				Instance.StartItWatcher(value);
			}
		}
	}

	private static void ReachStopPostfix(object __instance)
	{
		if (PhotonNetwork.IsMasterClient)
		{
			Character value = Traverse.Create(__instance).Field("character").GetValue<Character>();
			if (!((Object)(object)value?.refs?.view == (Object)null) && Instance._itWatcherViewId == value.refs.view.ViewID)
			{
				Instance.StopItWatcher();
			}
		}
	}

	private void StartItWatcher(Character it)
	{
		StopItWatcher();
		if (!((Object)(object)it == (Object)null) && !((Object)(object)it.refs?.view == (Object)null))
		{
			_itWatcherViewId = it.refs.view.ViewID;
			_itWatcherCo = ((MonoBehaviour)this).StartCoroutine(ItWatch(it));
		}
	}

	private void StopItWatcher()
	{
		if (_itWatcherCo != null)
		{
			((MonoBehaviour)this).StopCoroutine(_itWatcherCo);
			_itWatcherCo = null;
		}
		_itWatcherViewId = -1;
	}

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

	private void HostPerformTag(Character it, Character target)
	{
		if (PhotonNetwork.IsMasterClient && !((Object)(object)target?.refs?.view == (Object)null) && !((Object)(object)it?.refs?.view == (Object)null) && !TaggingBlockedByCampfire(it, target))
		{
			SetItNow(target, 1.5);
			RagdollWithGrayscale(target, 5f);
			ApplyHeadStartBoostsTo(it);
			int ownerActorNr = it.refs.view.OwnerActorNr;
			int ownerActorNr2 = target.refs.view.OwnerActorNr;
			_tagsMade[ownerActorNr] = (_tagsMade.TryGetValue(ownerActorNr, out var value) ? value : 0) + 1;
			_tagsGot[ownerActorNr2] = (_tagsGot.TryGetValue(ownerActorNr2, out var value2) ? value2 : 0) + 1;
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] {SafeName(it)} tagged {SafeName(target)}. New IT (grace {1.5:0.00}s).");
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Stats updated - {SafeName(it)}: {_tagsMade[ownerActorNr]} tags made, {SafeName(target)}: {_tagsGot[ownerActorNr2]} tags got");
			StopItWatcher();
		}
	}

	private void TryPatchEyePersistence()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Expected O, but got Unknown
		try
		{
			_harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterCustomization), "OnRevive_RPC", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PEAKTagPlugin).GetMethod("EyeReassertPostfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("[Tag] Eye persistence patch failed: " + ex.Message));
		}
	}

	private static void EyeReassertPostfix(object __instance)
	{
		try
		{
			Character val = null;
			Component val2 = (Component)((__instance is Component) ? __instance : null);
			if (val2 != null)
			{
				val = val2.GetComponent<Character>();
			}
			if ((Object)(object)val == (Object)null)
			{
				Traverse val3 = Traverse.Create(__instance);
				val = val3.Field("_character").GetValue<Character>() ?? val3.Field("character").GetValue<Character>();
			}
			if (!((Object)(object)val?.refs?.view == (Object)null) && Instance._itViewId == val.refs.view.ViewID)
			{
				val.refs.view.RPC("CharacterPassedOut", (RpcTarget)3, Array.Empty<object>());
			}
		}
		catch
		{
		}
	}

	private void StartGiftLoop()
	{
		if (_giftCo == null && (_giftEnabled == null || _giftEnabled.Value))
		{
			_giftCo = ((MonoBehaviour)this).StartCoroutine(GiftLoop());
		}
	}

	private void StopGiftLoop()
	{
		if (_giftCo != null)
		{
			((MonoBehaviour)this).StopCoroutine(_giftCo);
			_giftCo = null;
		}
	}

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

	private void TryGiveRandomGiftsToAll()
	{
		try
		{
			List<GiftDef> list = new List<GiftDef>(_giftPool.Length);
			bool flag = _giftExcludeRescueHook?.Value ?? true;
			for (int i = 0; i < _giftPool.Length; i++)
			{
				GiftDef item = _giftPool[i];
				if (!flag || item.id != 100)
				{
					list.Add(item);
				}
			}
			if (list.Count == 0)
			{
				return;
			}
			List<Character> allCharacters = Character.AllCharacters;
			int count = allCharacters.Count;
			for (int j = 0; j < count; j++)
			{
				Character val = allCharacters[j];
				if (IsAlive(val) && !val.isBot && (Object)(object)val.refs?.items != (Object)null)
				{
					GiftDef gift = list[Random.Range(0, list.Count)];
					TryGiveItemTo(val, gift);
				}
			}
		}
		catch
		{
		}
	}

	private void StartNonItDistanceWatch()
	{
		if (_nonItDistanceWatchCo == null)
		{
			_nonItDistanceWatchCo = ((MonoBehaviour)this).StartCoroutine(NonItDistanceWatchLoop());
		}
	}

	private void StopNonItDistanceWatch()
	{
		if (_nonItDistanceWatchCo != null)
		{
			((MonoBehaviour)this).StopCoroutine(_nonItDistanceWatchCo);
			_nonItDistanceWatchCo = null;
		}
	}

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

	private void StartBoostGiftLoop()
	{
		if (_boostGiftCo == null)
		{
			_boostGiftCo = ((MonoBehaviour)this).StartCoroutine(BoostGiftLoop());
		}
	}

	private void StopBoostGiftLoop()
	{
		if (_boostGiftCo != null)
		{
			((MonoBehaviour)this).StopCoroutine(_boostGiftCo);
			_boostGiftCo = null;
		}
		if (_lolliChainCo != null)
		{
			((MonoBehaviour)this).StopCoroutine(_lolliChainCo);
			_lolliChainCo = null;
		}
		if (_drinkChainCo != null)
		{
			((MonoBehaviour)this).StopCoroutine(_drinkChainCo);
			_drinkChainCo = null;
		}
	}

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

	private void ApplyHeadStartBoostsTo(Character who)
	{
		if (!((Object)(object)who == (Object)null))
		{
			if (_lolliChainCo != null)
			{
				((MonoBehaviour)this).StopCoroutine(_lolliChainCo);
			}
			if (_drinkChainCo != null)
			{
				((MonoBehaviour)this).StopCoroutine(_drinkChainCo);
			}
			int times = Mathf.Max(1, (_infiniteMultiplier != null) ? _infiniteMultiplier.Value : 3);
			int times2 = Mathf.Max(1, (_boostMultiplier != null) ? _boostMultiplier.Value : 3);
			_lolliChainCo = ((MonoBehaviour)this).StartCoroutine(ChainFeed(who, 44, times, "Lollipop (HeadStart)"));
			_drinkChainCo = ((MonoBehaviour)this).StartCoroutine(ChainFeed(who, 27, times2, "Energy (HeadStart)"));
		}
	}

	private void PickBoostSet(out bool doLolli, out bool doEnergy, out bool doBonus)
	{
		doLolli = (doEnergy = (doBonus = false));
		float value = Random.value;
		int num = ((value < 0.5f) ? 1 : ((value < 0.8f) ? 2 : 3));
		List<int> list = new List<int> { 0, 1, 2 };
		for (int i = 0; i < num; i++)
		{
			int index = Random.Range(0, list.Count);
			int num2 = list[index];
			list.RemoveAt(index);
			switch (num2)
			{
			case 0:
				doLolli = true;
				break;
			case 1:
				doEnergy = true;
				break;
			default:
				doBonus = true;
				break;
			}
		}
	}

	[IteratorStateMachine(typeof(<ChainFeed>d__104))]
	private IEnumerator ChainFeed(Character receiver, ushort itemID, int times, string label)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ChainFeed>d__104(0)
		{
			<>4__this = this,
			receiver = receiver,
			itemID = itemID,
			times = times,
			label = label
		};
	}

	private bool ForceFeedOnce(Character receiver, ushort itemID, string label, out Item spawnedItem)
	{
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		spawnedItem = null;
		Item val = default(Item);
		if (!ItemDatabase.TryGetItem(itemID, ref val) || (Object)(object)val == (Object)null)
		{
			return false;
		}
		Vector3 val2 = ((Component)receiver).transform.position + Vector3.up * 0.5f;
		GameObject val3 = PhotonNetwork.InstantiateItemRoom(((Object)((Component)val).gameObject).name, val2, Quaternion.identity);
		if (!Object.op_Implicit((Object)(object)val3))
		{
			return false;
		}
		Item component = val3.GetComponent<Item>();
		if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)((MonoBehaviourPun)component).photonView))
		{
			return false;
		}
		receiver.FeedItem(component);
		spawnedItem = component;
		return true;
	}

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

	private void GiveFullBonusStamina(Character target)
	{
		if (!((Object)(object)target?.refs?.view == (Object)null))
		{
			int num = ((PhotonNetwork.CurrentRoom == null) ? 1 : PhotonNetwork.CurrentRoom.PlayerCount);
			target.refs.view.RPC("MoraleBoost", target.refs.view.Owner, new object[2] { 1f, num });
		}
	}

	public void OnRoomPropertiesUpdate(Hashtable changed)
	{
		if (changed == null)
		{
			return;
		}
		if (((Dictionary<object, object>)(object)changed).ContainsKey((object)"tag_itViewId"))
		{
			_prevItViewId = _itViewId;
			_itViewId = (int)changed[(object)"tag_itViewId"];
			RefreshItEyes();
			((MonoBehaviour)this).StartCoroutine(DeferRefreshItEyes(_itViewId));
			if (_itWatcherViewId != _itViewId)
			{
				StopItWatcher();
			}
		}
		if (!((Dictionary<object, object>)(object)changed).ContainsKey((object)"tag_graceUntil"))
		{
			return;
		}
		object obj = changed[(object)"tag_graceUntil"];
		if (obj is double graceUntil)
		{
			_graceUntil = graceUntil;
		}
		else if (obj is float)
		{
			float num = (float)obj;
			if (true)
			{
				_graceUntil = num;
			}
		}
	}

	public void OnMasterClientSwitched(Player newMasterClient)
	{
		if (PhotonNetwork.IsMasterClient)
		{
			StartGiftLoop();
			StartNonItDistanceWatch();
			StartBoostGiftLoop();
			StartFreezeAfflictions();
			RefreshItEyes();
		}
		else
		{
			StopGiftLoop();
			StopNonItDistanceWatch();
			StopBoostGiftLoop();
			StopFreezeAfflictions();
			ClearPlayerPowers();
		}
	}

	void IInRoomCallbacks.OnPlayerEnteredRoom(Player newPlayer)
	{
		((MonoBehaviour)this).StartCoroutine(DeferRefreshItEyes(_itViewId));
	}

	void IInRoomCallbacks.OnPlayerLeftRoom(Player otherPlayer)
	{
		RefreshItEyes();
	}

	void IInRoomCallbacks.OnPlayerPropertiesUpdate(Player targetPlayer, Hashtable changedProps)
	{
	}

	private static bool IsUnlitCampfireNear(Vector3 pos, float radius)
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Invalid comparison between Unknown and I4
		//IL_003f: 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_004a: Unknown result type (might be due to invalid IL or missing references)
		RefreshCampfireCache();
		float num = radius * radius;
		for (int i = 0; i < _campfires.Count; i++)
		{
			Campfire val = _campfires[i];
			if (!((Object)(object)val == (Object)null) && (int)val.state == 0)
			{
				Vector3 val2 = ((Component)val).transform.position - pos;
				if (((Vector3)(ref val2)).sqrMagnitude <= num)
				{
					return true;
				}
			}
		}
		return false;
	}

	private static bool TaggingBlockedByCampfire(Character it, Character target)
	{
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		if (!PhotonNetwork.IsMasterClient)
		{
			return false;
		}
		try
		{
			if ((Object)(object)Instance != (Object)null && PhotonNetwork.Time < Instance._campfireItCooldownUntil)
			{
				int? obj;
				if (it == null)
				{
					obj = null;
				}
				else
				{
					CharacterRefs refs = it.refs;
					if (refs == null)
					{
						obj = null;
					}
					else
					{
						PhotonView view = refs.view;
						obj = ((view != null) ? new int?(view.ViewID) : null);
					}
				}
				int? num = obj;
				int valueOrDefault = num.GetValueOrDefault(-1);
				if (valueOrDefault != -1 && valueOrDefault == Instance._itViewId)
				{
					return true;
				}
			}
			Vector3 pos = ((it != null) ? it.Center : Vector3.zero);
			Vector3 pos2 = ((target != null) ? target.Center : Vector3.zero);
			if (IsUnlitCampfireNear(pos, 15f))
			{
				return true;
			}
			if (IsUnlitCampfireNear(pos2, 15f))
			{
				return true;
			}
		}
		catch
		{
		}
		return false;
	}

	private static void RefreshCampfireCache()
	{
		float realtimeSinceStartup = Time.realtimeSinceStartup;
		if ((Object)(object)Instance == (Object)null || realtimeSinceStartup < Instance._campfireCacheNextRebuildTime)
		{
			return;
		}
		Instance._campfireCacheNextRebuildTime = realtimeSinceStartup + 5f;
		_campfires.Clear();
		try
		{
			Campfire[] array = Object.FindObjectsOfType<Campfire>();
			if (array != null && array.Length != 0)
			{
				_campfires.AddRange(array);
			}
		}
		catch
		{
		}
	}

	private static bool IsAlive(Character c)
	{
		return (Object)(object)c != (Object)null && (Object)(object)c.data != (Object)null && !c.data.dead && c.data.fullyConscious;
	}

	private static Character FindCharacterByViewID(int viewId)
	{
		foreach (Character allCharacter in Character.AllCharacters)
		{
			if ((Object)(object)allCharacter?.refs?.view != (Object)null && allCharacter.refs.view.ViewID == viewId)
			{
				return allCharacter;
			}
		}
		return null;
	}

	private void RagdollWithGrayscale(Character who, float seconds)
	{
		if ((Object)(object)who?.refs?.view == (Object)null)
		{
			return;
		}
		try
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Applying ragdoll + grayscale to {SafeName(who)} for {seconds} seconds");
			who.refs.view.RPC("CharacterPassedOut", (RpcTarget)3, Array.Empty<object>());
			who.refs.view.RPC("RPCA_Fall", (RpcTarget)0, new object[1] { seconds });
			((MonoBehaviour)this).StartCoroutine(GrayscaleWindow(who, seconds));
			((BaseUnityPlugin)this).Logger.LogInfo((object)("[Tag] Ragdoll + grayscale applied successfully to " + SafeName(who)));
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("[Tag] Failed to apply ragdoll + grayscale to " + SafeName(who) + ": " + ex.Message));
		}
	}

	private static void TryRagdoll(Character who, float seconds)
	{
		try
		{
			if (who == null)
			{
				return;
			}
			CharacterRefs refs = who.refs;
			if (refs != null)
			{
				PhotonView view = refs.view;
				if (view != null)
				{
					view.RPC("RPCA_Fall", (RpcTarget)0, new object[1] { seconds });
				}
			}
		}
		catch
		{
		}
	}

	private static void TryMarkEyes(Character who, bool makePassedOut)
	{
		try
		{
			if (!((Object)(object)who?.refs?.view == (Object)null))
			{
				if (makePassedOut)
				{
					who.refs.view.RPC("CharacterPassedOut", (RpcTarget)3, Array.Empty<object>());
				}
				else
				{
					who.refs.view.RPC("OnRevive_RPC", (RpcTarget)3, Array.Empty<object>());
				}
			}
		}
		catch
		{
		}
	}

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

	private static string SafeName(Character c)
	{
		object obj;
		if (c == null)
		{
			obj = null;
		}
		else
		{
			CharacterRefs refs = c.refs;
			if (refs == null)
			{
				obj = null;
			}
			else
			{
				PhotonView view = refs.view;
				if (view == null)
				{
					obj = null;
				}
				else
				{
					Player owner = view.Owner;
					obj = ((owner != null) ? owner.NickName : null);
				}
			}
		}
		if (obj == null)
		{
			obj = ((c != null) ? ((Object)c).name : null) ?? "Unknown";
		}
		return (string)obj;
	}

	private bool TryGiveItemTo(Character c, GiftDef gift)
	{
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Expected O, but got Unknown
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Player player = c.player;
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			ItemSlot val = default(ItemSlot);
			if (HasPocketSpace(player) && player.AddItem(gift.id, (ItemInstanceData)null, ref val) && val != null && val.itemSlotID <= 2)
			{
				return true;
			}
			if (TryGetBackpackFreeSlot(player, out var data, out var freeIndex))
			{
				Item val2 = default(Item);
				if (!ItemDatabase.TryGetItem(gift.id, ref val2))
				{
					return false;
				}
				ItemInstanceData val3 = new ItemInstanceData(Guid.NewGuid());
				ItemInstanceDataHandler.AddInstanceData(val3);
				data.AddItem(val2, val3, freeIndex);
				InventorySyncData val4 = default(InventorySyncData);
				((InventorySyncData)(ref val4))..ctor(player.itemSlots, player.backpackSlot, player.tempFullSlot);
				((MonoBehaviourPun)player).photonView.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2]
				{
					IBinarySerializable.ToManagedArray<InventorySyncData>(val4),
					false
				});
				return true;
			}
			return false;
		}
		catch
		{
			return false;
		}
	}

	private static bool HasPocketSpace(Player p)
	{
		for (int i = 0; i < p.itemSlots.Length; i++)
		{
			if (p.itemSlots[i].IsEmpty())
			{
				return true;
			}
		}
		return false;
	}

	private static bool TryGetBackpackFreeSlot(Player p, out BackpackData data, out byte freeIndex)
	{
		data = null;
		freeIndex = byte.MaxValue;
		if (p.backpackSlot == null || !p.backpackSlot.hasBackpack || ((ItemSlot)p.backpackSlot).data == null)
		{
			return false;
		}
		if (!((ItemSlot)p.backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref data) || data == null)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				((ItemSlot)p.backpackSlot).data.RegisterNewEntry<BackpackData>((DataEntryKey)7);
				((ItemSlot)p.backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref data);
			}
			if (data == null)
			{
				return false;
			}
		}
		for (byte b = 0; b < data.itemSlots.Length; b++)
		{
			if (data.itemSlots[b].IsEmpty())
			{
				freeIndex = b;
				return true;
			}
		}
		return false;
	}

	private void TryPatchLuggageAwakeAutoOpen()
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Expected O, but got Unknown
		try
		{
			_harmony.Patch((MethodBase)AccessTools.Method(typeof(Luggage), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(PEAKTagPlugin).GetMethod("LuggageAwake_AutoOpen_Postfix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("[Tag] Failed to patch Luggage.Awake: " + ex.Message));
		}
	}

	private static void LuggageAwake_AutoOpen_Postfix(object __instance)
	{
		try
		{
			if (PhotonNetwork.IsMasterClient)
			{
				Component val = (Component)((__instance is Component) ? __instance : null);
				PhotonView val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<PhotonView>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.RPC("OpenLuggageRPC", (RpcTarget)0, new object[1] { false });
				}
			}
		}
		catch
		{
		}
	}

	private void TryPatchLuggageSpawnRoutineBlock()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Expected O, but got Unknown
		try
		{
			_harmony.Patch((MethodBase)AccessTools.Method(typeof(Luggage), "SpawnItemRoutine", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PEAKTagPlugin).GetMethod("LuggageSpawnRoutine_Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			_harmony.Patch((MethodBase)AccessTools.Method(typeof(Luggage), "SpawnItems", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PEAKTagPlugin).GetMethod("LuggageSpawnRoutine_Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("[Tag] Failed to patch Luggage spawn routines: " + ex.Message));
		}
	}

	private static bool LuggageSpawnRoutine_Prefix()
	{
		return false;
	}

	private void TryPatchLuggageNoLoot()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Expected O, but got Unknown
		try
		{
			_harmony.Patch((MethodBase)AccessTools.Method(typeof(Luggage), "OpenLuggageRPC", new Type[1] { typeof(bool) }, (Type[])null), new HarmonyMethod(typeof(PEAKTagPlugin).GetMethod("LuggageOpen_NoLoot_Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("[Tag] Failed to patch Luggage.OpenLuggageRPC: " + ex.Message));
		}
	}

	private void TryPatchHostAfflictions()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Expected O, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Expected O, but got Unknown
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Expected O, but got Unknown
		try
		{
			_harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterAfflictions), "AddAffliction", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PEAKTagPlugin).GetMethod("AddAffliction_HostBlock_Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			_harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterAfflictions), "AddStatus", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PEAKTagPlugin).GetMethod("AddStatus_HostBlock_Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			_harmony.Patch((MethodBase)AccessTools.Method(typeof(CharacterAfflictions), "SetStatus", (Type[])null, (Type[])null), new HarmonyMethod(typeof(PEAKTagPlugin).GetMethod("SetStatus_HostBlock_Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[Tag] Host affliction blocking patches applied successfully.");
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("[Tag] Failed to patch host afflictions: " + ex.Message));
		}
	}

	private static void LuggageOpen_NoLoot_Prefix(ref bool spawnItems)
	{
		spawnItems = false;
	}

	private static bool AddAffliction_HostBlock_Prefix(CharacterAfflictions __instance)
	{
		if (__instance != null)
		{
			Character character = __instance.character;
			if (((character != null) ? new bool?(character.IsLocal) : null).GetValueOrDefault() && PhotonNetwork.IsMasterClient)
			{
				return false;
			}
		}
		return true;
	}

	private static bool AddStatus_HostBlock_Prefix(CharacterAfflictions __instance)
	{
		if (__instance != null)
		{
			Character character = __instance.character;
			if (((character != null) ? new bool?(character.IsLocal) : null).GetValueOrDefault() && PhotonNetwork.IsMasterClient)
			{
				return false;
			}
		}
		return true;
	}

	private static bool SetStatus_HostBlock_Prefix(CharacterAfflictions __instance)
	{
		if (__instance != null)
		{
			Character character = __instance.character;
			if (((character != null) ? new bool?(character.IsLocal) : null).GetValueOrDefault() && PhotonNetwork.IsMasterClient)
			{
				return false;
			}
		}
		return true;
	}

	public void PreOpenAllLuggageNoLoot()
	{
		if (!PhotonNetwork.IsMasterClient)
		{
			return;
		}
		try
		{
			IEnumerable aLL_LUGGAGE = Luggage.ALL_LUGGAGE;
			if (aLL_LUGGAGE == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[Tag] Luggage.ALL_LUGGAGE not available.");
				return;
			}
			int num = 0;
			foreach (object item in aLL_LUGGAGE)
			{
				Component val = (Component)((item is Component) ? item : null);
				PhotonView val2 = ((val != null) ? val.GetComponent<PhotonView>() : null);
				if (val2 != null)
				{
					val2.RPC("OpenLuggageRPC", (RpcTarget)0, new object[1] { false });
					num++;
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Pre-opened {num} luggage (no loot).");
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("[Tag] Pre-open luggage sweep failed: " + ex.Message));
		}
	}

	private void StartFreezeAfflictions()
	{
		if (_freezeAfflictionsCo == null)
		{
			_freezeAfflictionsCo = ((MonoBehaviour)this).StartCoroutine(FreezeAfflictionsLoop());
		}
	}

	private void StopFreezeAfflictions()
	{
		if (_freezeAfflictionsCo != null)
		{
			((MonoBehaviour)this).StopCoroutine(_freezeAfflictionsCo);
			_freezeAfflictionsCo = null;
		}
	}

	private void ResetScoreboardStats()
	{
		_tagsMade.Clear();
		_tagsGot.Clear();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[Tag] Scoreboard stats reset for new run.");
	}

	private void Update()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetKeyDown(_scoreboardKey.Value))
		{
			bool key = Input.GetKey(_scoreboardModifierKey.Value);
			if (!_scoreboardRequireModifier.Value || key)
			{
				_scoreboardVisible = !_scoreboardVisible;
				((BaseUnityPlugin)this).Logger.LogInfo((object)("[Tag] Scoreboard " + (_scoreboardVisible ? "shown" : "hidden") + "."));
			}
		}
		if (PhotonNetwork.IsMasterClient)
		{
			CheckAndActivatePowers();
		}
	}

	private void OnGUI()
	{
		if (_scoreboardVisible)
		{
			RenderScoreboard();
		}
	}

	private void RenderScoreboard()
	{
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Expected O, but got Unknown
		//IL_0078: 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_0091: Expected O, but got Unknown
		//IL_00a9: 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_00c3: Expected O, but got Unknown
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: 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_01ea: Expected O, but got Unknown
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_046a: Unknown result type (might be due to invalid IL or missing references)
		if (_scoreboardBackgroundColor == null || _scoreboardTextColor == null || _scoreboardHeaderColor == null || _scoreboardFontSize == null || _scoreboardWidth == null || _scoreboardHeight == null || _scoreboardX == null || _scoreboardY == null)
		{
			return;
		}
		GUIStyle val = new GUIStyle();
		val.fontSize = _scoreboardFontSize.Value + 4;
		val.fontStyle = (FontStyle)1;
		val.normal.textColor = Color.white;
		val.alignment = (TextAnchor)4;
		GUIStyle val2 = new GUIStyle();
		val2.fontSize = _scoreboardFontSize.Value;
		val2.normal.textColor = Color.white;
		val2.alignment = (TextAnchor)0;
		GUIStyle val3 = new GUIStyle(val2);
		val3.normal.textColor = Color.yellow;
		val3.fontStyle = (FontStyle)1;
		Rect val4 = default(Rect);
		((Rect)(ref val4))..ctor(_scoreboardX.Value, _scoreboardY.Value, _scoreboardWidth.Value, _scoreboardHeight.Value);
		GUI.color = _scoreboardBackgroundColor.Value;
		GUI.Box(val4, "");
		GUI.color = Color.white;
		Rect val5 = default(Rect);
		((Rect)(ref val5))..ctor(_scoreboardX.Value, _scoreboardY.Value, _scoreboardWidth.Value, 40f);
		GUI.Label(val5, "PEAK TAG SCOREBOARD", val);
		Rect val6 = default(Rect);
		((Rect)(ref val6))..ctor(_scoreboardX.Value + 10f, _scoreboardY.Value + 50f, _scoreboardWidth.Value - 20f, _scoreboardHeight.Value - 60f);
		if (_tagsMade.Count == 0 && _tagsGot.Count == 0)
		{
			GUIStyle val7 = new GUIStyle(val2);
			val7.alignment = (TextAnchor)4;
			GUI.Label(val6, "No tags recorded yet.\nStart playing to see scores!", val7);
			return;
		}
		HashSet<int> hashSet = new HashSet<int>();
		foreach (KeyValuePair<int, int> item in _tagsMade)
		{
			hashSet.Add(item.Key);
		}
		foreach (KeyValuePair<int, int> item2 in _tagsGot)
		{
			hashSet.Add(item2.Key);
		}
		List<int> list = new List<int>(hashSet);
		list.Sort(delegate(int a, int b)
		{
			_tagsMade.TryGetValue(a, out var value3);
			_tagsGot.TryGetValue(a, out var value4);
			_tagsMade.TryGetValue(b, out var value5);
			_tagsGot.TryGetValue(b, out var value6);
			int value7 = value3 - value4;
			return (value5 - value6).CompareTo(value7);
		});
		float num = 0f;
		float num2 = _scoreboardFontSize.Value + 8;
		Rect val9 = default(Rect);
		foreach (int item3 in list)
		{
			if (num + num2 > ((Rect)(ref val6)).height)
			{
				break;
			}
			Room currentRoom = PhotonNetwork.CurrentRoom;
			Player val8 = ((currentRoom != null) ? currentRoom.GetPlayer(item3, false) : null);
			string text = ((val8 != null) ? val8.NickName : null) ?? $"Player {item3}";
			_tagsMade.TryGetValue(item3, out var value);
			_tagsGot.TryGetValue(item3, out var value2);
			int num3 = value - value2;
			string text2 = $"{text}: {value} tags, {value2} tagged (Net: {num3:+0;-0})";
			((Rect)(ref val9))..ctor(((Rect)(ref val6)).x, ((Rect)(ref val6)).y + num, ((Rect)(ref val6)).width, num2);
			GUI.Label(val9, text2, val2);
			num += num2;
		}
		if (_itViewId == -1)
		{
			return;
		}
		Character val10 = FindCharacterByViewID(_itViewId);
		if ((Object)(object)val10 != (Object)null)
		{
			CharacterRefs refs = val10.refs;
			object obj;
			if (refs == null)
			{
				obj = null;
			}
			else
			{
				PhotonView view = refs.view;
				obj = ((view != null) ? view.Owner : null);
			}
			Player val11 = (Player)obj;
			if (val11 != null)
			{
				num += 15f;
				Rect val12 = default(Rect);
				((Rect)(ref val12))..ctor(((Rect)(ref val6)).x, ((Rect)(ref val6)).y + num, ((Rect)(ref val6)).width, num2);
				GUI.Label(val12, "Current IT: " + val11.NickName, val3);
			}
		}
	}

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

	private void RefreshItEyes()
	{
		try
		{
			List<Character> allCharacters = Character.AllCharacters;
			int count = allCharacters.Count;
			for (int i = 0; i < count; i++)
			{
				Character val = allCharacters[i];
				if (!((Object)(object)val?.refs?.view == (Object)null) && !((Object)(object)val.data == (Object)null))
				{
					if (val.refs.view.ViewID == _itViewId)
					{
						TryMarkEyes(val, makePassedOut: true);
					}
					else if (!val.data.passedOut && !val.data.fullyPassedOut && !val.data.dead)
					{
						TryMarkEyes(val, makePassedOut: false);
					}
				}
			}
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("[Tag] RefreshItEyes exception: " + ex.Message));
		}
	}

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

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

	private void TriggerPowerReadyAudioCue(Character itCharacter)
	{
		//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_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)itCharacter == (Object)null) && !((Object)(object)itCharacter.refs?.view == (Object)null))
		{
			Vector3 center = itCharacter.Center;
			itCharacter.refs.view.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { center, true });
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Triggered power ready audio cue at IT position: {center}");
		}
	}

	private bool IsPowerActivationTriggered(Character character)
	{
		if ((Object)(object)character?.data == (Object)null)
		{
			return false;
		}
		bool isCrouching = character.data.isCrouching;
		bool isReaching = character.data.isReaching;
		return isCrouching && isReaching;
	}

	private void ApplyPlayerStunEffect(Character itCharacter)
	{
		if ((Object)(object)itCharacter == (Object)null)
		{
			return;
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)("[Tag] Player Stun Power activated by " + SafeName(itCharacter)));
		float num = _playerStunPowerTime?.Value ?? 5f;
		List<Character> allCharacters = Character.AllCharacters;
		int count = allCharacters.Count;
		for (int i = 0; i < count; i++)
		{
			Character val = allCharacters[i];
			if (IsAlive(val) && !val.isBot && (Object)(object)val != (Object)(object)itCharacter)
			{
				try
				{
					val.refs.view.RPC("RPCA_Fall", (RpcTarget)0, new object[1] { num });
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Applied {num}s ragdoll to {SafeName(val)}");
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("[Tag] Failed to ragdoll " + SafeName(val) + ": " + ex.Message));
				}
			}
		}
	}

	private void ApplyPlayerWarpEffect(Character itCharacter)
	{
		//IL_007a: 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_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: 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_0158: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)itCharacter == (Object)null)
		{
			return;
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)("[Tag] Player Warp Power activated by " + SafeName(itCharacter)));
		Character val = null;
		float num = float.MaxValue;
		List<Character> allCharacters = Character.AllCharacters;
		int count = allCharacters.Count;
		for (int i = 0; i < count; i++)
		{
			Character val2 = allCharacters[i];
			if (IsAlive(val2) && !val2.isBot && (Object)(object)val2 != (Object)(object)itCharacter && val2.Center.y < num)
			{
				num = val2.Center.y;
				val = val2;
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		for (int j = 0; j < count; j++)
		{
			Character val3 = allCharacters[j];
			if (IsAlive(val3) && !val3.isBot && (Object)(object)val3 != (Object)(object)itCharacter && (Object)(object)val3 != (Object)(object)val)
			{
				try
				{
					Vector3 val4 = val.Center + new Vector3(Random.Range(-2f, 2f), 0f, Random.Range(-2f, 2f));
					val3.refs.view.RPC("WarpPlayerRPC", (RpcTarget)0, new object[2] { val4, true });
					((BaseUnityPlugin)this).Logger.LogInfo((object)("[Tag] Warped " + SafeName(val3) + " to " + SafeName(val) + "'s area"));
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("[Tag] Failed to warp " + SafeName(val3) + ": " + ex.Message));
				}
			}
		}
	}

	private void ApplyPlayerItemDropEffect(Character itCharacter)
	{
		//IL_00e9: 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)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: 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_0110: 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_0316: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: 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_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)itCharacter == (Object)null)
		{
			return;
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)("[Tag] Player Item Drop Power activated by " + SafeName(itCharacter)));
		List<Character> allCharacters = Character.AllCharacters;
		int count = allCharacters.Count;
		BackpackData val4 = default(BackpackData);
		InventorySyncData val7 = default(InventorySyncData);
		for (int i = 0; i < count; i++)
		{
			Character val = allCharacters[i];
			if (!IsAlive(val) || val.isBot || !((Object)(object)val != (Object)(object)itCharacter))
			{
				continue;
			}
			try
			{
				Player player = val.player;
				if ((Object)(object)player == (Object)null)
				{
					continue;
				}
				for (int j = 0; j < 3; j++)
				{
					if (j >= player.itemSlots.Length || player.itemSlots[j].IsEmpty())
					{
						continue;
					}
					Item prefab = player.itemSlots[j].prefab;
					if ((Object)(object)prefab != (Object)null)
					{
						Vector3 val2 = val.Center + Vector3.up * 0.5f;
						GameObject val3 = PhotonNetwork.InstantiateItemRoom(((Object)((Component)prefab).gameObject).name, val2, Quaternion.identity);
						if ((Object)(object)val3 != (Object)null)
						{
							((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Dropped {((Object)prefab).name} from {SafeName(val)}'s pocket {j}");
						}
						player.itemSlots[j].prefab = null;
						player.itemSlots[j].data = null;
					}
				}
				if (player.backpackSlot == null || !player.backpackSlot.hasBackpack || ((ItemSlot)player.backpackSlot).data == null || !((ItemSlot)player.backpackSlot).data.TryGetDataEntry<BackpackData>((DataEntryKey)7, ref val4) || val4 == null)
				{
					continue;
				}
				for (byte b = 0; b < val4.itemSlots.Length; b++)
				{
					if (!val4.itemSlots[b].IsEmpty())
					{
						Item prefab2 = val4.itemSlots[b].prefab;
						if ((Object)(object)prefab2 != (Object)null)
						{
							Vector3 val5 = val.Center + Vector3.up * 0.5f;
							GameObject val6 = PhotonNetwork.InstantiateItemRoom(((Object)((Component)prefab2).gameObject).name, val5, Quaternion.identity);
							if ((Object)(object)val6 != (Object)null)
							{
								((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Dropped {((Object)prefab2).name} from {SafeName(val)}'s backpack slot {b}");
							}
							val4.itemSlots[b].prefab = null;
							val4.itemSlots[b].data = null;
						}
					}
				}
				((InventorySyncData)(ref val7))..ctor(player.itemSlots, player.backpackSlot, player.tempFullSlot);
				((MonoBehaviourPun)player).photonView.RPC("SyncInventoryRPC", (RpcTarget)1, new object[2]
				{
					IBinarySerializable.ToManagedArray<InventorySyncData>(val7),
					false
				});
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("[Tag] Failed to drop items from " + SafeName(val) + ": " + ex.Message));
			}
		}
	}

	private void GivePowerGiftToIt(Character itCharacter)
	{
		if ((Object)(object)itCharacter == (Object)null)
		{
			return;
		}
		float num = _playerStunPowerChance.Value + _playerWarpPowerChance.Value + _playerItemDropChance.Value;
		float num2 = 1f - num;
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Power Gift Roll - Total Power: {num:P1}, No Power: {num2:P1}");
		float num3 = Random.Range(0f, 1f);
		if (num3 < num2)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Power Gift Roll Result: No Power (roll: {num3:F3} < {num2:F3})");
			return;
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Power Gift Roll Result: Power Given (roll: {num3:F3} >= {num2:F3})");
		float num4 = (num3 - num2) / num;
		float num5 = 0f;
		num5 += _playerStunPowerChance.Value / num;
		if (num4 < num5)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Power Gift Result: Player Stun Power (roll: {num4:F3} < {num5:F3})");
			AssignPowerToIt(itCharacter, PowerType.PlayerStun);
			return;
		}
		num5 += _playerWarpPowerChance.Value / num;
		if (num4 < num5)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Power Gift Result: Player Warp Power (roll: {num4:F3} < {num5:F3})");
			AssignPowerToIt(itCharacter, PowerType.PlayerWarp);
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Power Gift Result: Player Item Drop Power (roll: {num4:F3} >= {num5:F3})");
			AssignPowerToIt(itCharacter, PowerType.PlayerItemDrop);
		}
	}

	private void AssignPowerToIt(Character itCharacter, PowerType powerType)
	{
		if (!((Object)(object)itCharacter?.refs?.view == (Object)null))
		{
			int ownerActorNr = itCharacter.refs.view.OwnerActorNr;
			_playerPowers[ownerActorNr] = powerType;
			_powerAvailable[ownerActorNr] = true;
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] Assigned {powerType} power to {SafeName(itCharacter)} (ActorID: {ownerActorNr})");
			TriggerPowerReadyAudioCue(itCharacter);
		}
	}

	private void CheckAndActivatePowers()
	{
		if (!PhotonNetwork.IsMasterClient)
		{
			return;
		}
		List<Character> allCharacters = Character.AllCharacters;
		int count = allCharacters.Count;
		for (int i = 0; i < count; i++)
		{
			Character val = allCharacters[i];
			if (!IsAlive(val) || val.isBot)
			{
				continue;
			}
			PhotonView val2 = val.refs?.view;
			if (val2 == null)
			{
				continue;
			}
			int ownerActorNr = val2.OwnerActorNr;
			if (_powerAvailable.TryGetValue(ownerActorNr, out var value) && value && val2.ViewID == _itViewId && IsPowerActivationTriggered(val) && _playerPowers.TryGetValue(ownerActorNr, out var value2))
			{
				switch (value2)
				{
				case PowerType.PlayerStun:
					ApplyPlayerStunEffect(val);
					break;
				case PowerType.PlayerWarp:
					ApplyPlayerWarpEffect(val);
					break;
				case PowerType.PlayerItemDrop:
					ApplyPlayerItemDropEffect(val);
					break;
				}
				_powerAvailable[ownerActorNr] = false;
				_playerPowers[ownerActorNr] = PowerType.None;
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"[Tag] {SafeName(val)} used their {value2} power");
			}
		}
	}

	private void ClearPlayerPowers()
	{
		_playerPowers.Clear();
		_powerAvailable.Clear();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[Tag] Cleared all player powers");
	}
}