Decompiled source of AdminSystem v3.3.1

BepInEx/plugins/Hikaria.AdminSystem/Hikaria.AdminSystem.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using AIGraph;
using AK;
using Agents;
using AirNavigation;
using BepInEx.Unity.IL2CPP.Utils;
using BepInEx.Unity.IL2CPP.Utils.Collections;
using CellMenu;
using ChainedPuzzles;
using Clonesoft.Json;
using CullingSystem;
using Enemies;
using FluffyUnderware.Curvy;
using GameData;
using Gear;
using Globals;
using Hikaria.AdminSystem.Extensions;
using Hikaria.AdminSystem.Features.Item;
using Hikaria.AdminSystem.Features.Player;
using Hikaria.AdminSystem.Managers;
using Hikaria.AdminSystem.Suggestion.Suggestors;
using Hikaria.AdminSystem.Suggestion.Suggestors.Attributes;
using Hikaria.AdminSystem.Suggestion.Suggestors.Tags;
using Hikaria.AdminSystem.Suggestions.Suggestors.Attributes;
using Hikaria.AdminSystem.Suggestions.Suggestors.Tags;
using Hikaria.AdminSystem.Utilities;
using Hikaria.AdminSystem.Utility;
using Hikaria.Core;
using Hikaria.Core.Interfaces;
using Hikaria.ItemMarker.Managers;
using Hikaria.QC;
using Hikaria.QC.Actions;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using LevelGeneration;
using Localization;
using Microsoft.CodeAnalysis;
using Player;
using SNetwork;
using StateMachines;
using TMPro;
using TheArchive.Core;
using TheArchive.Core.Attributes;
using TheArchive.Core.Attributes.Feature.Settings;
using TheArchive.Core.FeaturesAPI;
using TheArchive.Core.Localization;
using TheArchive.Core.Models;
using TheArchive.Core.ModulesAPI;
using TheArchive.Features.Security;
using TheArchive.Interfaces;
using TheArchive.Loader;
using TheArchive.Utilities;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4a1b9f36-ece1-456d-8dda-ddac7b4821c8")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
}
namespace Hikaria.AdminSystem
{
	[ArchiveDependency(/*Could not decode attribute arguments.*/)]
	[ArchiveDependency(/*Could not decode attribute arguments.*/)]
	[ArchiveDependency(/*Could not decode attribute arguments.*/)]
	[ArchiveModule("Hikaria.AdminSystem", "AdminSystem", "3.3.0")]
	public class EntryPoint : IArchiveModule
	{
		public static class Groups
		{
			public static FeatureGroup ModuleGroup => FeatureGroups.GetOrCreateModuleGroup("Admin System", new Dictionary<Language, string>
			{
				{
					(Language)1,
					"管理系统"
				},
				{
					(Language)0,
					"Admin System"
				}
			});

			public static FeatureGroup Item => ModuleGroup.GetOrCreateSubGroup("Item", false);

			public static FeatureGroup Weapon => ModuleGroup.GetOrCreateSubGroup("Weapon", false);

			public static FeatureGroup Player => ModuleGroup.GetOrCreateSubGroup("Player", false);

			public static FeatureGroup Enemy => ModuleGroup.GetOrCreateSubGroup("Enemy", false);

			public static FeatureGroup Misc => ModuleGroup.GetOrCreateSubGroup("Misc", false);

			public static FeatureGroup Security => ModuleGroup.GetOrCreateSubGroup("Security", false);

			public static FeatureGroup InLevel => ModuleGroup.GetOrCreateSubGroup("InLevel", false);

			public static FeatureGroup Dev => ModuleGroup.GetOrCreateSubGroup("Develop", true);

			public static FeatureGroup Visual => ModuleGroup.GetOrCreateSubGroup("Visual", false);

			static Groups()
			{
				Item.SetLanguage((Language)1, "物品");
				Item.SetLanguage((Language)0, "Item");
				Weapon.SetLanguage((Language)1, "武器");
				Weapon.SetLanguage((Language)0, "Weapon");
				Player.SetLanguage((Language)1, "玩家");
				Player.SetLanguage((Language)0, "Player");
				InLevel.SetLanguage((Language)1, "游戏内");
				InLevel.SetLanguage((Language)0, "InLevel");
				Misc.SetLanguage((Language)1, "杂项");
				Misc.SetLanguage((Language)0, "Misc");
				Enemy.SetLanguage((Language)1, "敌人");
				Enemy.SetLanguage((Language)0, "Enemy");
				Security.SetLanguage((Language)1, "安全");
				Security.SetLanguage((Language)0, "Security");
				Dev.SetLanguage((Language)1, "开发者选项");
				Dev.SetLanguage((Language)0, "Develop");
				Visual.SetLanguage((Language)1, "可视化");
				Visual.SetLanguage((Language)0, "Visual");
			}
		}

		public bool ApplyHarmonyPatches => false;

		public bool UsesLegacyPatches => false;

		public ArchiveLegacyPatcher Patcher { get; set; }

		public string ModuleGroup => FeatureGroup.op_Implicit(Groups.ModuleGroup);

		public void Init()
		{
			Logs.LogMessage("OK");
		}

		public void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
		}

		public void OnLateUpdate()
		{
		}

		public void OnExit()
		{
		}
	}
	public static class PluginInfo
	{
		public const string GUID = "Hikaria.AdminSystem";

		public const string NAME = "AdminSystem";

		public const string VERSION = "3.3.0";

		public const int REVISION = 10500;
	}
}
namespace Hikaria.AdminSystem.Utilities
{
	internal static class ConsoleLogs
	{
		public static void LogToConsole(string logText, LogLevel logLevel = 8)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			QuantumConsole.Instance.LogToConsole(logText, logLevel, false, true);
		}

		public static void LogToConsoleAsync(string logText, LogLevel logLevel = 8)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			QuantumConsole.Instance.LogToConsoleAsync(logText, logLevel);
		}
	}
	public static class FigExt
	{
		public static void HighlightPoint(Camera camera, Vector3 pos, string text, Vector2 textSize, Color textColor, Color crossColor, Color lineColor, Material material, float verticalLineSize = 1f, float crossSize = 0.25f, float textHeightMulti = 0.3f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_0012: 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_001d: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0087: 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_008d: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00c2: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = pos + Vector3.up * verticalLineSize;
			if (verticalLineSize > 0f)
			{
				Fig.DrawLine(pos, val, lineColor, material, 1f);
			}
			if (crossSize > 0f)
			{
				Vector3 val2 = (Vector3.forward + Vector3.left) * crossSize;
				Vector3 val3 = (Vector3.forward + Vector3.right) * crossSize;
				Fig.DrawLine(pos + val2, pos - val2, crossColor, material, 1f);
				Fig.DrawLine(pos + val3, pos - val3, crossColor, material, 1f);
			}
			if (!string.IsNullOrWhiteSpace(text))
			{
				Quaternion val4 = Quaternion.LookRotation(val - ((Component)camera).transform.position, Vector3.up);
				Fig.DrawText(text, val + Vector3.up * textHeightMulti, val4, textSize, textColor, material, (TextAnchor)7, (TextAlignment)1, 1f);
			}
		}

		public static void DrawFacingText(Camera camera, Vector3 pos, string text, Vector2 textSize, Color textColor, Material material)
		{
			//IL_0000: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = Quaternion.LookRotation(pos - ((Component)camera).transform.position, Vector3.up);
			Fig.DrawText(text, pos, val, textSize, textColor, material, (TextAnchor)7, (TextAlignment)1, 1f);
		}
	}
	internal static class MaterialHelper
	{
		public enum Render
		{
			OnTop = 0,
			Never = 1,
			InWorld = 4,
			BehindWorld = 7,
			Always = 8
		}

		public const string SHADER_NAME = "UI/Fig";

		public const string SHADER_PROPERTY_OPACITY = "_Opacity";

		public const string SHADER_PROPERTY_SOFTNESS = "_Softness";

		public const string SHADER_PROPERTY_DOTCOUNT = "_DotCount";

		public const string SHADER_PROPERTY_DOTSNAP = "_DotSnap";

		public const string SHADER_PROPERTY_ZTEST = "_ZTest";

		public const string SHADER_PROPERTY_WORLD_SIZE = "_WorldSize";

		private static readonly HashSet<int> s_RegisteredMaterialIDs = new HashSet<int>();

		private static Material s_DefaultInWorld;

		private static Material s_DefaultInWorldFaded;

		private static Material s_DefaultOverlay;

		private static Material s_DefaultOverlayFaded;

		private static Material s_DefaultBehindWorld;

		private static Material s_DefaultBehindWorldFaded;

		public static Shader SHADER_UI_FIG { get; private set; }

		public static int ID_SHADER_PROPERTY_OPACITY { get; private set; }

		public static int ID_SHADER_PROPERTY_SOFTNESS { get; private set; }

		public static int ID_SHADER_PROPERTY_DOTCOUNT { get; private set; }

		public static int ID_SHADER_PROPERTY_DOTSNAP { get; private set; }

		public static int ID_SHADER_PROPERTY_ZTEST { get; private set; }

		public static int ID_SHADER_PROPERTY_WORLD_SIZE { get; private set; }

		public static Material DefaultInWorld
		{
			get
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				if ((Object)(object)s_DefaultInWorld != (Object)null)
				{
					return s_DefaultInWorld;
				}
				SetupShaderAndCacheProperties();
				s_DefaultInWorld = new Material(SHADER_UI_FIG);
				((Object)(object)s_DefaultInWorld).DoNotDestroyAndSetHideFlags();
				SetOpacity(s_DefaultInWorld, 1f);
				SetSoftness(s_DefaultInWorld, 0f);
				SetDotCount(s_DefaultInWorld, 100f);
				SetDotSnap(s_DefaultInWorld, 0f);
				SetRenderMode(s_DefaultInWorld, Render.InWorld);
				SetWorldSize(s_DefaultInWorld, 0f);
				RegisterFigMaterial(s_DefaultInWorld);
				return s_DefaultInWorld;
			}
		}

		public static Material DefaultInWorldFaded
		{
			get
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				if ((Object)(object)s_DefaultInWorldFaded != (Object)null)
				{
					return s_DefaultInWorldFaded;
				}
				SetupShaderAndCacheProperties();
				s_DefaultInWorldFaded = new Material(s_DefaultInWorld);
				((Object)(object)s_DefaultInWorldFaded).DoNotDestroyAndSetHideFlags();
				SetOpacity(s_DefaultInWorldFaded, 0.2f);
				RegisterFigMaterial(s_DefaultInWorldFaded);
				return s_DefaultInWorldFaded;
			}
		}

		public static Material DefaultOverlay
		{
			get
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				if ((Object)(object)s_DefaultOverlay != (Object)null)
				{
					return s_DefaultOverlay;
				}
				SetupShaderAndCacheProperties();
				s_DefaultOverlay = new Material(DefaultInWorld);
				((Object)(object)s_DefaultOverlay).DoNotDestroyAndSetHideFlags();
				SetRenderMode(s_DefaultOverlay, Render.Always);
				RegisterFigMaterial(s_DefaultOverlay);
				return s_DefaultOverlay;
			}
		}

		public static Material DefaultOverlayFaded
		{
			get
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				if ((Object)(object)s_DefaultOverlayFaded != (Object)null)
				{
					return s_DefaultOverlayFaded;
				}
				SetupShaderAndCacheProperties();
				s_DefaultOverlayFaded = new Material(DefaultOverlay);
				((Object)(object)s_DefaultOverlayFaded).DoNotDestroyAndSetHideFlags();
				SetOpacity(s_DefaultOverlayFaded, 0.2f);
				RegisterFigMaterial(s_DefaultOverlayFaded);
				return s_DefaultOverlayFaded;
			}
		}

		public static Material DefaultBehindWorld
		{
			get
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				if ((Object)(object)s_DefaultBehindWorld != (Object)null)
				{
					return s_DefaultBehindWorld;
				}
				SetupShaderAndCacheProperties();
				s_DefaultBehindWorld = new Material(DefaultInWorld);
				((Object)(object)s_DefaultBehindWorld).DoNotDestroyAndSetHideFlags();
				SetRenderMode(s_DefaultBehindWorld, Render.BehindWorld);
				RegisterFigMaterial(s_DefaultBehindWorld);
				return s_DefaultBehindWorld;
			}
		}

		public static Material DefaultBehindWorldFaded
		{
			get
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				if ((Object)(object)s_DefaultBehindWorldFaded != (Object)null)
				{
					return s_DefaultBehindWorldFaded;
				}
				SetupShaderAndCacheProperties();
				s_DefaultBehindWorldFaded = new Material(DefaultBehindWorld);
				((Object)(object)s_DefaultBehindWorldFaded).DoNotDestroyAndSetHideFlags();
				SetOpacity(s_DefaultBehindWorldFaded, 0.2f);
				RegisterFigMaterial(s_DefaultBehindWorldFaded);
				return s_DefaultBehindWorldFaded;
			}
		}

		internal static void SetupShaderAndCacheProperties()
		{
			if (ID_SHADER_PROPERTY_OPACITY == 0)
			{
				SHADER_UI_FIG = Shader.Find("UI/Fig");
				((Object)(object)SHADER_UI_FIG).DoNotDestroyAndSetHideFlags();
				ID_SHADER_PROPERTY_OPACITY = Shader.PropertyToID("_Opacity");
				ID_SHADER_PROPERTY_SOFTNESS = Shader.PropertyToID("_Softness");
				ID_SHADER_PROPERTY_DOTCOUNT = Shader.PropertyToID("_DotCount");
				ID_SHADER_PROPERTY_DOTSNAP = Shader.PropertyToID("_DotSnap");
				ID_SHADER_PROPERTY_ZTEST = Shader.PropertyToID("_ZTest");
				ID_SHADER_PROPERTY_WORLD_SIZE = Shader.PropertyToID("_WorldSize");
			}
		}

		public static Material SetOpacity(Material figMat, float opacity)
		{
			figMat.SetFloat(ID_SHADER_PROPERTY_OPACITY, opacity);
			return figMat;
		}

		public static Material SetSoftness(Material figMat, float softness)
		{
			figMat.SetFloat(ID_SHADER_PROPERTY_SOFTNESS, softness);
			return figMat;
		}

		public static Material SetDotCount(Material figMat, float dotCount)
		{
			figMat.SetFloat(ID_SHADER_PROPERTY_DOTCOUNT, dotCount);
			return figMat;
		}

		public static Material SetDotSnap(Material figMat, float dotSnap)
		{
			figMat.SetFloat(ID_SHADER_PROPERTY_DOTSNAP, dotSnap);
			return figMat;
		}

		public static Material SetRenderMode(Material figMat, Render mode)
		{
			figMat.SetFloat(ID_SHADER_PROPERTY_ZTEST, (float)mode);
			return figMat;
		}

		public static Material SetWorldSize(Material figMat, float worldSize)
		{
			figMat.SetFloat(ID_SHADER_PROPERTY_WORLD_SIZE, worldSize);
			return figMat;
		}

		public static void RegisterFigMaterial(Material mat)
		{
			int instanceID = ((Object)mat).GetInstanceID();
			if (!s_RegisteredMaterialIDs.Contains(instanceID))
			{
				s_RegisteredMaterialIDs.Add(instanceID);
				Fig.RegisterMaterial(mat);
			}
		}
	}
	public class UnityMainThreadDispatcher : MonoBehaviour
	{
		private static readonly Queue<Action> _executionQueue = new Queue<Action>();

		private static UnityMainThreadDispatcher _instance = null;

		public void Update()
		{
			lock (_executionQueue)
			{
				while (_executionQueue.Count > 0)
				{
					_executionQueue.Dequeue()();
				}
			}
		}

		public static void Enqueue(IEnumerator action)
		{
			lock (_executionQueue)
			{
				_executionQueue.Enqueue(delegate
				{
					((MonoBehaviour)_instance).StartCoroutine(CollectionExtensions.WrapToIl2Cpp(action));
				});
			}
		}

		public static void Enqueue(Action action)
		{
			Enqueue(_instance.ActionWrapper(action));
		}

		public static Task EnqueueAsync(Action action)
		{
			TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
			Enqueue(_instance.ActionWrapper(WrappedAction));
			return tcs.Task;
			void WrappedAction()
			{
				try
				{
					action();
					tcs.TrySetResult(result: true);
				}
				catch (Exception exception)
				{
					tcs.TrySetException(exception);
				}
			}
		}

		private IEnumerator ActionWrapper(Action a)
		{
			a();
			yield return null;
		}

		private void Awake()
		{
			if ((Object)(object)_instance == (Object)null)
			{
				_instance = this;
				Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
			}
		}

		private void OnDestroy()
		{
			_instance = null;
		}

		public void Init()
		{
			throw new NotImplementedException();
		}
	}
}
namespace Hikaria.AdminSystem.Utility
{
	public static class AdminUtils
	{
		private static LocalPlayerAgent _localPlayerAgent;

