Decompiled source of REPO TeamTools v1.0.0

RepoTeamTools.dll

Decompiled 9 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RepoTeamTools")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("RepoTeamTools")]
[assembly: AssemblyTitle("RepoTeamTools")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Codex.Welcoming
{
	[BepInPlugin("codex.repoteamtools.welcome", "Welcoming", "1.0.0")]
	public sealed class WelcomingPlugin : BaseUnityPlugin
	{
		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<string> Message;

		private void Awake()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Welcome", "Enabled", true, "Send a public chat message when a player joins your lobby.");
			Message = ((BaseUnityPlugin)this).Config.Bind<string>("Welcome", "Message", "We got a new player, {player}!", "Use {player} where the joining player's name should appear.");
			new Harmony("codex.repoteamtools.welcome").PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Welcoming loaded. Only the host sends join messages.");
		}
	}
	[HarmonyPatch(typeof(NetworkManager), "OnPlayerEnteredRoom")]
	internal static class WelcomeOnJoinPatch
	{
		private static void Postfix(Player newPlayer)
		{
			if (WelcomingPlugin.Enabled.Value && PhotonNetwork.IsMasterClient && newPlayer != null && !((Object)(object)PlayerAvatar.instance == (Object)null))
			{
				string newValue = (string.IsNullOrWhiteSpace(newPlayer.NickName) ? "A player" : newPlayer.NickName);
				string text = (WelcomingPlugin.Message.Value ?? string.Empty).Replace("{player}", newValue);
				if (text.Length > 120)
				{
					text = text.Substring(0, 120);
				}
				if (text.Length > 0)
				{
					PlayerAvatar.instance.ChatMessageSend(text);
				}
			}
		}
	}
}
namespace Codex.TeammateHUD
{
	[BepInPlugin("codex.repoteamtools.teammatehud", "Teammate HUD", "1.0.0")]
	public sealed class TeammateHUDPlugin : BaseUnityPlugin
	{
		private sealed class TeammateInfo
		{
			public string Name;

			public float Distance;

			public bool Downed;

			public bool HasHealth;

			public float Health;

			public float MaxHealth;

			public bool HasEnergy;

			public float Energy;

			public float MaxEnergy;
		}

		private readonly List<TeammateInfo> _visibleTeammates = new List<TeammateInfo>();

		private ConfigEntry<bool> _enabled;

		private ConfigEntry<KeyCode> _toggleKey;

		private ConfigEntry<float> _maxDistance;

		private ConfigEntry<int> _maxTeammates;

		private Texture2D _pixel;

		private GUIStyle _titleStyle;

		private GUIStyle _nameStyle;

		private GUIStyle _detailStyle;

		private float _nextRefresh;

		private void Awake()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Expected O, but got Unknown
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Enabled", true, "Show nearby teammate status cards.");
			_toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("HUD", "ToggleKey", (KeyCode)291, "Show or hide the teammate HUD.");
			_maxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "MaxDistance", 24f, new ConfigDescription("Only show teammates within this distance.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 60f), Array.Empty<object>()));
			_maxTeammates = ((BaseUnityPlugin)this).Config.Bind<int>("HUD", "MaxTeammates", 4, new ConfigDescription("Maximum number of teammate cards.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
			_pixel = new Texture2D(1, 1, (TextureFormat)4, false);
			_pixel.SetPixel(0, 0, Color.white);
			_pixel.Apply();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Teammate HUD loaded. Press F10 to show or hide the status panel.");
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(_toggleKey.Value))
			{
				_enabled.Value = !_enabled.Value;
			}
			if (_enabled.Value && !(Time.unscaledTime < _nextRefresh))
			{
				_nextRefresh = Time.unscaledTime + 0.25f;
				RefreshVisibleTeammates();
			}
		}

		private void RefreshVisibleTeammates()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00df: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			_visibleTeammates.Clear();
			PlayerAvatar val = SemiFunc.PlayerGetLocal();
			Camera main = Camera.main;
			if ((Object)(object)val == (Object)null || (Object)(object)main == (Object)null)
			{
				return;
			}
			PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
			foreach (PlayerAvatar val2 in array)
			{
				if ((Object)(object)val2 == (Object)null || (Object)(object)val2 == (Object)(object)val || !((Component)val2).gameObject.activeInHierarchy)
				{
					continue;
				}
				Vector3 val3 = ((Component)val2).transform.position + Vector3.up * 0.85f;
				float num = Vector3.Distance(((Component)val).transform.position, ((Component)val2).transform.position);
				if (!(num > _maxDistance.Value))
				{
					Vector3 val4 = main.WorldToScreenPoint(val3);
					if (!(val4.z <= 0f) && !(val4.x < 0f) && !(val4.x > (float)Screen.width) && !(val4.y < 0f) && !(val4.y > (float)Screen.height) && HasLineOfSight(((Component)main).transform.position, val3, ((Component)val).transform, ((Component)val2).transform))
					{
						TeammateInfo item = ReadTeammate(val2, num);
						_visibleTeammates.Add(item);
					}
				}
			}
			_visibleTeammates.Sort((TeammateInfo a, TeammateInfo b) => a.Distance.CompareTo(b.Distance));
			if (_visibleTeammates.Count > _maxTeammates.Value)
			{
				_visibleTeammates.RemoveRange(_maxTeammates.Value, _visibleTeammates.Count - _maxTeammates.Value);
			}
		}

