Decompiled source of OpsCoordinator v1.0.2

OpsCoordinator.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using OpsCoordinator;
using OpsCoordinator.Behaviours;
using OpsCoordinator.NetcodePatcher;
using OpsCoordinator.Network;
using OpsCoordinator.UI;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Rendering;
using UnityEngine.Rendering.HighDefinition;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("OpsCoordinator")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A template for Lethal Company")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+e28807e2130dee56762ca6035b04993daafa8b3e")]
[assembly: AssemblyProduct("OpsCoordinator")]
[assembly: AssemblyTitle("OpsCoordinator")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
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 LethalCompanyTemplate
{
	[HarmonyPatch(typeof(Terminal))]
	internal class OpsTerminalPatch
	{
		private static bool pendingPurchase;

		[HarmonyPatch("ParsePlayerSentence")]
		[HarmonyPostfix]
		private static void OnParsePlayerSentence(Terminal __instance, ref TerminalNode __result)
		{
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			string typedInput = GetTypedInput(__instance);
			if (string.IsNullOrEmpty(typedInput))
			{
				return;
			}
			ModLogger.Info($"Terminal input parsed: '{typedInput}' (pendingPurchase={pendingPurchase})");
			int num = OpsMapSettings.UpgradeCost?.Value ?? 350;
			if (typedInput == "store")
			{
				pendingPurchase = false;
				TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
				val.displayText = "STORE - AVAILABLE UPGRADES\n\n" + $"- OPS COORDINATOR TACTICAL PACKAGE — Cost: {num} credits\n\n" + "Type 'ops' (or 'coordinator' / 'tactical') to view/purchase this upgrade.\n";
				val.clearPreviousText = true;
				__result = val;
				return;
			}
			if (pendingPurchase && (typedInput == "confirm" || typedInput == "deny"))
			{
				pendingPurchase = false;
				TerminalNode val2 = ScriptableObject.CreateInstance<TerminalNode>();
				val2.clearPreviousText = true;
				if (typedInput == "deny")
				{
					val2.displayText = "Purchase cancelled.\n";
					__result = val2;
					return;
				}
				OpsNetworkManager instance = OpsNetworkManager.Instance;
				if ((Object)(object)instance != (Object)null && ((NetworkBehaviour)instance).IsSpawned && instance.OpsUnlocked.Value)
				{
					val2.displayText = "OPS COORDINATOR is already unlocked for this crew.\n";
					__result = val2;
					return;
				}
				if ((Object)(object)NetworkManager.Singleton == (Object)null || !NetworkManager.Singleton.IsListening || (Object)(object)instance == (Object)null || !((NetworkBehaviour)instance).IsSpawned)
				{
					ModLogger.Error("OpsNetworkManager not ready to receive purchase request.");
					val2.displayText = "ERROR: Ops network not ready. Try again in a moment.\n";
					__result = val2;
					return;
				}
				if (__instance.groupCredits < num)
				{
					val2.displayText = "Insufficient credits.\n\n" + $"OPS COORDINATOR TACTICAL PACKAGE costs {num} credits.\n" + $"Current balance: {__instance.groupCredits} credits.\n";
					__result = val2;
					return;
				}
				int num2 = __instance.groupCredits - num;
				__instance.SyncGroupCreditsServerRpc(num2, __instance.numberOfItemsInDropship);
				instance.RequestUnlockServerRpc();
				ModLogger.Info($"Purchase confirmed: {num} credits deducted, unlock request sent.");
				val2.displayText = "OPS COORDINATOR TACTICAL PACKAGE - PURCHASED\n\n" + $"New balance: {num2} credits.\n\n" + "Press F7 to open the tactical map (F6 for the ledger).\n";
				__result = val2;
				return;
			}
			string[] array = (OpsMapSettings.UpgradeKeywords?.Value ?? "ops,coordinator,tactical").Split(',');
			bool flag = false;
			string[] array2 = array;
			foreach (string text in array2)
			{
				string text2 = text.Trim();
				if (text2.Length > 0 && typedInput.Contains(text2))
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				TerminalNode val3 = ScriptableObject.CreateInstance<TerminalNode>();
				OpsNetworkManager instance2 = OpsNetworkManager.Instance;
				if ((Object)(object)instance2 != (Object)null && ((NetworkBehaviour)instance2).IsSpawned && instance2.OpsUnlocked.Value)
				{
					val3.displayText = "OPS COORDINATOR TACTICAL PACKAGE\n\nAlready unlocked for this crew.\n\nPress F7 to open the tactical map (F6 for the ledger).\n";
					pendingPurchase = false;
				}
				else
				{
					val3.displayText = "OPS COORDINATOR TACTICAL PACKAGE\n\n" + $"Cost: {num} credits (current balance: {__instance.groupCredits})\n\n" + "• Real-time squad map\n• Loot / Threat / Extract pings\n• Player status ledger\n\nType CONFIRM to purchase or DENY to cancel.\n";
					pendingPurchase = true;
				}
				val3.clearPreviousText = true;
				__result = val3;
			}
			else if (typedInput.Length > 0 && typedInput != "confirm" && typedInput != "deny")
			{
				pendingPurchase = false;
			}
		}

		private static string GetTypedInput(Terminal terminal)
		{
			try
			{
				string text = (((Object)(object)terminal.screenText != (Object)null) ? terminal.screenText.text : null);
				if (text != null && terminal.textAdded > 0 && terminal.textAdded <= text.Length)
				{
					return text.Substring(text.Length - terminal.textAdded).ToLower().Trim();
				}
			}
			catch
			{
			}
			return (terminal.currentText ?? string.Empty).ToLower().Trim();
		}
	}
}
namespace OpsCoordinator
{
	public static class ModLogger
	{
		private static readonly Dictionary<string, float> lastLogTime = new Dictionary<string, float>();

		public static void Info(string message)
		{
			if ((Object)(object)Plugin.Instance != (Object)null)
			{
				Plugin.Instance.PublicLogger.LogInfo((object)message);
			}
			else
			{
				Debug.Log((object)("[OpsCoordinator] " + message));
			}
		}

		public static void Warning(string message)
		{
			if ((Object)(object)Plugin.Instance != (Object)null)
			{
				Plugin.Instance.PublicLogger.LogWarning((object)message);
			}
			else
			{
				Debug.LogWarning((object)("[OpsCoordinator] " + message));
			}
		}

		public static void Error(string message)
		{
			if ((Object)(object)Plugin.Instance != (Object)null)
			{
				Plugin.Instance.PublicLogger.LogError((object)message);
			}
			else
			{
				Debug.LogError((object)("[OpsCoordinator] " + message));
			}
		}

		public static void Debug(string key, string message, float throttleSeconds = 0f)
		{
			if (throttleSeconds > 0f)
			{
				if (lastLogTime.TryGetValue(key, out var value) && Time.realtimeSinceStartup - value < throttleSeconds)
				{
					return;
				}
				lastLogTime[key] = Time.realtimeSinceStartup;
			}
			if ((Object)(object)Plugin.Instance != (Object)null)
			{
				Plugin.Instance.PublicLogger.LogDebug((object)message);
			}
			else
			{
				Debug.Log((object)("[OpsCoordinator][DEBUG] " + message));
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager), "Update")]
	public static class OpsMapTogglePatch
	{
		private static bool mapVisible;

		private static bool cursorFreed;

		public static void Postfix(HUDManager __instance)
		{
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			Transform orCreate = OpsUIRoot.GetOrCreate();
			Transform val = ((orCreate != null) ? orCreate.Find("OpsModUI") : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Transform val2 = val.Find("OpsMapPanel");
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			if (((Component)val2).gameObject.activeSelf != mapVisible)
			{
				((Component)val2).gameObject.SetActive(mapVisible);
			}
			ConfigEntry<KeyboardShortcut> toggleMapKey = OpsMapSettings.ToggleMapKey;
			int num;
			KeyboardShortcut value;
			if (toggleMapKey == null)
			{
				num = 0;
			}
			else
			{
				value = toggleMapKey.Value;
				num = (((KeyboardShortcut)(ref value)).IsDown() ? 1 : 0);
			}
			bool flag = (byte)num != 0;
			bool flag2 = (Object)(object)OpsNetworkManager.Instance != (Object)null && OpsNetworkManager.Instance.OpsUnlocked.Value;
			PlayerControllerB val3 = GameNetworkManager.Instance?.localPlayerController;
			bool flag3 = (Object)(object)val3 != (Object)null && val3.inTerminalMenu;
			if (flag && !flag3)
			{
				if (!flag2)
				{
					Debug.Log((object)"[OpsCoordinator] Map is locked - purchase the Ops Coordinator upgrade at the terminal first.");
				}
				else
				{
					mapVisible = !mapVisible;
					((Component)val2).gameObject.SetActive(mapVisible);
					Debug.Log((object)$"[OpsCoordinator] Map visibility toggled: {mapVisible}");
				}
			}
			if (mapVisible && flag3)
			{
				((Component)val2).gameObject.SetActive(false);
			}
			else if (mapVisible && !flag3 && !((Component)val2).gameObject.activeSelf && flag2)
			{
				((Component)val2).gameObject.SetActive(true);
			}
			if (mapVisible && !flag2)
			{
				mapVisible = false;
				((Component)val2).gameObject.SetActive(false);
			}
			if (mapVisible)
			{
				Image component = ((Component)val2).GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					float num2 = OpsMapSettings.MapOpacity?.Value ?? 0.55f;
					((Graphic)component).color = new Color(0f, 0f, 0f, num2);
				}
				ConfigEntry<KeyboardShortcut> freeCursorKey = OpsMapSettings.FreeCursorKey;
				int num3;
				if (freeCursorKey == null)
				{
					num3 = 0;
				}
				else
				{
					value = freeCursorKey.Value;
					num3 = (((KeyboardShortcut)(ref value)).IsPressed() ? 1 : 0);
				}
				bool flag4 = (byte)num3 != 0;
				if (flag4 && !cursorFreed)
				{
					Cursor.lockState = (CursorLockMode)0;
					Cursor.visible = true;
					cursorFreed = true;
					Debug.Log((object)"[OpsCoordinator] Cursor freed for map interaction.");
				}
				else if (!flag4 && cursorFreed)
				{
					Cursor.lockState = (CursorLockMode)1;
					Cursor.visible = false;
					cursorFreed = false;
					Debug.Log((object)"[OpsCoordinator] Cursor re-locked.");
				}
			}
			else if (cursorFreed)
			{
				Cursor.lockState = (CursorLockMode)1;
				Cursor.visible = false;
				cursorFreed = false;
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager), "Awake")]
	public static class OpsUIInjectPatch
	{
		public static void Postfix(HUDManager __instance)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"[OpsCoordinator][UIInject] HUDManager.Awake postfix running...");
			if (!OpsMapSettings.LedgerEnabled.Value)
			{
				Debug.Log((object)"[OpsCoordinator][UIInject] LedgerEnabled is false; skipping ledger text creation.");
				return;
			}
			Transform orCreate = OpsUIRoot.GetOrCreate();
			Transform val = orCreate.Find("OpsLedgerText");
			if ((Object)(object)val != (Object)null)
			{
				Debug.Log((object)"[OpsCoordinator][UIInject] Ledger text already exists, skipping injection.");
				return;
			}
			try
			{
				GameObject val2 = new GameObject("OpsLedgerText");
				val2.transform.SetParent(orCreate, false);
				Text val3 = val2.AddComponent<Text>();
				val3.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
				if ((Object)(object)val3.font == (Object)null)
				{
					Debug.LogWarning((object)"[OpsCoordinator][UIInject] LegacyRuntime.ttf failed, trying Arial.ttf");
					val3.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				}
				if ((Object)(object)val3.font == (Object)null)
				{
					Debug.LogError((object)"[OpsCoordinator][UIInject] NO FONT LOADED! Text will be invisible.");
				}
				else
				{
					Debug.Log((object)("[OpsCoordinator][UIInject] Font loaded: " + ((Object)val3.font).name));
				}
				val3.fontSize = 13;
				((Graphic)val3).color = Color.yellow;
				val3.alignment = (TextAnchor)0;
				val3.horizontalOverflow = (HorizontalWrapMode)0;
				val3.verticalOverflow = (VerticalWrapMode)0;
				val3.text = "Press F6 - Ops";
				((Graphic)val3).raycastTarget = false;
				RectTransform component = val2.GetComponent<RectTransform>();
				component.sizeDelta = new Vector2(240f, 140f);
				OpsUILayout.ApplyCornerAnchor(component, OpsMapSettings.LedgerCorner.Value, OpsMapSettings.LedgerMarginX.Value, OpsMapSettings.LedgerMarginY.Value);
				OpsUIBehaviour opsUIBehaviour = val2.AddComponent<OpsUIBehaviour>();
				opsUIBehaviour.SetTextComponent(val3);
				Debug.Log((object)"[OpsCoordinator][UIInject] OpsUIInjectPatch completed successfully.");
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"[OpsCoordinator][UIInject] Exception: {arg}");
			}
		}
	}
	[BepInPlugin("com.opscoordinator.lethalcompany", "OpsCoordinator", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin Instance;

		public ManualLogSource PublicLogger => ((BaseUnityPlugin)this).Logger;

		private void Awake()
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			NetcodePatcherInit();
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"OpsCoordinator v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded successfully!");
			OpsMapSettings.Init(((BaseUnityPlugin)this).Config);
			new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID).PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[OpsCoordinator] Terminal integration initialized.");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[OpsCoordinator] Starting player state polling...");
			((MonoBehaviour)this).StartCoroutine(PollPlayerState());
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[OpsCoordinator] Fully initialized.");
		}

		private static void NetcodePatcherInit()
		{
			Type[] array;
			try
			{
				array = Assembly.GetExecutingAssembly().GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				array = ex.Types.Where((Type t) => t != null).ToArray();
			}
			int num = 0;
			Type[] array2 = array;
			foreach (Type type in array2)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo in methods)
				{
					if (methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false).Length != 0)
					{
						((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[NetcodeInit] Invoking " + type.Name + "." + methodInfo.Name));
						methodInfo.Invoke(null, null);
						num++;
					}
				}
			}
			((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"[NetcodeInit] Invoked {num} initializer(s).");
			if (num == 0)
			{
				MethodInfo method = typeof(OpsNetworkManager).GetMethod("InitializeRPCS_OpsNetworkManager", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"[NetcodeInit] Fallback InitializeRPCS found: {method != null}");
				method?.Invoke(null, null);
			}
		}

		private IEnumerator PollPlayerState()
		{
			while (true)
			{
				yield return (object)new WaitForSeconds(2f);
				try
				{
					if ((Object)(object)StartOfRound.Instance == (Object)null)
					{
						continue;
					}
					OpsUIBehaviour.LatestPlayerStates.Clear();
					PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
					foreach (PlayerControllerB player in allPlayerScripts)
					{
						if ((Object)(object)player == (Object)null || !player.isPlayerControlled)
						{
							continue;
						}
						int heldCount = 0;
						string firstName = null;
						int totalValue = 0;
						GrabbableObject[] itemSlots = player.ItemSlots;
						foreach (GrabbableObject item in itemSlots)
						{
							if (!((Object)(object)item == (Object)null))
							{
								heldCount++;
								if (firstName == null)
								{
									firstName = (((Object)(object)item.itemProperties != (Object)null) ? item.itemProperties.itemName : "???");
								}
								totalValue += item.scrapValue;
							}
						}
						OpsUIBehaviour.LatestPlayerStates[player.playerClientId] = new PlayerSnapshot
						{
							Name = player.playerUsername,
							HeldItemCount = heldCount,
							FirstItemName = firstName,
							IsInside = player.isInsideFactory,
							TotalValue = totalValue
						};
					}
				}
				catch (Exception ex)
				{
					Exception ex2 = ex;
					ModLogger.Debug("poll_player_state_error", "PollPlayerState error: " + ex2.Message, 10f);
				}
			}
		}
	}
	public struct PlayerSnapshot
	{
		public string Name;

		public int HeldItemCount;

		public string FirstItemName;

		public bool IsInside;

		public int TotalValue;
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "OpsCoordinator";

		public const string PLUGIN_NAME = "OpsCoordinator";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace OpsCoordinator.Upgrades
{
	public class OpsTerminalUpgrade : NetworkBehaviour
	{
		public static OpsTerminalUpgrade Instance { get; private set; }

		public bool IsUnlocked { get; private set; } = false;

		private void Awake()
		{
			Instance = this;
		}

		public void UnlockOpsSystem()
		{
			if (!IsUnlocked)
			{
				IsUnlocked = true;
				ModLogger.Info("=== OPS COORDINATOR FULLY UNLOCKED ===");
				if (OpsMapSettings.MapEnabled != null)
				{
					OpsMapSettings.MapEnabled.Value = true;
				}
			}
		}

		protected override void __initializeVariables()
		{
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			((NetworkBehaviour)this).__initializeRpcs();
		}

		protected internal override string __getTypeName()
		{
			return "OpsTerminalUpgrade";
		}
	}
}
namespace OpsCoordinator.UI
{
	[HarmonyPatch(typeof(StartOfRound), "Start")]
	public static class OpsMapBackgroundRefreshPatch
	{
		public static void Postfix(StartOfRound __instance)
		{
			Transform val = OpsUIRoot.GetOrCreate().Find("OpsModUI");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Transform val2 = val.Find("OpsMapPanel");
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			Transform val3 = val2.Find("MapRect");
			if (!((Object)(object)val3 == (Object)null))
			{
				Image component = ((Component)val3).GetComponent<Image>();
				if (!((Object)(object)component == (Object)null))
				{
					OpsMapBackgrounds.ApplyTo(component);
					ModLogger.Info("Tactical map background refreshed for new moon.");
				}
			}
		}
	}
	public static class OpsMapBackgrounds
	{
		private static readonly Dictionary<string, Sprite> moonBlueprints = new Dictionary<string, Sprite>();

		private static bool initialized = false;

		public static void Init()
		{
			//IL_001f: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: 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)
			if (!initialized)
			{
				initialized = true;
				moonBlueprints["Experimentation"] = MakeScanTexture(Color.blue, 1);
				moonBlueprints["Assurance"] = MakeScanTexture(Color.green, 2);
				moonBlueprints["Vow"] = MakeScanTexture(Color.cyan, 3);
				moonBlueprints["March"] = MakeScanTexture(Color.magenta, 4);
				moonBlueprints["Adamance"] = MakeScanTexture(Color.yellow, 5);
				moonBlueprints["Offense"] = MakeScanTexture(Color.red, 6);
				moonBlueprints["Titan"] = MakeScanTexture(Color.gray, 7);
			}
		}

		public static void ApplyTo(Image mapBackground)
		{
			//IL_0074: 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)
			if (!((Object)(object)mapBackground == (Object)null))
			{
				Init();
				string text = "Experimentation";
				if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.currentLevel != (Object)null)
				{
					text = ((Object)StartOfRound.Instance.currentLevel).name;
				}
				if (moonBlueprints.TryGetValue(text, out var value))
				{
					mapBackground.sprite = value;
				}
				else
				{
					mapBackground.sprite = MakeScanTexture(Color.green, text.GetHashCode());
				}
				((Graphic)mapBackground).color = new Color(1f, 1f, 1f, OpsMapSettings.MapOpacity?.Value ?? 0.5f);
				mapBackground.type = (Type)0;
				mapBackground.preserveAspect = true;
			}
		}

		private static Sprite MakeScanTexture(Color tint, int seed)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0040: 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_004c: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0063: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(256, 256);
			Random random = new Random(seed);
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.01f, 0.03f, 0.02f, 1f);
			Color val3 = Color.Lerp(val2, tint, 0.35f);
			Color val4 = Color.Lerp(val2, tint, 0.7f);
			Color val5 = Color.Lerp(val2, tint, 0.5f);
			Color val6 = Color.Lerp(val2, tint, 1f);
			Color[] array = (Color[])(object)new Color[65536];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = val2;
			}
			for (int j = 0; j < 6; j++)
			{
				float num = random.Next(0, 256);
				float num2 = random.Next(0, 256);
				int num3 = random.Next(90, 200);
				float num4 = (float)(random.NextDouble() * 2.0 - 1.0);
				float num5 = (float)(random.NextDouble() * 2.0 - 1.0);
				for (int k = 0; k < num3; k++)
				{
					int num6 = Mathf.Clamp((int)num, 0, 255);
					int num7 = Mathf.Clamp((int)num2, 0, 255);
					array[num7 * 256 + num6] = val3;
					num4 += (float)(random.NextDouble() * 0.6 - 0.3);
					num5 += (float)(random.NextDouble() * 0.6 - 0.3);
					num4 = Mathf.Clamp(num4, -1.5f, 1.5f);
					num5 = Mathf.Clamp(num5, -1.5f, 1.5f);
					num += num4;
					num2 += num5;
					if (num < 0f || num >= 256f || num2 < 0f || num2 >= 256f)
					{
						break;
					}
				}
			}
			float num8 = 97.28f;
			float num9 = 140.8f;
			float num10 = 76.8f;
			float num11 = 40.96f;
			float num12 = -0.38397244f;
			float num13 = Mathf.Cos(num12);
			float num14 = Mathf.Sin(num12);
			for (int l = 0; l < 256; l++)
			{
				for (int m = 0; m < 256; m++)
				{
					float num15 = (float)l - num8;
					float num16 = (float)m - num9;
					float num17 = num15 * num13 - num16 * num14;
					float num18 = num15 * num14 + num16 * num13;
					float num19 = num17 * num17 / (num10 * num10) + num18 * num18 / (num11 * num11);
					if (num19 <= 1f)
					{
						bool flag = num19 > 0.88f;
						bool flag2 = (l + m) % 10 < 4;
						Color val7 = (flag ? val6 : (flag2 ? val5 : val4));
						array[m * 256 + l] = val7;
					}
				}
			}
			val.SetPixels(array);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f));
		}

		public static Sprite MakeCompassRoseSprite()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_01e0: 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_0099: 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_009f: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false);
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
			Color val3 = default(Color);
			((Color)(ref val3))..ctor(0.35f, 0.85f, 1f, 0.9f);
			Vector2 val4 = default(Vector2);
			((Vector2)(ref val4))..ctor(64f, 64f);
			float num = 56f;
			int[] array = new int[12]
			{
				0, 30, 60, 90, 120, 150, 180, 210, 240, 270,
				300, 330
			};
			Color[] array2 = (Color[])(object)new Color[16384];
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					Vector2 val5 = new Vector2((float)i, (float)j) - val4;
					float magnitude = ((Vector2)(ref val5)).magnitude;
					float num2 = Mathf.Atan2(val5.x, val5.y) * 57.29578f;
					num2 = (num2 + 360f) % 360f;
					Color val6 = val2;
					bool flag = Mathf.Abs(magnitude - num) < 1.4f;
					bool flag2 = false;
					int[] array3 = array;
					foreach (int num3 in array3)
					{
						float num4 = Mathf.DeltaAngle(num2, (float)num3);
						float num5 = ((num3 % 90 == 0) ? 16f : 8f);
						if (Mathf.Abs(num4) < 2.5f && magnitude > num - num5 && magnitude < num + 4f)
						{
							flag2 = true;
							break;
						}
					}
					if (flag || flag2)
					{
						val6 = val3;
					}
					array2[j * 128 + i] = val6;
				}
			}
			val.SetPixels(array2);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f));
		}
	}
	public enum OpsScreenCorner
	{
		TopLeft,
		TopRight,
		BottomLeft,
		BottomRight
	}
	public static class OpsUILayout
	{
		public static void ApplyCornerAnchor(RectTransform rect, OpsScreenCorner corner, float marginX, float marginY)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			if (1 == 0)
			{
			}
			Vector2 val = (Vector2)(corner switch
			{
				OpsScreenCorner.TopLeft => new Vector2(0f, 1f), 
				OpsScreenCorner.TopRight => new Vector2(1f, 1f), 
				OpsScreenCorner.BottomLeft => new Vector2(0f, 0f), 
				OpsScreenCorner.BottomRight => new Vector2(1f, 0f), 
				_ => new Vector2(0f, 1f), 
			});
			if (1 == 0)
			{
			}
			Vector2 val2 = (rect.pivot = (rect.anchorMax = (rect.anchorMin = val)));
			float num = ((val2.x == 0f) ? marginX : (0f - marginX));
			float num2 = ((val2.y == 1f) ? (0f - marginY) : marginY);
			rect.anchoredPosition = new Vector2(num, num2);
		}
	}
	public static class OpsUIRoot
	{
		private const string RootName = "OpsUIRoot";

		public static Transform GetOrCreate()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			GameObject val = GameObject.Find("OpsUIRoot");
			if ((Object)(object)val != (Object)null)
			{
				return val.transform;
			}
			GameObject val2 = new GameObject("OpsUIRoot");
			Canvas val3 = val2.AddComponent<Canvas>();
			val3.renderMode = (RenderMode)0;
			val3.sortingOrder = 1000;
			val2.AddComponent<CanvasScaler>();
			val2.AddComponent<GraphicRaycaster>();
			Object.DontDestroyOnLoad((Object)(object)val2);
			Debug.Log((object)"[OpsCoordinator][UI] Created OpsUIRoot canvas.");
			return val2.transform;
		}
	}
}
namespace OpsCoordinator.Patches
{
	[HarmonyPatch(typeof(HUDManager), "Start")]
	public static class OpsCoordinatorInitPatch
	{
		public static void Postfix()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (!((Object)(object)GameObject.Find("OpsCoordinatorBehaviour") != (Object)null))
			{
				GameObject val = new GameObject("OpsCoordinatorBehaviour");
				val.AddComponent<OpsCoordinatorBehaviour>();
				Object.DontDestroyOnLoad((Object)(object)val);
				Debug.Log((object)"[OpsCoordinator] Coordinator created via HUDManager.Start patch.");
			}
		}
	}
	[HarmonyPatch(typeof(HUDManager), "Start")]
	public static class OpsMapInjectPatch
	{
		public static void Postfix(HUDManager __instance)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0075: 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_00e1: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Expected O, but got Unknown
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Expected O, but got Unknown
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Expected O, but got Unknown
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			if (!OpsMapSettings.MapEnabled.Value)
			{
				Debug.Log((object)"[OpsCoordinator] MapEnabled is false; skipping map creation.");
				return;
			}
			Transform orCreate = OpsUIRoot.GetOrCreate();
			Transform val = orCreate.Find("OpsModUI");
			if ((Object)(object)val == (Object)null)
			{
				GameObject val2 = new GameObject("OpsModUI");
				val2.transform.SetParent(orCreate, false);
				RectTransform val3 = val2.AddComponent<RectTransform>();
				val3.sizeDelta = new Vector2(340f, 380f);
				OpsUILayout.ApplyCornerAnchor(val3, OpsMapSettings.MapCorner.Value, OpsMapSettings.MapMarginX.Value, OpsMapSettings.MapMarginY.Value);
				val = val2.transform;
			}
			if (!((Object)(object)val.Find("OpsMapPanel") != (Object)null))
			{
				Debug.Log((object)"[OpsCoordinator] Injecting OpsMapPanel...");
				GameObject val4 = new GameObject("OpsMapPanel");
				val4.transform.SetParent(val, false);
				val4.SetActive(false);
				RectTransform val5 = val4.AddComponent<RectTransform>();
				val5.anchorMin = Vector2.zero;
				val5.anchorMax = Vector2.one;
				val5.offsetMin = Vector2.zero;
				val5.offsetMax = Vector2.zero;
				Image val6 = val4.AddComponent<Image>();
				((Graphic)val6).color = new Color(0f, 0f, 0f, 0.35f);
				GameObject val7 = new GameObject("MapRect");
				val7.transform.SetParent(val4.transform, false);
				RectTransform val8 = val7.AddComponent<RectTransform>();
				val8.anchorMin = Vector2.zero;
				val8.anchorMax = Vector2.one;
				val8.offsetMin = new Vector2(8f, 50f);
				val8.offsetMax = new Vector2(-8f, -8f);
				Image val9 = val7.AddComponent<Image>();
				((Graphic)val9).color = new Color(0.08f, 0.15f, 0.12f, 0.65f);
				GameObject val10 = new GameObject("OpsMapDisplay");
				val10.transform.SetParent(val7.transform, false);
				RectTransform val11 = val10.AddComponent<RectTransform>();
				val11.anchorMin = Vector2.zero;
				val11.anchorMax = Vector2.one;
				val11.offsetMin = Vector2.zero;
				val11.offsetMax = Vector2.zero;
				RawImage val12 = val10.AddComponent<RawImage>();
				((Graphic)val12).color = Color.white;
				OpsMapCameraBehaviour opsMapCameraBehaviour = val4.AddComponent<OpsMapCameraBehaviour>();
				opsMapCameraBehaviour.mapDisplayImage = val12;
				OpsMapOverlay opsMapOverlay = val4.AddComponent<OpsMapOverlay>();
				opsMapOverlay.Setup(val12);
				CreateCompassRose(val4.transform);
				GameObject val13 = new GameObject("OpsMapLegend");
				val13.transform.SetParent(val4.transform, false);
				RectTransform val14 = val13.AddComponent<RectTransform>();
				val14.anchorMin = new Vector2(0f, 0f);
				val14.anchorMax = new Vector2(1f, 0f);
				val14.pivot = new Vector2(0.5f, 0f);
				val14.anchoredPosition = new Vector2(0f, 2f);
				val14.sizeDelta = new Vector2(-16f, 40f);
				Text val15 = val13.AddComponent<Text>();
				val15.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
				val15.fontSize = 12;
				val15.alignment = (TextAnchor)0;
				val15.horizontalOverflow = (HorizontalWrapMode)0;
				val15.verticalOverflow = (VerticalWrapMode)0;
				val15.text = "<color=#ffffff>●</color> You   <color=#00ff00>●</color> Ally-In   <color=#ff4040>●</color> Ally-Out\n<color=#ffff00>■</color> Loot   <color=#ff00ff>■</color> Threat   <color=#00ffff>■</color> Extract";
				OpsMapInputBehaviour opsMapInputBehaviour = val4.AddComponent<OpsMapInputBehaviour>();
				opsMapInputBehaviour.mapRect = val8;
				OpsMapLineBehaviour opsMapLineBehaviour = val4.AddComponent<OpsMapLineBehaviour>();
				opsMapLineBehaviour.mapRect = val8;
				opsMapInputBehaviour.cameraBehaviour = opsMapCameraBehaviour;
				opsMapLineBehaviour.cameraBehaviour = opsMapCameraBehaviour;
				Debug.Log((object)"[OpsCoordinator] OpsMapPanel injected successfully.");
			}
		}

		private static void CreateCompassRose(Transform parent)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002c: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("OpsCompassRose");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(1f, 0f);
			val2.anchorMax = new Vector2(1f, 0f);
			val2.pivot = new Vector2(1f, 0f);
			val2.anchoredPosition = new Vector2(-8f, 50f);
			val2.sizeDelta = new Vector2(56f, 56f);
			Image val3 = val.AddComponent<Image>();
			val3.sprite = OpsMapBackgrounds.MakeCompassRoseSprite();
			((Graphic)val3).color = Color.white;
			((Graphic)val3).raycastTarget = false;
			float num = 26f;
			CreateDirectionLabel(val.transform, "N", new Vector2(0f, num));
			CreateDirectionLabel(val.transform, "S", new Vector2(0f, 0f - num));
			CreateDirectionLabel(val.transform, "W", new Vector2(0f - num, 0f));
			CreateDirectionLabel(val.transform, "E", new Vector2(num, 0f));
		}

		private static void CreateDirectionLabel(Transform parent, string letter, Vector2 anchoredPos)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Compass_" + letter);
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.anchorMin = new Vector2(0.5f, 0.5f);
			val2.anchorMax = new Vector2(0.5f, 0.5f);
			val2.pivot = new Vector2(0.5f, 0.5f);
			val2.anchoredPosition = anchoredPos;
			val2.sizeDelta = new Vector2(16f, 16f);
			Text val3 = val.AddComponent<Text>();
			val3.font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
			val3.fontSize = 10;
			val3.fontStyle = (FontStyle)1;
			val3.alignment = (TextAnchor)4;
			((Graphic)val3).color = new Color(0.55f, 0.95f, 1f, 0.95f);
			val3.text = letter;
			((Graphic)val3).raycastTarget = false;
		}
	}
}
namespace OpsCoordinator.Network
{
	[HarmonyPatch(typeof(GameNetworkManager))]
	internal class NetworkPatches
	{
		private static GameObject opsManagerPrefab;

		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void RegisterOpsManagerPrefab()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if (!((Object)(object)opsManagerPrefab != (Object)null))
			{
				opsManagerPrefab = new GameObject("OpsNetworkManager");
				opsManagerPrefab.AddComponent<NetworkObject>();
				opsManagerPrefab.AddComponent<OpsNetworkManager>();
				Object.DontDestroyOnLoad((Object)(object)opsManagerPrefab);
				opsManagerPrefab.SetActive(false);
				NetworkManager singleton = NetworkManager.Singleton;
				if ((Object)(object)singleton != (Object)null)
				{
					singleton.AddNetworkPrefab(opsManagerPrefab);
					ModLogger.Info("OpsNetworkManager prefab registered.");
				}
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		private static void SpawnOnRoundStart()
		{
			NetworkManager singleton = NetworkManager.Singleton;
			if (singleton == null || !singleton.IsServer)
			{
				return;
			}
			ModLogger.Debug("spawn_attempt", "StartOfRound.Start - Attempting to spawn OpsNetworkManager (server).", 5f);
			if ((Object)(object)OpsNetworkManager.Instance == (Object)null && (Object)(object)opsManagerPrefab != (Object)null)
			{
				GameObject val = Object.Instantiate<GameObject>(opsManagerPrefab);
				val.SetActive(true);
				NetworkObject component = val.GetComponent<NetworkObject>();
				if (component != null)
				{
					component.Spawn(true);
				}
				ModLogger.Info("OpsNetworkManager spawned via StartOfRound.");
			}
		}
	}
	public class OpsNetworkManager : NetworkBehaviour
	{
		public readonly NetworkList<TacticalMarker> Markers = new NetworkList<TacticalMarker>();