		public static LocalPlayerAgent LocalPlayerAgent
		{
			get
			{
				if ((Object)(object)_localPlayerAgent == (Object)null)
				{
					PlayerAgent localPlayerAgent = PlayerManager.GetLocalPlayerAgent();
					_localPlayerAgent = ((localPlayerAgent != null) ? ((Il2CppObjectBase)localPlayerAgent).TryCast<LocalPlayerAgent>() : null);
				}
				return _localPlayerAgent;
			}
		}

		public static bool TryGetPlayerAgentBySlotIndex(int slot, out PlayerAgent player)
		{
			slot--;
			if (!PlayerManager.TryGetPlayerAgent(ref slot, ref player))
			{
				return false;
			}
			return true;
		}

		public static T CopyProperties<T>(T source, T target)
		{
			PropertyInfo[] properties = source.GetType().GetProperties();
			foreach (PropertyInfo sourceProp in properties)
			{
				if (!target.GetType().GetProperties().Any((PropertyInfo targetProp) => targetProp.Name == sourceProp.Name && targetProp.GetType() == sourceProp.GetType() && targetProp.CanWrite))
				{
					continue;
				}
				object value = sourceProp.GetValue(source);
				PropertyInfo property = target.GetType().GetProperty(sourceProp.Name);
				if (property.PropertyType != typeof(Il2CppObjectBase) || property.PropertyType != typeof(Object))
				{
					if (property.PropertyType.IsByRef)
					{
						property.SetValue(target, CopyProperties(value, new object()));
					}
					else
					{
						property.SetValue(target, value);
					}
				}
			}
			return target;
		}

		public static bool CanFireHitObject(Vector3 sourcePos, GameObject targetObj)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			RaycastHit val = default(RaycastHit);
			if (Physics.Raycast(sourcePos, targetObj.transform.position - sourcePos, ref val, Vector3.Distance(targetObj.transform.position, sourcePos), LayerManager.MASK_BULLETWEAPON_RAY))
			{
				return ((RaycastHit)(ref val)).transform.IsChildOf(targetObj.gameObject.transform);
			}
			return false;
		}

		public static bool CanSeeEnemyPlus(Vector3 sourcePos, EnemyAgent enemy)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			RaycastHit val = default(RaycastHit);
			foreach (Dam_EnemyDamageLimb item in (Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)enemy.Damage.DamageLimbs)
			{
				if (!((Object)(object)item == (Object)null) && !Physics.Raycast(sourcePos, item.DamageTargetPos - sourcePos, ref val, Vector3.Distance(item.DamageTargetPos, sourcePos), LayerManager.MASK_WORLD))
				{
					return true;
				}
			}
			return false;
		}
	}
	internal static class Logs
	{
		private static IArchiveLogger _logger;

		private static IArchiveLogger Logger => _logger ?? (_logger = LoaderWrapper.CreateLoggerInstance("Hikaria.AdminSystem", ConsoleColor.White));

		public static void LogDebug(object data)
		{
			Logger.Debug(data.ToString());
		}

		public static void LogError(object data)
		{
			Logger.Error(data.ToString());
		}

		public static void LogInfo(object data)
		{
			Logger.Info(data.ToString());
		}

		public static void LogMessage(object data)
		{
			Logger.Msg(ConsoleColor.White, data.ToString());
		}

		public static void LogWarning(object data)
		{
			Logger.Warning(data.ToString());
		}

		public static void LogNotice(object data)
		{
			Logger.Notice(data.ToString());
		}

		public static void LogSuccess(object data)
		{
			Logger.Success(data.ToString());
		}

		public static void LogException(Exception ex)
		{
			Logger.Exception(ex);
		}
	}
}
namespace Hikaria.AdminSystem.Suggestions.Suggestors
{
	public class FogSettingsDataBlockIDSuggestor : GameDataBlockIDSuggestorBase<FogSettingsDataBlock>
	{
	}
	public sealed class ItemDataBlockNameSuggestor : GameDataBlockNameSuggestorBase<ItemDataBlock>
	{
	}
}
namespace Hikaria.AdminSystem.Suggestions.Suggestors.Tags
{
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public struct ZoneAliasTag : IQcSuggestorTag
	{
	}
}
namespace Hikaria.AdminSystem.Suggestions.Suggestors.Attributes
{
	public sealed class FogSettingsDataBlockIDAttribute : SuggestorTagAttribute
	{
		private readonly IQcSuggestorTag[] _tags = (IQcSuggestorTag[])(object)new IQcSuggestorTag[1] { (IQcSuggestorTag)(object)default(GameDataBlockIDTag<FogSettingsDataBlock>) };

		public override IQcSuggestorTag[] GetSuggestorTags()
		{
			return _tags;
		}
	}
	public sealed class ItemDataBlockNameAttribute : SuggestorTagAttribute
	{
		private readonly IQcSuggestorTag[] _tags = (IQcSuggestorTag[])(object)new IQcSuggestorTag[1] { (IQcSuggestorTag)(object)default(GameDataBlockNameTag<ItemDataBlock>) };

		public override IQcSuggestorTag[] GetSuggestorTags()
		{
			return _tags;
		}
	}
	public sealed class ZoneAliasAttribute : SuggestorTagAttribute
	{
		private readonly IQcSuggestorTag[] _tags = (IQcSuggestorTag[])(object)new IQcSuggestorTag[1] { (IQcSuggestorTag)(object)default(ZoneAliasTag) };

		public override IQcSuggestorTag[] GetSuggestorTags()
		{
			return _tags;
		}
	}
}
namespace Hikaria.AdminSystem.Suggestion
{
	public sealed class GameDataBlockIDSuggestion<T> : IQcSuggestion where T : GameDataBlockBase<T>
	{
		private readonly uint _id;

		private readonly string _completion;

		private readonly string _secondarySignature;

		public string FullSignature => _id.ToString();

		public string PrimarySignature => _id.ToString();

		public string SecondarySignature => _secondarySignature;

		public GameDataBlockIDSuggestion(uint id, GameDataBlockBase<T> block)
		{
			_id = id;
			_secondarySignature = string.Empty;
			if (block != null)
			{
				_secondarySignature = " " + block.name;
			}
			_completion = _id.ToString();
		}

		public bool MatchesPrompt(string prompt)
		{
			return prompt == _id.ToString();
		}

		public string GetCompletion(string prompt)
		{
			return _completion;
		}

		public string GetCompletionTail(string prompt)
		{
			return string.Empty;
		}