		private static bool HasLineOfSight(Vector3 origin, Vector3 target, Transform localTransform, Transform teammateTransform)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = target - origin;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude <= 0.01f)
			{
				return true;
			}
			RaycastHit[] array = Physics.RaycastAll(origin, val / magnitude, magnitude, -5, (QueryTriggerInteraction)1);
			Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
			for (int num = 0; num < array.Length; num++)
			{
				Transform transform = ((RaycastHit)(ref array[num])).transform;
				if (!((Object)(object)transform == (Object)null) && !((Object)(object)transform == (Object)(object)localTransform) && !transform.IsChildOf(localTransform))
				{
					if (!((Object)(object)transform == (Object)(object)teammateTransform))
					{
						return transform.IsChildOf(teammateTransform);
					}
					return true;
				}
			}
			return true;
		}

		private static TeammateInfo ReadTeammate(PlayerAvatar player, float distance)
		{
			Component[] componentsInChildren = ((Component)player).GetComponentsInChildren<Component>(true);
			TeammateInfo teammateInfo = new TeammateInfo();
			teammateInfo.Name = ReadString(componentsInChildren, new string[5] { "playername", "displayname", "nickname", "username", "steamname" }) ?? "Teammate";
			teammateInfo.Distance = distance;
			TeammateInfo teammateInfo2 = teammateInfo;
			teammateInfo2.HasHealth = TryReadNumber(componentsInChildren, new string[4] { "syncedhealth", "playerhealthvalue", "currenthealth", "health" }, out teammateInfo2.Health);
			teammateInfo2.HasHealth = teammateInfo2.HasHealth && TryReadNumber(componentsInChildren, new string[1] { "maxhealth" }, out teammateInfo2.MaxHealth);
			if (teammateInfo2.HasHealth && teammateInfo2.MaxHealth <= 0f)
			{
				teammateInfo2.HasHealth = false;
			}
			bool flag = TryReadNumber(componentsInChildren, new string[4] { "energycurrent", "currentenergy", "stamina", "energy" }, out teammateInfo2.Energy);
			bool flag2 = TryReadNumber(componentsInChildren, new string[3] { "maxenergy", "maxstamina", "energymax" }, out teammateInfo2.MaxEnergy);
			teammateInfo2.HasEnergy = flag && flag2 && teammateInfo2.MaxEnergy > 0f;
			if (TryReadBoolean(componentsInChildren, new string[5] { "isdead", "dead", "isdowned", "downed", "playerdead" }, out var result))
			{
				teammateInfo2.Downed = result;
			}
			if (teammateInfo2.HasHealth && teammateInfo2.Health <= 0f)
			{
				teammateInfo2.Downed = true;
			}
			return teammateInfo2;
		}

		private static string ReadString(Component[] components, string[] names)
		{
			foreach (Component val in components)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				foreach (MemberInfo member in GetMembers(((object)val).GetType()))
				{
					if (Matches(member.Name, names))
					{
						string text = ReadMember(val, member) as string;
						if (!string.IsNullOrWhiteSpace(text))
						{
							return text;
						}
					}
				}
			}
			return null;
		}

		private static bool TryReadNumber(Component[] components, string[] names, out float result)
		{
			foreach (Component val in components)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				foreach (MemberInfo member in GetMembers(((object)val).GetType()))
				{
					if (!Matches(member.Name, names))
					{
						continue;
					}
					object obj = ReadMember(val, member);
					if (obj == null)
					{
						continue;
					}
					try
					{
						if (obj is float || obj is double || obj is int || obj is short || obj is long || obj is byte)
						{
							result = Convert.ToSingle(obj);
							return true;
						}
					}
					catch
					{
					}
				}
			}
			result = 0f;
			return false;
		}

		private static bool TryReadBoolean(Component[] components, string[] names, out bool result)
		{
			foreach (Component val in components)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				foreach (MemberInfo member in GetMembers(((object)val).GetType()))
				{
					if (Matches(member.Name, names))
					{
						object obj = ReadMember(val, member);
						if (obj is bool)
						{
							result = (bool)obj;
							return true;
						}
					}
				}
			}
			result = false;
			return false;
		}

		private static List<MemberInfo> GetMembers(Type type)
		{
			List<MemberInfo> list = new List<MemberInfo>();
			Type type2 = type;
			while (type2 != null)
			{
				list.AddRange(type2.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic));
				PropertyInfo[] properties = type2.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (PropertyInfo propertyInfo in properties)
				{
					if (propertyInfo.GetIndexParameters().Length == 0 && propertyInfo.CanRead)
					{
						list.Add(propertyInfo);
					}
				}
				type2 = type2.BaseType;
			}
			return list;
		}

		private static object ReadMember(object target, MemberInfo member)
		{
			try
			{
				FieldInfo fieldInfo = member as FieldInfo;
				if (fieldInfo != null)
				{
					return fieldInfo.GetValue(target);
				}
				PropertyInfo propertyInfo = member as PropertyInfo;
				if (propertyInfo != null)
				{
					return propertyInfo.GetValue(target, null);
				}
			}
			catch
			{
			}
			return null;
		}

		private static bool Matches(string name, string[] hints)
		{
			string text = name.Replace("_", string.Empty).ToLowerInvariant();
			for (int i = 0; i < hints.Length; i++)
			{
				if (text == hints[i] || text.EndsWith(hints[i]))
				{
					return true;
				}
			}
			return false;
		}

		private void OnGUI()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			if (_enabled.Value && _visibleTeammates.Count != 0)
			{
				EnsureStyles();
				float num = 300f;
				float num2 = 64f;
				float num3 = 38f + num2 * (float)_visibleTeammates.Count;
				Rect rect = default(Rect);
				((Rect)(ref rect))..ctor(16f, 16f, num, num3);
				DrawRect(rect, new Color(0.025f, 0.035f, 0.045f, 0.88f));
				DrawRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 3f), new Color(0.38f, 0.92f, 0.74f, 1f));
				GUI.color = new Color(0.73f, 0.9f, 0.91f, 1f);
				GUI.Label(new Rect(((Rect)(ref rect)).x + 12f, ((Rect)(ref rect)).y + 8f, ((Rect)(ref rect)).width - 24f, 22f), "TEAM STATUS   ·   F10 TOGGLE", _titleStyle);
				GUI.color = Color.white;
				for (int i = 0; i < _visibleTeammates.Count; i++)
				{
					DrawTeammate(((Rect)(ref rect)).x + 10f, ((Rect)(ref rect)).y + 34f + num2 * (float)i, _visibleTeammates[i]);
				}
			}
		}

		private void DrawTeammate(float x, float y, TeammateInfo info)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			DrawRect(new Rect(x, y, 280f, 58f), new Color(0.07f, 0.09f, 0.11f, 0.88f));
			GUI.color = Color.white;
			GUI.Label(new Rect(x + 9f, y + 4f, 158f, 20f), info.Name, _nameStyle);
			GUI.color = new Color(0.68f, 0.77f, 0.81f, 1f);
			GUI.Label(new Rect(x + 167f, y + 5f, 104f, 18f), Mathf.RoundToInt(info.Distance) + " m  ·  " + (info.Downed ? "DOWN" : "ACTIVE"), _detailStyle);
			DrawStat(x + 9f, y + 29f, "HP", info.HasHealth, info.Health, info.MaxHealth, new Color(0.35f, 0.86f, 0.57f, 1f));
			DrawStat(x + 145f, y + 29f, "STA", info.HasEnergy, info.Energy, info.MaxEnergy, new Color(0.35f, 0.72f, 1f, 1f));
			GUI.color = Color.white;
		}

		private void DrawStat(float x, float y, string label, bool available, float value, float maximum, Color color)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			string text = (available ? (Mathf.Clamp(Mathf.RoundToInt(value / maximum * 100f), 0, 100) + "%") : "—");
			GUI.color = (Color)(available ? color : new Color(0.55f, 0.58f, 0.6f, 1f));
			GUI.Label(new Rect(x, y, 43f, 18f), label, _detailStyle);
			GUI.Label(new Rect(x + 43f, y, 42f, 18f), text, _detailStyle);
			if (available)
			{
				DrawRect(new Rect(x + 86f, y + 5f, 42f, 7f), new Color(0.18f, 0.21f, 0.23f, 1f));
				DrawRect(new Rect(x + 86f, y + 5f, 42f * Mathf.Clamp01(value / maximum), 7f), color);
			}
			GUI.color = Color.white;
		}

		private void EnsureStyles()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//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_004c: 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)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			if (_titleStyle == null)
			{
				_titleStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 11,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3
				};
				_nameStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 14,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3,
					clipping = (TextClipping)1
				};
				_detailStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 11,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3,
					clipping = (TextClipping)1
				};
			}
		}

		private void DrawRect(Rect rect, Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Color color2 = GUI.color;
			GUI.color = color;
			GUI.DrawTexture(rect, (Texture)(object)_pixel);
			GUI.color = color2;
		}

		private void OnDestroy()
		{
			if ((Object)(object)_pixel != (Object)null)
			{
				Object.Destroy((Object)(object)_pixel);
			}
		}
	}
}
namespace Codex.RepoPing
{
	[BepInPlugin("codex.repoteamtools.ping", "RepoPing", "1.0.1")]
	public sealed class RepoPingPlugin : BaseUnityPlugin, IOnEventCallback
	{
		private sealed class PingMarker
		{
			public readonly int Actor;

