Decompiled source of CSCrosshairMod v2.0.0

CrosshairMod.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComputerysModdingUtilities;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: StraftatMod(true)]
[assembly: AssemblyCompany("CrosshairMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0")]
[assembly: AssemblyProduct("CS Crosshair Mod")]
[assembly: AssemblyTitle("CrosshairMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace CrosshairMod
{
	public static class CrosshairConfig
	{
		public static ConfigEntry<int> crosshairLength;

		public static ConfigEntry<int> crosshairGap;

		public static ConfigEntry<int> crosshairThickness;

		public static ConfigEntry<bool> crosshairDot;

		public static ConfigEntry<Plugin.OutlineStyle> crosshairOutlineStyle;

		public static ConfigEntry<bool> crosshairTStyle;

		public static ConfigEntry<byte> crosshairColorR;

		public static ConfigEntry<byte> crosshairColorG;

		public static ConfigEntry<byte> crosshairColorB;

		public static ConfigEntry<byte> crosshairColorA;

		public static ConfigEntry<byte> crosshairOutlineColorR;

		public static ConfigEntry<byte> crosshairOutlineColorG;

		public static ConfigEntry<byte> crosshairOutlineColorB;

		public static ConfigEntry<byte> crosshairOutlineColorA;

		public static ConfigEntry<string> crosshairFromCS;

		public static ConfigEntry<bool> crosshairPreview;

		public static void BindTo(ConfigFile config)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Expected O, but got Unknown
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Expected O, but got Unknown
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Expected O, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Expected O, but got Unknown
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Expected O, but got Unknown
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Expected O, but got Unknown
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Expected O, but got Unknown
			crosshairPreview = config.Bind<bool>("Preview", "Preview", false, new ConfigDescription("Draw crosshair in menu", (AcceptableValueBase)null, Array.Empty<object>()));
			crosshairLength = config.Bind<int>("Style.Sizing", "Size/Length", 8, new ConfigDescription("Crosshair Size", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 255), Array.Empty<object>()));
			crosshairGap = config.Bind<int>("Style.Sizing", "Gap", 4, new ConfigDescription("Crosshair Gap", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 128), Array.Empty<object>()));
			crosshairThickness = config.Bind<int>("Style.Sizing", "Thickness", 2, new ConfigDescription("Crosshair Thickness", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 32), Array.Empty<object>()));
			crosshairDot = config.Bind<bool>("Style.Features", "Draw Dot", false, new ConfigDescription("Show center dot", (AcceptableValueBase)null, Array.Empty<object>()));
			crosshairOutlineStyle = config.Bind<Plugin.OutlineStyle>("Style.Features", "Outline Type", Plugin.OutlineStyle.None, new ConfigDescription("Outline type: 0 - None, 1 - Full, 2 - Half", (AcceptableValueBase)null, Array.Empty<object>()));
			crosshairTStyle = config.Bind<bool>("Style.Features", "T-Style", false, new ConfigDescription("Use T-style crosshair", (AcceptableValueBase)null, Array.Empty<object>()));
			crosshairColorR = config.Bind<byte>("Style.Color", "Red", byte.MaxValue, new ConfigDescription("Red value of crosshair color", (AcceptableValueBase)(object)new AcceptableValueRange<byte>((byte)0, byte.MaxValue), Array.Empty<object>()));
			crosshairColorG = config.Bind<byte>("Style.Color", "Green", byte.MaxValue, new ConfigDescription("Green value of crosshair color", (AcceptableValueBase)(object)new AcceptableValueRange<byte>((byte)0, byte.MaxValue), Array.Empty<object>()));
			crosshairColorB = config.Bind<byte>("Style.Color", "Blue", byte.MaxValue, new ConfigDescription("Blue value of crosshair color", (AcceptableValueBase)(object)new AcceptableValueRange<byte>((byte)0, byte.MaxValue), Array.Empty<object>()));
			crosshairColorA = config.Bind<byte>("Style.Color", "Alpha", byte.MaxValue, new ConfigDescription("Alpha value of crosshair color", (AcceptableValueBase)(object)new AcceptableValueRange<byte>((byte)0, byte.MaxValue), Array.Empty<object>()));
			crosshairOutlineColorR = config.Bind<byte>("Style.Color", "Outline Red", byte.MaxValue, new ConfigDescription("Red value of crosshair outline color", (AcceptableValueBase)(object)new AcceptableValueRange<byte>((byte)0, byte.MaxValue), Array.Empty<object>()));
			crosshairOutlineColorG = config.Bind<byte>("Style.Color", "Outline Green", byte.MaxValue, new ConfigDescription("Green value of crosshair outline color", (AcceptableValueBase)(object)new AcceptableValueRange<byte>((byte)0, byte.MaxValue), Array.Empty<object>()));
			crosshairOutlineColorB = config.Bind<byte>("Style.Color", "Outline Blue", byte.MaxValue, new ConfigDescription("Blue value of crosshair outline color", (AcceptableValueBase)(object)new AcceptableValueRange<byte>((byte)0, byte.MaxValue), Array.Empty<object>()));
			crosshairOutlineColorA = config.Bind<byte>("Style.Color", "Outline Alpha", byte.MaxValue, new ConfigDescription("Alpha value of crosshair outline color", (AcceptableValueBase)(object)new AcceptableValueRange<byte>((byte)0, byte.MaxValue), Array.Empty<object>()));
			crosshairFromCS = config.Bind<string>("Style.Import", "CS Share Code", "CSjNcfcGjo8LLy2pDpCynr5e5efCGW6yXuf7B6aQ7wkWmU", new ConfigDescription("CS2 share code", (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	public class CrosshairInfo
	{
		public int ScreenHeight;

		public int Style;

		public bool HasCenterDot;

		public int Length;

		public int Thickness;

		public int Gap;

		public int OutlineStyle;

		public int Red;

		public int Green;

		public int Blue;

		public int OutlineRed;

		public int OutlineGreen;

		public int OutlineBlue;

		public int Alpha;

		public int OutlineAlpha;

		public int SpreadLimit;

		public int SplitDistance;

		public float InnerSplitAlpha;

		public float OuterSplitAlpha;

		public float SplitSizeRatio;

		public bool IsTStyle;

		public bool SameColorForIronsight;

		public float IronsightDotScale;

		public bool FollowRecoil;
	}
	public static class CS2ShareCode
	{
		private const string DICTIONARY = "ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789";

		private static readonly int DICTIONARY_LENGTH = "ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789".Length;

		private static readonly Regex SHARECODE_PATTERN = new Regex("CS[A-Za-z2-9]{44}$", RegexOptions.Compiled);

		private static int CalculateChecksum(List<int> bytes)
		{
			int num = 0;
			for (int i = 1; i < bytes.Count; i++)
			{
				num += bytes[i];
			}
			return num % 256;
		}

		public static string Encode(CrosshairInfo c)
		{
			int num = (c.SplitDistance & 0x7F) | ((Mathf.RoundToInt(c.InnerSplitAlpha * 100f) & 0x7F) << 7) | ((Mathf.RoundToInt((c.OuterSplitAlpha - 0.3f) * 100f) & 0x7F) << 14) | ((Mathf.RoundToInt(c.SplitSizeRatio * 100f) & 0x7F) << 21);
			List<int> list = new List<int>
			{
				0,
				1,
				c.ScreenHeight & 0xFF,
				(c.ScreenHeight >> 8) & 0xFF,
				(c.Style & 0x1F) | (Convert.ToInt32(c.FollowRecoil) << 5) | (Convert.ToInt32(c.HasCenterDot) << 6) | (Convert.ToInt32(c.IsTStyle) << 7),
				c.Red,
				c.Green,
				c.Blue,
				c.Alpha,
				c.OutlineRed,
				c.OutlineGreen,
				c.OutlineBlue,
				c.OutlineAlpha,
				(c.Thickness & 0x1F) | ((c.OutlineStyle & 3) << 6),
				c.Gap & 0xFF,
				(c.Gap >> 8) & 0xFF,
				c.Length,
				c.SpreadLimit & 0xFF,
				num & 0xFF,
				(num >> 8) & 0xFF,
				(num >> 16) & 0xFF,
				(num >> 24) & 0xFF,
				Mathf.RoundToInt((c.IronsightDotScale - 0.1f) * 100f) & 0xFF,
				0,
				0,
				0,
				0,
				0,
				0,
				0,
				0,
				0
			};
			list[21] |= Convert.ToInt32(c.SameColorForIronsight) << 4;
			list[0] = CalculateChecksum(list);
			BigInteger bigInteger = 0;
			BigInteger bigInteger2 = 1;
			for (int num2 = list.Count - 1; num2 >= 0; num2--)
			{
				bigInteger += list[num2] * bigInteger2;
				bigInteger2 *= (BigInteger)256;
			}
			int length = "ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789".Length;
			StringBuilder stringBuilder = new StringBuilder("CS");
			for (int i = 0; i < 44; i++)
			{
				BigInteger bigInteger3 = bigInteger % length;
				bigInteger /= (BigInteger)length;
				stringBuilder.Append("ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789"[(int)bigInteger3]);
			}
			return stringBuilder.ToString();
		}

		public static CrosshairInfo Decode(string shareCode)
		{
			if (!SHARECODE_PATTERN.IsMatch(shareCode))
			{
				Plugin.Logger.LogError((object)("Invalid share code format '" + shareCode + "'"));
				throw new Exception("Invalid share code format '" + shareCode + "'");
			}
			char[] array = shareCode.Substring(2, shareCode.Length - 2).Reverse().ToArray();
			BigInteger bigInteger = 0;
			BigInteger bigInteger2 = "ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789".Length;
			char[] array2 = array;
			foreach (char c in array2)
			{
				int num = "ABCDEFGHJKLMNOPQRSTUVWXYZabcdefhijkmnopqrstuvwxyz23456789".IndexOf(c);
				if (num == -1)
				{
					Plugin.Logger.LogError((object)$"Invalid character '{c}' in share code '{shareCode}'");
					throw new Exception($"Invalid character '{c}' in share code '{shareCode}'");
				}
				bigInteger *= bigInteger2;
				bigInteger += (BigInteger)num;
			}
			int[] array3 = new int[32];
			for (int num2 = 31; num2 >= 0; num2--)
			{
				array3[num2] = (int)(bigInteger % 256);
				bigInteger /= (BigInteger)256;
			}
			int num3 = 0;
			for (int j = 1; j < 32; j++)
			{
				num3 += array3[j];
			}
			if (array3[0] != num3 % 256)
			{
				Plugin.Logger.LogWarning((object)"Checksum mismatch in share code");
			}
			int num4 = array3[18] | (array3[19] << 8) | (array3[20] << 16) | (array3[21] << 24);
			return new CrosshairInfo
			{
				ScreenHeight = (array3[2] | (array3[3] << 8)),
				Style = (array3[4] & 0x1F),
				FollowRecoil = ((array3[4] & 0x20) != 0),
				HasCenterDot = ((array3[4] & 0x40) == 64),
				IsTStyle = ((array3[4] & 0x80) == 128),
				Red = array3[5],
				Green = array3[6],
				Blue = array3[7],
				Alpha = array3[8],
				OutlineRed = array3[9],
				OutlineGreen = array3[10],
				OutlineBlue = array3[11],
				OutlineAlpha = array3[12],
				Thickness = (array3[13] & 0x1F),
				OutlineStyle = ((array3[13] >> 6) & 3),
				Gap = (short)((array3[14] & 0xFF) | ((array3[15] & 0xFF) << 8)),
				Length = array3[16],
				SpreadLimit = (array3[17] & 0xFF),
				SplitDistance = (array3[18] & 0x7F),
				InnerSplitAlpha = MathF.Round((float)((num4 >> 7) & 0x7F) / 100f, 2),
				OuterSplitAlpha = MathF.Round((float)((num4 >> 14) & 0x7F) / 100f + 0.3f, 2),
				SplitSizeRatio = MathF.Round((float)((num4 >> 21) & 0x7F) / 100f, 2),
				SameColorForIronsight = ((array3[21] & 0x10) == 16),
				IronsightDotScale = 0.1f + (float)array3[22] / 100f
			};
		}
	}
	[HarmonyPatch(typeof(Crosshair))]
	public static class CrosshairPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		public static void SetupCrosshair(Crosshair __instance)
		{
			Plugin.CreateCrosshairUI(((Component)__instance).transform.parent);
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		public static void UpdateCrosshair(ref Crosshair __instance)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.queueReload)
			{
				Plugin.UpdateCrosshair();
				Plugin.queueReload = false;
			}
			if ((Object)(object)__instance.player != (Object)null && __instance.canScopeAim && __instance.player.isAiming)
			{
				Plugin.root.SetActive(false);
				return;
			}
			if (!CrosshairConfig.crosshairPreview.Value)
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name == "MainMenu")
				{
					Plugin.root.SetActive(false);
					return;
				}
			}
			Plugin.root.SetActive(true);
		}
	}
	[BepInPlugin("CrosshairMod", "CS Crosshair Mod", "2.0.0")]
	[BepInProcess("STRAFTAT.exe")]
	public class Plugin : BaseUnityPlugin
	{
		public enum OutlineStyle
		{
			None,
			Full,
			Half
		}

		internal static ManualLogSource Logger;

		private static readonly Harmony HarmonyInstance = new Harmony("CrosshairMod");

		public static GameObject root;

		private static Image[] lines;

		private static Image[] outlines;

		private static Image dot;

		private static Image dotOutline;

		public static bool queueReload = true;

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			CrosshairConfig.BindTo(((BaseUnityPlugin)this).Config);
			((BaseUnityPlugin)this).Config.SettingChanged += OnConfigChanged;
			HarmonyInstance.PatchAll();
			Logger.LogInfo((object)"Crosshair Mod Loaded");
		}

		private void OnConfigChanged(object sender, SettingChangedEventArgs e)
		{
			if ((object)e.ChangedSetting == CrosshairConfig.crosshairFromCS)
			{
				CrosshairInfo crosshairInfo = CS2ShareCode.Decode(CrosshairConfig.crosshairFromCS.Value);
				CrosshairConfig.crosshairLength.Value = crosshairInfo.Length;
				CrosshairConfig.crosshairGap.Value = crosshairInfo.Gap;
				CrosshairConfig.crosshairThickness.Value = crosshairInfo.Thickness;
				CrosshairConfig.crosshairDot.Value = crosshairInfo.HasCenterDot;
				CrosshairConfig.crosshairOutlineStyle.Value = (OutlineStyle)crosshairInfo.OutlineStyle;
				CrosshairConfig.crosshairTStyle.Value = crosshairInfo.IsTStyle;
				CrosshairConfig.crosshairColorR.Value = Convert.ToByte(crosshairInfo.Red);
				CrosshairConfig.crosshairColorG.Value = Convert.ToByte(crosshairInfo.Green);
				CrosshairConfig.crosshairColorB.Value = Convert.ToByte(crosshairInfo.Blue);
				CrosshairConfig.crosshairColorA.Value = Convert.ToByte(crosshairInfo.Alpha);
				CrosshairConfig.crosshairOutlineColorR.Value = Convert.ToByte(crosshairInfo.OutlineRed);
				CrosshairConfig.crosshairOutlineColorG.Value = Convert.ToByte(crosshairInfo.OutlineGreen);
				CrosshairConfig.crosshairOutlineColorB.Value = Convert.ToByte(crosshairInfo.OutlineBlue);
				CrosshairConfig.crosshairOutlineColorA.Value = Convert.ToByte(crosshairInfo.OutlineAlpha);
			}
			else
			{
				CrosshairInfo c = new CrosshairInfo
				{
					Gap = CrosshairConfig.crosshairGap.Value,
					Length = CrosshairConfig.crosshairLength.Value,
					Thickness = CrosshairConfig.crosshairThickness.Value,
					HasCenterDot = CrosshairConfig.crosshairDot.Value,
					OutlineStyle = (int)CrosshairConfig.crosshairOutlineStyle.Value,
					IsTStyle = CrosshairConfig.crosshairTStyle.Value,
					Red = Convert.ToInt32(CrosshairConfig.crosshairColorR.Value),
					Green = Convert.ToInt32(CrosshairConfig.crosshairColorG.Value),
					Blue = Convert.ToInt32(CrosshairConfig.crosshairColorB.Value),
					Alpha = Convert.ToInt32(CrosshairConfig.crosshairColorA.Value),
					OutlineRed = Convert.ToInt32(CrosshairConfig.crosshairOutlineColorR.Value),
					OutlineGreen = Convert.ToInt32(CrosshairConfig.crosshairOutlineColorG.Value),
					OutlineBlue = Convert.ToInt32(CrosshairConfig.crosshairOutlineColorB.Value),
					OutlineAlpha = Convert.ToInt32(CrosshairConfig.crosshairOutlineColorA.Value)
				};
				CrosshairConfig.crosshairFromCS.Value = CS2ShareCode.Encode(c);
			}
			UpdateCrosshair();
		}

		public static void UpdateCrosshair()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a0: 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_02c7: 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_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_0452: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_045f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_0482: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: 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_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Unknown result type (might be due to invalid IL or missing references)
			if (lines == null || outlines == null)
			{
				return;
			}
			int value = CrosshairConfig.crosshairGap.Value;
			int value2 = CrosshairConfig.crosshairLength.Value;
			int value3 = CrosshairConfig.crosshairThickness.Value;
			bool value4 = CrosshairConfig.crosshairDot.Value;
			OutlineStyle value5 = CrosshairConfig.crosshairOutlineStyle.Value;
			bool flag = value5 != OutlineStyle.None;
			int num = ((value5 != OutlineStyle.Full) ? 1 : 2);
			bool value6 = CrosshairConfig.crosshairTStyle.Value;
			Color color = Color32.op_Implicit(new Color32(CrosshairConfig.crosshairColorR.Value, CrosshairConfig.crosshairColorG.Value, CrosshairConfig.crosshairColorB.Value, CrosshairConfig.crosshairColorA.Value));
			Color color2 = Color32.op_Implicit(new Color32(CrosshairConfig.crosshairOutlineColorR.Value, CrosshairConfig.crosshairOutlineColorG.Value, CrosshairConfig.crosshairOutlineColorB.Value, CrosshairConfig.crosshairOutlineColorA.Value));
			int num2 = value3 / 2 + value + value2 / 2;
			RectTransform rectTransform = ((Graphic)lines[0]).rectTransform;
			RectTransform rectTransform2 = ((Graphic)outlines[0]).rectTransform;
			Vector2 anchoredPosition = default(Vector2);
			((Vector2)(ref anchoredPosition))..ctor(0f, (float)(num2 + ((value3 % 2 != 0) ? 1 : 0)));
			rectTransform2.anchoredPosition = anchoredPosition;
			rectTransform.anchoredPosition = anchoredPosition;
			RectTransform rectTransform3 = ((Graphic)lines[1]).rectTransform;
			RectTransform rectTransform4 = ((Graphic)outlines[1]).rectTransform;
			((Vector2)(ref anchoredPosition))..ctor(0f, (float)(-num2 - ((value2 % 2 != 0) ? 1 : 0)));
			rectTransform4.anchoredPosition = anchoredPosition;
			rectTransform3.anchoredPosition = anchoredPosition;
			RectTransform rectTransform5 = ((Graphic)lines[2]).rectTransform;
			RectTransform rectTransform6 = ((Graphic)outlines[2]).rectTransform;
			((Vector2)(ref anchoredPosition))..ctor((float)(-num2 - ((value3 % 2 != 0) ? 1 : 0)), 0f);
			rectTransform6.anchoredPosition = anchoredPosition;
			rectTransform5.anchoredPosition = anchoredPosition;
			RectTransform rectTransform7 = ((Graphic)lines[3]).rectTransform;
			RectTransform rectTransform8 = ((Graphic)outlines[3]).rectTransform;
			((Vector2)(ref anchoredPosition))..ctor((float)(num2 + ((value2 % 2 != 0) ? 1 : 0)), 0f);
			rectTransform8.anchoredPosition = anchoredPosition;
			rectTransform7.anchoredPosition = anchoredPosition;
			if (value5 == OutlineStyle.Half)
			{
				((Graphic)outlines[0]).rectTransform.anchoredPosition = ((Graphic)lines[0]).rectTransform.anchoredPosition + Vector2.up * (float)(value2 % 2) + Vector2.left * (float)(value3 % 2);
				((Graphic)outlines[1]).rectTransform.anchoredPosition = ((Graphic)lines[1]).rectTransform.anchoredPosition + Vector2.up * (float)(value2 % 2) + Vector2.left * (float)(value3 % 2);
				((Graphic)outlines[2]).rectTransform.anchoredPosition = ((Graphic)lines[2]).rectTransform.anchoredPosition + Vector2.left * (float)(value2 % 2) + Vector2.up * (float)(value3 % 2);
				((Graphic)outlines[3]).rectTransform.anchoredPosition = ((Graphic)lines[3]).rectTransform.anchoredPosition + Vector2.left * (float)(value2 % 2) + Vector2.up * (float)(value3 % 2);
			}
			for (int i = 0; i < 4; i++)
			{
				Image obj = lines[i];
				((Graphic)obj).color = color;
				RectTransform rectTransform9 = ((Graphic)obj).rectTransform;
				rectTransform9.sizeDelta = ((i >= 2) ? new Vector2((float)value2, (float)value3) : new Vector2((float)value3, (float)value2));
				((Component)outlines[i]).gameObject.SetActive(flag && value2 > 0 && value3 > 0);
				if (flag && value2 > 0 && value3 > 0)
				{
					Image obj2 = outlines[i];
					((Graphic)obj2).color = color2;
					((Graphic)obj2).rectTransform.sizeDelta = rectTransform9.sizeDelta + Vector2.one * (float)num;
				}
			}
			((Component)lines[0]).gameObject.SetActive(!value6);
			((Component)outlines[0]).gameObject.SetActive(!value6 && flag && value2 > 0 && value3 > 0);
			((Component)dot).gameObject.SetActive(value4);
			((Component)dotOutline).gameObject.SetActive(flag && value4);
			if (value4)
			{
				((Graphic)dot).color = color;
				((Graphic)dot).rectTransform.sizeDelta = Vector2.one * (float)value3;
				if (flag)
				{
					((Graphic)dotOutline).color = color2;
					((Graphic)dotOutline).rectTransform.sizeDelta = ((Graphic)dot).rectTransform.sizeDelta + Vector2.one * (float)num;
					((Graphic)dotOutline).rectTransform.anchoredPosition = ((Graphic)dot).rectTransform.anchoredPosition + ((value5 == OutlineStyle.Half) ? ((Vector2.up + Vector2.left) * (float)(value3 % 2)) : Vector2.zero);
				}
			}
		}

		public static void CreateCrosshairUI(Transform uiRoot = null)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			//IL_0042: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Expected O, but got Unknown
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			root = new GameObject("[MOD] Custom Crosshair");
			Canvas val = root.AddComponent<Canvas>();
			val.renderMode = (RenderMode)0;
			val.sortingOrder = 999;
			RectTransform component = root.GetComponent<RectTransform>();
			Vector2 val2 = default(Vector2);
			if ((Object)(object)component != (Object)null)
			{
				val2 = (component.anchorMin = (component.anchorMax = Vector2.one * 0.5f));
				component.pivot = Vector2.one * 0.5f;
				component.anchoredPosition = Vector2.zero;
			}
			else
			{
				Logger.LogError((object)"Crosshair GamObject does not have RectTransform");
			}
			CanvasScaler obj = root.AddComponent<CanvasScaler>();
			obj.uiScaleMode = (ScaleMode)0;
			obj.scaleFactor = 1f;
			GameObject val5 = new GameObject("CrosshairGroup");
			val5.transform.SetParent(((Component)val).transform, false);
			RectTransform obj2 = val5.AddComponent<RectTransform>();
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			obj2.anchorMax = val2;
			obj2.anchorMin = val2;
			obj2.anchoredPosition = Vector2.zero;
			dotOutline = new GameObject("DotOutline").AddComponent<Image>();
			((Component)dotOutline).transform.SetParent(val5.transform, false);
			lines = (Image[])(object)new Image[4];
			outlines = (Image[])(object)new Image[4];
			for (int i = 0; i < 4; i++)
			{
				GameObject val6 = new GameObject("Outline" + i);
				val6.transform.SetParent(val5.transform, false);
				Image val7 = val6.AddComponent<Image>();
				outlines[i] = val7;
				GameObject val8 = new GameObject("Line" + i);
				val8.transform.SetParent(val5.transform, false);
				Image val9 = val8.AddComponent<Image>();
				RectTransform rectTransform = ((Graphic)val9).rectTransform;
				RectTransform rectTransform2 = ((Graphic)val9).rectTransform;
				((Vector2)(ref val2))..ctor(0.5f, 0.5f);
				rectTransform2.anchorMax = val2;
				rectTransform.anchorMin = val2;
				((Graphic)val9).rectTransform.pivot = new Vector2(0.5f, 0.5f);
				lines[i] = val9;
			}
			dot = new GameObject("Dot").AddComponent<Image>();
			((Component)dot).transform.SetParent(val5.transform, false);
			UpdateCrosshair();
			if (Object.op_Implicit((Object)(object)uiRoot))
			{
				root.transform.SetParent(uiRoot, false);
			}
			root.transform.localPosition = Vector3.zero;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CrosshairMod";

		public const string PLUGIN_NAME = "CS Crosshair Mod";

		public const string PLUGIN_VERSION = "2.0.0";
	}
}