		public readonly NetworkVariable<bool> OpsUnlocked = new NetworkVariable<bool>(false, (NetworkVariableReadPermission)0, (NetworkVariableWritePermission)0);

		private int nextMarkerId = 0;

		private float markerLifetime = 45f;

		public static OpsNetworkManager Instance { get; private set; }

		public override void OnNetworkSpawn()
		{
			((NetworkBehaviour)this).OnNetworkSpawn();
			Instance = this;
			object arg = ((NetworkBehaviour)this).IsServer;
			object arg2 = ((NetworkBehaviour)this).IsSpawned;
			NetworkManager singleton = NetworkManager.Singleton;
			ModLogger.Info($"OpsNetworkManager spawned. IsServer={arg}, IsSpawned={arg2}, ClientId={((singleton != null) ? new ulong?(singleton.LocalClientId) : ((ulong?)null))}");
		}

		public override void OnNetworkDespawn()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
			((NetworkBehaviour)this).OnNetworkDespawn();
		}

		private void Update()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (!((NetworkBehaviour)this).IsServer || !((NetworkBehaviour)this).IsSpawned)
			{
				return;
			}
			NetworkTime serverTime = NetworkManager.Singleton.ServerTime;
			float num = (float)((NetworkTime)(ref serverTime)).Time;
			for (int num2 = Markers.Count - 1; num2 >= 0; num2--)
			{
				if (num - Markers[num2].Timestamp > markerLifetime)
				{
					Markers.RemoveAt(num2);
				}
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void RequestUnlockServerRpc(ServerRpcParams rpcParams = default(ServerRpcParams))
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Invalid comparison between Unknown and I4
			//IL_005f: 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_007c: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(1489470067u, rpcParams, (RpcDelivery)0);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 1489470067u, rpcParams, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (!((NetworkBehaviour)this).IsServer || !((NetworkBehaviour)this).IsSpawned)
				{
					ModLogger.Warning("RequestUnlockServerRpc ignored: not server or not spawned.");
					return;
				}
				if (OpsUnlocked.Value)
				{
					ModLogger.Info("RequestUnlockServerRpc: already unlocked, ignoring.");
					return;
				}
				OpsUnlocked.Value = true;
				ModLogger.Info($"Ops Coordinator unlocked by client {rpcParams.Receive.SenderClientId}.");
			}
		}