			public readonly int Kind;

			public readonly Vector3 Position;

			public readonly float ExpiresAt;

			public PingMarker(int actor, int kind, Vector3 position, float expiresAt)
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				Actor = actor;
				Kind = kind;
				Position = position;
				ExpiresAt = expiresAt;
			}
		}

		private sealed class PingKind
		{
			public readonly string Title;

			public readonly string Description;

			public readonly Color Color;

			public PingKind(string title, string description, Color color)
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				Title = title;
				Description = description;
				Color = color;
			}
		}

		private const byte PingEventCode = 173;

		private const int PacketMagic = 1380992817;

		private const byte PacketVersion = 1;

		private const float MarkerLifetime = 14f;

		private const int MaxMarkers = 32;

		private const float AimRange = 180f;

		private static readonly PingKind[] Kinds = new PingKind[8]
		{
			new PingKind("LOOK", "Look here", new Color(0.25f, 0.91f, 1f, 1f)),
			new PingKind("DANGER", "Danger", new Color(1f, 0.3f, 0.3f, 1f)),
			new PingKind("LOOT", "Valuable", new Color(1f, 0.78f, 0.2f, 1f)),
			new PingKind("GO", "Move here", new Color(0.3f, 1f, 0.56f, 1f)),
			new PingKind("HELP", "Need help", new Color(0.83f, 0.48f, 1f, 1f)),
			new PingKind("WAIT", "Wait", new Color(1f, 0.56f, 0.22f, 1f)),
			new PingKind("NO", "No", new Color(1f, 0.38f, 0.62f, 1f)),
			new PingKind("YES", "Yes", new Color(0.35f, 1f, 0.78f, 1f))
		};

		private readonly List<PingMarker> _markers = new List<PingMarker>();

		private ConfigEntry<KeyCode> _pingKey;

		private ConfigEntry<float> _markerDuration;

		private ConfigEntry<bool> _showNames;

		private bool _wheelOpen;

		private int _selectedKind;

		private Vector2 _selectionVector;

		private float _nextSendTime;

		private string _activeRoomName;

		private Texture2D _pixel;

		private Texture2D _discTexture;

		private Texture2D _ringTexture;

		private GUIStyle _titleStyle;

		private GUIStyle _hintStyle;

		private GUIStyle _tileStyle;

		private GUIStyle _markerStyle;

		private GUIStyle _subStyle;

		private GUIStyle _tinyStyle;

		private GUIStyle _centerStyle;

		private void Awake()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			_pingKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "WheelKey", (KeyCode)103, "Hold to open the ping wheel; release to send the selected ping.");
			_markerDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Markers", "DurationSeconds", 14f, "How long shared pings stay visible (3–30 seconds).");
			_showNames = ((BaseUnityPlugin)this).Config.Bind<bool>("Markers", "ShowPlayerNames", true, "Show who sent each ping.");
			_pixel = new Texture2D(1, 1, (TextureFormat)4, false);
			_pixel.SetPixel(0, 0, Color.white);
			_pixel.Apply();
			_discTexture = MakeCircleTexture(ring: false);
			_ringTexture = MakeCircleTexture(ring: true);
			PhotonNetwork.AddCallbackTarget((object)this);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"RepoPing loaded. Hold G, move toward a wheel option, then release to ping.");
		}

		private void Update()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			string text = ((PhotonNetwork.InRoom && PhotonNetwork.CurrentRoom != null) ? PhotonNetwork.CurrentRoom.Name : null);
			if (!string.Equals(text, _activeRoomName, StringComparison.Ordinal))
			{
				_activeRoomName = text;
				_markers.Clear();
				_wheelOpen = false;
			}
			if (Input.GetKeyDown(_pingKey.Value))
			{
				OpenWheel();
			}
			if (_wheelOpen)
			{
				Vector2 val = default(Vector2);
				((Vector2)(ref val))..ctor(Input.GetAxisRaw("Mouse X"), Input.GetAxisRaw("Mouse Y"));
				if (((Vector2)(ref val)).sqrMagnitude > 0.0001f)
				{
					_selectionVector += val;
					if (((Vector2)(ref _selectionVector)).sqrMagnitude > 100f)
					{
						_selectionVector = ((Vector2)(ref _selectionVector)).normalized * 10f;
					}
					UpdateSelection();
				}
				if (Input.GetKeyUp(_pingKey.Value))
				{
					SendPing(_selectedKind);
					_wheelOpen = false;
				}
				else if (Input.GetKeyDown((KeyCode)27))
				{
					_wheelOpen = false;
				}
			}
			float unscaledTime = Time.unscaledTime;
			for (int num = _markers.Count - 1; num >= 0; num--)
			{
				if (unscaledTime >= _markers[num].ExpiresAt)
				{
					_markers.RemoveAt(num);
				}
			}
		}

		private void OpenWheel()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.InRoom && Time.unscaledTime >= _nextSendTime)
			{
				_wheelOpen = true;
				_selectedKind = 0;
				_selectionVector = Vector2.zero;
			}
		}

		private void UpdateSelection()
		{
			if (!(((Vector2)(ref _selectionVector)).sqrMagnitude < 0.15f))
			{
				float num = Mathf.Atan2(_selectionVector.y, _selectionVector.x) * 57.29578f;
				float num2 = (90f - num + 360f) % 360f;
				_selectedKind = Mathf.Clamp(Mathf.FloorToInt((num2 + 22.5f) / 45f) % Kinds.Length, 0, Kinds.Length - 1);
			}
		}

		private void SendPing(int kindIndex)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			if (!PhotonNetwork.InRoom || Time.unscaledTime < _nextSendTime)
			{
				return;
			}
			Camera main = Camera.main;
			if (!((Object)(object)main == (Object)null))
			{
				Ray val = main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0f));
				Vector3 point = ((Ray)(ref val)).origin + ((Ray)(ref val)).direction * 180f;
				RaycastHit val2 = default(RaycastHit);
				if (Physics.Raycast(val, ref val2, 180f, -5, (QueryTriggerInteraction)1))
				{
					point = ((RaycastHit)(ref val2)).point;
				}
				byte[] array = CreatePacket(kindIndex, point);
				AddMarker((PhotonNetwork.LocalPlayer != null) ? PhotonNetwork.LocalPlayer.ActorNumber : (-1), kindIndex, point);
				PhotonNetwork.RaiseEvent((byte)173, (object)array, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)0,
					CachingOption = (EventCaching)0
				}, SendOptions.SendReliable);
				_nextSendTime = Time.unscaledTime + 0.45f;
			}
		}

		private static byte[] CreatePacket(int kindIndex, Vector3 point)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			byte[] array = new byte[18];
			Buffer.BlockCopy(BitConverter.GetBytes(1380992817), 0, array, 0, 4);
			array[4] = 1;
			array[5] = (byte)Mathf.Clamp(kindIndex, 0, Kinds.Length - 1);
			Buffer.BlockCopy(BitConverter.GetBytes(point.x), 0, array, 6, 4);
			Buffer.BlockCopy(BitConverter.GetBytes(point.y), 0, array, 10, 4);
			Buffer.BlockCopy(BitConverter.GetBytes(point.z), 0, array, 14, 4);
			return array;
		}

		public void OnEvent(EventData photonEvent)
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			if (photonEvent == null || photonEvent.Code != 173 || !(photonEvent.CustomData is byte[] array) || array.Length != 18 || BitConverter.ToInt32(array, 0) != 1380992817 || array[4] != 1)
			{
				return;
			}
			int num = array[5];
			if (num < Kinds.Length)
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(BitConverter.ToSingle(array, 6), BitConverter.ToSingle(array, 10), BitConverter.ToSingle(array, 14));
				if (IsFinite(val.x) && IsFinite(val.y) && IsFinite(val.z) && !(Mathf.Abs(val.x) > 100000f) && !(Mathf.Abs(val.y) > 100000f) && !(Mathf.Abs(val.z) > 100000f))
				{
					AddMarker(photonEvent.Sender, num, val);
				}
			}
		}

		private static bool IsFinite(float value)
		{
			if (!float.IsNaN(value))
			{
				return !float.IsInfinity(value);
			}
			return false;
		}

		private void AddMarker(int actor, int kind, Vector3 point)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			for (int num = _markers.Count - 1; num >= 0; num--)
			{
				if (_markers[num].Actor == actor && _markers[num].Kind == kind && Vector3.Distance(_markers[num].Position, point) < 0.35f)
				{
					_markers.RemoveAt(num);
				}
			}
			float num2 = Mathf.Clamp(_markerDuration.Value, 3f, 30f);
			_markers.Add(new PingMarker(actor, kind, point, Time.unscaledTime + num2));
			if (_markers.Count > 32)
			{
				_markers.RemoveAt(0);
			}
		}

		private void OnGUI()
		{
			EnsureStyles();
			if (PhotonNetwork.InRoom && (Object)(object)Camera.main != (Object)null)
			{
				DrawMarkers(Camera.main);
			}
			if (_wheelOpen)
			{
				DrawWheel();
			}
		}

		private void DrawMarkers(Camera camera)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			float unscaledTime = Time.unscaledTime;
			PingMarker pingMarker;
			int num;
			Vector2 edgePoint = default(Vector2);
			PingKind pingKind;
			float num2;
			float num3;
			float num4;
			float num5;
			float num6;
			string text;
			string text2;
			float num7;
			for (int i = 0; i < _markers.Count; pingKind = Kinds[pingMarker.Kind], num2 = Mathf.Clamp(edgePoint.x - 86f, 6f, (float)Screen.width - 178f), num3 = Mathf.Clamp(edgePoint.y - 39f, 6f, (float)Screen.height - 72f), num4 = Mathf.Clamp01((pingMarker.ExpiresAt - unscaledTime) / Mathf.Clamp(_markerDuration.Value, 3f, 30f)), num5 = 1f + Mathf.Sin(unscaledTime * 6.5f + (float)i) * 0.06f, num6 = 10f * num5, DrawDisc(edgePoint, 24f * num5, new Color(pingKind.Color.r, pingKind.Color.g, pingKind.Color.b, 0.13f)), DrawDisc(edgePoint, 14f * num5, new Color(pingKind.Color.r, pingKind.Color.g, pingKind.Color.b, 0.25f)), DrawRing(edgePoint, num6 + 3f, 2f, pingKind.Color), DrawDisc(edgePoint, 4f, Color.white), DrawRect(new Rect(num2, num3, 172f, 42f), new Color(0.025f, 0.045f, 0.06f, 0.9f)), DrawRect(new Rect(num2, num3, 3f, 42f), pingKind.Color), text = ((num != 0) ? "◀ " : ""), GUI.Label(new Rect(num2 + 10f, num3 + 4f, 156f, 18f), text + pingKind.Title.ToUpperInvariant(), _markerStyle), text2 = (_showNames.Value ? (GetPlayerName(pingMarker.Actor) + "  ·  ") : ""), num7 = Vector3.Distance(((Component)camera).transform.position, pingMarker.Position), GUI.Label(new Rect(num2 + 10f, num3 + 22f, 156f, 15f), text2 + Mathf.RoundToInt(num7) + " m", _subStyle), DrawRect(new Rect(num2, num3 + 40f, 172f * num4, 2f), pingKind.Color), i++)
			{
				pingMarker = _markers[i];
				Vector3 val = camera.WorldToScreenPoint(pingMarker.Position);
				if (!(val.z <= 0f) && !(val.x < 0f) && !(val.x > (float)Screen.width) && !(val.y < 0f))
				{
					num = ((val.y > (float)Screen.height) ? 1 : 0);
					if (num == 0)
					{
						((Vector2)(ref edgePoint))..ctor(val.x, (float)Screen.height - val.y);
						continue;
					}
				}
				else
				{
					num = 1;
				}
				edgePoint = GetEdgePoint(camera, pingMarker.Position);
			}
		}

		private static Vector2 GetEdgePoint(Camera camera, Vector3 world)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)camera).transform.InverseTransformPoint(world);
			float num = Mathf.Atan2(0f - val.x, 0f - val.z);
			float num2 = (float)Screen.width * 0.5f;
			float num3 = (float)Screen.height * 0.5f;
			float num4 = Mathf.Max(20f, num2 - 46f);
			float num5 = Mathf.Max(20f, num3 - 54f);
			return new Vector2(num2 + Mathf.Sin(num) * num4, num3 + Mathf.Cos(num) * num5);
		}

		private void DrawWheel()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_044a: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)Screen.width * 0.5f;
			float num2 = (float)Screen.height * 0.5f;
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(num - 245f, num2 - 233f, 490f, 466f);
			DrawRect(rect, new Color(0.018f, 0.03f, 0.043f, 0.9f));
			DrawRect(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 3f), new Color(0.25f, 0.88f, 0.94f, 0.95f));
			GUI.Label(new Rect(((Rect)(ref rect)).x + 23f, ((Rect)(ref rect)).y + 19f, ((Rect)(ref rect)).width - 46f, 28f), "REPO PING", _titleStyle);
			GUI.Label(new Rect(((Rect)(ref rect)).x + 23f, ((Rect)(ref rect)).y + 51f, ((Rect)(ref rect)).width - 46f, 19f), "TACTICAL MARKER  /  SHARED WITH REPOPING PLAYERS", _hintStyle);
			float num3 = num;
			float num4 = num2 + 10f;
			DrawDisc(new Vector2(num3, num4), 166f, new Color(0.07f, 0.11f, 0.14f, 0.96f));
			DrawRing(new Vector2(num3, num4), 166f, 2f, new Color(0.19f, 0.3f, 0.33f, 0.9f));
			DrawDisc(new Vector2(num3, num4), 52f, new Color(0.025f, 0.045f, 0.058f, 1f));
			DrawRing(new Vector2(num3, num4), 52f, 2f, Kinds[_selectedKind].Color);
			GUI.Label(new Rect(num3 - 39f, num4 - 17f, 78f, 34f), "PING", _centerStyle);
			Vector2 val = default(Vector2);
			Rect rect2 = default(Rect);
			for (int i = 0; i < Kinds.Length; i++)
			{
				float num5 = (90f - (float)i * 45f) * (MathF.PI / 180f);
				((Vector2)(ref val))..ctor(Mathf.Cos(num5), 0f - Mathf.Sin(num5));
				Vector2 val2 = new Vector2(num3, num4) + val * 119f;
				((Rect)(ref rect2))..ctor(val2.x - 57f, val2.y - 23f, 114f, 46f);
				bool flag = i == _selectedKind;
				DrawRect(rect2, flag ? new Color(Kinds[i].Color.r * 0.2f + 0.035f, Kinds[i].Color.g * 0.2f + 0.04f, Kinds[i].Color.b * 0.2f + 0.05f, 1f) : new Color(0.045f, 0.07f, 0.085f, 0.97f));
				DrawRect(new Rect(((Rect)(ref rect2)).x, ((Rect)(ref rect2)).y, 3f, ((Rect)(ref rect2)).height), Kinds[i].Color);
				GUI.Label(new Rect(((Rect)(ref rect2)).x + 10f, ((Rect)(ref rect2)).y + 4f, ((Rect)(ref rect2)).width - 16f, ((Rect)(ref rect2)).height - 8f), Kinds[i].Title, _tileStyle);
				if (flag)
				{
					DrawRing(new Vector2(((Rect)(ref rect2)).center.x, ((Rect)(ref rect2)).center.y), 62f, 1f, new Color(Kinds[i].Color.r, Kinds[i].Color.g, Kinds[i].Color.b, 0.28f));
				}
			}
			GUI.Label(new Rect(((Rect)(ref rect)).x + 22f, ((Rect)(ref rect)).yMax - 49f, ((Rect)(ref rect)).width - 44f, 22f), "MOVE MOUSE TO SELECT  ·  RELEASE G TO SEND  ·  ESC TO CANCEL", _hintStyle);
		}

		private void DrawDisc(Vector2 center, float radius, Color color)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			DrawShape(_discTexture, center, radius, color);
		}

		private void DrawRing(Vector2 center, float radius, float thickness, Color color)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			DrawShape(_ringTexture, center, radius, color);
		}

		private static Texture2D MakeCircleTexture(bool ring)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(96, 96, (TextureFormat)4, false);
			((Texture)val).filterMode = (FilterMode)1;
			for (int i = 0; i < 96; i++)
			{
				for (int j = 0; j < 96; j++)
				{
					float num = ((float)j + 0.5f - 48f) / 48f;
					float num2 = ((float)i + 0.5f - 48f) / 48f;
					float num3 = Mathf.Sqrt(num * num + num2 * num2);
					float num4 = (ring ? Mathf.Clamp01((0.055f - Mathf.Abs(num3 - 0.88f)) * 96f) : Mathf.Clamp01((1f - num3) * 96f * 0.5f));
					val.SetPixel(j, i, new Color(1f, 1f, 1f, num4));
				}
			}
			val.Apply();
			return val;
		}

		private void DrawShape(Texture2D texture, Vector2 center, float radius, Color color)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)texture == (Object)null))
			{
				Color color2 = GUI.color;
				GUI.color = color;
				GUI.DrawTexture(new Rect(center.x - radius, center.y - radius, radius * 2f, radius * 2f), (Texture)(object)texture);
				GUI.color = color2;
			}
		}

		private void DrawLine(Vector2 start, Vector2 end, Color color, float width)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = end - start;
			float magnitude = ((Vector2)(ref val)).magnitude;
			if (!(magnitude < 0.5f))
			{
				Matrix4x4 matrix = GUI.matrix;
				Color color2 = GUI.color;
				GUI.color = color;
				GUIUtility.RotateAroundPivot(Mathf.Atan2(val.y, val.x) * 57.29578f, start);
				GUI.DrawTexture(new Rect(start.x, start.y - width * 0.5f, magnitude, width), (Texture)(object)_pixel);
				GUI.matrix = matrix;
				GUI.color = color2;
			}
		}

		private void DrawRect(Rect rect, Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Color color2 = GUI.color;
			GUI.color = color;
			GUI.DrawTexture(rect, (Texture)(object)_pixel);
			GUI.color = color2;
		}

		private string GetPlayerName(int actor)
		{
			if (PhotonNetwork.CurrentRoom != null)
			{
				Player player = PhotonNetwork.CurrentRoom.GetPlayer(actor, false);
				if (player != null && !string.IsNullOrWhiteSpace(player.NickName))
				{
					return player.NickName;
				}
			}
			return "CREW";
		}

		private void EnsureStyles()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_00ae: 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_00c8: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			//IL_00f5: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Expected O, but got Unknown
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Expected O, but got Unknown
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			if (_titleStyle == null)
			{
				_titleStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 22,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3
				};
				_titleStyle.normal.textColor = new Color(0.37f, 0.95f, 0.97f, 1f);
				_hintStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 10,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3,
					clipping = (TextClipping)1
				};
				_hintStyle.normal.textColor = new Color(0.58f, 0.7f, 0.75f, 1f);
				_tileStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 12,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4,
					clipping = (TextClipping)1
				};
				_tileStyle.normal.textColor = Color.white;
				_centerStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 13,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4
				};
				_centerStyle.normal.textColor = Color.white;
				_markerStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 12,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3,
					clipping = (TextClipping)1
				};
				_markerStyle.normal.textColor = Color.white;
				_subStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 10,
					alignment = (TextAnchor)3,
					clipping = (TextClipping)1
				};
				_subStyle.normal.textColor = new Color(0.74f, 0.83f, 0.86f, 1f);
				_tinyStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 9,
					alignment = (TextAnchor)4
				};
				_tinyStyle.normal.textColor = Color.white;
			}
		}

		private void OnDestroy()
		{
			PhotonNetwork.RemoveCallbackTarget((object)this);
			if ((Object)(object)_pixel != (Object)null)
			{
				Object.Destroy((Object)(object)_pixel);
			}
			if ((Object)(object)_discTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_discTexture);
			}
			if ((Object)(object)_ringTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_ringTexture);
			}
		}
	}
}
namespace Codex.CrewChecklist
{
	[BepInPlugin("codex.repoteamtools.checklist", "Crew Checklist", "1.0.1")]
	public sealed class CrewChecklistPlugin : BaseUnityPlugin
	{
		private ConfigEntry<bool> _showOnLaunch;