		public SuggestionContext? GetInnerSuggestionContext(SuggestionContext context)
		{
			return null;
		}
	}
	public sealed class GameDataBlockNameSuggestion<T> : IQcSuggestion where T : GameDataBlockBase<T>
	{
		private readonly string _name;

		private readonly string _completion;

		private readonly string _secondarySignature;

		public string FullSignature => _name;

		public string PrimarySignature => _name;

		public string SecondarySignature => _secondarySignature;

		public GameDataBlockNameSuggestion(string name, GameDataBlockBase<T> block)
		{
			_name = name;
			_secondarySignature = string.Empty;
			if (block != null)
			{
				_secondarySignature = $" [{block.persistentID}]";
			}
			_completion = _name;
		}

		public bool MatchesPrompt(string prompt)
		{
			return prompt == _name;
		}

		public string GetCompletion(string prompt)
		{
			return _completion;
		}

		public string GetCompletionTail(string prompt)
		{
			return string.Empty;
		}

		public SuggestionContext? GetInnerSuggestionContext(SuggestionContext context)
		{
			return null;
		}
	}
	public sealed class PlayerSlotIndexSuggestion : IQcSuggestion
	{
		private readonly int _slot;

		private readonly string _completion;

		private readonly string _secondarySignature;

		public string FullSignature => _slot.ToString();

		public string PrimarySignature => _slot.ToString();

		public string SecondarySignature => _secondarySignature;

		public PlayerSlotIndexSuggestion(int slot, PlayerAgent player)
		{
			_slot = slot;
			if ((Object)(object)player != (Object)null)
			{
				_secondarySignature = " " + PlayerNameExtentions.GetColoredName(player, (string)null);
			}
			else
			{
				_secondarySignature = string.Empty;
			}
			_completion = _slot.ToString();
		}

		public bool MatchesPrompt(string prompt)
		{
			return prompt == _slot.ToString();
		}

		public string GetCompletion(string prompt)
		{
			return _completion;
		}

		public string GetCompletionTail(string prompt)
		{
			return string.Empty;
		}

		public SuggestionContext? GetInnerSuggestionContext(SuggestionContext context)
		{
			return null;
		}
	}
}
namespace Hikaria.AdminSystem.Suggestion.Suggestors
{
	public sealed class EnemyDataBlockIDSuggestor : GameDataBlockIDSuggestorBase<EnemyDataBlock>
	{
	}
	public sealed class EnemyDataBlockNameSuggestor : GameDataBlockNameSuggestorBase<EnemyDataBlock>
	{
	}
	public abstract class GameDataBlockIDSuggestorBase<TBlock> : BasicCachedQcSuggestor<uint> where TBlock : GameDataBlockBase<TBlock>
	{
		protected override bool CanProvideSuggestions(SuggestionContext context, SuggestorOptions options)
		{
			return ((SuggestionContext)(ref context)).HasTag<GameDataBlockIDTag<TBlock>>();
		}

		protected override IQcSuggestion ItemToSuggestion(uint item)
		{
			return (IQcSuggestion)(object)new GameDataBlockIDSuggestion<TBlock>(item, GameDataBlockBase<TBlock>.GetBlock(item));
		}

		protected override IEnumerable<uint> GetItems(SuggestionContext context, SuggestorOptions options)
		{
			return (IEnumerable<uint>)GameDataBlockBase<TBlock>.GetAllPersistentIDs();
		}
	}
	public abstract class GameDataBlockNameSuggestorBase<TBlock> : BasicCachedQcSuggestor<string> where TBlock : GameDataBlockBase<TBlock>
	{
		protected override bool CanProvideSuggestions(SuggestionContext context, SuggestorOptions options)
		{
			return ((SuggestionContext)(ref context)).HasTag<GameDataBlockNameTag<TBlock>>();
		}

		protected override IQcSuggestion ItemToSuggestion(string item)
		{
			TBlock block = GameDataBlockBase<TBlock>.GetBlock(item);
			return (IQcSuggestion)(object)new GameDataBlockNameSuggestion<TBlock>(item, block);
		}

		protected override IEnumerable<string> GetItems(SuggestionContext context, SuggestorOptions options)
		{
			return (IEnumerable<string>)GameDataBlockBase<TBlock>.GetAllNames();
		}
	}
	public sealed class ItemDataBlockIDSuggestor : GameDataBlockIDSuggestorBase<ItemDataBlock>
	{
	}
	public sealed class PlayerSlotIndexSuggestor : BasicQcSuggestor<int>
	{
		protected override bool CanProvideSuggestions(SuggestionContext context, SuggestorOptions options)
		{
			return ((SuggestionContext)(ref context)).HasTag<PlayerSlotIndexTag>();
		}

		protected override IQcSuggestion ItemToSuggestion(int item)
		{
			AdminUtils.TryGetPlayerAgentBySlotIndex(item + 1, out var player);
			return (IQcSuggestion)(object)new PlayerSlotIndexSuggestion(item + 1, player);
		}

		protected override IEnumerable<int> GetItems(SuggestionContext context, SuggestorOptions options)
		{
			List<int> list = new List<int>();
			Enumerator<PlayerAgent> enumerator = PlayerManager.PlayerAgentsInLevel.GetEnumerator();
			while (enumerator.MoveNext())
			{
				PlayerAgent current = enumerator.Current;
				list.Add(current.PlayerSlotIndex);
			}
			return list;
		}
	}
	public sealed class ZoneAliasSuggestor : BasicQcSuggestor<int>
	{
		protected override bool CanProvideSuggestions(SuggestionContext context, SuggestorOptions options)
		{
			return ((SuggestionContext)(ref context)).HasTag<ZoneAliasTag>();
		}

		protected override IQcSuggestion ItemToSuggestion(int item)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			return (IQcSuggestion)new RawSuggestion(item.ToString(), false);
		}

		protected override IEnumerable<int> GetItems(SuggestionContext context, SuggestorOptions options)
		{
			LG_Floor currentFloor = Builder.CurrentFloor;
			return ((currentFloor != null) ? (from zone in SharedUtils.ToSystemList<LG_Zone>(currentFloor.allZones)
				select zone.Alias) : null) ?? Array.Empty<int>();
		}
	}
}
namespace Hikaria.AdminSystem.Suggestion.Suggestors.Tags
{
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public struct GameDataBlockIDTag<T> : IQcSuggestorTag where T : GameDataBlockBase<T>
	{
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public struct GameDataBlockNameTag<T> : IQcSuggestorTag where T : GameDataBlockBase<T>
	{
	}
	[StructLayout(LayoutKind.Sequential, Size = 1)]
	public struct PlayerSlotIndexTag : IQcSuggestorTag
	{
	}
}
namespace Hikaria.AdminSystem.Suggestion.Suggestors.Attributes
{
	public sealed class EnemyDataBlockIDAttribute : SuggestorTagAttribute
	{
		private readonly IQcSuggestorTag[] _tags = (IQcSuggestorTag[])(object)new IQcSuggestorTag[1] { (IQcSuggestorTag)(object)default(GameDataBlockIDTag<EnemyDataBlock>) };

		public override IQcSuggestorTag[] GetSuggestorTags()
		{
			return _tags;
		}
	}
	public sealed class EnemyDataBlockNameAttribute : SuggestorTagAttribute
	{
		private readonly IQcSuggestorTag[] _tags = (IQcSuggestorTag[])(object)new IQcSuggestorTag[1] { (IQcSuggestorTag)(object)default(GameDataBlockNameTag<EnemyDataBlock>) };

		public override IQcSuggestorTag[] GetSuggestorTags()
		{
			return _tags;
		}
	}
	public sealed class ItemDataBlockIDAttribute : SuggestorTagAttribute
	{
		private readonly IQcSuggestorTag[] _tags = (IQcSuggestorTag[])(object)new IQcSuggestorTag[1] { (IQcSuggestorTag)(object)default(GameDataBlockIDTag<ItemDataBlock>) };

		public override IQcSuggestorTag[] GetSuggestorTags()
		{
			return _tags;
		}
	}
	public sealed class PlayerSlotIndexAttribute : SuggestorTagAttribute
	{
		private readonly IQcSuggestorTag[] _tags = (IQcSuggestorTag[])(object)new IQcSuggestorTag[1] { (IQcSuggestorTag)(object)default(PlayerSlotIndexTag) };

		public override IQcSuggestorTag[] GetSuggestorTags()
		{
			return _tags;
		}
	}
}
namespace Hikaria.AdminSystem.Managers
{
	public class EnemyDamageDataHelper : InitSingletonBase<EnemyDamageDataHelper>, IInitAfterGameDataInitialized, IInitializable
	{
		public struct EnemyDamageData
		{
			public uint Id { get; set; }

			public bool IsImmortal { get; set; }

			public Dictionary<int, float> Weakspots { get; set; }

			public Dictionary<int, float> Normalspots { get; set; }

			public Dictionary<int, float> Armorspots { get; set; }

			public Dictionary<int, float> RealArmorSpots { get; set; }

			public bool HasWeakSpot => Weakspots.Count > 0;

			public bool HasNormalSpot => Normalspots.Count > 0;

			public bool HasArmorSpot => Armorspots.Count > 0;

			public bool HasRealArmorSpot => RealArmorSpots.Count > 0;

			public EnemyDamageData()
			{
				Id = 0u;
				IsImmortal = false;
				Weakspots = new Dictionary<int, float>();
				Normalspots = new Dictionary<int, float>();
				Armorspots = new Dictionary<int, float>();
				RealArmorSpots = new Dictionary<int, float>();
			}
		}

		public static Dictionary<uint, EnemyDataBlock> EnemyDataBlockLookup { get; set; } = new Dictionary<uint, EnemyDataBlock>();


		public static Dictionary<uint, EnemyDamageData> EnemyDamageDataLookup { get; set; } = new Dictionary<uint, EnemyDamageData>();


		public static float ArmorMultiThreshold { get; set; } = 0.1f;


		public void Init()
		{
			EnemyDataBlockLookup.Clear();
			foreach (EnemyDataBlock item in GameDataBlockBase<EnemyDataBlock>.GetAllBlocksForEditor())
			{
				EnemyDataBlockLookup.Add(((GameDataBlockBase<EnemyDataBlock>)(object)item).persistentID, item);
			}
		}

		public static EnemyDamageData GetOrGenerateEnemyDamageData(EnemyAgent enemy)
		{
			if (!EnemyDamageDataLookup.TryGetValue(enemy.EnemyDataID, out var value))
			{
				return GenerateAndStoreEnemyDamageData(enemy);
			}
			return value;
		}

		private static EnemyDamageData GenerateAndStoreEnemyDamageData(EnemyAgent enemy)
		{
			//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_004a: Expected I4, but got Unknown
			EnemyDamageData enemyDamageData = new EnemyDamageData();
			enemyDamageData.Id = enemy.EnemyDataID;
			foreach (Dam_EnemyDamageLimb item in (Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)enemy.Damage.DamageLimbs)
			{
				eLimbDamageType type = item.m_type;
				switch ((int)type)
				{
				case 2:
					if (item.m_armorDamageMulti <= ArmorMultiThreshold)
					{
						enemyDamageData.RealArmorSpots.Add(item.m_limbID, item.m_armorDamageMulti);
					}
					else
					{
						enemyDamageData.Armorspots.Add(item.m_limbID, item.m_armorDamageMulti);
					}
					break;
				case 1:
					enemyDamageData.Weakspots.Add(item.m_limbID, item.m_weakspotDamageMulti);
					break;
				case 0:
					enemyDamageData.Normalspots.Add(item.m_limbID, 1f);
					break;
				}
			}
			enemyDamageData.Armorspots = enemyDamageData.Armorspots.OrderByDescending((KeyValuePair<int, float> p) => p.Value).ToDictionary((KeyValuePair<int, float> p) => p.Key, (KeyValuePair<int, float> p) => p.Value);
			enemyDamageData.Weakspots = enemyDamageData.Weakspots.OrderByDescending((KeyValuePair<int, float> p) => p.Value).ToDictionary((KeyValuePair<int, float> p) => p.Key, (KeyValuePair<int, float> p) => p.Value);
			enemyDamageData.IsImmortal = enemyDamageData.RealArmorSpots.Count == ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)enemy.Damage.DamageLimbs).Count;
			EnemyDamageDataLookup.Add(enemy.EnemyDataID, enemyDamageData);
			return enemyDamageData;
		}