		[ServerRpc(RequireOwnership = false)]
		public void AddMarkerServerRpc(Vector3 position, int markerType, ulong createdBy)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Invalid comparison between Unknown and I4
			//IL_005f: 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_007e: 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_00a3: 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_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (networkManager == null || !networkManager.IsListening)
			{
				return;
			}
			if ((int)base.__rpc_exec_stage != 1 && (networkManager.IsClient || networkManager.IsHost))
			{
				ServerRpcParams val2 = default(ServerRpcParams);
				FastBufferWriter val = ((NetworkBehaviour)this).__beginSendServerRpc(2645559627u, val2, (RpcDelivery)0);
				((FastBufferWriter)(ref val)).WriteValueSafe(ref position);
				BytePacker.WriteValueBitPacked(val, markerType);
				BytePacker.WriteValueBitPacked(val, createdBy);
				((NetworkBehaviour)this).__endSendServerRpc(ref val, 2645559627u, val2, (RpcDelivery)0);
			}
			if ((int)base.__rpc_exec_stage == 1 && (networkManager.IsServer || networkManager.IsHost))
			{
				base.__rpc_exec_stage = (__RpcExecStage)0;
				if (((NetworkBehaviour)this).IsServer && ((NetworkBehaviour)this).IsSpawned)
				{
					TacticalMarker tacticalMarker = new TacticalMarker
					{
						Id = nextMarkerId++,
						Position = position,
						MarkerType = markerType,
						CreatedBy = createdBy
					};
					NetworkTime serverTime = NetworkManager.Singleton.ServerTime;
					tacticalMarker.Timestamp = (float)((NetworkTime)(ref serverTime)).Time;
					TacticalMarker tacticalMarker2 = tacticalMarker;
					Markers.Add(tacticalMarker2);
				}
			}
		}

		protected override void __initializeVariables()
		{
			if (Markers == null)
			{
				throw new Exception("OpsNetworkManager.Markers cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)Markers).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)Markers, "Markers");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)Markers);
			if (OpsUnlocked == null)
			{
				throw new Exception("OpsNetworkManager.OpsUnlocked cannot be null. All NetworkVariableBase instances must be initialized.");
			}
			((NetworkVariableBase)OpsUnlocked).Initialize((NetworkBehaviour)(object)this);
			((NetworkBehaviour)this).__nameNetworkVariable((NetworkVariableBase)(object)OpsUnlocked, "OpsUnlocked");
			base.NetworkVariableFields.Add((NetworkVariableBase)(object)OpsUnlocked);
			((NetworkBehaviour)this).__initializeVariables();
		}

		protected override void __initializeRpcs()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			((NetworkBehaviour)this).__registerRpc(1489470067u, new RpcReceiveHandler(__rpc_handler_1489470067), "RequestUnlockServerRpc");
			((NetworkBehaviour)this).__registerRpc(2645559627u, new RpcReceiveHandler(__rpc_handler_2645559627), "AddMarkerServerRpc");
			((NetworkBehaviour)this).__initializeRpcs();
		}

		private static void __rpc_handler_1489470067(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0023: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				ServerRpcParams server = rpcParams.Server;
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((OpsNetworkManager)(object)target).RequestUnlockServerRpc(server);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		private static void __rpc_handler_2645559627(NetworkBehaviour target, FastBufferReader reader, __RpcParams rpcParams)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = target.NetworkManager;
			if (networkManager != null && networkManager.IsListening)
			{
				Vector3 position = default(Vector3);
				((FastBufferReader)(ref reader)).ReadValueSafe(ref position);
				int markerType = default(int);
				ByteUnpacker.ReadValueBitPacked(reader, ref markerType);
				ulong createdBy = default(ulong);
				ByteUnpacker.ReadValueBitPacked(reader, ref createdBy);
				target.__rpc_exec_stage = (__RpcExecStage)1;
				((OpsNetworkManager)(object)target).AddMarkerServerRpc(position, markerType, createdBy);
				target.__rpc_exec_stage = (__RpcExecStage)0;
			}
		}

		protected internal override string __getTypeName()
		{
			return "OpsNetworkManager";
		}
	}
}
namespace OpsCoordinator.Behaviours
{
	public class OpsCoordinatorBehaviour : MonoBehaviour
	{
		private bool prevF6Down = false;