		private ConfigEntry<KeyCode> _toggleKey;

		private ConfigEntry<KeyCode> _resetKey;

		private ConfigEntry<string>[] _itemLabels;

		private ConfigEntry<bool>[] _checkedItems;

		private readonly string[] _items = new string[5] { "Agree on a plan", "Check the team's gear", "Keep track of each other", "Mark anything to remember", "Confirm the next step" };

		private Rect _windowRect = new Rect(24f, 120f, 286f, 244f);

		private Texture2D _pixel;

		private GUIStyle _titleStyle;

		private GUIStyle _itemStyle;

		private GUIStyle _selectedItemStyle;

		private GUIStyle _hintStyle;

		private bool _visible;

		private int _selectedIndex;

		private void Awake()
		{
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Expected O, but got Unknown
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			_showOnLaunch = ((BaseUnityPlugin)this).Config.Bind<bool>("Checklist", "ShowOnLaunch", true, "Open the checklist when the game starts.");
			_toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Checklist", "ToggleKey", (KeyCode)289, "Show or hide the local checklist.");
			_resetKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Checklist", "ResetKey", (KeyCode)290, "Uncheck every item.");
			_itemLabels = new ConfigEntry<string>[_items.Length];
			_checkedItems = new ConfigEntry<bool>[_items.Length];
			for (int i = 0; i < _items.Length; i++)
			{
				_itemLabels[i] = ((BaseUnityPlugin)this).Config.Bind<string>("Items", "Item" + (i + 1) + "Text", _items[i], "Checklist reminder text.");
				_checkedItems[i] = ((BaseUnityPlugin)this).Config.Bind<bool>("Items", "Item" + (i + 1), false, _items[i]);
			}
			_visible = _showOnLaunch.Value;
			_pixel = new Texture2D(1, 1, (TextureFormat)4, false);
			_pixel.SetPixel(0, 0, Color.white);
			_pixel.Apply();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Crew Checklist loaded. F8 toggles the local checklist; F9 clears it.");
		}