		public static void ClearGeneratedEnemyDamageData()
		{
			EnemyDamageDataLookup.Clear();
		}
	}
	public class TranslateHelper
	{
		public class EnemyIDNameData
		{
			public List<uint> IDs { get; set; }

			public string Name { get; set; }
		}

		public struct EnemyIDName
		{
			public List<uint> IDs { get; set; }

			public string Name { get; set; }
		}

		private static Dictionary<uint, string> EnemyID2NameLookup = new Dictionary<uint, string>();

		private static CustomSettings<List<EnemyIDNameData>> EnemyIDNames = new CustomSettings<List<EnemyIDNameData>>("EnemyIDNameLookup", new List<EnemyIDNameData>(), (Action<List<EnemyIDNameData>>)delegate(List<EnemyIDNameData> data)
		{
			EnemyID2NameLookup.Clear();
			foreach (EnemyIDNameData datum in data)
			{
				foreach (uint iD in datum.IDs)
				{
					EnemyID2NameLookup.TryAdd(iD, datum.Name);
				}
			}
		}, (LoadingTime)1, true);

		private static Dictionary<string, uint[]> EnemyName2ID = new Dictionary<string, uint[]>();

		public static string EnemyName(uint id)
		{
			if (!EnemyID2NameLookup.TryGetValue(id, out var value))
			{
				return $"{((GameDataBlockBase<EnemyDataBlock>)(object)GameDataBlockBase<EnemyDataBlock>.GetBlock(id)).name} [{id}]";
			}
			return value;
		}
	}
}
namespace Hikaria.AdminSystem.Features.Weapon
{
	[EnableFeatureByDefault]
	[DisallowInGameToggle]
	public class WeaponAutoAim : Feature
	{
		public class WeaponAutoAimSettings
		{
			[Localized]
			public enum AutoAimMode
			{
				Crosshair,
				Closest
			}

			[Localized]
			public enum AutoFireMode
			{
				Off,
				SemiAuto,
				FullyAuto
			}

			[FSDisplayName("启用自瞄")]
			public bool EnableAutoAim
			{
				get
				{
					return _enableAutoAim;
				}
				set
				{
					_enableAutoAim = value;
				}
			}

			[FSDisplayName("弹道修正")]
			public bool EnableTrajectoryRedirection { get; set; }

			[FSDisplayName("隔墙自瞄")]
			public bool WallHackAim { get; set; }

			[FSDisplayName("追踪子弹")]
			[FSDescription("仅适用于穿透子弹")]
			public bool MagicBullet { get; set; } = true;


			[FSDisplayName("追踪子弹忽略不可见")]
			public bool MagicBulletVisibleOnly { get; set; } = true;


			[FSDisplayName("追踪子弹最大修正角度")]
			public float MagicBulletMaxCorrectionAngle { get; set; } = 30f;


			[FSDisplayName("自瞄节点距离")]
			[FSDescription("默认为3个节点")]
			public int AutoAimNodeRange { get; set; } = 3;


			[FSDisplayName("自瞄模式")]
			[FSDescription("准心优先 或 近处优先")]
			public AutoAimMode AimMode { get; set; }

			[FSDisplayName("暂停自瞄按键")]
			[FSDescription("按下后可暂停自瞄,松开后恢复")]
			public KeyCode PauseAutoAimKey { get; set; } = (KeyCode)304;


			[FSDisplayName("反转暂停自瞄")]
			public bool ReversePauseAutoAim { get; set; }

			[FSDisplayName("自动开火模式")]
			public AutoFireMode AutoFire { get; set; }

			[FSDisplayName("自瞄范围半径")]
			[FSDescription("单位: 像素")]
			public float AimRadius { get; set; } = 540f;


			[FSDisplayName("全范围自瞄")]
			public bool IgnoreAimRadius { get; set; }

			[FSDisplayName("装甲部位检测阈值")]
			[FSDescription("默认值为0.1")]
			public float ArmorLimbDamageMultiThreshold
			{
				get
				{
					return EnemyDamageDataHelper.ArmorMultiThreshold;
				}
				set
				{
					EnemyDamageDataHelper.ArmorMultiThreshold = value;
					EnemyDamageDataHelper.ClearGeneratedEnemyDamageData();
				}
			}

			[FSHeader("颜色设置", true)]
			[FSDisplayName("目标通用颜色")]
			public SColor TargetedColor { get; set; } = new SColor(1.2f, 0.3f, 0.1f, (float?)1f);


			[FSDisplayName("目标弱点颜色")]
			public SColor TargetedWeakspotColor { get; set; } = new SColor(1.2f, 0.6f, 0f, (float?)1f);


			[FSDisplayName("无目标颜色")]
			public SColor UnTargetedColor { get; set; } = new SColor(0.3f, 0.1f, 0.1f, (float?)1f);


