Decompiled source of CommandMod v0.0.80

CommandMod.dll

Decompiled 3 months 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.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using DM;
using FhpSLib.BundleModCore;
using HarmonyLib;
using InControl;
using Landfall.TABS;
using Landfall.TABS.AI;
using Landfall.TABS.AI.Components;
using Landfall.TABS.AI.Components.Modifiers;
using Landfall.TABS.AI.Components.Tags;
using Landfall.TABS.GameState;
using Landfall.TABS_Input;
using SLMA;
using TFBGames;
using Unity.Entities;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Custom")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("made in SFT by FhpSlime")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3a45c3cf-230c-4310-952f-0887d4266a22")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace zhihui
{
	public static class UManager
	{
		public static string modname;

		public static string modder;

		private static string com;

		public static SLMABundleMod bundleMod;

		public static SLMABundleMod bundleMod1;

		static UManager()
		{
			modname = "SFT";
			modder = "FhpSlime";
		}

		public static void SetRiders(UnitBlueprint me, UnitBlueprint[] riders)
		{
			s.SetField<UnitBlueprint>(me, "Riders", (object)riders);
		}

		public static void EditBlueprint(UnitBlueprint unit, LandfallContentDatabase db)
		{
		}

		public static void EditClothes(GameObject cloth, CharacterItem item, PropItemData data, Unit unit, int index, LandfallContentDatabase db)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			Debug.Log((object)"Hey");
			if (unit.unitBlueprint.Entity.Name == "unit name")
			{
				Renderer[] componentsInChildren = cloth.GetComponentsInChildren<Renderer>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].materials = (Material[])(object)new Material[1] { (Material)SLMALoader.SDic["materials"]["Glow_Neon_Green_143734"] };
				}
			}
		}

		public static void EditProjectiles(GameObject proj, ProjectileHit projhit, Unit unit, LandfallContentDatabase db)
		{
		}

		public static void EditCombatMoves(GameObject move, int index, Unit unit, LandfallContentDatabase db)
		{
			//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_006b: 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_0081: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_0126: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: 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_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Expected O, but got Unknown
			if (unit.unitBlueprint.Entity.Name == "666" && Object.op_Implicit((Object)(object)move.GetComponentInChildren<DodgeMove>()) && index == 2)
			{
				move.GetComponentInChildren<DodgeMove>().moves[0].forceCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[5]
				{
					new Keyframe(0f, 0f),
					new Keyframe(1f, 1f),
					new Keyframe(2f, 1f),
					new Keyframe(0f, 0f),
					new Keyframe(0f, 0f)
				});
				move.GetComponentInChildren<DodgeMove>().forceMultiplier = -1f;
			}
			if (unit.unitBlueprint.Entity.Name == "666" && Object.op_Implicit((Object)(object)move.GetComponentInChildren<DodgeMove>()) && index == 3)
			{
				move.GetComponentInChildren<DodgeMove>().moves[0].forceCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[5]
				{
					new Keyframe(-1f, 1f),
					new Keyframe(1f, 1f),
					new Keyframe(5f, 4f),
					new Keyframe(0f, 0f),
					new Keyframe(0f, 0f)
				});
				move.GetComponentInChildren<DodgeMove>().forceMultiplier = -2f;
			}
			if (unit.unitBlueprint.Entity.Name == "666" && Object.op_Implicit((Object)(object)move.GetComponentInChildren<DodgeMove>()) && index == 4)
			{
				move.GetComponentInChildren<DodgeMove>().moves[0].forceCurve = new AnimationCurve((Keyframe[])(object)new Keyframe[5]
				{
					new Keyframe(-1f, 1f),
					new Keyframe(1f, 1f),
					new Keyframe(5f, 4f),
					new Keyframe(0f, 0f),
					new Keyframe(0f, 0f)
				});
			}
		}

		public static void CodeAfterSpawn(Unit unit, LandfallContentDatabase db)
		{
			//IL_0028: 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)
			if (unit.unitBlueprint.Entity.Name == "unit name")
			{
				Transform head = unit.data.head;
				head.localScale *= 2f;
			}
		}

		public static void Init(LandfallContentDatabase db)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			com = "Bundle Mod Init";
			com = "Bundle Mod Init";
			MyModItems.GetInstance();
			new GameObject
			{
				name = "MapsCore",
				hideFlags = (HideFlags)52
			}.AddComponent<ScenesManager>();
			com = "——————————Fations and Units——————————";
			com = "——————————Clothes——————————";
			com = "——————————Weapons——————————";
			com = "——————————Effects——————————";
			com = "——————————Explosions——————————";
			com = "——————————UnitBases——————————";
			com = "——————————Projectiles——————————";
			com = "——————————Moves——————————";
		}

		public static void EditWeapons(GameObject weapon, Team team, Unit unit, MeleeWeapon melee, RangeWeapon range, LandfallContentDatabase db)
		{
		}

		public static void SetMoveConditionalValue(this ConditionalEventInstance gameObject, ConditionType type, ValueType valuet, float value)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			bool flag = false;
			EventCondition[] conditions = gameObject.conditions;
			foreach (EventCondition val in conditions)
			{
				if (val.conditionType == type)
				{
					val.valueType = valuet;
					val.value = value;
					flag = true;
				}
			}
			if (!flag)
			{
				List<EventCondition> list = gameObject.conditions.ToList();
				list.Add(new EventCondition
				{
					conditionType = type,
					valueType = valuet,
					value = value
				});
				gameObject.conditions = list.ToArray();
			}
		}
	}
	[BepInPlugin("zhihui", "zhihui", "1.0.0")]
	internal class Loader : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ControlOptions))]
		[HarmonyPatch("SetupControls")]
		public static class ControlOptionsPatch
		{
			[HarmonyPrefix]
			public static void Prefix(ControlOptions __instance)
			{
				try
				{
					Debug.Log((object)"[zhihui] ControlOptions SetupControls被调用");
					PlayerActions instance = PlayerActions.Instance;
					if (instance != null)
					{
						PlayerAction val = ((IEnumerable<PlayerAction>)((PlayerActionSet)instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_RED_TEAM_CONTROL"));
						PlayerAction val2 = ((IEnumerable<PlayerAction>)((PlayerActionSet)instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_BLUE_TEAM_CONTROL"));
						PlayerAction val3 = ((IEnumerable<PlayerAction>)((PlayerActionSet)instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_UNIT_MARKING"));
						PlayerAction val4 = ((IEnumerable<PlayerAction>)((PlayerActionSet)instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_SHIFT_ALTERNATE"));
						PlayerAction val5 = ((IEnumerable<PlayerAction>)((PlayerActionSet)instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_CTRL_ALTERNATE"));
						Debug.Log((object)$"[zhihui] 检查PlayerAction: 红队={val != null}, 蓝队={val2 != null}, 标记={val3 != null}, Shift={val4 != null}, Ctrl={val5 != null}");
						UnitController.SetUnitControlPlayerActions(val, val2, val3, val4, val5);
					}
				}
				catch (Exception ex)
				{
					Debug.LogWarning((object)("[zhihui] ControlOptions补丁失败: " + ex.Message));
				}
			}
		}

		[HarmonyPatch(typeof(ControlOptions))]
		[HarmonyPatch("PlayerActionSetup")]
		public static class ControlOptionsPlayerActionSetupPatch
		{
			[HarmonyPrefix]
			public static void Prefix(ControlOptions __instance, PlayerActionSet playerActions, string headerText, ref int excludeActions)
			{
				if (headerText == "Ground")
				{
					Debug.Log((object)$"[zhihui] 修改excludeActions: {excludeActions} -> 0");
					excludeActions = 0;
				}
			}
		}

		[HarmonyPatch(typeof(PlayerActions))]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public static class PlayerActionsConstructorPatch
		{
			[HarmonyPostfix]
			public static void Postfix(PlayerActions __instance)
			{
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_012e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0156: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					bool num = ((PlayerActionSet)__instance).Actions.Any((PlayerAction a) => a.Name == "INPUT_RED_TEAM_CONTROL");
					bool flag = ((PlayerActionSet)__instance).Actions.Any((PlayerAction a) => a.Name == "INPUT_BLUE_TEAM_CONTROL");
					bool flag2 = ((PlayerActionSet)__instance).Actions.Any((PlayerAction a) => a.Name == "INPUT_UNIT_MARKING");
					bool flag3 = ((PlayerActionSet)__instance).Actions.Any((PlayerAction a) => a.Name == "INPUT_SHIFT_ALTERNATE");
					bool flag4 = ((PlayerActionSet)__instance).Actions.Any((PlayerAction a) => a.Name == "INPUT_CTRL_ALTERNATE");
					if (!num)
					{
						new PlayerAction("INPUT_RED_TEAM_CONTROL", (PlayerActionSet)(object)__instance).AddDefaultBinding((Key[])(object)new Key[1] { (Key)14 });
						Debug.Log((object)"[zhihui] 创建红队控制PlayerAction");
					}
					if (!flag)
					{
						new PlayerAction("INPUT_BLUE_TEAM_CONTROL", (PlayerActionSet)(object)__instance).AddDefaultBinding((Key[])(object)new Key[1] { (Key)15 });
						Debug.Log((object)"[zhihui] 创建蓝队控制PlayerAction");
					}
					if (!flag2)
					{
						new PlayerAction("INPUT_UNIT_MARKING", (PlayerActionSet)(object)__instance).AddDefaultBinding((Key[])(object)new Key[1] { (Key)110 });
						Debug.Log((object)"[zhihui] 创建标记单位PlayerAction");
					}
					if (!flag3)
					{
						new PlayerAction("INPUT_SHIFT_ALTERNATE", (PlayerActionSet)(object)__instance).AddDefaultBinding((Key[])(object)new Key[1] { (Key)5 });
						Debug.Log((object)"[zhihui] 创建Shift键PlayerAction");
					}
					if (!flag4)
					{
						new PlayerAction("INPUT_CTRL_ALTERNATE", (PlayerActionSet)(object)__instance).AddDefaultBinding((Key[])(object)new Key[1] { (Key)8 });
						Debug.Log((object)"[zhihui] 创建Ctrl键PlayerAction");
					}
					UnitController.SetUnitControlPlayerActions(((IEnumerable<PlayerAction>)((PlayerActionSet)__instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_RED_TEAM_CONTROL")), ((IEnumerable<PlayerAction>)((PlayerActionSet)__instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_BLUE_TEAM_CONTROL")), ((IEnumerable<PlayerAction>)((PlayerActionSet)__instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_UNIT_MARKING")), ((IEnumerable<PlayerAction>)((PlayerActionSet)__instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_SHIFT_ALTERNATE")), ((IEnumerable<PlayerAction>)((PlayerActionSet)__instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_CTRL_ALTERNATE")));
					Debug.Log((object)"[zhihui] PlayerActions构造函数补丁完成");
				}
				catch (Exception ex)
				{
					Debug.LogWarning((object)("[zhihui] PlayerActions构造函数补丁失败: " + ex.Message));
				}
			}
		}

		public static bool BundleMode = true;

		public static ConfigEntry<bool> ConfigEnableLineHint;

		private void Awake()
		{
			ConfigEnableLineHint = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "EnableLineHint", true, "Whether to enable the route line prompt");
			((MonoBehaviour)this).StartCoroutine("call");
		}

		private IEnumerator call()
		{
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
			yield return (object)new WaitUntil((Func<bool>)(() => ServiceLocator.GetService<ISaveLoaderService>() != null));
			yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)ServiceLocator.GetService<GlobalSettingsHandler>() != (Object)null));
			yield return (object)new WaitForSecondsRealtime(0.3f);
			int num = (ConfigEnableLineHint.Value ? 1 : 0);
			CreateSettingGameplay(useLocalization: false, (SettingsType)0, "EnableLineHint", num, num, new string[2] { "Disabled", "Enabled" }).OnValueChanged += OnLineHintToggled;
			ApplyLineHint(ConfigEnableLineHint.Value);
			((MonoBehaviour)this).StartCoroutine(DelayedCreatePlayerActions());
			SLMALoader.GetInstance();
			LandfallContentDatabase landfallContentDatabase = ContentDatabase.Instance().LandfallContentDatabase;
			UManager.Init(landfallContentDatabase);
			new Harmony(UManager.modname).PatchAll();
			GOSLMA.EditWeapons = ((GOSLMA.EditWeapons == null) ? new Action<GameObject, Team, Unit, MeleeWeapon, RangeWeapon, LandfallContentDatabase>(UManager.EditWeapons) : ((Action<GameObject, Team, Unit, MeleeWeapon, RangeWeapon, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, Team, Unit, MeleeWeapon, RangeWeapon, LandfallContentDatabase>(UManager.EditWeapons), GOSLMA.EditWeapons)));
			GOSLMA.EditClothes = ((GOSLMA.EditClothes == null) ? new Action<GameObject, CharacterItem, PropItemData, Unit, int, LandfallContentDatabase>(UManager.EditClothes) : ((Action<GameObject, CharacterItem, PropItemData, Unit, int, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, CharacterItem, PropItemData, Unit, int, LandfallContentDatabase>(UManager.EditClothes), GOSLMA.EditClothes)));
			GOSLMA.EditCombatMoves = ((GOSLMA.EditCombatMoves == null) ? new Action<GameObject, int, Unit, LandfallContentDatabase>(UManager.EditCombatMoves) : ((Action<GameObject, int, Unit, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, int, Unit, LandfallContentDatabase>(UManager.EditCombatMoves), GOSLMA.EditCombatMoves)));
			GOSLMA.CodeAfterSpawn = ((GOSLMA.CodeAfterSpawn == null) ? new Action<Unit, LandfallContentDatabase>(UManager.CodeAfterSpawn) : ((Action<Unit, LandfallContentDatabase>)Delegate.Combine(new Action<Unit, LandfallContentDatabase>(UManager.CodeAfterSpawn), GOSLMA.CodeAfterSpawn)));
			GOSLMA.EditProjectiles = ((GOSLMA.EditProjectiles == null) ? new Action<GameObject, ProjectileHit, Unit, LandfallContentDatabase>(UManager.EditProjectiles) : ((Action<GameObject, ProjectileHit, Unit, LandfallContentDatabase>)Delegate.Combine(new Action<GameObject, ProjectileHit, Unit, LandfallContentDatabase>(UManager.EditProjectiles), GOSLMA.EditProjectiles)));
			UnitBlueprint[] array = Resources.FindObjectsOfTypeAll<UnitBlueprint>();
			for (int i = 0; i < array.Length; i++)
			{
				UManager.EditBlueprint(array[i], landfallContentDatabase);
			}
			Debug.Log((object)("Loaded " + UManager.modname + " Successfully"));
			Debug.Log((object)(UManager.modname + "is made in SFT by FhpSlime"));
			Debug.Log((object)(UManager.modder + "wished you a pleasant trip"));
		}

		private void ApplyLineHint(bool enable)
		{
			try
			{
				UnitController.SetLineHintEnabled(enable);
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[zhihui] 路线线条提示设置调用失败: " + ex.Message));
			}
		}

		public static SettingsInstance CreateSettingGameplay(bool useLocalization, SettingsType type, string key, float defaultValue, float currentValue, string[] options = null, float min = 0f, float max = 1f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_0041: 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_0050: 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_0061: Expected O, but got Unknown
			SettingsInstance val = new SettingsInstance
			{
				localizeOptions = useLocalization,
				settingsType = type,
				m_settingsKey = key,
				settingName = key,
				toolTip = key,
				options = options,
				defaultValue = (int)defaultValue,
				currentValue = (int)currentValue,
				defaultSliderValue = defaultValue,
				currentSliderValue = currentValue,
				min = min,
				max = max
			};
			GlobalSettingsHandler service = ServiceLocator.GetService<GlobalSettingsHandler>();
			List<SettingsInstance> list = service.GameplaySettings.ToList();
			list.Add(val);
			typeof(GlobalSettingsHandler).GetField("m_gameplaySettings", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(service, list.ToArray());
			return val;
		}

		private void OnLineHintToggled(int newVal)
		{
			bool flag = newVal > 0;
			ConfigEnableLineHint.Value = flag;
			ApplyLineHint(flag);
		}

		private void CreateUnitControllerPlayerActions()
		{
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Expected O, but got Unknown
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			try
			{
				PlayerActions instance = PlayerActions.Instance;
				if (instance == null)
				{
					Debug.LogWarning((object)"[zhihui] PlayerActions.Instance为空,无法创建PlayerAction");
					return;
				}
				PlayerAction val = ((IEnumerable<PlayerAction>)((PlayerActionSet)instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_RED_TEAM_CONTROL"));
				PlayerAction val2 = ((IEnumerable<PlayerAction>)((PlayerActionSet)instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_BLUE_TEAM_CONTROL"));
				PlayerAction val3 = ((IEnumerable<PlayerAction>)((PlayerActionSet)instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_UNIT_MARKING"));
				PlayerAction val4 = ((IEnumerable<PlayerAction>)((PlayerActionSet)instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_SHIFT_ALTERNATE"));
				PlayerAction val5;
				if (val == null)
				{
					val5 = new PlayerAction("INPUT_RED_TEAM_CONTROL", (PlayerActionSet)(object)instance);
					val5.AddDefaultBinding((Key[])(object)new Key[1] { (Key)14 });
					Debug.Log((object)"[zhihui] 创建红队控制PlayerAction");
				}
				else
				{
					val5 = val;
					Debug.Log((object)"[zhihui] 使用现有红队控制PlayerAction");
				}
				PlayerAction val6;
				if (val2 == null)
				{
					val6 = new PlayerAction("INPUT_BLUE_TEAM_CONTROL", (PlayerActionSet)(object)instance);
					val6.AddDefaultBinding((Key[])(object)new Key[1] { (Key)15 });
					Debug.Log((object)"[zhihui] 创建蓝队控制PlayerAction");
				}
				else
				{
					val6 = val2;
					Debug.Log((object)"[zhihui] 使用现有蓝队控制PlayerAction");
				}
				PlayerAction val7;
				if (val3 == null)
				{
					val7 = new PlayerAction("INPUT_UNIT_MARKING", (PlayerActionSet)(object)instance);
					val7.AddDefaultBinding((Key[])(object)new Key[1] { (Key)110 });
					Debug.Log((object)"[zhihui] 创建单位标记PlayerAction");
				}
				else
				{
					val7 = val3;
					Debug.Log((object)"[zhihui] 使用现有单位标记PlayerAction");
				}
				PlayerAction val8;
				if (val4 == null)
				{
					val8 = new PlayerAction("INPUT_SHIFT_ALTERNATE", (PlayerActionSet)(object)instance);
					val8.AddDefaultBinding((Key[])(object)new Key[1] { (Key)5 });
					Debug.Log((object)"[zhihui] 创建Shift键PlayerAction");
				}
				else
				{
					val8 = val4;
					Debug.Log((object)"[zhihui] 使用现有Shift键PlayerAction");
				}
				PlayerAction val9 = ((IEnumerable<PlayerAction>)((PlayerActionSet)instance).Actions).FirstOrDefault((Func<PlayerAction, bool>)((PlayerAction a) => a.Name == "INPUT_CTRL_ALTERNATE"));
				PlayerAction val10;
				if (val9 == null)
				{
					val10 = new PlayerAction("INPUT_CTRL_ALTERNATE", (PlayerActionSet)(object)instance);
					val10.AddDefaultBinding((Key[])(object)new Key[1] { (Key)8 });
					Debug.Log((object)"[zhihui] 创建Ctrl键PlayerAction");
				}
				else
				{
					val10 = val9;
					Debug.Log((object)"[zhihui] 使用现有Ctrl键PlayerAction");
				}
				UnitController.SetUnitControlPlayerActions(val5, val6, val7, val8, val10);
				instance.SaveBindings(true);
				Debug.Log((object)("[zhihui] UnitController PlayerAction创建完成: 红队=" + ((val5 != null) ? val5.Name : null) + ", 蓝队=" + ((val6 != null) ? val6.Name : null) + ", 标记=" + ((val7 != null) ? val7.Name : null) + ", Shift=" + ((val8 != null) ? val8.Name : null)));
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("[zhihui] 创建UnitController PlayerAction失败: " + ex.Message));
			}
		}

		private IEnumerator DelayedCreatePlayerActions()
		{
			for (int i = 0; i < 10; i++)
			{
				yield return null;
			}
			if (PlayerActions.Instance != null)
			{
				CreateUnitControllerPlayerActions();
			}
			else
			{
				Debug.LogWarning((object)"[zhihui] PlayerActions.Instance仍然为空,无法创建PlayerAction");
			}
		}
	}
}
public class Item : MonoBehaviour
{
	public enum kind
	{
		Weapon,
		Cloth,
		Skill,
		Unit,
		Projectile,
		Other
	}

	public string name;

	public kind Kind;
}
namespace zhihui
{
	public class MyModItems : MonoBehaviour
	{
		private static Dictionary<string, Item> items;

		private static MyModItems instance { get; set; }

		public static MyModItems GetInstance()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)instance == (Object)null)
			{
				instance = new GameObject("MyModItems").AddComponent<MyModItems>();
				Object.DontDestroyOnLoad((Object)(object)instance);
			}
			return instance;
		}

		public void AddItem(Item item)
		{
			items.Add(item.name, item);
		}

		public Item GetItem(string name)
		{
			Item value = new Item
			{
				name = null,
				Kind = Item.kind.Other
			};
			items.TryGetValue(name, out value);
			return value;
		}
	}
	public class ExplosionFixer : MonoBehaviour
	{
		private void Update()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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)
			Team team = ((Component)this).GetComponentInParent<Unit>().data.team;
			if ((int)team == 0)
			{
				Explosion[] componentsInChildren = ((Component)this).GetComponentsInChildren<Explosion>();
				foreach (Explosion obj in componentsInChildren)
				{
					s.SetField<Explosion>(obj, "team", (object)team);
					obj.ignoreTeamMates = false;
					obj.onlyTeamMates = true;
				}
				componentsInChildren = ((Component)((Component)this).transform.GetChild(0)).GetComponentsInChildren<Explosion>();
				foreach (Explosion obj2 in componentsInChildren)
				{
					s.SetField<Explosion>(obj2, "team", (object)team);
					obj2.ignoreTeamMates = false;
					obj2.onlyTeamMates = true;
				}
			}
			else
			{
				Explosion[] componentsInChildren = ((Component)this).GetComponentsInChildren<Explosion>();
				foreach (Explosion obj3 in componentsInChildren)
				{
					s.SetField<Explosion>(obj3, "team", (object)team);
					obj3.ignoreTeamMates = true;
					obj3.onlyTeamMates = false;
				}
				componentsInChildren = ((Component)((Component)this).transform.GetChild(0)).GetComponentsInChildren<Explosion>();
				foreach (Explosion obj4 in componentsInChildren)
				{
					s.SetField<Explosion>(obj4, "team", (object)team);
					obj4.ignoreTeamMates = true;
					obj4.onlyTeamMates = false;
				}
			}
		}
	}
}
public class Example : MonoBehaviour
{
	public GameObject prefab;

	private void Start()
	{
		if ((Object)(object)prefab != (Object)null)
		{
			Transform[] componentsInChildren = prefab.GetComponentsInChildren<Transform>();
			if (componentsInChildren.Length > 1)
			{
				_ = componentsInChildren[1];
			}
		}
	}
}
public class UnitController : MonoBehaviour
{
	private class MoveTargetData
	{
		public Vector3 targetPosition;

		public Entity targetEntity;

		public bool isMoving;

		public bool needRestoreAI;

		public bool isBlankStanding;
	}

	private struct MovementComponentBackup
	{
		public bool hadKeepPreferredDistance;

		public bool hadFleeDistance;

		public bool hadKeepRangedDistance;

		public bool hadNeverStopRunning;

		public KeepPreferredDistance keepPreferredDistanceData;

		public FleeDistance fleeDistanceData;

		public KeepRangedDistance keepRangedDistanceData;

		public NeverStopRunning neverStopRunningData;
	}

	private enum WaypointType
	{
		Move,
		Attack
	}

	private class Waypoint
	{
		public WaypointType type;

		public Vector3 position;

		public Unit targetUnit;

		public Waypoint(Vector3 pos)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			type = WaypointType.Move;
			position = pos;
		}

		public Waypoint(Unit target)
		{
			type = WaypointType.Attack;
			targetUnit = target;
		}
	}

	[Header("控制设置")]
	[SerializeField]
	private LayerMask unitLayerMask = LayerMask.op_Implicit(-1);

	[SerializeField]
	private LayerMask groundLayerMask = LayerMask.op_Implicit(-1);

	[SerializeField]
	private float moveSpeed = 5f;

	[SerializeField]
	private float stopDistance = 1f;

	[SerializeField]
	private float yTolerance = 10f;

	[Header("UI设置")]
	[SerializeField]
	private Color selectedUnitColor = Color.green;

	[SerializeField]
	private Color targetPositionColor = Color.red;

	[SerializeField]
	private float targetMarkerSize = 0.5f;

	private bool _isControlMode;

	private Unit _selectedUnit;

	private Dictionary<Unit, MoveTargetData> _unitMoveTargets = new Dictionary<Unit, MoveTargetData>();

	private ITargetingComponent _originalTargetingType;

	private MouseLook _mouseLook;

	private Camera _mainCamera;

	private MovementComponentBackup _movementBackup;

	private bool _isDragging;

	private Vector2 _dragStartPos;

	private Vector2 _dragEndPos;

	private Vector3 _dragStartWorldPos;

	private Vector3 _dragEndWorldPos;

	private List<Unit> _selectedUnits = new List<Unit>();

	private const float _spreadRadius = 1.2f;

	private Team _controlTeam;

	private Dictionary<Unit, GameObject> _unitTargetMarkers;

	private Dictionary<Unit, GameObject> _unitTargetLines;

	private Unit _lockedEnemy;

	private GameObject _lockedEnemyLine;

	private Coroutine _lockedEnemyLineCoroutine;

	private ITargetingComponent _lockedEnemyTargetingBackup;

	private bool _isEnemyLockActive;

	private Dictionary<Unit, Unit> _enemyLockUnits = new Dictionary<Unit, Unit>();

	private Dictionary<Unit, GameObject> _lockedEnemyLines = new Dictionary<Unit, GameObject>();

	private Dictionary<Unit, List<Waypoint>> _unitWaypoints = new Dictionary<Unit, List<Waypoint>>();

	private HashSet<Unit> _alertedUnits = new HashSet<Unit>();

	[SerializeField]
	private float alertActivationRadius = 10f;

	[SerializeField]
	private float alertCheckRadius = 10f;

	private List<Unit> _cachedAllUnits;

	[Header("性能优化设置")]
	[SerializeField]
	private float alertCheckInterval;

	[SerializeField]
	private float mountCheckInterval;

	private float _lastAlertCheckTime;

	private float _lastMountCheckTime;

	private float _lastUnitCacheTime;

	private const float UNIT_CACHE_INTERVAL = 1f;

	private HashSet<Unit> _markedUnits = new HashSet<Unit>();

	private bool _lastCapsLockState;

	private Dictionary<Unit, Vector3> _alertedUnitOriginalPositions;

	public static bool LineHintEnabled;

	private static KeyCode _redTeamKey;

	private static KeyCode _blueTeamKey;

	private static KeyCode _capsLockKey;

	private static KeyCode _shiftKey;

	private static PlayerAction _redTeamPlayerAction;

	private static PlayerAction _blueTeamPlayerAction;

	private static PlayerAction _markingPlayerAction;

	private static PlayerAction _shiftPlayerAction;

	private static KeyCode _ctrlKey;

	private static PlayerAction _ctrlPlayerAction;

	private void Awake()
	{
		_mainCamera = Camera.main;
		_mouseLook = Object.FindObjectOfType<MouseLook>();
	}

	private void Update()
	{
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Invalid comparison between Unknown and I4
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e7: 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_02f2: 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_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0302: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03df: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0453: Unknown result type (might be due to invalid IL or missing references)
		//IL_0458: Unknown result type (might be due to invalid IL or missing references)
		//IL_0472: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0614: Unknown result type (might be due to invalid IL or missing references)
		//IL_061b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a9c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0abc: Unknown result type (might be due to invalid IL or missing references)
		//IL_09c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_09c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_09df: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b9c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ba3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bad: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bb2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bb7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c8b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c91: Unknown result type (might be due to invalid IL or missing references)
		//IL_12fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_13df: Unknown result type (might be due to invalid IL or missing references)
		//IL_1072: Unknown result type (might be due to invalid IL or missing references)
		//IL_107f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ffd: Unknown result type (might be due to invalid IL or missing references)
		//IL_1004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d4a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d51: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dcb: Unknown result type (might be due to invalid IL or missing references)
		//IL_1017: Unknown result type (might be due to invalid IL or missing references)
		//IL_1028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d64: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d75: Unknown result type (might be due to invalid IL or missing references)
		//IL_1130: Unknown result type (might be due to invalid IL or missing references)
		//IL_1135: Unknown result type (might be due to invalid IL or missing references)
		//IL_110b: Unknown result type (might be due to invalid IL or missing references)
		//IL_1110: Unknown result type (might be due to invalid IL or missing references)
		//IL_1181: Unknown result type (might be due to invalid IL or missing references)
		//IL_1186: Unknown result type (might be due to invalid IL or missing references)
		//IL_118b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e46: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e4d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ebd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ece: Unknown result type (might be due to invalid IL or missing references)
		//IL_0eff: Unknown result type (might be due to invalid IL or missing references)
		_selectedUnits.RemoveAll((Unit u) => (Object)(object)u == (Object)null);
		_cachedAllUnits.RemoveAll((Unit u) => (Object)(object)u == (Object)null);
		_markedUnits.RemoveWhere((Unit u) => (Object)(object)u == (Object)null);
		_unitMoveTargets = _unitMoveTargets.Where(delegate(KeyValuePair<Unit, MoveTargetData> kv)
		{
			KeyValuePair<Unit, MoveTargetData> keyValuePair2 = kv;
			return (Object)(object)keyValuePair2.Key != (Object)null;
		}).ToDictionary((KeyValuePair<Unit, MoveTargetData> kv) => kv.Key, (KeyValuePair<Unit, MoveTargetData> kv) => kv.Value);
		_enemyLockUnits = _enemyLockUnits.Where(delegate(KeyValuePair<Unit, Unit> kv)
		{
			KeyValuePair<Unit, Unit> keyValuePair = kv;
			if ((Object)(object)keyValuePair.Key != (Object)null)
			{
				keyValuePair = kv;
				return (Object)(object)keyValuePair.Value != (Object)null;
			}
			return false;
		}).ToDictionary((KeyValuePair<Unit, Unit> kv) => kv.Key, (KeyValuePair<Unit, Unit> kv) => kv.Value);
		UpdateUnitCache();
		if ((_redTeamPlayerAction == null) ? Input.GetKeyDown(GetRedTeamKey()) : ((OneAxisInputControl)_redTeamPlayerAction).WasPressed)
		{
			if (!_isControlMode || (int)_controlTeam != 0)
			{
				_controlTeam = (Team)0;
				if (!_isControlMode)
				{
					_isControlMode = true;
				}
				EnterControlMode();
			}
			else
			{
				_isControlMode = false;
				ExitControlMode();
			}
			ClearAllSelections();
		}
		if ((_blueTeamPlayerAction == null) ? Input.GetKeyDown(GetBlueTeamKey()) : ((OneAxisInputControl)_blueTeamPlayerAction).WasPressed)
		{
			if (!_isControlMode || (int)_controlTeam != 1)
			{
				_controlTeam = (Team)1;
				if (!_isControlMode)
				{
					_isControlMode = true;
				}
				EnterControlMode();
			}
			else
			{
				_isControlMode = false;
				ExitControlMode();
			}
			ClearAllSelections();
		}
		if (_isControlMode)
		{
			HandleControlMode();
		}
		if (_isControlMode)
		{
			if (Input.GetMouseButtonDown(0))
			{
				_isDragging = true;
				_dragStartPos = Vector2.op_Implicit(Input.mousePosition);
				_dragEndPos = _dragStartPos;
				_dragStartWorldPos = GetGroundPoint(_dragStartPos);
				_dragEndWorldPos = _dragStartWorldPos;
			}
			if (_isDragging && Input.GetMouseButton(0))
			{
				_dragEndPos = Vector2.op_Implicit(Input.mousePosition);
				_dragEndWorldPos = GetGroundPoint(_dragEndPos);
			}
			if (_isDragging && Input.GetMouseButtonUp(0))
			{
				_isDragging = false;
				_dragEndWorldPos = GetGroundPoint(_dragEndPos);
				Vector2 val = _dragEndPos - _dragStartPos;
				if (((Vector2)(ref val)).magnitude < 5f)
				{
					SelectUnit();
				}
				else
				{
					PerformBoxSelectionGround();
				}
			}
		}
		List<Unit> list = new List<Unit>();
		foreach (KeyValuePair<Unit, MoveTargetData> unitMoveTarget in _unitMoveTargets)
		{
			Unit key = unitMoveTarget.Key;
			MoveTargetData value = unitMoveTarget.Value;
			if ((Object)(object)key == (Object)null || !value.isMoving)
			{
				continue;
			}
			if (_unitWaypoints.ContainsKey(key) && _unitWaypoints[key].Count > 0)
			{
				RemoveAllMovementComponents(key);
			}
			Vector3 position = key.data.mainRig.position;
			Vector3 targetPosition = value.targetPosition;
			float num = Vector2.Distance(new Vector2(position.x, position.z), new Vector2(targetPosition.x, targetPosition.z));
			float num2 = Mathf.Abs(position.y - targetPosition.y);
			if (!(num <= stopDistance) || !(num2 <= yTolerance))
			{
				continue;
			}
			value.isMoving = false;
			RemoveTargetMarker(key);
			if ((Object)(object)key.api != (Object)null)
			{
				key.api.SetMovementSpeed(0f, true);
			}
			GeneralInput componentInChildren = ((Component)key).GetComponentInChildren<GeneralInput>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.inputDirection = Vector3.zero;
			}
			Rigidbody componentInChildren2 = ((Component)key).GetComponentInChildren<Rigidbody>();
			if ((Object)(object)componentInChildren2 != (Object)null)
			{
				componentInChildren2.velocity = Vector3.zero;
			}
			ForceMountStop(key);
			GameObjectEntity component = ((Component)key).GetComponent<GameObjectEntity>();
			if ((Object)(object)component != (Object)null && component.EntityManager != null)
			{
				component.EntityManager.SetComponentData<HasTargetTag>(component.Entity, new HasTargetTag
				{
					Target = Entity.Null
				});
				if (value.targetEntity != Entity.Null && component.EntityManager.Exists(value.targetEntity))
				{
					component.EntityManager.DestroyEntity(value.targetEntity);
				}
			}
			if (_unitWaypoints.ContainsKey(key) && _unitWaypoints[key].Count > 0)
			{
				while (_unitWaypoints[key].Count > 0)
				{
					Waypoint waypoint = _unitWaypoints[key][0];
					if (waypoint.type != WaypointType.Attack || (!((Object)(object)waypoint.targetUnit == (Object)null) && !((Object)(object)waypoint.targetUnit.data == (Object)null) && !waypoint.targetUnit.data.Dead))
					{
						break;
					}
					_unitWaypoints[key].RemoveAt(0);
				}
				if (_unitWaypoints[key].Count > 0)
				{
					Waypoint waypoint2 = _unitWaypoints[key][0];
					_unitWaypoints[key].RemoveAt(0);
					if (waypoint2.type == WaypointType.Move)
					{
						SetUnitMoveTarget(key, waypoint2.position);
						DrawWaypointLines(key, key.data.mainRig.position, waypoint2.position);
					}
					else if (waypoint2.type == WaypointType.Attack)
					{
						LockEnemyTarget(key, waypoint2.targetUnit);
						ShowLockedEnemyLine(key, waypoint2.targetUnit);
					}
					continue;
				}
			}
			if (value.needRestoreAI || (_unitWaypoints.ContainsKey(key) && _unitWaypoints[key].Count == 0))
			{
				if (_markedUnits.Contains(key))
				{
					RestoreUnitAI(key);
					_markedUnits.Remove(key);
					Debug.Log((object)("标记单位到达路径点,恢复AI: " + ((Object)key).name));
				}
				else if ((Object)(object)key.api != (Object)null)
				{
					key.api.SetTargetingType((ITargetingComponent)(object)default(BlankTargeting));
				}
				list.Add(key);
			}
			if (value.isBlankStanding)
			{
				if ((Object)(object)key.api != (Object)null)
				{
					key.api.SetTargetingType((ITargetingComponent)(object)default(BlankTargeting));
				}
				value.isBlankStanding = false;
				if (_alertedUnitOriginalPositions.ContainsKey(key))
				{
					_alertedUnitOriginalPositions.Remove(key);
				}
				Debug.Log((object)("警觉AI单位" + ((Object)key).name + "回到原站立点,切空AI"));
			}
		}
		foreach (Unit item in list)
		{
			_unitMoveTargets.Remove(item);
		}
		HashSet<Unit> hashSet = new HashSet<Unit>();
		foreach (KeyValuePair<Unit, Unit> enemyLockUnit in _enemyLockUnits)
		{
			Unit value2 = enemyLockUnit.Value;
			if ((Object)(object)value2 == (Object)null || (Object)(object)value2.data == (Object)null || value2.data.Dead)
			{
				hashSet.Add(value2);
			}
		}
		List<Unit> list2 = new List<Unit>();
		foreach (KeyValuePair<Unit, Unit> enemyLockUnit2 in _enemyLockUnits)
		{
			Unit key2 = enemyLockUnit2.Key;
			Unit value3 = enemyLockUnit2.Value;
			if ((Object)(object)key2 == (Object)null || (Object)(object)key2.data == (Object)null || key2.data.Dead || hashSet.Contains(value3))
			{
				if ((Object)(object)key2 != (Object)null)
				{
					if (_markedUnits.Contains(key2))
					{
						if (!_unitWaypoints.ContainsKey(key2) || _unitWaypoints[key2].Count <= 0)
						{
							RestoreUnitAI(key2);
							_markedUnits.Remove(key2);
							if (_unitMoveTargets.ContainsKey(key2))
							{
								_unitMoveTargets.Remove(key2);
							}
							Debug.Log((object)("标记单位敌人死亡且无waypoints,恢复AI: " + ((Object)key2).name));
						}
						else
						{
							RestoreUnitAI(key2);
							_markedUnits.Remove(key2);
							Debug.Log((object)("标记单位敌人死亡,恢复AI: " + ((Object)key2).name));
						}
					}
					else if (!_unitWaypoints.ContainsKey(key2) || _unitWaypoints[key2].Count <= 0)
					{
						DisableUnitAI(key2);
						if ((Object)(object)key2.api != (Object)null)
						{
							key2.api.SetMovementSpeed(0f, true);
						}
						GeneralInput componentInChildren3 = ((Component)key2).GetComponentInChildren<GeneralInput>();
						if ((Object)(object)componentInChildren3 != (Object)null)
						{
							componentInChildren3.inputDirection = Vector3.zero;
						}
						Rigidbody componentInChildren4 = ((Component)key2).GetComponentInChildren<Rigidbody>();
						if ((Object)(object)componentInChildren4 != (Object)null)
						{
							componentInChildren4.velocity = Vector3.zero;
						}
						ForceMountStop(key2);
						if (_unitMoveTargets.ContainsKey(key2))
						{
							_unitMoveTargets.Remove(key2);
						}
						Debug.Log((object)("敌人死亡且无waypoints,单位" + ((Object)key2).name + "切空AI并静止"));
					}
					else
					{
						RestoreUnitAI(key2);
					}
				}
				list2.Add(key2);
				if (_unitWaypoints.ContainsKey(key2) && _unitWaypoints[key2].Count > 0)
				{
					Waypoint waypoint3 = _unitWaypoints[key2][0];
					_unitWaypoints[key2].RemoveAt(0);
					if (waypoint3.type == WaypointType.Move)
					{
						SetUnitMoveTarget(key2, waypoint3.position);
						DrawWaypointLines(key2, key2.data.mainRig.position, waypoint3.position);
					}
					else if (waypoint3.type == WaypointType.Attack)
					{
						LockEnemyTarget(key2, waypoint3.targetUnit);
						ShowLockedEnemyLine(key2, waypoint3.targetUnit);
					}
				}
				else if (_unitWaypoints.ContainsKey(key2) && _unitWaypoints[key2].Count == 0 && _markedUnits.Contains(key2))
				{
					RestoreUnitAI(key2);
					_markedUnits.Remove(key2);
					Debug.Log((object)("标记单位敌人死亡后路径完成,恢复AI: " + ((Object)key2).name));
				}
			}
			else
			{
				GameObjectEntity component2 = ((Component)key2).GetComponent<GameObjectEntity>();
				GameObjectEntity component3 = ((Component)value3).GetComponent<GameObjectEntity>();
				if ((Object)(object)component3 != (Object)null && (Object)(object)component2 != (Object)null && component2.EntityManager != null)
				{
					component2.EntityManager.SetComponentData<HasTargetTag>(component2.Entity, new HasTargetTag
					{
						Target = component3.Entity
					});
				}
			}
		}
		foreach (Unit item2 in list2)
		{
			_enemyLockUnits.Remove(item2);
		}
		if (Time.time - _lastAlertCheckTime > alertCheckInterval)
		{
			_lastAlertCheckTime = Time.time;
			float num3 = 3f;
			foreach (Unit cachedAllUnit in _cachedAllUnits)
			{
				if ((Object)(object)cachedAllUnit == (Object)null || (Object)(object)cachedAllUnit.data == (Object)null || cachedAllUnit.data.Dead || cachedAllUnit.Team != _controlTeam || (Object)(object)cachedAllUnit.api == (Object)null || !(cachedAllUnit.api.CurrentTargetingType is BlankTargeting) || (_unitMoveTargets.ContainsKey(cachedAllUnit) && _unitMoveTargets[cachedAllUnit].isMoving) || _enemyLockUnits.ContainsKey(cachedAllUnit))
				{
					continue;
				}
				float unitAlertRange = GetUnitAlertRange(cachedAllUnit, forActivation: true);
				bool flag = false;
				foreach (Unit cachedAllUnit2 in _cachedAllUnits)
				{
					if (!((Object)(object)cachedAllUnit2 == (Object)null) && !((Object)(object)cachedAllUnit2.data == (Object)null) && !cachedAllUnit2.data.Dead && cachedAllUnit2.Team != cachedAllUnit.Team && Vector3.Distance(cachedAllUnit.data.mainRig.position, cachedAllUnit2.data.mainRig.position) <= unitAlertRange)
					{
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					continue;
				}
				if (!_alertedUnitOriginalPositions.ContainsKey(cachedAllUnit))
				{
					_alertedUnitOriginalPositions[cachedAllUnit] = cachedAllUnit.data.mainRig.position;
				}
				RestoreUnitAI(cachedAllUnit);
				_alertedUnits.Add(cachedAllUnit);
				foreach (Unit cachedAllUnit3 in _cachedAllUnits)
				{
					if (!((Object)(object)cachedAllUnit3 == (Object)null) && !((Object)(object)cachedAllUnit3 == (Object)(object)cachedAllUnit) && !((Object)(object)cachedAllUnit3.data == (Object)null) && !cachedAllUnit3.data.Dead && cachedAllUnit3.Team == cachedAllUnit.Team && !((Object)(object)cachedAllUnit3.api == (Object)null) && cachedAllUnit3.api.CurrentTargetingType is BlankTargeting && (!_unitMoveTargets.ContainsKey(cachedAllUnit3) || !_unitMoveTargets[cachedAllUnit3].isMoving) && !_enemyLockUnits.ContainsKey(cachedAllUnit3) && Vector3.Distance(cachedAllUnit.data.mainRig.position, cachedAllUnit3.data.mainRig.position) <= num3)
					{
						if (!_alertedUnitOriginalPositions.ContainsKey(cachedAllUnit3))
						{
							_alertedUnitOriginalPositions[cachedAllUnit3] = cachedAllUnit3.data.mainRig.position;
						}
						RestoreUnitAI(cachedAllUnit3);
						_alertedUnits.Add(cachedAllUnit3);
					}
				}
			}
			List<Unit> list3 = new List<Unit>();
			foreach (Unit alertedUnit in _alertedUnits)
			{
				if ((Object)(object)alertedUnit == (Object)null || (Object)(object)alertedUnit.data == (Object)null || alertedUnit.data.Dead)
				{
					list3.Add(alertedUnit);
					continue;
				}
				float unitAlertRange2 = GetUnitAlertRange(alertedUnit, forActivation: false);
				bool flag2 = false;
				foreach (Unit cachedAllUnit4 in _cachedAllUnits)
				{
					if (!((Object)(object)cachedAllUnit4 == (Object)null) && !((Object)(object)cachedAllUnit4.data == (Object)null) && !cachedAllUnit4.data.Dead && cachedAllUnit4.Team != alertedUnit.Team && Vector3.Distance(alertedUnit.data.mainRig.position, cachedAllUnit4.data.mainRig.position) <= unitAlertRange2)
					{
						flag2 = true;
						break;
					}
				}
				bool flag3 = false;
				if (_alertedUnitOriginalPositions.ContainsKey(alertedUnit) && Vector3.Distance(alertedUnit.data.mainRig.position, _alertedUnitOriginalPositions[alertedUnit]) > 15f)
				{
					flag3 = true;
				}
				if (!(!flag2 || flag3))
				{
					continue;
				}
				if (!_unitMoveTargets.ContainsKey(alertedUnit) || !_unitMoveTargets[alertedUnit].isMoving)
				{
					if (!_unitMoveTargets.ContainsKey(alertedUnit))
					{
						_unitMoveTargets[alertedUnit] = new MoveTargetData();
					}
					if (_alertedUnitOriginalPositions.ContainsKey(alertedUnit))
					{
						_unitMoveTargets[alertedUnit].targetPosition = _alertedUnitOriginalPositions[alertedUnit];
					}
					else
					{
						_unitMoveTargets[alertedUnit].targetPosition = alertedUnit.data.mainRig.position;
					}
					_unitMoveTargets[alertedUnit].isMoving = false;
					_unitMoveTargets[alertedUnit].isBlankStanding = false;
				}
				if (!_unitMoveTargets[alertedUnit].isMoving)
				{
					Vector3 targetPosition2 = _unitMoveTargets[alertedUnit].targetPosition;
					SetUnitMoveTarget(alertedUnit, targetPosition2);
					_unitMoveTargets[alertedUnit].isMoving = true;
					_unitMoveTargets[alertedUnit].needRestoreAI = false;
					_unitMoveTargets[alertedUnit].isBlankStanding = true;
				}
				list3.Add(alertedUnit);
			}
			foreach (Unit item3 in list3)
			{
				_alertedUnits.Remove(item3);
			}
		}
		foreach (Unit selectedUnit in _selectedUnits)
		{
			if ((Object)(object)selectedUnit != (Object)null && _unitMoveTargets.ContainsKey(selectedUnit) && _unitMoveTargets[selectedUnit].isMoving && (Object)(object)selectedUnit.api != (Object)null && !(selectedUnit.api.CurrentTargetingType is BlankTargeting))
			{
				string name = ((Object)selectedUnit).name;
				string text = ", targeting=";
				Debug.Log((object)("[UnitController] Update强制修正AI: " + name + text + ((object)selectedUnit.api.CurrentTargetingType)?.GetType().Name));
				DisableUnitAI(selectedUnit);
				SetUnitMoveTarget(selectedUnit, _unitMoveTargets[selectedUnit].targetPosition);
			}
		}
		foreach (KeyValuePair<Unit, MoveTargetData> unitMoveTarget2 in _unitMoveTargets)
		{
			Unit key3 = unitMoveTarget2.Key;
			MoveTargetData value4 = unitMoveTarget2.Value;
			if (!((Object)(object)key3 != (Object)null))
			{
				continue;
			}
			if (value4.isMoving)
			{
				if ((Object)(object)key3.api != (Object)null && !(key3.api.CurrentTargetingType is BlankTargeting))
				{
					string name2 = ((Object)key3).name;
					string text2 = ", targeting=";
					Debug.Log((object)("[UnitController] Update全局兜底AI: " + name2 + text2 + ((object)key3.api.CurrentTargetingType)?.GetType().Name));
					DisableUnitAI(key3);
					SetUnitMoveTarget(key3, value4.targetPosition);
				}
			}
			else if (value4.isBlankStanding && (Object)(object)key3.api != (Object)null && !(key3.api.CurrentTargetingType is BlankTargeting))
			{
				string name3 = ((Object)key3).name;
				string text3 = ", targeting=";
				Debug.Log((object)("[UnitController] Update空AI站立兜底: " + name3 + text3 + ((object)key3.api.CurrentTargetingType)?.GetType().Name));
				DisableUnitAI(key3);
			}
		}
	}

	private void LateUpdate()
	{
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		if (_isControlMode)
		{
			SetCursor(visible: true);
			CursorVisibilityController service = ServiceLocator.GetService<CursorVisibilityController>();
			if ((Object)(object)service != (Object)null)
			{
				service.SetVisibility(true);
			}
		}
		if (!(Time.time - _lastMountCheckTime > mountCheckInterval))
		{
			return;
		}
		_lastMountCheckTime = Time.time;
		foreach (Unit cachedAllUnit in _cachedAllUnits)
		{
			if (!((Object)(object)cachedAllUnit == (Object)null) && !((Object)(object)cachedAllUnit.data == (Object)null) && !cachedAllUnit.data.Dead && (Object)(object)cachedAllUnit.api != (Object)null && cachedAllUnit.api.CurrentTargetingType is BlankTargeting)
			{
				GeneralInput componentInChildren = ((Component)cachedAllUnit).GetComponentInChildren<GeneralInput>();
				if ((Object)(object)componentInChildren != (Object)null && componentInChildren.inputDirection == Vector3.zero)
				{
					ForceMountStop(cachedAllUnit);
				}
			}
		}
	}

	private void ToggleControlMode()
	{
		_isControlMode = !_isControlMode;
		if (_isControlMode)
		{
			EnterControlMode();
		}
		else
		{
			ExitControlMode();
		}
	}

	private void EnterControlMode()
	{
		Debug.Log((object)"进入单位控制模式");
		SetCursor(visible: true);
		ClearSelection();
	}

	private void ExitControlMode()
	{
		Debug.Log((object)"退出单位控制模式");
		SetCursor(visible: false);
		if ((Object)(object)_selectedUnit != (Object)null && _unitMoveTargets.ContainsKey(_selectedUnit) && _unitMoveTargets[_selectedUnit].isMoving)
		{
			_unitMoveTargets[_selectedUnit].needRestoreAI = true;
		}
		ClearSelection();
		_selectedUnit = null;
		Debug.Log((object)$"保持 {_markedUnits.Count} 个单位的标记状态");
	}

	private void HandleControlMode()
	{
		//IL_001d: 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_0094: 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_00b9: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: 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_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_0313: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: Unknown result type (might be due to invalid IL or missing references)
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0440: Unknown result type (might be due to invalid IL or missing references)
		if (_isDragging)
		{
			return;
		}
		bool flag = ((_markingPlayerAction == null) ? Input.GetKey(GetCapsLockKey()) : ((OneAxisInputControl)_markingPlayerAction).IsPressed);
		if (flag && !_lastCapsLockState)
		{
			HandleCapsLockMarking();
		}
		_lastCapsLockState = flag;
		if (Input.GetMouseButtonDown(0))
		{
			UnlockEnemyTarget();
			SelectUnit();
		}
		if (!Input.GetMouseButtonDown(1) || (_selectedUnits.Count <= 0 && !((Object)(object)_selectedUnit != (Object)null)))
		{
			return;
		}
		RaycastHit[] array = Physics.RaycastAll(_mainCamera.ScreenPointToRay(Input.mousePosition), float.PositiveInfinity, LayerMask.op_Implicit(unitLayerMask));
		Unit val = null;
		float num = float.MaxValue;
		RaycastHit[] array2 = array;
		for (int i = 0; i < array2.Length; i++)
		{
			RaycastHit val2 = array2[i];
			Unit componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Unit>();
			if ((Object)(object)componentInParent != (Object)null && (IsCtrlPressed() || componentInParent.Team != _controlTeam) && ((RaycastHit)(ref val2)).distance < num)
			{
				val = componentInParent;
				num = ((RaycastHit)(ref val2)).distance;
			}
		}
		if ((Object)(object)val != (Object)null)
		{
			if ((_shiftPlayerAction == null) ? Input.GetKey(GetShiftKey()) : ((OneAxisInputControl)_shiftPlayerAction).IsPressed)
			{
				List<Unit> list;
				if (_selectedUnits.Count <= 0)
				{
					(list = new List<Unit>()).Add(_selectedUnit);
				}
				else
				{
					list = _selectedUnits;
				}
				{
					foreach (Unit item in list)
					{
						if (!_unitWaypoints.ContainsKey(item))
						{
							_unitWaypoints[item] = new List<Waypoint>();
						}
						_unitWaypoints[item].Add(new Waypoint(val));
						DrawAllWaypointLines(item);
						if ((!_unitMoveTargets.ContainsKey(item) || !_unitMoveTargets[item].isMoving) && !_enemyLockUnits.ContainsKey(item))
						{
							LockEnemyTarget(item, val);
							ShowLockedEnemyLine(item, val);
						}
					}
					return;
				}
			}
			List<Unit> list2;
			if (_selectedUnits.Count <= 0)
			{
				(list2 = new List<Unit>()).Add(_selectedUnit);
			}
			else
			{
				list2 = _selectedUnits;
			}
			{
				foreach (Unit item2 in list2)
				{
					_unitWaypoints.Remove(item2);
					if ((Object)(object)item2 != (Object)null)
					{
						if (!_unitMoveTargets.ContainsKey(item2) || !_unitMoveTargets[item2].isMoving)
						{
							((MonoBehaviour)this).StartCoroutine(LockEnemyTargetWithFakePath(item2, val));
						}
						else
						{
							LockEnemyTarget(item2, val);
						}
					}
				}
				return;
			}
		}
		if ((_shiftPlayerAction == null) ? Input.GetKey(GetShiftKey()) : ((OneAxisInputControl)_shiftPlayerAction).IsPressed)
		{
			RaycastHit val3 = default(RaycastHit);
			if (!Physics.Raycast(_mainCamera.ScreenPointToRay(Input.mousePosition), ref val3, float.PositiveInfinity, LayerMask.op_Implicit(groundLayerMask)))
			{
				return;
			}
			Vector3 point = ((RaycastHit)(ref val3)).point;
			int count = _selectedUnits.Count;
			float num2 = 1.2f * Mathf.Sqrt((float)count / 4f);
			Vector3 val5 = default(Vector3);
			for (int j = 0; j < count; j++)
			{
				Unit val4 = _selectedUnits[j];
				float num3 = num2 * Mathf.Sqrt(Random.value);
				float num4 = Random.Range(0f, (float)Math.PI * 2f);
				((Vector3)(ref val5))..ctor(num3 * Mathf.Cos(num4), 0f, num3 * Mathf.Sin(num4));
				Vector3 val6 = point + val5 + Vector3.up * 0.5f;
				if (!_unitWaypoints.ContainsKey(val4))
				{
					_unitWaypoints[val4] = new List<Waypoint>();
				}
				_unitWaypoints[val4].Add(new Waypoint(val6));
				DrawAllWaypointLines(val4);
				if ((!_unitMoveTargets.ContainsKey(val4) || !_unitMoveTargets[val4].isMoving) && !_enemyLockUnits.ContainsKey(val4))
				{
					SetUnitMoveTarget(val4, val6);
				}
			}
			return;
		}
		List<Unit> list3;
		if (_selectedUnits.Count <= 0)
		{
			(list3 = new List<Unit>()).Add(_selectedUnit);
		}
		else
		{
			list3 = _selectedUnits;
		}
		foreach (Unit item3 in list3)
		{
			_unitWaypoints.Remove(item3);
		}
		UnlockEnemyTarget();
		SetMoveTargetForAll();
	}

	private void SelectUnit()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: 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_0039: 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_005b: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit[] array = Physics.RaycastAll(_mainCamera.ScreenPointToRay(Input.mousePosition), float.PositiveInfinity, LayerMask.op_Implicit(unitLayerMask));
		Unit val = null;
		float num = float.MaxValue;
		RaycastHit[] array2 = array;
		for (int i = 0; i < array2.Length; i++)
		{
			RaycastHit val2 = array2[i];
			Unit componentInParent = ((Component)((RaycastHit)(ref val2)).collider).GetComponentInParent<Unit>();
			if ((Object)(object)componentInParent != (Object)null && componentInParent.Team == _controlTeam && ((RaycastHit)(ref val2)).distance < num)
			{
				val = componentInParent;
				num = ((RaycastHit)(ref val2)).distance;
			}
		}
		if (!((Object)(object)val != (Object)null))
		{
			return;
		}
		ClearAllSelections();
		_selectedUnits.Add(val);
		_selectedUnit = val;
		if (_enemyLockUnits.ContainsKey(val))
		{
			Unit enemy = _enemyLockUnits[val];
			if (_unitTargetLines.ContainsKey(val))
			{
				Object.Destroy((Object)(object)_unitTargetLines[val]);
				_unitTargetLines.Remove(val);
			}
			ShowLockedEnemyLine(val, enemy);
			AddUnitHighlight(val);
			Debug.Log((object)("选中单位(锁定敌人): " + ((Object)val).name));
		}
		else
		{
			HandleUnitAIOnSelect(val);
			AddUnitHighlight(val);
			Debug.Log((object)("选中单位: " + ((Object)val).name));
		}
	}

	private void SetMoveTarget()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: 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_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit val = default(RaycastHit);
		if (!Physics.Raycast(_mainCamera.ScreenPointToRay(Input.mousePosition), ref val, float.PositiveInfinity, LayerMask.op_Implicit(groundLayerMask)))
		{
			return;
		}
		Vector3 point = ((RaycastHit)(ref val)).point;
		CreateTargetMarker(_selectedUnit, point);
		Debug.Log((object)$"设置移动目标: {point}");
		if (!((Object)(object)_selectedUnit != (Object)null) || !((Object)(object)_selectedUnit.api != (Object)null))
		{
			return;
		}
		DisableUnitAI(_selectedUnit);
		_ = _selectedUnit.api;
		GameObjectEntity component = ((Component)_selectedUnit).GetComponent<GameObjectEntity>();
		if ((Object)(object)component != (Object)null && component.EntityManager != null)
		{
			EntityManager entityManager = component.EntityManager;
			EntityArchetype val2 = entityManager.CreateArchetype((ComponentType[])(object)new ComponentType[1] { ComponentType.op_Implicit(typeof(GroundPosition)) });
			Entity val3 = entityManager.CreateEntity(val2);
			entityManager.SetComponentData<GroundPosition>(val3, new GroundPosition
			{
				Value = float3.op_Implicit(point)
			});
			entityManager.SetComponentData<HasTargetTag>(component.Entity, new HasTargetTag
			{
				Target = val3
			});
			if (!_unitMoveTargets.ContainsKey(_selectedUnit))
			{
				_unitMoveTargets[_selectedUnit] = new MoveTargetData();
			}
			_unitMoveTargets[_selectedUnit].targetPosition = point;
			_unitMoveTargets[_selectedUnit].targetEntity = val3;
			_unitMoveTargets[_selectedUnit].isMoving = true;
			_unitMoveTargets[_selectedUnit].needRestoreAI = false;
		}
	}

	private void DisableUnitAI(Unit unit)
	{
		if (!((Object)(object)unit == (Object)null))
		{
			object name = ((Object)unit).name;
			object api = unit.api;
			UnitAPI api2 = unit.api;
			object arg = ((!((Object)(object)api2 == (Object)null)) ? ((object)api2.CurrentTargetingType)?.GetType().Name : null);
			Debug.Log((object)$"[UnitController] DisableUnitAI: {name}, api={api}, targeting={arg}");
			ResetUnitMovementState(unit);
			if ((Object)(object)unit.api != (Object)null)
			{
				_originalTargetingType = unit.api.CurrentTargetingType;
				unit.api.SetTargetingType((ITargetingComponent)(object)default(BlankTargeting));
			}
			DisablePlayerControllableConditionalEvents(unit);
			Debug.Log((object)("切换单位AI为空白AI: " + ((Object)unit).name));
			ForceMountStop(unit);
		}
	}

	private void RestoreUnitAI(Unit unit)
	{
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: 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_00b4: 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_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: 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_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)unit == (Object)null)
		{
			return;
		}
		if ((Object)(object)unit.api != (Object)null)
		{
			unit.api.SetTargetingType(unit.api.DefaultTargetingType);
		}
		GameObjectEntity component = ((Component)unit).GetComponent<GameObjectEntity>();
		if ((Object)(object)component != (Object)null && component.EntityManager != null)
		{
			EntityManager entityManager = component.EntityManager;
			Entity entity = component.Entity;
			Type[] array = new Type[4]
			{
				typeof(KeepPreferredDistance),
				typeof(FleeDistance),
				typeof(KeepRangedDistance),
				typeof(NeverStopRunning)
			};
			foreach (Type type in array)
			{
				if (entityManager.HasComponent(entity, ComponentType.op_Implicit(type)))
				{
					entityManager.RemoveComponent(entity, ComponentType.op_Implicit(type));
				}
			}
			if ((Object)(object)unit.unitBlueprint != (Object)null && unit.unitBlueprint.MovementComponents != null)
			{
				foreach (IMovementComponent movementComponent in unit.unitBlueprint.MovementComponents)
				{
					if (movementComponent is KeepPreferredDistance val)
					{
						entityManager.AddComponentData<KeepPreferredDistance>(entity, val);
					}
					else if (movementComponent is FleeDistance val2)
					{
						entityManager.AddComponentData<FleeDistance>(entity, val2);
					}
					else if (movementComponent is KeepRangedDistance val3)
					{
						entityManager.AddComponentData<KeepRangedDistance>(entity, val3);
					}
					else if (movementComponent is NeverStopRunning val4)
					{
						entityManager.AddComponentData<NeverStopRunning>(entity, val4);
					}
				}
			}
		}
		RestorePlayerControllableConditionalEvents(unit);
		Debug.Log((object)("恢复单位AI: " + ((Object)unit).name));
		ForceMountRun(unit);
	}

	private void AddUnitHighlight(Unit unit)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)unit != (Object)null)
		{
			if (_markedUnits.Contains(unit))
			{
				unit.SetHighlight(Color.yellow);
			}
			else
			{
				unit.SetHighlight(selectedUnitColor);
			}
		}
	}

	private void RemoveUnitHighlight(Unit unit)
	{
		if ((Object)(object)unit != (Object)null)
		{
			unit.RemoveHighlight();
		}
	}

	private void ClearSelection()
	{
		if ((Object)(object)_selectedUnit != (Object)null)
		{
			RemoveUnitHighlight(_selectedUnit);
			if (_unitMoveTargets.ContainsKey(_selectedUnit) && _unitMoveTargets[_selectedUnit].isMoving)
			{
				_unitMoveTargets[_selectedUnit].needRestoreAI = true;
			}
			RemoveTargetMarker(_selectedUnit);
		}
	}

	private void HandleUnitAIOnSelect(Unit unit)
	{
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: 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_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: 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_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		Debug.Log((object)$"HandleUnitAIOnSelect: unit={(((Object)(object)unit != (Object)null) ? ((Object)unit).name : null)}, isLocked={_enemyLockUnits.ContainsKey(unit)}, isMoving={_unitMoveTargets.ContainsKey(unit) && _unitMoveTargets[unit].isMoving}");
		bool flag = _unitMoveTargets.ContainsKey(unit) && _unitMoveTargets[unit].isMoving;
		if (_enemyLockUnits.ContainsKey(unit))
		{
			Unit enemy = _enemyLockUnits[unit];
			if (_unitTargetLines.ContainsKey(unit))
			{
				Object.Destroy((Object)(object)_unitTargetLines[unit]);
				_unitTargetLines.Remove(unit);
			}
			ShowLockedEnemyLine(unit, enemy);
		}
		else
		{
			if (flag)
			{
				return;
			}
			if (IsUnitInBlankAIState(unit))
			{
				Debug.Log((object)("[UnitController] 重新选中空AI单位,保持空AI状态: " + ((Object)unit).name));
				return;
			}
			Debug.Log((object)("[UnitController] 选中单位,切换到空AI: " + ((Object)unit).name));
			ResetUnitMovementState(unit);
			if ((Object)(object)unit.api != (Object)null)
			{
				_originalTargetingType = unit.api.CurrentTargetingType;
				unit.api.SetTargetingType((ITargetingComponent)(object)default(BlankTargeting));
			}
			GameObjectEntity component = ((Component)unit).GetComponent<GameObjectEntity>();
			if ((Object)(object)component != (Object)null && component.EntityManager != null)
			{
				EntityManager entityManager = component.EntityManager;
				Entity entity = component.Entity;
				_movementBackup = default(MovementComponentBackup);
				_movementBackup.hadKeepPreferredDistance = entityManager.HasComponent<KeepPreferredDistance>(entity);
				if (_movementBackup.hadKeepPreferredDistance)
				{
					_movementBackup.keepPreferredDistanceData = entityManager.GetComponentData<KeepPreferredDistance>(entity);
					entityManager.RemoveComponent<KeepPreferredDistance>(entity);
				}
				_movementBackup.hadFleeDistance = entityManager.HasComponent<FleeDistance>(entity);
				if (_movementBackup.hadFleeDistance)
				{
					_movementBackup.fleeDistanceData = entityManager.GetComponentData<FleeDistance>(entity);
					entityManager.RemoveComponent<FleeDistance>(entity);
				}
				_movementBackup.hadKeepRangedDistance = entityManager.HasComponent<KeepRangedDistance>(entity);
				if (_movementBackup.hadKeepRangedDistance)
				{
					_movementBackup.keepRangedDistanceData = entityManager.GetComponentData<KeepRangedDistance>(entity);
					entityManager.RemoveComponent<KeepRangedDistance>(entity);
				}
				_movementBackup.hadNeverStopRunning = entityManager.HasComponent<NeverStopRunning>(entity);
				if (_movementBackup.hadNeverStopRunning)
				{
					_movementBackup.neverStopRunningData = entityManager.GetComponentData<NeverStopRunning>(entity);
					entityManager.RemoveComponent<NeverStopRunning>(entity);
				}
			}
			DisablePlayerControllableConditionalEvents(unit);
			ForceMountStop(unit);
		}
	}

	private void SetMoveTargetForAll()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_013a: 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_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: 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_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		UnlockEnemyTarget();
		RaycastHit val = default(RaycastHit);
		if (!Physics.Raycast(_mainCamera.ScreenPointToRay(Input.mousePosition), ref val, float.PositiveInfinity, LayerMask.op_Implicit(groundLayerMask)))
		{
			return;
		}
		Vector3 point = ((RaycastHit)(ref val)).point;
		int count = _selectedUnits.Count;
		float num = 1.2f * Mathf.Sqrt((float)count / 4f);
		Vector3 val3 = default(Vector3);
		for (int i = 0; i < count; i++)
		{
			Unit val2 = _selectedUnits[i];
			HandleUnitAIOnSelect(val2);
			DisableUnitAI(val2);
			float num2 = num * Mathf.Sqrt(Random.value);
			float num3 = Random.Range(0f, (float)Math.PI * 2f);
			((Vector3)(ref val3))..ctor(num2 * Mathf.Cos(num3), 0f, num2 * Mathf.Sin(num3));
			Vector3 val4 = point + val3;
			CreateTargetMarker(val2, val4);
			if ((Object)(object)val2 != (Object)null && (Object)(object)val2.api != (Object)null)
			{
				_ = val2.api;
				GameObjectEntity component = ((Component)val2).GetComponent<GameObjectEntity>();
				if ((Object)(object)component != (Object)null && component.EntityManager != null)
				{
					EntityManager entityManager = component.EntityManager;
					EntityArchetype val5 = entityManager.CreateArchetype((ComponentType[])(object)new ComponentType[1] { ComponentType.op_Implicit(typeof(GroundPosition)) });
					Entity val6 = entityManager.CreateEntity(val5);
					entityManager.SetComponentData<GroundPosition>(val6, new GroundPosition
					{
						Value = float3.op_Implicit(val4)
					});
					entityManager.SetComponentData<HasTargetTag>(component.Entity, new HasTargetTag
					{
						Target = val6
					});
					if (!_unitMoveTargets.ContainsKey(val2))
					{
						_unitMoveTargets[val2] = new MoveTargetData();
					}
					_unitMoveTargets[val2].targetPosition = val4;
					_unitMoveTargets[val2].targetEntity = val6;
					_unitMoveTargets[val2].isMoving = true;
					_unitMoveTargets[val2].needRestoreAI = false;
				}
			}
			ForceMountRun(val2);
		}
	}

	private void ClearAllSelections()
	{
		foreach (Unit selectedUnit in _selectedUnits)
		{
			RemoveUnitHighlight(selectedUnit);
			RemoveTargetMarker(selectedUnit);
			if (_unitMoveTargets.ContainsKey(selectedUnit) && _unitMoveTargets[selectedUnit].isMoving)
			{
				_unitMoveTargets[selectedUnit].needRestoreAI = true;
			}
			else
			{
				Debug.Log((object)("[UnitController] 保持单位空AI状态: " + ((Object)selectedUnit).name));
			}
		}
		_selectedUnits.Clear();
		_selectedUnit = null;
	}

	private void CreateTargetMarker(Unit unit, Vector3 position)
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Expected O, but got Unknown
		//IL_0072: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Expected O, but got Unknown
		//IL_00c4: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		if (LineHintEnabled)
		{
			RemoveTargetMarker(unit);
			if ((Object)(object)unit != (Object)null && (Object)(object)unit.data != (Object)null && (Object)(object)unit.data.mainRig != (Object)null)
			{
				GameObject val = new GameObject("TargetLine_" + ((Object)unit).name);
				LineRenderer obj = val.AddComponent<LineRenderer>();
				obj.positionCount = 2;
				obj.SetPosition(0, unit.data.mainRig.position);
				obj.SetPosition(1, position);
				obj.startWidth = 0.12f;
				obj.endWidth = 0.12f;
				((Renderer)obj).material = new Material(Shader.Find("Unlit/Color"));
				Color val2 = (_markedUnits.Contains(unit) ? Color.yellow : Color.green);
				((Renderer)obj).material.color = val2;
				obj.startColor = val2;
				obj.endColor = val2;
				obj.useWorldSpace = true;
				((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)obj).receiveShadows = false;
				_unitTargetLines[unit] = val;
				((MonoBehaviour)this).StartCoroutine(AutoRemoveTargetLine(unit, val, 0.5f));
			}
		}
	}

	private IEnumerator AutoRemoveTargetLine(Unit unit, GameObject lineObj, float delay)
	{
		yield return (object)new WaitForSeconds(delay);
		if (_unitTargetLines.ContainsKey(unit) && (Object)(object)_unitTargetLines[unit] == (Object)(object)lineObj)
		{
			Object.Destroy((Object)(object)lineObj);
			_unitTargetLines.Remove(unit);
		}
	}

	private void RemoveTargetMarker(Unit unit)
	{
		if ((Object)(object)unit != (Object)null && _unitTargetMarkers.ContainsKey(unit))
		{
			Object.Destroy((Object)(object)_unitTargetMarkers[unit]);
			_unitTargetMarkers.Remove(unit);
		}
		if ((Object)(object)unit != (Object)null && _unitTargetLines.ContainsKey(unit))
		{
			Object.Destroy((Object)(object)_unitTargetLines[unit]);
			_unitTargetLines.Remove(unit);
		}
	}

	private void SetCursorVisible(bool visible)
	{
		Cursor.visible = visible;
		Cursor.lockState = (CursorLockMode)((!visible) ? 1 : 0);
		if ((Object)(object)_mouseLook != (Object)null)
		{
			((Behaviour)_mouseLook).enabled = !visible;
		}
		CursorVisibilityController service = ServiceLocator.GetService<CursorVisibilityController>();
		if ((Object)(object)service != (Object)null)
		{
			service.SetVisibility(visible);
		}
	}

	private void SetCursor(bool visible)
	{
		Cursor.visible = visible;
		Cursor.lockState = (CursorLockMode)((!visible) ? 1 : 0);
		if ((Object)(object)_mouseLook != (Object)null)
		{
			((Behaviour)_mouseLook).enabled = !visible;
		}
	}

	private void OnDestroy()
	{
		if (_isControlMode)
		{
			ExitControlMode();
		}
	}

	private void OnGUI()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: 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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		if (_isControlMode && _isDragging)
		{
			Rect screenRect = GetScreenRect(_dragStartPos, _dragEndPos);
			DrawScreenRect(screenRect, new Color(0.3f, 0.8f, 1f, 0.2f));
			DrawScreenRectBorder(screenRect, 2f, new Color(0.3f, 0.8f, 1f, 0.8f));
		}
	}

	private Rect GetScreenRect(Vector2 screenPosition1, Vector2 screenPosition2)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: 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_002a: 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_0030: 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_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: 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_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		screenPosition1.y = (float)Screen.height - screenPosition1.y;
		screenPosition2.y = (float)Screen.height - screenPosition2.y;
		Vector2 val = Vector2.Min(screenPosition1, screenPosition2);
		Vector2 val2 = Vector2.Max(screenPosition1, screenPosition2);
		return Rect.MinMaxRect(val.x, val.y, val2.x, val2.y);
	}

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

	private void DrawScreenRectBorder(Rect rect, float thickness, Color color)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: 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_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_0081: 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)
		DrawScreenRect(new Rect(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMin, ((Rect)(ref rect)).width, thickness), color);
		DrawScreenRect(new Rect(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMax - thickness, ((Rect)(ref rect)).width, thickness), color);
		DrawScreenRect(new Rect(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).yMin, thickness, ((Rect)(ref rect)).height), color);
		DrawScreenRect(new Rect(((Rect)(ref rect)).xMax - thickness, ((Rect)(ref rect)).yMin, thickness, ((Rect)(ref rect)).height), color);
	}

	private Vector3 GetGroundPoint(Vector2 screenPos)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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_002c: Unknown result type (might be due to invalid IL or missing references)
		RaycastHit val = default(RaycastHit);
		if (Physics.Raycast(_mainCamera.ScreenPointToRay(Vector2.op_Implicit(screenPos)), ref val, 500f, LayerMask.op_Implicit(groundLayerMask)))
		{
			return ((RaycastHit)(ref val)).point;
		}
		return Vector3.zero;
	}

	public UnitController()
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		alertCheckInterval = 0.5f;
		mountCheckInterval = 0.2f;
		_cachedAllUnits = new List<Unit>();
		_alertedUnitOriginalPositions = new Dictionary<Unit, Vector3>();
		_unitTargetMarkers = new Dictionary<Unit, GameObject>();
		_unitTargetLines = new Dictionary<Unit, GameObject>();
	}

	private void LockEnemyTarget(Unit self, Unit enemy)
	{
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: 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_009b: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)self == (Object)null) && !((Object)(object)enemy == (Object)null))
		{
			RestoreUnitAI(self);
			if ((Object)(object)self.api != (Object)null)
			{
				_lockedEnemyTargetingBackup = self.api.CurrentTargetingType;
				self.api.SetTargetingType((ITargetingComponent)(object)default(BlankTargeting));
			}
			GameObjectEntity component = ((Component)self).GetComponent<GameObjectEntity>();
			GameObjectEntity component2 = ((Component)enemy).GetComponent<GameObjectEntity>();
			if ((Object)(object)component != (Object)null && component.EntityManager != null && (Object)(object)component2 != (Object)null)
			{
				component.EntityManager.SetComponentData<HasTargetTag>(component.Entity, new HasTargetTag
				{
					Target = component2.Entity
				});
			}
			_lockedEnemy = enemy;
			_isEnemyLockActive = true;
			_enemyLockUnits[self] = enemy;
			ShowLockedEnemyLine(self, enemy);
			ForceMountRun(self);
		}
	}

	private IEnumerator LockEnemyTargetWithFakePath(Unit self, Unit enemy)
	{
		Vector3 targetPosition = ((Component)self).transform.position + new Vector3(9999f, 0f, 9999f);
		if (!_unitMoveTargets.ContainsKey(self))
		{
			_unitMoveTargets[self] = new MoveTargetData();
		}
		_unitMoveTargets[self].targetPosition = targetPosition;
		_unitMoveTargets[self].isMoving = true;
		_unitMoveTargets[self].needRestoreAI = false;
		yield return (object)new WaitForSeconds(0.1f);
		LockEnemyTarget(self, enemy);
	}

	private void UnlockEnemyTarget()
	{
		List<Unit> list;
		if (_selectedUnits.Count <= 0)
		{
			if (!((Object)(object)_selectedUnit != (Object)null))
			{
				list = new List<Unit>();
			}
			else
			{
				(list = new List<Unit>()).Add(_selectedUnit);
			}
		}
		else
		{
			list = _selectedUnits;
		}
		foreach (Unit item in list)
		{
			if ((Object)(object)item != (Object)null)
			{
				_enemyLockUnits.Remove(item);
				if (_lockedEnemyLines.ContainsKey(item))
				{
					Object.Destroy((Object)(object)_lockedEnemyLines[item]);
					_lockedEnemyLines.Remove(item);
				}
			}
		}
		_lockedEnemy = null;
		_isEnemyLockActive = false;
		_lockedEnemyTargetingBackup = null;
	}

	private void ShowLockedEnemyLine(Unit self, Unit enemy)
	{
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Expected O, but got Unknown
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Expected O, but got Unknown
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		if (LineHintEnabled)
		{
			if (_lockedEnemyLines.ContainsKey(self) && (Object)(object)_lockedEnemyLines[self] != (Object)null)
			{
				Object.Destroy((Object)(object)_lockedEnemyLines[self]);
				_lockedEnemyLines.Remove(self);
			}
			if ((Object)(object)self != (Object)null && (Object)(object)self.data != (Object)null && (Object)(object)self.data.mainRig != (Object)null && (Object)(object)enemy != (Object)null && (Object)(object)enemy.data != (Object)null && (Object)(object)enemy.data.mainRig != (