		private void Update()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown(_toggleKey.Value))
			{
				_visible = !_visible;
			}
			if (_visible && Input.GetKeyDown((KeyCode)274))
			{
				_selectedIndex = (_selectedIndex + 1) % _items.Length;
			}
			if (_visible && Input.GetKeyDown((KeyCode)273))
			{
				_selectedIndex = (_selectedIndex + _items.Length - 1) % _items.Length;
			}
			if (_visible && (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)))
			{
				_checkedItems[_selectedIndex].Value = !_checkedItems[_selectedIndex].Value;
			}
			if (Input.GetKeyDown(_resetKey.Value))
			{
				ConfigEntry<bool>[] checkedItems = _checkedItems;
				for (int i = 0; i < checkedItems.Length; i++)
				{
					checkedItems[i].Value = false;
				}
			}
		}

		private void OnGUI()
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			if (_visible)
			{
				EnsureStyles();
				((Rect)(ref _windowRect)).width = Mathf.Clamp(((Rect)(ref _windowRect)).width, 250f, Mathf.Max(250f, (float)Screen.width - 24f));
				((Rect)(ref _windowRect)).height = 244f;
				((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 8f, Mathf.Max(8f, (float)Screen.width - ((Rect)(ref _windowRect)).width - 8f));
				((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 8f, Mathf.Max(8f, (float)Screen.height - ((Rect)(ref _windowRect)).height - 8f));
				GUI.BeginGroup(_windowRect);
				DrawWindow();
				GUI.EndGroup();
			}
		}

		private void DrawWindow()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(0f, 0f, ((Rect)(ref _windowRect)).width, ((Rect)(ref _windowRect)).height);
			DrawRect(rect, new Color(0.025f, 0.045f, 0.065f, 0.96f));
			DrawRect(new Rect(0f, 0f, ((Rect)(ref rect)).width, 3f), new Color(0.34f, 0.94f, 0.76f, 1f));
			GUI.Label(new Rect(14f, 10f, ((Rect)(ref rect)).width - 28f, 24f), "CREW CHECKLIST", _titleStyle);
			GUI.Label(new Rect(14f, 34f, ((Rect)(ref rect)).width - 28f, 18f), "A local reminder board for your next run.", _hintStyle);
			Rect rect2 = default(Rect);
			for (int i = 0; i < _items.Length; i++)
			{
				((Rect)(ref rect2))..ctor(12f, 62f + (float)i * 29f, ((Rect)(ref rect)).width - 24f, 25f);
				bool flag = i == _selectedIndex;
				DrawRect(rect2, flag ? new Color(0.1f, 0.2f, 0.21f, 1f) : new Color(0.07f, 0.1f, 0.13f, 1f));
				string text = (_checkedItems[i].Value ? "[x] " : "[ ] ");
				GUI.Label(new Rect(((Rect)(ref rect2)).x + 8f, ((Rect)(ref rect2)).y + 1f, ((Rect)(ref rect2)).width - 16f, 22f), text + _itemLabels[i].Value, flag ? _selectedItemStyle : _itemStyle);
			}
			GUI.Label(new Rect(14f, 212f, ((Rect)(ref rect)).width - 28f, 20f), "UP/DOWN SELECT   ENTER CHECK   F9 CLEAR", _hintStyle);
		}

		private void EnsureStyles()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			if (_titleStyle == null)
			{
				_titleStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 15,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3
				};
				_titleStyle.normal.textColor = new Color(0.34f, 0.94f, 0.76f, 1f);
				_itemStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 13,
					alignment = (TextAnchor)3,
					clipping = (TextClipping)1
				};
				_itemStyle.normal.textColor = Color.white;
				_selectedItemStyle = new GUIStyle(_itemStyle);
				_selectedItemStyle.normal.textColor = new Color(0.55f, 1f, 0.84f, 1f);
				_hintStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 10,
					alignment = (TextAnchor)3,
					clipping = (TextClipping)1
				};
				_hintStyle.normal.textColor = new Color(0.68f, 0.78f, 0.82f, 1f);
			}
		}

		private void DrawRect(Rect rect, Color color)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Color color2 = GUI.color;
			GUI.color = color;
			GUI.DrawTexture(rect, (Texture)(object)_pixel);
			GUI.color = color2;
		}

		private void OnDestroy()
		{
			if ((Object)(object)_pixel != (Object)null)
			{
				Object.Destroy((Object)(object)_pixel);
			}
		}
	}
}