			[FSDisplayName("非活跃颜色")]
			public SColor PassiveDetection { get; set; } = new SColor(0.5f, 0.5f, 0.5f, (float?)0.5f);

		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private class BulletWeapon__OnWield__Patch
		{
			private static void Postfix(BulletWeapon __instance)
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Invalid comparison between Unknown and I4
				if (_enableAutoAim && (int)GameStateManager.Current.m_currentStateName == 10 && IsWeaponOwner(__instance))
				{
					WeaponAutoAimHandler weaponAutoAimHandler = ((Component)__instance).gameObject.GetComponent<WeaponAutoAimHandler>();
					if ((Object)(object)weaponAutoAimHandler == (Object)null)
					{
						weaponAutoAimHandler = ((Component)__instance).gameObject.AddComponent<WeaponAutoAimHandler>();
					}
					weaponAutoAimHandler.Setup(__instance, ((Item)__instance).Owner, ((Item)__instance).Owner.FPSCamera);
					((Behaviour)weaponAutoAimHandler).enabled = _enableAutoAim;
				}
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		public class BulletWeapon__OnUnWield__Patch
		{
			private static void Prefix(BulletWeapon __instance)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Invalid comparison between Unknown and I4
				if ((int)GameStateManager.Current.m_currentStateName == 10 && IsWeaponOwner(__instance))
				{
					WeaponAutoAimHandler component = ((Component)__instance).gameObject.GetComponent<WeaponAutoAimHandler>();
					if (!((Object)(object)component == (Object)null))
					{
						component.DoClear();
						((Behaviour)component).enabled = false;
					}
				}
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		public class PlayerEnemyCollision__FindNearbyEnemiesMovementReduction__Patch
		{
			private static bool Prefix(PlayerEnemyCollision __instance, Vector3 pos, ref float __result)
			{
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				if (!_enableAutoAim)
				{
					return true;
				}
				float num = 1f;
				if (((Agent)__instance.m_owner).CourseNode == null)
				{
					__result = num;
					return false;
				}
				__instance.m_enemies.Clear();
				AIG_CourseNode.GetEnemiesInNodes(((Agent)__instance.m_owner).CourseNode, Settings.AutoAimNodeRange, __instance.m_enemies);
				for (int i = 0; i < __instance.m_enemies.Count; i++)
				{
					EnemyAgent val = __instance.m_enemies[i];
					Vector3 val2 = val.Position - pos;
					if (((Agent)val).Alive && ((Vector3)(ref val2)).magnitude < val.EnemyBalancingData.EnemyCollisionRadius)
					{
						float enemyCollisionPlayerMovementReduction = val.EnemyBalancingData.EnemyCollisionPlayerMovementReduction;
						float num2 = num - enemyCollisionPlayerMovementReduction;
						float enemyCollisionMinimumMoveSpeedModifier = val.EnemyBalancingData.EnemyCollisionMinimumMoveSpeedModifier;
						num = Mathf.Min(num, Mathf.Max(num2, enemyCollisionMinimumMoveSpeedModifier));
					}
				}
				__result = num;
				return false;
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private class Shotgun__Fire__Patch
		{
			private static void Prefix(Shotgun __instance)
			{
				if (_enableAutoAim && ((Agent)((Item)__instance).Owner).IsLocallyOwned)
				{
					IsLocalShotgunFireShots = true;
				}
			}

			private static void Postfix(Shotgun __instance)
			{
				if (_enableAutoAim && ((Agent)((Item)__instance).Owner).IsLocallyOwned)
				{
					IsLocalShotgunFireShots = false;
				}
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		public class Weapon__CastWeaponRay__Patch
		{
			public static Type[] ParameterTypes()
			{
				return new Type[4]
				{
					typeof(Transform),
					typeof(WeaponHitData).MakeByRefType(),
					typeof(Vector3),
					typeof(int)
				};
			}

			private static void Prefix(ref WeaponHitData weaponRayData, Vector3 originPos)
			{
				//IL_00d5: 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_012d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0132: Unknown result type (might be due to invalid IL or missing references)
				//IL_0172: Unknown result type (might be due to invalid IL or missing references)
				//IL_0177: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: 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)
				//IL_0181: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
				if (!_enableAutoAim)
				{
					return;
				}
				if (IsLocalShotgunFireShots)
				{
					weaponRayData.owner = (PlayerAgent)(object)AdminUtils.LocalPlayerAgent;
				}
				else
				{
					PlayerAgent owner = weaponRayData.owner;
					if (owner == null || !((Agent)owner).IsLocallyOwned)
					{
						return;
					}
				}
				ItemEquippable wieldedItem = weaponRayData.owner.Inventory.WieldedItem;
				ArchetypeDataBlock val = ((wieldedItem != null) ? wieldedItem.ArchetypeData : null) ?? null;
				if (val == null)
				{
					return;
				}
				if (!WeaponAutoAimHandler.TryGetInstance(((GameDataBlockBase<ArchetypeDataBlock>)(object)val).persistentID, out var weaponAutoAim))
				{
					weaponAutoAim = ((Component)weaponRayData.owner.Inventory.WieldedItem).GetComponent<WeaponAutoAimHandler>();
					if ((Object)(object)weaponAutoAim == (Object)null)
					{
						return;
					}
					WeaponAutoAimHandler.Register(((GameDataBlockBase<ArchetypeDataBlock>)(object)val).persistentID, weaponAutoAim);
				}
				if (!Settings.EnableTrajectoryRedirection || weaponAutoAim.PauseAutoAim)
				{
					return;
				}
				bool flag = false;
				if (!weaponAutoAim.HasTarget)
				{
					if (!IsLocalShotgunFireShots && (!Settings.MagicBullet || !weaponAutoAim.IsPiercingBullet))
					{
						return;
					}
					weaponAutoAim.ForceUpdate(originPos);
					if (!weaponAutoAim.HasTarget)
					{
						return;
					}
					flag = true;
				}
				if (!flag && (IsLocalShotgunFireShots || (Settings.MagicBullet && weaponAutoAim.IsPiercingBullet)))
				{
					weaponAutoAim.ForceUpdate(originPos);
				}
				if (weaponAutoAim.HasTarget && (InputMapper.GetButtonKeyMouse((InputAction)7, (eFocusState)4) || Settings.AutoFire == WeaponAutoAimSettings.AutoFireMode.FullyAuto))
				{
					Vector3 fireDir = weaponRayData.fireDir;
					weaponRayData.randomSpread = 0f;
					weaponRayData.angOffsetX = 0f;
					weaponRayData.angOffsetY = 0f;
					weaponRayData.maxRayDist = 2000f;
					if (Settings.EnableTrajectoryRedirection)
					{
						WeaponHitData obj = weaponRayData;
						Vector3 val2 = weaponAutoAim.AimTargetPos - originPos;
						obj.fireDir = ((Vector3)(ref val2)).normalized;
					}
					if (!IsLocalShotgunFireShots)
					{
						weaponAutoAim.TempIgnoreTargetEnemy();
					}
					weaponAutoAim.SetLastFireDir(IsLocalShotgunFireShots ? fireDir : weaponRayData.fireDir);
				}
			}
		}

		public class WeaponAutoAimHandler : MonoBehaviour
		{
			private HashSet<EnemyAgent> IgnoredEnemies = new HashSet<EnemyAgent>();

			private GameObject m_ReticleHolder;

			private CrosshairHitIndicator m_Reticle;

			private EnemyAgent m_Target;

			private Dam_EnemyDamageLimb m_TargetLimb;

			private Camera m_PlayerCamera;

			private bool m_HasTarget;

			private BulletWeapon m_BulletWeapon;

			private PlayerAgent m_Owner;

			private Vector3 m_TargetedEulerAngles = new Vector3(0f, 0f, 45f);

			private float fireTimer;

			private Vector3 LastFireDir = Vector3.zero;

			private float updateTick = 0.05f;

			public Vector3 AimTargetPos
			{
				get
				{
					//IL_0012: 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_0026: Unknown result type (might be due to invalid IL or missing references)
					if (!_enableAutoAim)
					{
						return m_Owner.FPSCamera.CameraRayPos;
					}
					if (HasTarget)
					{
						return m_TargetLimb.DamageTargetPos;
					}
					return m_Owner.FPSCamera.CameraRayPos;
				}
			}

			public static WeaponAutoAimHandler Current { get; private set; }

			public List<EnemyAgent> AroundEnemies { get; private set; } = new List<EnemyAgent>();


			public bool IsPiercingBullet
			{
				get
				{
					ArchetypeDataBlock archetypeData = ((ItemEquippable)m_BulletWeapon).ArchetypeData;
					if (archetypeData == null)
					{
						return false;
					}
					return archetypeData.PiercingBullets;
				}
			}

			public static Dictionary<uint, WeaponAutoAimHandler> AutoAimInstances { get; private set; } = new Dictionary<uint, WeaponAutoAimHandler>();


			public static HashSet<WeaponAutoAimHandler> AllAutoAimInstances { get; private set; } = new HashSet<WeaponAutoAimHandler>();


			public bool HasTarget
			{
				get
				{
					if ((Object)(object)m_Target != (Object)null && ((Agent)m_Target).Alive)
					{
						return (Object)(object)m_TargetLimb != (Object)null;
					}
					return false;
				}
			}

			public bool PauseAutoAim
			{
				get
				{
					//IL_0011: 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)
					if ((!Settings.ReversePauseAutoAim && Input.GetKey(Settings.PauseAutoAimKey)) || (Settings.ReversePauseAutoAim && !Input.GetKey(Settings.PauseAutoAimKey)))
					{
						return Settings.AutoFire == WeaponAutoAimSettings.AutoFireMode.Off;
					}
					return false;
				}
			}

			public static void Register(uint persistentID, WeaponAutoAimHandler weaponAutoAim)
			{
				AutoAimInstances.Add(persistentID, weaponAutoAim);
			}

			public static void Unregister(uint persistentID)
			{
				AutoAimInstances.Remove(persistentID);
			}

			public static bool TryGetInstance(uint persistentID, out WeaponAutoAimHandler weaponAutoAim)
			{
				return AutoAimInstances.TryGetValue(persistentID, out weaponAutoAim);
			}

			private void Awake()
			{
				Current = this;
				AllAutoAimInstances.Add(this);
			}

			private void OnDestroy()
			{
				AllAutoAimInstances.Remove(this);
				if ((Object)(object)m_Reticle != (Object)null)
				{
					((GuiLayerComp)m_Reticle).SetVisible(false, false);
				}
				m_HasTarget = false;
				m_Target = null;
				SharedUtils.SafeDestroy((Component)(object)m_Reticle);
				SharedUtils.SafeDestroy(m_ReticleHolder);
			}

			public void Setup(BulletWeapon weapon, PlayerAgent owner, FPSCamera camera)
			{
				if ((Object)(object)m_Owner == (Object)null)
				{
					m_BulletWeapon = weapon;
					m_Owner = owner;
					m_PlayerCamera = ((Component)camera).gameObject.GetComponent<Camera>();
					SetupReticle();
				}
				((Behaviour)this).enabled = _enableAutoAim;
			}

			public void DoClear()
			{
				if ((Object)(object)m_Reticle != (Object)null)
				{
					CrosshairHitIndicator reticle = m_Reticle;
					if (reticle != null)
					{
						((GuiLayerComp)reticle).SetVisible(false, false);
					}
				}
				m_HasTarget = false;
				m_Target = null;
				Unregister(((GameDataBlockBase<ArchetypeDataBlock>)(object)((ItemEquippable)m_BulletWeapon).ArchetypeData).persistentID);
			}

			public void DoAfterLevelClear()
			{
				DoClear();
				SharedUtils.SafeDestroy((Component)(object)m_Reticle);
				SharedUtils.SafeDestroy(m_ReticleHolder);
				SharedUtils.SafeDestroy((Component)(object)this);
			}

			private void SetupReticle()
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Expected O, but got Unknown
				//IL_0060: 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_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				m_ReticleHolder = new GameObject();
				m_ReticleHolder.transform.SetParent(((GuiLayer)GuiManager.CrosshairLayer).CanvasTrans);
				m_Reticle = Object.Instantiate<CrosshairHitIndicator>(GuiManager.CrosshairLayer.m_hitIndicatorFriendly, m_ReticleHolder.transform);
				((Object)m_Reticle).name = "AutoAimIndicator";
				((Component)m_Reticle).transform.localScale = Vector3.zero;
				SetVFX(SColorExtensions.ToUnityColor(Settings.TargetedColor), m_TargetedEulerAngles);
				((Component)m_Reticle).transform.localEulerAngles = m_TargetedEulerAngles;
			}

			private void Update()
			{
				//IL_000c: 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_0035: Unknown result type (might be due to invalid IL or missing references)
				UpdateTargetEnemy(m_Owner.FPSCamera.Position);
				UpdateColor();
				UpdateAutoFire();
				IgnoredEnemies.Clear();
				LastFireDir = Vector3.zero;
			}

			public void ForceUpdate(Vector3 sourcePos)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				if (!PauseAutoAim)
				{
					UpdateTargetEnemy(sourcePos, force: true);
					UpdateColor();
				}
			}

			private void UpdateTargetEnemy(Vector3 sourcePos, bool force = false)
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: 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_0176: 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)
				if (PauseAutoAim)
				{
					m_Target = null;
					m_TargetLimb = null;
					m_HasTarget = false;
					((Component)m_Reticle).transform.localScale = Vector3.zero;
					return;
				}
				if ((Object)(object)m_Target != (Object)null && (Object)(object)m_TargetLimb != (Object)null)
				{
					m_ReticleHolder.transform.position = m_PlayerCamera.WorldToScreenPoint(m_TargetLimb.DamageTargetPos);
					if (!m_HasTarget)
					{
						((Component)m_Reticle).transform.localScale = Vector3.one * 2f;
						((Component)m_Reticle).transform.localEulerAngles = m_TargetedEulerAngles;
						((GuiLayerComp)m_Reticle).AnimateScale(1.5f, 0.13f);
						m_HasTarget = true;
					}
				}
				else
				{
					Transform transform = ((Component)m_Reticle).transform;
					transform.localEulerAngles += new Vector3(0f, 0f, 5f);
				}
				if (m_HasTarget && ((Object)(object)m_Target == (Object)null || (Object)(object)m_TargetLimb == (Object)null))
				{
					((GuiLayerComp)m_Reticle).AnimateScale(0f, 0.5f);
					m_HasTarget = false;
				}
				updateTick += Time.deltaTime;
				if (updateTick >= 0.04f || force)
				{
					UpdateAroundEnemy(sourcePos);
					UpdateBestEnemyTarget(sourcePos);
					UpdateTargetEnemyLimb(sourcePos);
					updateTick = 0f;
				}
			}

			private void UpdateColor()
			{
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Invalid comparison between Unknown and I4
				//IL_00af: 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_00cf: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: Unknown result type (might be due to invalid IL or missing references)
				//IL_0119: Unknown result type (might be due to invalid IL or missing references)
				//IL_012e: Unknown result type (might be due to invalid IL or missing references)
				if (!PauseAutoAim)
				{
					if (m_HasTarget)
					{
						m_Reticle.m_hitColor = (((Object)(object)m_TargetLimb == (Object)null) ? SColorExtensions.ToUnityColor(Settings.UnTargetedColor) : (((int)m_TargetLimb.m_type == 1) ? SColorExtensions.ToUnityColor(Settings.TargetedWeakspotColor) : SColorExtensions.ToUnityColor(Settings.TargetedColor)));
					}
					else
					{
						m_Reticle.m_hitColor = SColorExtensions.ToUnityColor(Settings.UnTargetedColor);
					}
					if (!InputMapper.GetButtonKeyMouse((InputAction)7, (eFocusState)4) || ((ItemEquippable)m_BulletWeapon).GetCurrentClip() <= 0 || PauseAutoAim)
					{
						m_ReticleHolder.transform.localScale = Vector3.one * 0.5f;
						Transform transform = m_ReticleHolder.transform;
						transform.localEulerAngles += new Vector3(0f, 0f, 2f);
						m_Reticle.m_hitColor = SColorExtensions.ToUnityColor(Settings.PassiveDetection);
					}
					else
					{
						m_ReticleHolder.transform.localScale = Vector3.one;
						m_ReticleHolder.transform.localEulerAngles = Vector3.zero;
					}
					m_Reticle.UpdateColorsWithAlphaMul(m_Reticle.m_hitColor.a);
				}
			}

			private void SetVFX(Color color, Vector3 euler)
			{
				//IL_000b: 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)
				((Component)m_Reticle).transform.localEulerAngles = euler;
				m_Reticle.m_hitColor = color;
				m_Reticle.UpdateColorsWithAlphaMul(1f);
			}

			private void UpdateTargetEnemyLimb(Vector3 sourcePos)
			{
				//IL_0114: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0191: Unknown result type (might be due to invalid IL or missing references)
				//IL_020e: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)m_Target == (Object)null || PauseAutoAim)
				{
					m_TargetLimb = null;
					return;
				}
				EnemyDamageDataHelper.EnemyDamageData orGenerateEnemyDamageData = EnemyDamageDataHelper.GetOrGenerateEnemyDamageData(m_Target);
				if (orGenerateEnemyDamageData.IsImmortal)
				{
					if (OneShotKill.OneShotKillLookup.TryGetValue(SNet.LocalPlayer.Lookup, out var value) && value)
					{
						foreach (KeyValuePair<int, float> armorspot in orGenerateEnemyDamageData.Armorspots)
						{
							Dam_EnemyDamageLimb val = ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)m_Target.Damage.DamageLimbs)[armorspot.Key];
							if (!val.IsDestroyed && AdminUtils.CanFireHitObject(sourcePos, ((Component)val).gameObject))
							{
								m_TargetLimb = val;
								return;
							}
						}
					}
					m_TargetLimb = null;
					return;
				}
				if (orGenerateEnemyDamageData.HasWeakSpot)
				{
					foreach (KeyValuePair<int, float> weakspot in orGenerateEnemyDamageData.Weakspots)
					{
						Dam_EnemyDamageLimb val2 = ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)m_Target.Damage.DamageLimbs)[weakspot.Key];
						if (!val2.IsDestroyed && AdminUtils.CanFireHitObject(sourcePos, ((Component)val2).gameObject))
						{
							m_TargetLimb = val2;
							return;
						}
					}
				}
				if (orGenerateEnemyDamageData.HasNormalSpot)
				{
					foreach (KeyValuePair<int, float> normalspot in orGenerateEnemyDamageData.Normalspots)
					{
						Dam_EnemyDamageLimb val3 = ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)m_Target.Damage.DamageLimbs)[normalspot.Key];
						if (!val3.IsDestroyed && AdminUtils.CanFireHitObject(sourcePos, ((Component)val3).gameObject))
						{
							m_TargetLimb = val3;
							return;
						}
					}
				}
				if (orGenerateEnemyDamageData.HasArmorSpot)
				{
					foreach (KeyValuePair<int, float> armorspot2 in orGenerateEnemyDamageData.Armorspots)
					{
						Dam_EnemyDamageLimb val4 = ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)m_Target.Damage.DamageLimbs)[armorspot2.Key];
						if (!val4.IsDestroyed && AdminUtils.CanFireHitObject(sourcePos, ((Component)val4).gameObject))
						{
							m_TargetLimb = val4;
							return;
						}
					}
				}
				bool value2 = default(bool);
				if (orGenerateEnemyDamageData.HasRealArmorSpot && OneShotKill.OneShotKillLookup.TryGetValue(SNet.LocalPlayer.Lookup, out value2) && value2)
				{
					foreach (KeyValuePair<int, float> realArmorSpot in orGenerateEnemyDamageData.RealArmorSpots)
					{
						Dam_EnemyDamageLimb val5 = ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)m_Target.Damage.DamageLimbs)[realArmorSpot.Key];
						if (!val5.IsDestroyed && AdminUtils.CanFireHitObject(sourcePos, ((Component)val5).gameObject))
						{
							m_TargetLimb = val5;
							return;
						}
					}
				}
				m_TargetLimb = null;
			}

			private void UpdateAutoFire(bool force = false)
			{
				if (PauseAutoAim)
				{
					return;
				}
				if (HasTarget && ((Settings.AutoFire == WeaponAutoAimSettings.AutoFireMode.SemiAuto && InputMapper.GetButtonKeyMouse((InputAction)7, (eFocusState)4)) || Settings.AutoFire == WeaponAutoAimSettings.AutoFireMode.FullyAuto) && ((ItemEquippable)m_BulletWeapon).GetCurrentClip() > 0)
				{
					fireTimer -= Time.deltaTime;
					if (fireTimer <= 0f || force)
					{
						m_BulletWeapon.Fire(true);
						m_BulletWeapon.TriggerSingleFireAudio();
						fireTimer = ((ItemEquippable)m_BulletWeapon).ArchetypeData.ShotDelay;
					}
				}
				else
				{
					fireTimer = 0f;
				}
			}

			private void UpdateBestEnemyTarget(Vector3 sourcePos)
			{
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Unknown result type (might be due to invalid IL or missing references)
				//IL_0108: Unknown result type (might be due to invalid IL or missing references)
				//IL_0109: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0155: Unknown result type (might be due to invalid IL or missing references)
				//IL_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_0172: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Unknown result type (might be due to invalid IL or missing references)
				//IL_0187: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a3: 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_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_01ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
				if (AroundEnemies == null || AroundEnemies.Count == 0 || PauseAutoAim)
				{
					m_Target = null;
					return;
				}
				EnemyAgent target = null;
				float num = 100000f;
				Vector2 val2 = default(Vector2);
				Vector2 val4 = default(Vector2);
				foreach (EnemyAgent aroundEnemy in AroundEnemies)
				{
					if (IsPiercingBullet && Settings.MagicBullet && LastFireDir != Vector3.zero && Math.Abs(Vector3.Angle(((Agent)aroundEnemy).AimTarget.position - sourcePos, LastFireDir)) > Settings.MagicBulletMaxCorrectionAngle)
					{
						continue;
					}
					WeaponAutoAimSettings.AutoAimMode aimMode = Settings.AimMode;
					if (aimMode == WeaponAutoAimSettings.AutoAimMode.Crosshair || aimMode != WeaponAutoAimSettings.AutoAimMode.Closest)
					{
						Vector3 val = ((CameraController)m_Owner.FPSCamera).m_camera.WorldToScreenPoint(((Agent)aroundEnemy).AimTarget.position);
						((Vector2)(ref val2))..ctor((float)(Screen.width / 2), (float)(Screen.height / 2));
						float num2 = Vector3.Distance(val, Vector2.op_Implicit(val2));
						_ = ((Agent)aroundEnemy).AimTarget.position - sourcePos;
						if ((Settings.IgnoreAimRadius || (val.z > 0f && num2 <= Settings.AimRadius)) && num2 < num)
						{
							num = num2;
							target = aroundEnemy;
						}
						continue;
					}
					float num3 = Vector3.Distance(((Agent)aroundEnemy).AimTarget.position, ((Agent)m_Owner).Position);
					_ = ((Agent)aroundEnemy).AimTarget.position - m_Owner.FPSCamera.Position;
					Vector3 val3 = ((CameraController)m_Owner.FPSCamera).m_camera.WorldToScreenPoint(((Agent)aroundEnemy).AimTarget.position);
					((Vector2)(ref val4))..ctor((float)(Screen.width / 2), (float)(Screen.height / 2));
					float num4 = Vector3.Distance(val3, Vector2.op_Implicit(val4));
					if ((Settings.IgnoreAimRadius || (val3.z > 0f && num4 <= Settings.AimRadius)) && num3 < num)
					{
						num = num3;
						target = aroundEnemy;
					}
				}
				m_Target = target;
			}

			private void UpdateAroundEnemy(Vector3 sourcePos)
			{
				//IL_002b: 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_006b: Unknown result type (might be due to invalid IL or missing references)
				AroundEnemies.Clear();
				if (PauseAutoAim)
				{
					return;
				}
				if (Settings.MagicBulletVisibleOnly)
				{
					sourcePos = m_Owner.FPSCamera.Position;
				}
				Enumerator<EnemyAgent> enumerator = m_Owner.EnemyCollision.m_enemies.GetEnumerator();
				while (enumerator.MoveNext())
				{
					EnemyAgent current = enumerator.Current;
					if (!IgnoredEnemies.Contains(current) && (Settings.WallHackAim || AdminUtils.CanSeeEnemyPlus(sourcePos, current)) && ((Agent)current).Alive && ((Dam_SyncedDamageBase)current.Damage).Health > 0f && !current.Damage.IsImortal)
					{
						AroundEnemies.Add(current);
					}
				}
			}

			public void TempIgnoreTargetEnemy()
			{
				if (!((Object)(object)m_Target == (Object)null))
				{
					IgnoredEnemies.Add(m_Target);
				}
			}

			public void SetLastFireDir(Vector3 dir)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				LastFireDir = dir;
			}
		}

		[Command(/*Could not decode attribute arguments.*/)]
		private static bool _enableAutoAim;

		private static bool IsLocalShotgunFireShots;

		public override string Name => "自瞄";

		public override string Description => "使用枪械时启用自瞄";

		public override FeatureGroup Group => EntryPoint.Groups.Weapon;

		[FeatureConfig]
		public static WeaponAutoAimSettings Settings { get; set; }

		public override void Init()
		{
			ClassInjector.RegisterTypeInIl2Cpp<WeaponAutoAimHandler>(false);
		}

		public override void OnGameStateChanged(int state)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			eGameStateName val = (eGameStateName)(byte)state;
			if ((int)val != 11 && (int)val != 4 && (int)val != 5 && (int)val != 15)
			{
				return;
			}
			foreach (WeaponAutoAimHandler allAutoAimInstance in WeaponAutoAimHandler.AllAutoAimInstances)
			{
				if ((Object)(object)allAutoAimInstance != (Object)null)
				{
					allAutoAimInstance.DoAfterLevelClear();
				}
			}
		}

		private static bool IsWeaponOwner(BulletWeapon bulletWeapon)
		{
			if ((Object)(object)bulletWeapon == (Object)null || (Object)(object)((Item)bulletWeapon).Owner == (Object)null)
			{
				return false;
			}
			return ((Agent)((Item)bulletWeapon).Owner).IsLocallyOwned;
		}
	}
	[EnableFeatureByDefault]
	[DisallowInGameToggle]
	public class WeaponAutoTrigger : Feature
	{
		public class WeaponAutoTriggerSettings
		{
			[FSDisplayName("状态")]
			[FSDescription("枪械处于瞄准状态并瞄准敌人时自动开火")]
			public bool Enabled
			{
				get
				{
					return _enabled;
				}
				set
				{
					_enabled = value;
				}
			}

			[FSDisplayName("暂停自动扳机按键")]
			[FSDescription("按下后可暂停自动扳机,松开后恢复")]
			public KeyCode PauseAutoTriggerKey { get; set; } = (KeyCode)304;


			[FSDisplayName("反转暂停自动扳机")]
			public bool ReversePauseAutoFire { get; set; }

			[FSDisplayName("装甲部位检测阈值")]
			[FSDescription("默认值为0.1")]
			[FSSlider(/*Could not decode attribute arguments.*/)]
			public float ArmorLimbDamageMultiThreshold
			{
				get
				{
					return EnemyDamageDataHelper.ArmorMultiThreshold;
				}
				set
				{
					EnemyDamageDataHelper.ArmorMultiThreshold = value;
					EnemyDamageDataHelper.ClearGeneratedEnemyDamageData();
				}
			}

			[FSInline]
			[JsonIgnore]
			[FSDisplayName("当前武器参数调节")]
			public List<WeaponAutoTriggerPreference> Preferences
			{
				get
				{
					List<WeaponAutoTriggerPreference> list = new List<WeaponAutoTriggerPreference>();
					if (CurrentWeaponPref != null)
					{
						list.Add(CurrentWeaponPref);
					}
					return list;
				}
				set
				{
				}
			}
		}

		[Localized]
		public enum AutoTriggerLogicType
		{
			Generic,
			WeakspotOnly
		}

		public class WeaponAutoTriggerPreference
		{
			[FSReadOnly(true)]
			[FSHeader("当前武器参数设置", true)]
			[FSDisplayName("武器ID")]
			public uint ArchetypeDataID { get; set; }

			[FSReadOnly(true)]
			[FSDisplayName("武器名称")]
			public string ArchetypeName { get; set; }

			[FSDisplayName("自动开火逻辑")]
			public AutoTriggerLogicType AutoTriggerLogic { get; set; }

			[FSDisplayName("可靠性")]
			[FSDescription("默认值为1")]
			[FSSlider(/*Could not decode attribute arguments.*/)]
			public float Reliability { get; set; } = 1f;


			[FSDisplayName("衰减距离判定阈值")]
			[FSDescription("最大值为15")]
			[FSSlider(/*Could not decode attribute arguments.*/)]
			public float FalloffThreshold { get; set; } = 12f;


			[FSDisplayName("伤害衰减阈值")]
			[FSDescription("默认值为0.25")]
			[FSSlider(/*Could not decode attribute arguments.*/)]
			public float DamageFalloffThreshold { get; set; } = 0.25f;


			[FSDisplayName("霰弹枪单次伤害阈值")]
			[FSDescription("默认值为0.75, 非霰弹类武器请忽略此项")]
			[FSSlider(/*Could not decode attribute arguments.*/)]
			public float ShotgunDamagePerFireThreshold { get; set; } = 0.75f;


			public WeaponAutoTriggerPreference()
			{
			}

			public WeaponAutoTriggerPreference(ArchetypeDataBlock block)
			{
				ArchetypeDataID = ((GameDataBlockBase<ArchetypeDataBlock>)(object)block).persistentID;
				ArchetypeName = LocalizedText.op_Implicit(block.PublicName);
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private class BulletWeaponArchetype__OnWield__Patch
		{
			private static void Postfix(BulletWeaponArchetype __instance)
			{
				PlayerAgent owner = __instance.m_owner;
				if (owner != null && ((Agent)owner).IsLocallyOwned)
				{
					IsWieldBulletWeapon = true;
					ArchetypeDataBlock archetypeData = __instance.m_archetypeData;
					if (!PreferencesLookup.Value.TryGetValue(((GameDataBlockBase<ArchetypeDataBlock>)(object)archetypeData).persistentID, out CurrentWeaponPref))
					{
						CurrentWeaponPref = new WeaponAutoTriggerPreference(archetypeData);
						PreferencesLookup.Value.Add(((GameDataBlockBase<ArchetypeDataBlock>)(object)archetypeData).persistentID, CurrentWeaponPref);
					}
				}
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private class BulletWeaponArchetype__OnUnWield__Patch
		{
			private static void Postfix(BulletWeaponArchetype __instance)
			{
				PlayerAgent owner = __instance.m_owner;
				if (owner != null && ((Agent)owner).IsLocallyOwned)
				{
					IsWieldBulletWeapon = false;
					CurrentWeaponPref = null;
				}
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private class ItemEquippable__get_FireButton__Patch
		{
			private static bool Prefix(ref bool __result)
			{
				if (!IsWieldBulletWeapon || !OverrideFireButton)
				{
					return true;
				}
				__result = true;
				return false;
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private class ItemEquippable__get_FireButtonPressed__Patch
		{
			private static bool Prefix(ref bool __result)
			{
				if (!IsWieldBulletWeapon || !OverrideFireButtonPressed)
				{
					return true;
				}
				__result = true;
				return false;
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private class BulletWeaponArchetype__Update__Patch
		{
			private static void Prefix(BulletWeaponArchetype __instance)
			{
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0154: Unknown result type (might be due to invalid IL or missing references)
				//IL_015a: Invalid comparison between Unknown and I4
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_047d: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_021a: 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_04cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_04db: Unknown result type (might be due to invalid IL or missing references)
				//IL_0508: Unknown result type (might be due to invalid IL or missing references)
				//IL_050d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0261: Unknown result type (might be due to invalid IL or missing references)
				//IL_0266: Unknown result type (might be due to invalid IL or missing references)
				//IL_0531: Unknown result type (might be due to invalid IL or missing references)
				//IL_053d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0555: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_045d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0463: Invalid comparison between Unknown and I4
				//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0332: Unknown result type (might be due to invalid IL or missing references)
				//IL_0334: Unknown result type (might be due to invalid IL or missing references)
				//IL_02fb: 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_0307: Unknown result type (might be due to invalid IL or missing references)
				//IL_030d: Unknown result type (might be due to invalid IL or missing references)
				//IL_030f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0314: Unknown result type (might be due to invalid IL or missing references)
				//IL_0316: Unknown result type (might be due to invalid IL or missing references)
				//IL_031b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0322: Unknown result type (might be due to invalid IL or missing references)
				//IL_0324: 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_032b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0330: Unknown result type (might be due to invalid IL or missing references)
				//IL_0592: Unknown result type (might be due to invalid IL or missing references)
				//IL_0598: Invalid comparison between Unknown and I4
				//IL_0587: Unknown result type (might be due to invalid IL or missing references)
				//IL_058d: Invalid comparison between Unknown and I4
				//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0412: Unknown result type (might be due to invalid IL or missing references)
				//IL_0417: Unknown result type (might be due to invalid IL or missing references)
				//IL_0616: Unknown result type (might be due to invalid IL or missing references)
				if (!_enabled)
				{
					return;
				}
				PlayerAgent owner = __instance.m_owner;
				if ((Object)(object)owner == (Object)null || !((Agent)owner).IsLocallyOwned)
				{
					return;
				}
				BulletWeapon weapon = __instance.m_weapon;
				if (weapon.m_clip <= 0)
				{
					if (((PlayerInventoryBase)((Weapon)weapon).m_inventory).CanReloadCurrent() && !((ItemEquippable)weapon).IsReloading)
					{
						((PlayerInventoryBase)((Weapon)weapon).m_inventory).TriggerReload();
					}
					return;
				}
				if (!((ItemEquippable)weapon).AimButtonHeld || ((ItemEquippable)weapon).FireButton || ((ItemEquippable)weapon).FireButtonPressed)
				{
					return;
				}
				bool key = Input.GetKey(Settings.PauseAutoTriggerKey);
				if ((Settings.ReversePauseAutoFire && !key) || (!Settings.ReversePauseAutoFire && key) || CurrentWeaponPref == null)
				{
					return;
				}
				FPSCamera fPSCamera = owner.FPSCamera;
				fPSCamera.UpdateCameraRay();
				float num = 0f;
				if (Random.Range(0f, 1f) > CurrentWeaponPref.Reliability && Clock.Time - weapon.m_lastFireTime <= weapon.m_fireRecoilCooldown)
				{
					num = 0.025f;
				}
				RaycastHit val = default(RaycastHit);
				if (!Physics.SphereCast(fPSCamera.Position, num, fPSCamera.CameraRayDir, ref val, ((Weapon)weapon).MaxRayDist, LayerManager.MASK_BULLETWEAPON_RAY))
				{
					return;
				}
				GameObject gameObject = ((Component)((RaycastHit)(ref val)).collider).gameObject;
				if ((Object)(object)gameObject == (Object)null)
				{
					return;
				}
				Dam_EnemyDamageLimb component = gameObject.GetComponent<Dam_EnemyDamageLimb>();
				if ((Object)(object)component == (Object)null)
				{
					return;
				}
				Dam_EnemyDamageBase @base = component.m_base;
				if (@base.IsImortal || ((int)component.m_type == 2 && component.m_armorDamageMulti <= Settings.ArmorLimbDamageMultiThreshold))
				{
					return;
				}
				EnemyAgent owner2 = component.m_base.Owner;
				if (!((Agent)owner2).Alive)
				{
					return;
				}
				EnemyDamageDataHelper.EnemyDamageData orGenerateEnemyDamageData = EnemyDamageDataHelper.GetOrGenerateEnemyDamageData(owner2);
				if (orGenerateEnemyDamageData.IsImmortal)
				{
					return;
				}
				ArchetypeDataBlock archetypeData = ((ItemEquippable)weapon).ArchetypeData;
				Vector3 cameraRayDir = fPSCamera.CameraRayDir;
				Vector3 position = fPSCamera.Position;
				float distance = ((RaycastHit)(ref val)).distance;
				Shotgun val2 = ((Il2CppObjectBase)weapon).TryCast<Shotgun>();
				bool flag = (Object)(object)val2 != (Object)null;
				float num2 = 0f;
				if (flag)
				{
					Vector3 up = ((ItemEquippable)weapon).MuzzleAlign.up;
					Vector3 right = ((ItemEquippable)weapon).MuzzleAlign.right;
					ushort globalID = ((Agent)owner2).GlobalID;
					float num3 = archetypeData.ShotgunBulletSpread;
					float damageWithBoosterEffect = archetypeData.GetDamageWithBoosterEffect(owner, ((Item)weapon).ItemDataBlock.inventorySlot);
					damageWithBoosterEffect = AgentModifierManager.ApplyModifier((Agent)(object)owner2, (AgentModifier)7, damageWithBoosterEffect);
					float num4 = damageWithBoosterEffect * (float)archetypeData.ShotgunBulletCount * CurrentWeaponPref.ShotgunDamagePerFireThreshold;
					float num5 = 0f;
					float num6 = 0f;
					RaycastHit val4 = default(RaycastHit);
					for (int i = 0; i < archetypeData.ShotgunBulletCount; i++)
					{
						cameraRayDir = fPSCamera.CameraRayDir;
						float num7 = val2.m_segmentSize * (float)i;
						float num8 = 0f;
						float num9 = 0f;
						if (i > 0)
						{
							num8 += (float)archetypeData.ShotgunConeSize * Mathf.Cos(num7);
							num9 += (float)archetypeData.ShotgunConeSize * Mathf.Sin(num7);
						}
						if (Mathf.Abs(num8) > 0f)
						{
							cameraRayDir = Quaternion.AngleAxis(num8, up) * cameraRayDir;
						}
						if (Mathf.Abs(num9) > 0f)
						{
							cameraRayDir = Quaternion.AngleAxis(num9, right) * cameraRayDir;
						}
						if (num3 > 0f)
						{
							Vector2 val3 = Random.insideUnitCircle * num3;
							cameraRayDir = Quaternion.AngleAxis(val3.x, up) * cameraRayDir;
							cameraRayDir = Quaternion.AngleAxis(val3.y, right) * cameraRayDir;
						}
						if (!Physics.Raycast(position, cameraRayDir, ref val4, ((Weapon)weapon).MaxRayDist, LayerManager.MASK_BULLETWEAPON_RAY))
						{
							continue;
						}
						GameObject gameObject2 = ((Component)((RaycastHit)(ref val4)).collider).gameObject;
						if ((Object)(object)gameObject2 == (Object)null)
						{
							continue;
						}
						Dam_EnemyDamageLimb component2 = gameObject2.GetComponent<Dam_EnemyDamageLimb>();
						if (!((Object)(object)component2 == (Object)null) && ((Agent)component2.m_base.Owner).GlobalID == globalID)
						{
							num6 = ((RaycastHit)(ref val4)).distance;
							num5 = component.ApplyWeakspotAndArmorModifiers(damageWithBoosterEffect, archetypeData.PrecisionDamageMulti);
							if (num6 > archetypeData.DamageFalloff.x)
							{
								num5 *= Mathf.Max(1f - (num6 - archetypeData.DamageFalloff.x) / (archetypeData.DamageFalloff.y - archetypeData.DamageFalloff.x), BulletWeapon.s_falloffMin);
							}
							if (owner2.EnemyBalancingData.AllowDamgeBonusFromBehind)
							{
								num5 = component.ApplyDamageFromBehindBonus(num5, ((Agent)owner).Position, cameraRayDir, 1f);
							}
							num2 += num5;
						}
					}
					if (owner2.IsScout)
					{
						ES_ScoutScream scoutScream = owner2.Locomotion.ScoutScream;
						if (scoutScream != null && (int)scoutScream.m_state != 4)
						{
							return;
						}
					}
					if (num2 >= num4)
					{
						goto IL_0642;
					}
				}
				else
				{
					float damageWithBoosterEffect2 = archetypeData.GetDamageWithBoosterEffect(owner, ((Item)weapon).ItemDataBlock.inventorySlot);
					damageWithBoosterEffect2 = AgentModifierManager.ApplyModifier((Agent)(object)owner2, (AgentModifier)7, damageWithBoosterEffect2);
					damageWithBoosterEffect2 = component.ApplyWeakspotAndArmorModifiers(damageWithBoosterEffect2, archetypeData.PrecisionDamageMulti);
					if (distance > archetypeData.DamageFalloff.x)
					{
						damageWithBoosterEffect2 *= Mathf.Max(1f - (distance - archetypeData.DamageFalloff.x) / (archetypeData.DamageFalloff.y - archetypeData.DamageFalloff.x), BulletWeapon.s_falloffMin);
					}
					if (owner2.EnemyBalancingData.AllowDamgeBonusFromBehind)
					{
						damageWithBoosterEffect2 = component.ApplyDamageFromBehindBonus(damageWithBoosterEffect2, ((Agent)owner).Position, cameraRayDir, 1f);
					}
					num2 = damageWithBoosterEffect2;
				}
				if (!((Dam_SyncedDamageBase)@base).WillDamageKill(num2))
				{
					if (distance > (archetypeData.DamageFalloff.y - archetypeData.DamageFalloff.x) * CurrentWeaponPref.DamageFalloffThreshold + archetypeData.DamageFalloff.x || flag)
					{
						return;
					}
					if (owner2.IsScout)
					{
						ES_ScoutScream scoutScream2 = owner2.Locomotion.ScoutScream;
						if (scoutScream2 != null && (int)scoutScream2.m_state != 4)
						{
							return;
						}
					}
					if ((int)component.m_type != 1 && (CurrentWeaponPref.AutoTriggerLogic == AutoTriggerLogicType.WeakspotOnly || !(distance <= Mathf.Min(CurrentWeaponPref.FalloffThreshold, archetypeData.DamageFalloff.x))) && orGenerateEnemyDamageData.HasWeakSpot && !__instance.HasChargeup)
					{
						foreach (int key2 in orGenerateEnemyDamageData.Weakspots.Keys)
						{
							Dam_EnemyDamageLimb val5 = ((Il2CppArrayBase<Dam_EnemyDamageLimb>)(object)owner2.Damage.DamageLimbs)[key2];
							if (!val5.IsDestroyed && AdminUtils.CanFireHitObject(position, ((Component)val5).gameObject))
							{
								return;
							}
						}
					}
				}
				goto IL_0642;
				IL_0642:
				OverrideFireButton = true;
				OverrideFireButtonPressed = true;
			}

			private static void Postfix(BulletWeaponArchetype __instance)
			{
				if (_enabled)
				{
					PlayerAgent owner = __instance.m_owner;
					if (owner != null && ((Agent)owner).IsLocallyOwned)
					{
						OverrideFireButtonPressed = false;
						OverrideFireButton = false;
					}
				}
			}
		}

		[Command(/*Could not decode attribute arguments.*/)]
		private static bool _enabled;

		private static WeaponAutoTriggerPreference CurrentWeaponPref;

		private static CustomSettings<Dictionary<uint, WeaponAutoTriggerPreference>> PreferencesLookup = new CustomSettings<Dictionary<uint, WeaponAutoTriggerPreference>>("WeaponAutoTriggerPreferences.json", new Dictionary<uint, WeaponAutoTriggerPreference>(), (Action<Dictionary<uint, WeaponAutoTriggerPreference>>)null, (LoadingTime)1, true);

		private static bool IsWieldBulletWeapon;

		private static bool OverrideFireButton;

		private static bool OverrideFireButtonPressed;

		public override string Name => "自动扳机";

		public override string Description => "使用枪械时启用自动扳机\n<color=red>本功能与自动瞄准冲突</color>";

		public override FeatureGroup Group => EntryPoint.Groups.Weapon;

		[FeatureConfig]
		public static WeaponAutoTriggerSettings Settings { get; set; }
	}
	[HideInModSettings]
	[EnableFeatureByDefault]
	[DisallowInGameToggle]
	internal class WeaponEnhancement : Feature
	{
		public class WeaponEnhanceSettings
		{
			[FSDisplayName("无限弹夹容量")]
			public bool InfiniteClip
			{
				get
				{
					return _infiniteClip;
				}
				set
				{
					_infiniteClip = value;
				}
			}

			[FSDisplayName("清晰瞄具")]
			[FSDescription("去除枪械瞄具污渍, 加强热成像瞄具")]
			public bool ClearSight
			{
				get
				{
					return _clearSight;
				}
				set
				{
					_clearSight = value;
				}
			}

			[FSDisplayName("无伤害衰减")]
			[FSDescription("枪械伤害没有距离衰减")]
			public bool NoDamageFalloff
			{
				get
				{
					return _noDamageFalloff;
				}
				set
				{
					_noDamageFalloff = value;
				}
			}

			[FSDisplayName("无弹道扩散")]
			[FSDescription("枪械弹道无扩散, 散弹子弹散步减小")]
			public bool NoSpread
			{
				get
				{
					return _noSpread;
				}
				set
				{
					_noSpread = value;
				}
			}

			[FSDisplayName("无后座")]
			[FSDescription("枪械无后坐力")]
			public bool NoRecoil
			{
				get
				{
					return _noRecoil;
				}
				set
				{
					_noRecoil = value;
				}
			}

			[FSDisplayName("子弹穿墙")]
			[FSDescription("枪械子弹穿墙")]
			public bool WallHack
			{
				get
				{
					return EnableWallHack;
				}
				set
				{
					EnableWallHack = value;
				}
			}

			[FSDisplayName("无声枪")]
			[FSDescription("枪械无开火声音, 即不惊怪(仅客机可用)")]
			public bool SilentWeapon
			{
				get
				{
					return _silentWeapon;
				}
				set
				{
					_silentWeapon = value;
				}
			}

			[FSDisplayName("自动上弹")]
			[FSDescription("优先消耗后备弹药")]
			public bool AutoReload
			{
				get
				{
					return _autoReload;
				}
				set
				{
					_autoReload = value;
				}
			}

			[FSDisplayName("特殊部位伤害溢出")]
			[FSDescription("启用后可以在特殊部位单次打出超过最大生命值上限的伤害")]
			public bool IgnoreLimbMaxHealthClamp
			{
				get
				{
					return _ignoreLimbMaxHealthClamp;
				}
				set
				{
					_ignoreLimbMaxHealthClamp = value;
				}
			}

			[FSDisplayName("多部位穿透")]
			[FSDescription("启用后可以穿透同一敌人的多个部位")]
			public bool MultiLimbPierce
			{
				get
				{
					return _multiLimbPierce;
				}
				set
				{
					_multiLimbPierce = value;
				}
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private static class Dam_EnemyDamageLimb_Custom__ApplyWeakspotAndArmorModifiers__Patch
		{
			private static bool Prefix(Dam_EnemyDamageLimb_Custom __instance, ref float __result, float dam, float precisionMulti = 1f)
			{
				if (!_ignoreLimbMaxHealthClamp)
				{
					return true;
				}
				__result = dam * Mathf.Max(((Dam_EnemyDamageLimb)__instance).m_weakspotDamageMulti * precisionMulti, 1f) * ((Dam_EnemyDamageLimb)__instance).m_armorDamageMulti;
				return false;
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private class BulletWeapon__BulletHit__Patch
		{
			private static void Prefix(ref uint damageSearchID)
			{
				if (_multiLimbPierce)
				{
					damageSearchID = 0u;
				}
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private class BulletWeapon__Fire__Patch
		{
			private static void Postfix(BulletWeapon __instance)
			{
				if (IsWeaponOwner(__instance))
				{
					if (_autoReload)
					{
						((PlayerInventoryBase)((Weapon)__instance).m_inventory).DoReload();
					}
					if (_infiniteClip)
					{
						__instance.m_clip = ((ItemEquippable)__instance).ClipSize;
						__instance.UpdateAmmoStatus();
					}
				}
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private class Shotgun__Fire__Patch
		{
			private static void Postfix(Shotgun __instance)
			{
				if (IsWeaponOwner((BulletWeapon)(object)__instance))
				{
					if (_autoReload)
					{
						((PlayerInventoryBase)((Weapon)__instance).m_inventory).DoReload();
					}
					if (_infiniteClip)
					{
						((BulletWeapon)__instance).m_clip = ((ItemEquippable)__instance).ClipSize;
						((BulletWeapon)__instance).UpdateAmmoStatus();
					}
				}
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private class PlayerSync__RegisterFiredBullets__Patch
		{
			private static bool Prefix(PlayerSync __instance)
			{
				if (!__instance.m_agent.Owner.IsLocal || !_silentWeapon)
				{
					return true;
				}
				return false;
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private class Weapon__ApplyRecoil__Patch
		{
			private static bool Prefix()
			{
				return !_noRecoil;
			}
		}

		[ArchivePatch(/*Could not decode attribute arguments.*/)]
		private class BulletWeapon__OnWield__Patch
		{
			private static void Postfix(ref BulletWeapon __instance)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Invalid comparison between Unknown and I4
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Expected O, but got Unknown
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				if ((int)GameStateManager.Current.m_currentStateName == 10 && IsWeaponOwner(__instance))
				{
					if (!WeaponInstanceArchetypeDataLookup.TryGetValue(((GameDataBlockBase<ArchetypeDataBlock>)(object)((ItemEquippable)__instance).ArchetypeData).persistentID, out var value))
					{
						WeaponInstanceArchetypeDataLookup.Add(((GameDataBlockBase<ArchetypeDataBlock>)(object)((ItemEquippable)__instance).ArchetypeData).persistentID, AdminUtils.CopyProperties<ArchetypeDataBlock>(((ItemEquippable)__instance).ArchetypeData, new ArchetypeDataBlock()));
					}
					else
					{
						((ItemEquippable)__instance).ArchetypeData = value;
					}
					if (_noDamageFalloff)
					{
						((ItemEquippable)__instance).ArchetypeData.DamageFalloff = FalloffBlocker;
					}
					if (_noRecoil)
					{
						((ItemEquippable)__instance).ArchetypeData.RecoilDataID = 0u;
					}
					if (_noSpread)
					{
						((ItemEquippable)__instance).ArchetypeData.AimSpread = 0f;
						((ItemEquippable)__instance).ArchetypeData.HipFireSpread = 0f;
						((ItemEquippable)__instance).ArchetypeData.ShotgunBulletSpread = 0;
						((ItemEquippable)__instance).ArchetypeData.ShotgunConeSize = 1;
					}
					SetupClearSight(((Component)__instance).gameObject, _clearSight);
				}
			}
		}

		[Command(/*Could not decode attribute arguments.*/)]
		private static bool _infiniteClip;

		[Command(/*Could not decode attribute arguments.*/)]
		private static bool _clearSight;

		[Command(/*Could not decode attribute arguments.*/)]
		private static bool _noDamageFalloff;

		[Command(/*Could not decode attribute arguments.*/)]
		private static bool _noSpread;

		[Command(/*Could not decode attribute arguments.*/)]
		private static bool _noRecoil;

		private static bool _enableWallHack;

		[Command(/*Could not decode attribute arguments.*/)]
		private static bool _silentWeapon;

		[Command(/*Could not decode attribute arguments.*/)]
		private static bool _autoReload;

		[Command(/*Could not decode attribute arguments.*/)]
		private static bool _ignoreLimbMaxHealthClamp;

		[Command(/*Could not decode attribute arguments.*/)]
		private static bool _multiLimbPierce;

		private static Dictionary<uint, ArchetypeDataBlock> WeaponInstanceArchetypeDataLookup = new Dictionary<uint, ArchetypeDataBlock>();

		private static List<string> ClearSightShaderProps = new List<string> { "falloff", "distortion", "dirt" };

		private static List<string> ClearSightCompNames = new List<string> { "thermal", "glass" };

		private static Vector2 FalloffBlocker = new Vector2(1000f, 1001f);

		private static int EnemyDamagableLayerMask;

		private static int BulletPiercingPassMask;

		private static int BulletWeaponRayMask;

		public override string Name => "武器增强";

		public override string Description => "增强武器属性";

		public override FeatureGroup Group => EntryPoint.Groups.Weapon;

		[FeatureConfig]
		public static WeaponEnhanceSettings Settings { get; set; }

		[Command(/*Could not decode attribute arguments.*/)]
		private static bool EnableWallHack
		{
			get
			{
				return _enableWallHack;
			}
			set
			{
				_enableWallHack = value;
				LayerManager.MASK_BULLETWEAPON_PIERCING_PASS = (_enableWallHack ? EnemyDamagableLayerMask : BulletPiercingPassMask);
				LayerMana