		private bool prevGDown = false;

		private bool prevHDown = false;

		private bool prevJDown = false;

		private void Update()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ConfigEntry<KeyboardShortcut> toggleLedgerKey = OpsMapSettings.ToggleLedgerKey;
				int num;
				KeyboardShortcut value;
				if (toggleLedgerKey == null)
				{
					num = 0;
				}
				else
				{
					value = toggleLedgerKey.Value;
					num = (((KeyboardShortcut)(ref value)).IsDown() ? 1 : 0);
				}
				bool flag = (byte)num != 0;
				if (flag && !prevF6Down)
				{
					if (!IsOpsUnlocked())
					{
						Debug.Log((object)"[OpsCoordinator] Ledger is locked - purchase the Ops Coordinator upgrade at the terminal first.");
					}
					else if ((Object)(object)OpsUIBehaviour.Instance != (Object)null)
					{
						OpsUIBehaviour.Instance.ToggleLedger();
					}
					else
					{
						Debug.LogError((object)"[OpsCoordinator] OpsUIBehaviour.Instance is null - ledger UI was never created (check LedgerEnabled config).");
					}
				}
				prevF6Down = flag;
				ConfigEntry<KeyboardShortcut> lootPingKey = OpsMapSettings.LootPingKey;
				int num2;
				if (lootPingKey == null)
				{
					num2 = 0;
				}
				else
				{
					value = lootPingKey.Value;
					num2 = (((KeyboardShortcut)(ref value)).IsDown() ? 1 : 0);
				}
				bool flag2 = (byte)num2 != 0;
				if (flag2 && !prevGDown && IsOpsUnlocked())
				{
					TrySendPing(0);
				}
				prevGDown = flag2;
				ConfigEntry<KeyboardShortcut> threatPingKey = OpsMapSettings.ThreatPingKey;
				int num3;
				if (threatPingKey == null)
				{
					num3 = 0;
				}
				else
				{
					value = threatPingKey.Value;
					num3 = (((KeyboardShortcut)(ref value)).IsDown() ? 1 : 0);
				}
				bool flag3 = (byte)num3 != 0;
				if (flag3 && !prevHDown && IsOpsUnlocked())
				{
					TrySendPing(1);
				}
				prevHDown = flag3;
				ConfigEntry<KeyboardShortcut> extractPingKey = OpsMapSettings.ExtractPingKey;
				int num4;
				if (extractPingKey == null)
				{
					num4 = 0;
				}
				else
				{
					value = extractPingKey.Value;
					num4 = (((KeyboardShortcut)(ref value)).IsDown() ? 1 : 0);
				}
				bool flag4 = (byte)num4 != 0;
				if (flag4 && !prevJDown && IsOpsUnlocked())
				{
					TrySendPing(2);
				}
				prevJDown = flag4;
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"[OpsCoordinator] Exception in Update(): {arg}");
			}
		}

		private static bool IsOpsUnlocked()
		{
			return (Object)(object)OpsNetworkManager.Instance != (Object)null && OpsNetworkManager.Instance.OpsUnlocked.Value;
		}

		private void TrySendPing(int markerType)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			if (!((Object)(object)val == (Object)null))
			{
				if ((Object)(object)OpsNetworkManager.Instance == (Object)null)
				{
					Debug.LogError((object)"[OpsCoordinator] TrySendPing: OpsNetworkManager.Instance is null");
					return;
				}
				Transform transform = ((Component)val.gameplayCamera).transform;
				RaycastHit val3 = default(RaycastHit);
				Vector3 val2 = (Physics.Raycast(transform.position, transform.forward, ref val3, 15f) ? ((RaycastHit)(ref val3)).point : (transform.position + transform.forward * 5f));
				OpsNetworkManager.Instance.AddMarkerServerRpc(val2, markerType, val.playerClientId);
				Debug.Log((object)$"[OpsCoordinator] Sent marker type {markerType} at {val2}");
			}
		}
	}
	public class OpsMapCameraBehaviour : MonoBehaviour
	{
		[Header("Camera Settings - Outdoors")]
		public float cameraHeight = 120f;

		public float initialOrthographicSize = 36f;

		[Header("Camera Settings - Indoors")]
		public float indoorCameraHeight = 10f;

		public float indoorOrthographicSize = 11f;

		public float orthographicSizeMin = 6f;

		public float orthographicSizeMax = 120f;

		public LayerMask cullingMask = LayerMask.op_Implicit(-1);

		[Header("Render Texture")]
		public int textureWidth = 512;

		public int textureHeight = 512;

		public int textureDepth = 24;

		[Header("UI References")]
		public RawImage mapDisplayImage;

		private Camera mapCamera;

		private RenderTexture mapRenderTexture;

		private GameObject cameraPivot;

		private bool cameraInitialized = false;

		private float currentHeight;

		private bool wasIndoors;

		private bool indoorStateKnown = false;

		private bool transitioning = false;

		private float transitionTargetHeight;

		private float transitionTargetOrthoSize;

		private const float FarClipMargin = 100f;

		private readonly List<Renderer> iconRenderers = new List<Renderer>();

		private readonly List<Renderer> hiddenThisRender = new List<Renderer>();

		private float iconRefreshTimer = 0f;

		private const float IconRefreshInterval = 1f;

		private int radarLayer = -1;

		private bool warnedNoRadarLayer = false;

		private static readonly List<Renderer> sTempRenderers = new List<Renderer>();

		public bool IsInitialized => cameraInitialized;

		private float OutdoorHeight => OpsMapSettings.OutdoorCameraHeight?.Value ?? cameraHeight;

		private float IndoorHeight => OpsMapSettings.IndoorCameraHeight?.Value ?? indoorCameraHeight;

		private bool HideVanillaIcons => !(OpsMapSettings.ShowVanillaRadarIcons?.Value ?? false);

		private void OnEnable()
		{
			if (!cameraInitialized)
			{
				InitializeCamera();
			}
			if ((Object)(object)cameraPivot != (Object)null)
			{
				cameraPivot.SetActive(true);
			}
			RefreshIconCache();
			LogCameraStatus();
		}

		private void OnDisable()
		{
			if ((Object)(object)cameraPivot != (Object)null)
			{
				cameraPivot.SetActive(false);
			}
		}

		private void InitializeCamera()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_004d: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			radarLayer = LayerMask.NameToLayer("MapRadar");
			cameraPivot = new GameObject("OpsMapCameraPivot");
			cameraPivot.transform.SetParent(((Component)this).transform, false);
			mapRenderTexture = new RenderTexture(textureWidth, textureHeight, textureDepth, (RenderTextureFormat)7)
			{
				name = "OpsMapRenderTexture",
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)1
			};
			mapRenderTexture.Create();
			GameObject val = new GameObject("OpsMapCamera");
			val.transform.SetParent(cameraPivot.transform, false);
			mapCamera = val.AddComponent<Camera>();
			mapCamera.orthographic = true;
			mapCamera.orthographicSize = initialOrthographicSize;
			mapCamera.targetTexture = mapRenderTexture;
			mapCamera.clearFlags = (CameraClearFlags)2;
			mapCamera.backgroundColor = new Color(0.012f, 0.035f, 0.022f, 1f);
			mapCamera.nearClipPlane = 0.05f;
			mapCamera.farClipPlane = OutdoorHeight + 100f;
			Camera val2 = StartOfRound.Instance?.mapScreen?.mapCamera;
			if ((Object)(object)val2 == (Object)null)
			{
				val2 = Camera.main;
			}
			if ((Object)(object)val2 != (Object)null)
			{
				mapCamera.cullingMask = val2.cullingMask;
				HDAdditionalCameraData component = ((Component)val2).GetComponent<HDAdditionalCameraData>();
				if ((Object)(object)component != (Object)null)
				{
					HDAdditionalCameraData val3 = val.AddComponent<HDAdditionalCameraData>();
					val3.volumeLayerMask = component.volumeLayerMask;
					val3.probeLayerMask = component.probeLayerMask;
					val3.clearColorMode = component.clearColorMode;
					val3.backgroundColorHDR = mapCamera.backgroundColor;
					val3.antialiasing = component.antialiasing;
					val3.customRenderingSettings = component.customRenderingSettings;
					val3.renderingPathCustomFrameSettings = component.renderingPathCustomFrameSettings;
					val3.renderingPathCustomFrameSettingsOverrideMask = component.renderingPathCustomFrameSettingsOverrideMask;
					Debug.Log((object)"[OpsCoordinator][Camera] Copied HDRP camera data from the game's map camera.");
				}
				else
				{
					Debug.LogWarning((object)"[OpsCoordinator][Camera] Reference camera had no HDAdditionalCameraData; adding a default one so HDRP doesn't leave the camera unconfigured.");
					val.AddComponent<HDAdditionalCameraData>();
				}
			}
			else
			{
				Debug.LogWarning((object)"[OpsCoordinator][Camera] No reference camera found for culling mask / HDRP data.");
				val.AddComponent<HDAdditionalCameraData>();
			}
			RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering;
			RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
			mapCamera.pixelRect = new Rect(0f, 0f, (float)((Texture)mapRenderTexture).width, (float)((Texture)mapRenderTexture).height);
			((Behaviour)mapCamera).enabled = true;
			if ((Object)(object)mapDisplayImage != (Object)null)
			{
				mapDisplayImage.texture = (Texture)(object)mapRenderTexture;
				ApplyGreenMaterial(mapDisplayImage);
			}
			currentHeight = OutdoorHeight;
			cameraInitialized = true;
			Debug.Log((object)"[OpsCoordinator][Camera] Tactical camera initialized.");
		}

		private void RefreshIconCache()
		{
			iconRenderers.Clear();
			GrabbableObject[] array = Object.FindObjectsByType<GrabbableObject>((FindObjectsSortMode)0);
			foreach (GrabbableObject val in array)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val.radarIcon == (Object)null))
				{
					((Component)val.radarIcon).GetComponentsInChildren<Renderer>(true, sTempRenderers);
					iconRenderers.AddRange(sTempRenderers);
				}
			}
			if (radarLayer < 0)
			{
				if (!warnedNoRadarLayer)
				{
					Debug.LogWarning((object)"[OpsCoordinator][Camera] 'MapRadar' layer not found; enemy/player map dots cannot be identified.");
					warnedNoRadarLayer = true;
				}
				return;
			}
			if ((Object)(object)RoundManager.Instance != (Object)null)
			{
				foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies)
				{
					if (!((Object)(object)spawnedEnemy == (Object)null))
					{
						AddRadarLayerRenderers(((Component)spawnedEnemy).transform);
					}
				}
			}
			if (!((Object)(object)StartOfRound.Instance != (Object)null))
			{
				return;
			}
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val2 in allPlayerScripts)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					AddRadarLayerRenderers(((Component)val2).transform);
				}
			}
		}

		private void AddRadarLayerRenderers(Transform root)
		{
			((Component)root).GetComponentsInChildren<Renderer>(true, sTempRenderers);
			foreach (Renderer sTempRenderer in sTempRenderers)
			{
				if ((Object)(object)sTempRenderer != (Object)null && ((Component)sTempRenderer).gameObject.layer == radarLayer)
				{
					iconRenderers.Add(sTempRenderer);
				}
			}
		}

		private void OnBeginCameraRendering(ScriptableRenderContext context, Camera cam)
		{
			if ((Object)(object)cam != (Object)(object)mapCamera || !HideVanillaIcons)
			{
				return;
			}
			hiddenThisRender.Clear();
			foreach (Renderer iconRenderer in iconRenderers)
			{
				if ((Object)(object)iconRenderer != (Object)null && iconRenderer.enabled)
				{
					iconRenderer.enabled = false;
					hiddenThisRender.Add(iconRenderer);
				}
			}
		}

		private void OnEndCameraRendering(ScriptableRenderContext context, Camera cam)
		{
			if ((Object)(object)cam != (Object)(object)mapCamera)
			{
				return;
			}
			foreach (Renderer item in hiddenThisRender)
			{
				if ((Object)(object)item != (Object)null)
				{
					item.enabled = true;
				}
			}
			hiddenThisRender.Clear();
		}

		private void ApplyGreenMaterial(RawImage rawImage)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0026: 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)
			Material val = new Material(Shader.Find("Sprites/Default"));
			val.color = new Color(0.7f, 1f, 0.75f, 0.98f);
			((Graphic)rawImage).material = val;
			((Graphic)rawImage).color = new Color(0.85f, 1f, 0.9f, 1f);
		}

		private void Update()
		{
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			if (!cameraInitialized || (Object)(object)mapCamera == (Object)null)
			{
				return;
			}
			if (HideVanillaIcons)
			{
				iconRefreshTimer -= Time.deltaTime;
				if (iconRefreshTimer <= 0f)
				{
					iconRefreshTimer = 1f;
					RefreshIconCache();
				}
			}
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			bool isInsideFactory = val.isInsideFactory;
			if (!indoorStateKnown || isInsideFactory != wasIndoors)
			{
				transitionTargetHeight = (isInsideFactory ? IndoorHeight : OutdoorHeight);
				transitionTargetOrthoSize = (isInsideFactory ? indoorOrthographicSize : initialOrthographicSize);
				transitioning = true;
				wasIndoors = isInsideFactory;
				indoorStateKnown = true;
			}
			if (transitioning)
			{
				currentHeight = Mathf.Lerp(currentHeight, transitionTargetHeight, Time.deltaTime * 6f);
				mapCamera.orthographicSize = Mathf.Lerp(mapCamera.orthographicSize, transitionTargetOrthoSize, Time.deltaTime * 6f);
				if (Mathf.Abs(currentHeight - transitionTargetHeight) < 0.1f && Mathf.Abs(mapCamera.orthographicSize - transitionTargetOrthoSize) < 0.1f)
				{
					currentHeight = transitionTargetHeight;
					mapCamera.orthographicSize = transitionTargetOrthoSize;
					transitioning = false;
				}
			}
			Vector3 position = ((Component)val).transform.position + Vector3.up * currentHeight;
			cameraPivot.transform.position = position;
			cameraPivot.transform.rotation = Quaternion.Euler(90f, 0f, 0f);
			mapCamera.farClipPlane = currentHeight + 100f;
		}

		public void SetZoom(float newSize)
		{
			mapCamera.orthographicSize = Mathf.Clamp(newSize, orthographicSizeMin, orthographicSizeMax);
		}

		public float GetZoom()
		{
			Camera obj = mapCamera;
			return (obj != null) ? obj.orthographicSize : initialOrthographicSize;
		}

		public Vector2 WorldToMapLocalPosition(Vector3 worldPos, RectTransform mapRect)
		{
			//IL_003c: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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)
			//IL_0071: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//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_0099: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mapCamera == (Object)null || (Object)(object)mapRenderTexture == (Object)null || (Object)(object)mapRect == (Object)null)
			{
				return Vector2.zero;
			}
			Vector3 val = mapCamera.WorldToScreenPoint(worldPos);
			float num = val.x / (float)((Texture)mapRenderTexture).width;
			float num2 = val.y / (float)((Texture)mapRenderTexture).height;
			Rect rect = mapRect.rect;
			return new Vector2((num - 0.5f) * ((Rect)(ref rect)).width, (num2 - 0.5f) * ((Rect)(ref rect)).height);
		}

		public Vector3 MapLocalToWorld(Vector2 localPos, RectTransform mapRect, float groundY = 0f)
		{
			//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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mapCamera == (Object)null || (Object)(object)mapRenderTexture == (Object)null || (Object)(object)mapRect == (Object)null)
			{
				return Vector3.zero;
			}
			Rect rect = mapRect.rect;
			float num = localPos.x / ((Rect)(ref rect)).width + 0.5f;
			float num2 = localPos.y / ((Rect)(ref rect)).height + 0.5f;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(num * (float)((Texture)mapRenderTexture).width, num2 * (float)((Texture)mapRenderTexture).height, currentHeight);
			Vector3 val2 = mapCamera.ScreenToWorldPoint(val);
			Ray val3 = default(Ray);
			((Ray)(ref val3))..ctor(val2, Vector3.down);
			RaycastHit val4 = default(RaycastHit);
			return (Vector3)(Physics.Raycast(val3, ref val4, currentHeight * 2f) ? ((RaycastHit)(ref val4)).point : new Vector3(val2.x, groundY, val2.z));
		}

		private void OnDestroy()
		{
			RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering;
			RenderPipelineManager.endCameraRendering -= OnEndCameraRendering;
			if ((Object)(object)mapRenderTexture != (Object)null)
			{
				mapRenderTexture.Release();
				Object.Destroy((Object)(object)mapRenderTexture);
			}
		}

		private void LogCameraStatus()
		{
			Debug.Log((object)$"[OpsCoordinator][Camera] Ready | Size: {GetZoom()} | Height: {currentHeight}");
		}
	}
	public static class OpsMapIcons
	{
		private static Sprite cachedCircleSprite;

		private static Sprite cachedConeSprite;

		public static Sprite CircleSprite => ((Object)(object)cachedCircleSprite != (Object)null) ? cachedCircleSprite : (cachedCircleSprite = MakeCircleSprite());

		public static Sprite ConeSprite => ((Object)(object)cachedConeSprite != (Object)null) ? cachedConeSprite : (cachedConeSprite = MakeConeSprite());

		private static Sprite MakeCircleSprite(int size = 64)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(size, size, (TextureFormat)4, false);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor((float)size / 2f, (float)size / 2f);
			float num = (float)size / 2f - 1.5f;
			Color[] array = (Color[])(object)new Color[size * size];
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num2 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), val2);
					float num3 = 1f;
					if (num2 > num)
					{
						num3 = Mathf.Clamp01(1f - (num2 - num) / 1.5f);
					}
					array[i * size + j] = new Color(1f, 1f, 1f, num3);
				}
			}
			val.SetPixels(array);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, (float)size, (float)size), new Vector2(0.5f, 0.5f));
		}

		private static Sprite MakeConeSprite(int width = 64, int height = 128)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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)
			Texture2D val = new Texture2D(width, height, (TextureFormat)4, false);
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < height; i++)
			{
				float num = (float)i / (float)(height - 1);
				float num2 = (float)width / 2f * num;
				for (int j = 0; j < width; j++)
				{
					float num3 = Mathf.Abs((float)j + 0.5f - (float)width / 2f);
					float num4 = 0f;
					if (num3 <= num2)
					{
						num4 = Mathf.Lerp(0.9f, 0.1f, num);
						float num5 = num2 - num3;
						if (num5 < 1.5f)
						{
							num4 *= Mathf.Clamp01(num5 / 1.5f);
						}
					}
					array[i * width + j] = new Color(1f, 1f, 1f, num4);
				}
			}
			val.SetPixels(array);
			val.Apply();
			return Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0f));
		}
	}
	public class OpsMapInputBehaviour : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IScrollHandler, IDragHandler
	{
		public RectTransform mapRect;

		public OpsMapCameraBehaviour cameraBehaviour;

		private float zoom = 1f;

		private float zoomMin = 0.5f;

		private float zoomMax = 2.5f;

		private Vector2 panOffset = Vector2.zero;

		private void Start()
		{
			if ((Object)(object)mapRect == (Object)null)
			{
				Debug.LogWarning((object)"[OpsCoordinator] OpsMapInputBehaviour missing mapRect reference.");
			}
		}

		public void OnPointerClick(PointerEventData eventData)
		{
			//IL_004a: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_00b7: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Invalid comparison between Unknown and I4
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Invalid comparison between Unknown and I4
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Invalid comparison between Unknown and I4
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)mapRect == (Object)null)
			{
				return;
			}
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			ulong playerClientId = val.playerClientId;
			Vector2 val2 = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle(mapRect, eventData.position, eventData.pressEventCamera, ref val2);
			Vector2 val3 = (val2 - panOffset) / zoom;
			Vector3 position = default(Vector3);
			if ((Object)(object)cameraBehaviour != (Object)null && cameraBehaviour.IsInitialized)
			{
				position = cameraBehaviour.MapLocalToWorld(val3, mapRect);
			}
			else
			{
				((Vector3)(ref position))..ctor(val3.x * 3f, 0f, val3.y * 3f);
			}
			if ((Object)(object)OpsNetworkManager.Instance != (Object)null)
			{
				if ((int)eventData.button == 0)
				{
					OpsNetworkManager.Instance.AddMarkerServerRpc(position, 0, playerClientId);
				}
				else if ((int)eventData.button == 1)
				{
					OpsNetworkManager.Instance.AddMarkerServerRpc(position, 1, playerClientId);
				}
				else if ((int)eventData.button == 2)
				{
					OpsNetworkManager.Instance.AddMarkerServerRpc(position, 2, playerClientId);
				}
			}
		}

		public void OnScroll(PointerEventData eventData)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)cameraBehaviour != (Object)null && cameraBehaviour.IsInitialized)
			{
				float num = cameraBehaviour.GetZoom();
				float num2 = (0f - eventData.scrollDelta.y) * 5f;
				cameraBehaviour.SetZoom(num + num2);
				return;
			}
			zoom += eventData.scrollDelta.y * 0.1f;
			zoom = Mathf.Clamp(zoom, zoomMin, zoomMax);
			if ((Object)(object)mapRect != (Object)null)
			{
				((Transform)mapRect).localScale = new Vector3(zoom, zoom, 1f);
			}
		}

		public void OnDrag(PointerEventData eventData)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0037: 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)
			if (!((Object)(object)mapRect == (Object)null))
			{
				panOffset += eventData.delta;
				RectTransform obj = mapRect;
				obj.anchoredPosition += eventData.delta;
			}
		}
	}
	public class OpsMapLineBehaviour : MonoBehaviour
	{
		public RectTransform mapRect;

		public OpsMapCameraBehaviour cameraBehaviour;

		private readonly List<LineRenderer> activeLines = new List<LineRenderer>();

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

		private static Sprite cachedMarkerSprite;

		private void Awake()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)cachedMarkerSprite == (Object)null)
			{
				cachedMarkerSprite = Sprite.Create(Texture2D.whiteTexture, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f));
			}
		}

		private void Update()
		{
			if (!((Object)(object)mapRect == (Object)null) && !((Object)(object)cameraBehaviour == (Object)null) && cameraBehaviour.IsInitialized && !((Object)(object)GameNetworkManager.Instance == (Object)null))
			{
				ClearGraphics();
				DrawPlayerMarker();
				DrawSquadLines();
				DrawMarkerLines();
			}
		}

		private void ClearGraphics()
		{
			foreach (LineRenderer activeLine in activeLines)
			{
				Object.Destroy((Object)(object)((Component)activeLine).gameObject);
			}
			activeLines.Clear();
			foreach (GameObject activeMarkerDot in activeMarkerDots)
			{
				Object.Destroy((Object)(object)activeMarkerDot);
			}
			activeMarkerDots.Clear();
		}

		private void DrawPlayerMarker()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_006b: 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_0089: 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_00d2: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: 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)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if (!((Object)(object)localPlayerController == (Object)null))
			{
				Vector2 anchoredPosition = cameraBehaviour.WorldToMapLocalPosition(((Component)localPlayerController).transform.position, mapRect);
				GameObject val = new GameObject("PlayerMarker");
				val.transform.SetParent((Transform)(object)mapRect, false);
				RectTransform val2 = val.AddComponent<RectTransform>();
				val2.sizeDelta = new Vector2(60f, 60f);
				val2.anchoredPosition = anchoredPosition;
				val2.pivot = new Vector2(0.5f, 0.5f);
				CreateVisionCone(val.transform);
				CreateCircleDot(val.transform, new Color(1f, 1f, 1f, 0.9f), 15f);
				Vector3 forward = ((Component)localPlayerController).transform.forward;
				float num = Mathf.Atan2(forward.x, forward.z) * 57.29578f;
				((Transform)val2).localRotation = Quaternion.Euler(0f, 0f, 0f - num);
			}
		}

		private void CreateVisionCone(Transform parent)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002c: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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)
			GameObject val = new GameObject("FacingCone");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.pivot = new Vector2(0.5f, 0f);
			val2.anchorMin = new Vector2(0.5f, 0.5f);
			val2.anchorMax = new Vector2(0.5f, 0.5f);
			val2.anchoredPosition = Vector2.zero;
			val2.sizeDelta = new Vector2(28f, 38f);
			Image val3 = val.AddComponent<Image>();
			val3.sprite = OpsMapIcons.ConeSprite;
			((Graphic)val3).color = new Color(1f, 1f, 1f, 0.45f);
			((Graphic)val3).raycastTarget = false;
			activeMarkerDots.Add(val);
		}

		private void CreateCircleDot(Transform parent, Color color, float size)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("PlayerDot");
			val.transform.SetParent(parent, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = new Vector2(size, size);
			Image val3 = val.AddComponent<Image>();
			val3.sprite = OpsMapIcons.CircleSprite;
			((Graphic)val3).color = color;
			((Graphic)val3).raycastTarget = false;
			activeMarkerDots.Add(val);
		}

		private void DrawSquadLines()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_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_00a9: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: 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_00bd: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null)
			{
				return;
			}
			Vector2 a = cameraBehaviour.WorldToMapLocalPosition(((Component)localPlayerController).transform.position, mapRect);
			PlayerControllerB[] allPlayerScripts = StartOfRound.Instance.allPlayerScripts;
			foreach (PlayerControllerB val in allPlayerScripts)
			{
				if (!((Object)(object)val == (Object)null) && val.isPlayerControlled && !((Object)(object)val == (Object)(object)localPlayerController))
				{
					Vector2 val2 = cameraBehaviour.WorldToMapLocalPosition(((Component)val).transform.position, mapRect);
					Color val3 = (val.isInsideFactory ? Color.green : Color.red);
					CreateLine(a, val2, val3);
					CreateTeammateDot(val2, new Color(val3.r, val3.g, val3.b, 0.8f));
				}
			}
		}

		private void DrawMarkerLines()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00da: 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_00dd: 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)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB localPlayerController = GameNetworkManager.Instance.localPlayerController;
			if ((Object)(object)localPlayerController == (Object)null || OpsNetworkManager.Instance?.Markers == null)
			{
				return;
			}
			Vector2 a = cameraBehaviour.WorldToMapLocalPosition(((Component)localPlayerController).transform.position, mapRect);
			foreach (TacticalMarker marker in OpsNetworkManager.Instance.Markers)
			{
				Vector2 val = cameraBehaviour.WorldToMapLocalPosition(marker.Position, mapRect);
				int markerType = marker.MarkerType;
				if (1 == 0)
				{
				}
				Color val2 = (Color)(markerType switch
				{
					0 => Color.yellow, 
					1 => Color.magenta, 
					2 => Color.cyan, 
					_ => Color.white, 
				});
				if (1 == 0)
				{
				}
				Color val3 = val2;
				CreateLine(a, val, val3);
				CreateMarkerDot(val, val3);
			}
		}

		private void CreateLine(Vector2 a, Vector2 b, Color c)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_003d: 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_0076: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("OpsMapLine");
			val.transform.SetParent((Transform)(object)mapRect, false);
			LineRenderer val2 = val.AddComponent<LineRenderer>();
			((Renderer)val2).material = new Material(Shader.Find("Sprites/Default"));
			val2.startColor = c;
			val2.endColor = c;
			val2.startWidth = 2f;
			val2.endWidth = 2f;
			val2.positionCount = 2;
			val2.useWorldSpace = false;
			val2.SetPosition(0, new Vector3(a.x, a.y, 0f));
			val2.SetPosition(1, new Vector3(b.x, b.y, 0f));
			activeLines.Add(val2);
		}

		private void CreateTeammateDot(Vector2 pos, Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0031: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("TeammateDot");
			val.transform.SetParent((Transform)(object)mapRect, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = new Vector2(12f, 12f);
			val2.anchoredPosition = pos;
			Image val3 = val.AddComponent<Image>();
			val3.sprite = OpsMapIcons.CircleSprite;
			((Graphic)val3).color = color;
			((Graphic)val3).raycastTarget = false;
			activeMarkerDots.Add(val);
		}

		private void CreateMarkerDot(Vector2 pos, Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0031: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("MarkerDot");
			val.transform.SetParent((Transform)(object)mapRect, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = new Vector2(10f, 10f);
			val2.anchoredPosition = pos;
			Image val3 = val.AddComponent<Image>();
			val3.sprite = cachedMarkerSprite;
			((Graphic)val3).color = color;
			((Graphic)val3).raycastTarget = false;
			activeMarkerDots.Add(val);
		}
	}
	public class OpsMapOverlay : MonoBehaviour
	{
		private RawImage overlayImage;

		private Material overlayMaterial;

		public void Setup(RawImage targetDisplay)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00be: Expected O, but got Unknown
			if (!((Object)(object)targetDisplay == (Object)null))
			{
				GameObject val = new GameObject("OpsMapOverlay");
				val.transform.SetParent(((Component)targetDisplay).transform.parent, false);
				RectTransform val2 = val.AddComponent<RectTransform>();
				val2.anchorMin = Vector2.zero;
				val2.anchorMax = Vector2.one;
				val2.offsetMin = Vector2.zero;
				val2.offsetMax = Vector2.zero;
				overlayImage = val.AddComponent<RawImage>();
				((Graphic)overlayImage).color = new Color(1f, 1f, 1f, 0.05f);
				((Graphic)overlayImage).raycastTarget = false;
				overlayMaterial = new Material(Shader.Find("Sprites/Default"));
				((Graphic)overlayImage).material = overlayMaterial;
				UpdateOverlayMaterial();
			}
		}

		private void UpdateOverlayMaterial()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)overlayMaterial == (Object)null))
			{
				overlayMaterial.SetFloat("_ScanlineDensity", 80f);
				overlayMaterial.SetFloat("_ScanlineIntensity", 0.18f);
				overlayMaterial.SetFloat("_ScanlineSpeed", 0.8f);
				overlayMaterial.SetFloat("_GridThickness", 1.2f);
				overlayMaterial.SetColor("_GridColor", new Color(0.1f, 0.6f, 0.3f, 0.25f));
				overlayMaterial.EnableKeyword("_SCANLINES_ON");
				overlayMaterial.EnableKeyword("_GRID_ON");