using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ComputerysModdingUtilities;
using HarmonyLib;
using ModMenu.Api;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ezCrosshair")]
[assembly: AssemblyDescription("STRAFTAT: pick your own crosshair, its color and size.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: StraftatMod(true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace EzCrosshair;
internal static class Images
{
public static string Get(string name)
{
return name switch
{
"brackets" => "iVBORw0KGgoAAAANSUhEUgAAACAAAAAWCAYAAAChWZ5EAAAC/ElEQVR4nLWWT0gUYRjGfzO7C1ObNSGJ0KGFDIz8R1fbDkmwtBl0EUWCBVEPeti7UHvZ+wZKRkiCRRp0qG1gICyoDhIEq6symeKIBQNabZAx4Z/tsN+us+um4toDw8x88/H8nnn5vpkXsnIh4UHiEOXxeCTAnT+IhGubIzvgsE5ajJ84jABerzcLcueCrJPGI5ggkniQBFwKhUI1DQ0NfiA5PDz8LpFIlBSitr7W3X6r/TJwPjmZfPt45PEMsJVlyoDMOhKZakj+Jn9Xa6j1Tll5WcvZc2dPlkQHesI9x9Vy9WZrqPW2/4q/SwznmLJzcjQWbQs2B1uAilLBWekv9OxlRaA50BKNRducz/MCNAWaLgn4G2BMi2s/Sg4Q178DT4VnhWDsDBCNRRuBRgAtro31dPbMlArPKtwZntHj+lNx2yhYQGZlbgFHVUWtrzxWWWNMG4vLS8tz9ob9UwTccpopbsW1G8zesDfz7rFlIGV9tT6Zhrno8/lqVEWtBz4Cv3MVCF4PNpDZFUuAecCX3U2m8JYECyhYA9mJkUhkT7fYYKzX+GIYhmUYsQex3r3mC0+zcLxYgCVx7KrA9UAvUAVUBZoDewb4l6+7yMT9SRFn+8AOQPEKnBHHrtKf6/3APDCvv9T798Eq6lusAr5IJMJe6yDcEe6ng/2Agdwa8BWO5yqgvdQSQFqk3DHxEOQT3mnBAjIVkAE7ZacmrV/WdHVN9YWFxYWLilv5AGBv2GtOl8J9vg8dATh1+tRFX7XvjLVqzaTs1BTwB3AhAsiAPGFM3LNS1qaVsvShkaE6RVG8B3pXp9x4Bx4O1Jmrpm6umpsTxsSgALsAV94iHNfH3wMLwFWgO9gcLJkvPLqF54Jg5JQXoC/c90SLa69Kpjp07ca13LUW1171hfueOJ9n/gWOhuT1+Ov7K99WZoGpuc9za5SowbuDf9pD7c9GH43OJhPJt2T+LWkyn33RgbmQUPL6wUNpyVRVldlux3Jb3uPySFDYf/6/prRQefC/qb//SibWbnQAAAAASUVORK5CYII=",
"chunky plus" => "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAPUlEQVR4nMXOOwoAIAwE0Vnvf+e18IMhKFppFcjwomwDIKkN+ck2ZbPMNRCk5UII38UhpaDLn/84sVNzLVbxsxQK66rOnQAAAABJRU5ErkJggg==",
"circle" => "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAABhWlDQ1BJQ0MgUHJvZmlsZQAAeJx9kT1Iw0AcxV9TtaIVBTuIOmSoThZERRylikWwUNoKrTqYXPohNGlIUlwcBdeCgx+LVQcXZ10dXAVB8APEydFJ0UVK/F9SaBHjwXE/3t173L0DhFqJqWbbOKBqlpGMRcVMdkUMvKIbfejAEESJmXo8tZCG5/i6h4+vdxGe5X3uz9Gj5EwG+ETiWaYbFvE68fSmpXPeJw6xoqQQnxOPGXRB4keuyy6/cS44LPDMkJFOzhGHiMVCC8stzIqGSjxFHFZUjfKFjMsK5y3OaqnCGvfkLwzmtOUU12kOI4ZFxJGACBkVbKAECxFaNVJMJGk/6uEfdPwJcsnk2gAjxzzKUCE5fvA/+N2tmZ+ccJOCUaD9xbY/RoDALlCv2vb3sW3XTwD/M3ClNf3lGjDzSXq1qYWPgN5t4OK6qcl7wOUOMPCkS4bkSH6aQj4PvJ/RN2WB/luga9XtrbGP0wcgTV0t3QAHh8BogbLXPN7d2drbv2ca/f0AcCJypllzgSYAAABaSURBVHichY/RCcAgDESfDuMqQpw1ncCZLLhA+tEobSj0wUG4HCEHNwVQYLoO9/ZyABY0VkgBq7XaQkRWSPGTFvHAzPyQgQ7QWtvmY+4AJaV0xifdezX5rHkBA+Q5eLIiGpIAAAAASUVORK5CYII=",
"cross" => "iVBORw0KGgoAAAANSUhEUgAAAAwAAAAMCAYAAABWdVznAAAAPElEQVR4nGP8//8/AxYAE2REl2DCphofoL0GFhziGG5H1oDua3TFKPJkOQmn9dhsxGXDf3SnkO0k2msAAAv8CBv+J3ZPAAAAAElFTkSuQmCC",
"dark diamond" => "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAABhGlDQ1BJQ0MgUHJvZmlsZQAAeJx9kT1Iw0AcxV9TRSkVBwuKOGRonexiRRxLFYtgobQVWnUwufQLmjQkKS6OgmvBwY/FqoOLs64OroIg+AHi6uKk6CIl/i8ptIjx4Lgf7+497t4BQqvGVLMvDqiaZWSSCTFfWBUHXhFAEKOIICYxU09lF3PwHF/38PH1LsqzvM/9OYaUoskAn0gcZ7phEW8Qz25aOud94hCrSArxOfGUQRckfuS67PIb57LDAs8MGbnMPHGIWCz3sNzDrGKoxDPEYUXVKF/Iu6xw3uKs1hqsc0/+wmBRW8lyneYEklhCCmmIkNFAFTVYiNKqkWIiQ/sJD/+440+TSyZXFYwcC6hDheT4wf/gd7dmKTbtJgUTQP+LbX9EgIFdoN207e9j226fAP5n4Err+ustYO6T9GZXCx8Bw9vAxXVXk/eAyx1g7EmXDMmR/DSFUgl4P6NvKgAjt0Bgze2ts4/TByBHXS3fAAeHwGSZstc93j3Y29u/Zzr9/QAHc3LiC+VReAAAAJNJREFUeJyNkDsOAjEMRMdQI9hF3jsgcQMQNbegpsqF01CCQpcWPQoShLIpGMmN5/lr+hGwkrSXlCXdzeyhVsAABCCVCMCmB52B6O7Z3TMQgQuwrpCX6ghkSXzSVDgAk4ATkNz9C9UonRNwWEh6zRaeaylg+mP0UPccgWvnmCPg7eVj5z3b6lsDu6RdefjNzJ7VewNyVrX/e0ljMwAAAABJRU5ErkJggg==",
"diamond" => "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAcklEQVR4nJWQywnEMAxEX1KH+9hCUohRGSlt+8hpzgYfjFEuMqxDWJIBgdA89FuYlYBP5F/gmFx3H1AGakQGUnhTpx1okoqkArSopV8oA83MuofMrAecB7wBVVLxi6JzBbaVF3o8+vExf98zmOVmjduHn8G4YXw9M5RzAAAAAElFTkSuQmCC",
"dot" => "iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAZklEQVR4nIXPwQnDQAxE0bfuIBe3YNy4dotwMc41GFyCcogCJiHkg0CMhmHUMhO01mbcvDjxyEzKsGLgqBmYy2zGiIg9i4jYr6YFR35QScvkD1MV2nrv97dY+1Y3v0qu0C5pX2/CE/ZiPhIntsABAAAAAElFTkSuQmCC",
"outlined plus" => "iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAVklEQVR4nN2SMQ7AMAgDz1X//2V3qLqkOKXKFm8IdIITIsdDrWromACwjT1yfgA62QBw8radUs4J8JfpFEnrJ4jJCc9mUvlDwO0gddc/sZMNAFlvU+IFejsTGMmz0YEAAAAASUVORK5CYII=",
"pinhole" => "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAbklEQVR4nJWQUQ3DMAwFT9NQhEB4mI0RpBCKJSD82IyG+5NMnaK22knvy6cn27BSRm5pQI60W8nM0swu5Qaku6eklJTuvshlNknKiaRzc3k9LT15Ax9gi4i91vod9N6JCIBtOP8d8yM/SefjlocfG0M/Yk1SZxgAAAAASUVORK5CYII=",
"plus" => "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAK0lEQVR4nGP8//8/AxqACTAiCzKhq8IFqK+QhQHhJnSAIk6SiYxoYoPN1wC5RgcU0AuUbwAAAABJRU5ErkJggg==",
"square" => "iVBORw0KGgoAAAANSUhEUgAAAAQAAAAECAYAAACp8Z5+AAAAFklEQVR4nGP8////fwYkwMSABggLAAAGXQQE3kxYjAAAAABJRU5ErkJggg==",
"star" => "iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAUklEQVR4nI2QUQrAMAxCdWfs7tjC7vj204yRpaNCQFRQYkAJIfgtHinUFnw/KEBAAzpf9OnJFCMr5OrfoCWdkkbhj+k5Nsb1tO/xcvW14PLuw29t+lWwzaChlAAAAABJRU5ErkJggg==",
_ => null,
};
}
}
internal static class Blur
{
private sealed class Follower : MonoBehaviour
{
public Image Panel;
public RawImage Pic;
private readonly Vector3[] corners = (Vector3[])(object)new Vector3[4];
private void LateUpdate()
{
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Expected O, but got Unknown
//IL_006f: 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_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0211: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Panel == (Object)null)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
bool isActiveAndEnabled = ((Behaviour)Panel).isActiveAndEnabled;
if (isActiveAndEnabled)
{
Want();
}
bool flag = isActiveAndEnabled && Usable;
if (((Behaviour)Pic).enabled != flag)
{
((Behaviour)Pic).enabled = flag;
}
if (flag)
{
RectTransform val = (RectTransform)((Component)this).transform;
RectTransform rectTransform = ((Graphic)Panel).rectTransform;
if (val.anchorMin != rectTransform.anchorMin)
{
val.anchorMin = rectTransform.anchorMin;
}
if (val.anchorMax != rectTransform.anchorMax)
{
val.anchorMax = rectTransform.anchorMax;
}
if (val.pivot != rectTransform.pivot)
{
val.pivot = rectTransform.pivot;
}
if (val.anchoredPosition != rectTransform.anchoredPosition)
{
val.anchoredPosition = rectTransform.anchoredPosition;
}
if (val.sizeDelta != rectTransform.sizeDelta)
{
val.sizeDelta = rectTransform.sizeDelta;
}
if (((Transform)val).localScale != ((Transform)rectTransform).localScale)
{
((Transform)val).localScale = ((Transform)rectTransform).localScale;
}
if ((Object)(object)Pic.texture != (Object)(object)Result)
{
Pic.texture = (Texture)(object)Result;
}
val.GetWorldCorners(corners);
float num = Mathf.Max(1f, (float)Screen.width);
float num2 = Mathf.Max(1f, (float)Screen.height);
Rect val2 = default(Rect);
((Rect)(ref val2))..ctor(corners[0].x / num, corners[0].y / num2, (corners[2].x - corners[0].x) / num, (corners[2].y - corners[0].y) / num2);
if (Pic.uvRect != val2)
{
Pic.uvRect = val2;
}
}
}
}
private sealed class Grabber : MonoBehaviour
{
private void Update()
{
if (Time.frameCount - wantedFrame > 30)
{
((Behaviour)this).enabled = false;
}
}
private void OnRenderImage(RenderTexture src, RenderTexture dst)
{
Graphics.Blit((Texture)(object)src, dst);
if (Wanted && !((Object)(object)src == (Object)null) && !Overlay.InMainMenu())
{
Process((Texture)(object)src);
}
}
}
public static RenderTexture Result;
private static int wantedFrame = -10;
private static Grabber grabber;
private static Material mat;
private static Camera[] cams = (Camera[])(object)new Camera[16];
private static readonly float[] TapAt = new float[5] { 0f, 1.3846f, -1.3846f, 3.2308f, -3.2308f };
private static readonly float[] TapAlpha = MakeAlphas(new float[5] { 0.227f, 0.3162f, 0.3162f, 0.0703f, 0.0703f });
public static bool Usable
{
get
{
if ((Object)(object)Result != (Object)null)
{
return !Overlay.InMainMenu();
}
return false;
}
}
public static bool Wanted => Time.frameCount - wantedFrame <= 2;
public static void Want()
{
if (wantedFrame != Time.frameCount)
{
wantedFrame = Time.frameCount;
EnsureGrabber();
}
}
private static void EnsureGrabber()
{
Camera val = null;
FirstPersonController val2 = (((Object)(object)Crosshair.Instance != (Object)null) ? Crosshair.Instance.player : null);
if ((Object)(object)val2 != (Object)null)
{
val = val2.playerCamera;
}
if ((Object)(object)val == (Object)null || !((Behaviour)val).isActiveAndEnabled)
{
val = TopCamera();
}
if (Overlay.InMainMenu())
{
if ((Object)(object)grabber != (Object)null)
{
((Behaviour)grabber).enabled = false;
}
}
else
{
if ((Object)(object)val == (Object)null)
{
return;
}
if ((Object)(object)grabber != (Object)null && (Object)(object)((Component)grabber).gameObject == (Object)(object)((Component)val).gameObject)
{
if (!((Behaviour)grabber).enabled)
{
((Behaviour)grabber).enabled = true;
}
return;
}
if ((Object)(object)grabber != (Object)null)
{
Object.Destroy((Object)(object)grabber);
}
grabber = ((Component)val).GetComponent<Grabber>();
if ((Object)(object)grabber == (Object)null)
{
grabber = ((Component)val).gameObject.AddComponent<Grabber>();
}
((Behaviour)grabber).enabled = true;
}
}
private static Camera TopCamera()
{
if (cams.Length < Camera.allCamerasCount)
{
cams = (Camera[])(object)new Camera[Camera.allCamerasCount + 8];
}
int allCameras = Camera.GetAllCameras(cams);
Camera val = null;
for (int i = 0; i < allCameras; i++)
{
Camera val2 = cams[i];
if (!((Object)(object)val2 == (Object)null) && ((Behaviour)val2).isActiveAndEnabled && !((Object)(object)val2.targetTexture != (Object)null) && ((Object)(object)val == (Object)null || val2.depth > val.depth))
{
val = val2;
}
}
Array.Clear(cams, 0, allCameras);
if (!((Object)(object)val != (Object)null))
{
return Camera.main;
}
return val;
}
public static void Behind(Image panel)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)panel == (Object)null))
{
RectTransform val = Ui.Node("blur", ((Component)panel).transform.parent);
((Transform)val).SetSiblingIndex(((Component)panel).transform.GetSiblingIndex());
Image obj = ((Component)val).gameObject.AddComponent<Image>();
obj.sprite = panel.sprite;
obj.type = (Type)1;
((Graphic)obj).color = Color.white;
((Graphic)obj).raycastTarget = false;
((Component)val).gameObject.AddComponent<Mask>().showMaskGraphic = false;
RawImage val2 = ((Component)Ui.Node("picture", (Transform)(object)val)).gameObject.AddComponent<RawImage>();
((Graphic)val2).raycastTarget = false;
Ui.Fill(((Graphic)val2).rectTransform);
Follower follower = ((Component)val).gameObject.AddComponent<Follower>();
follower.Panel = panel;
follower.Pic = val2;
}
}
private static float[] MakeAlphas(float[] weights)
{
float[] array = new float[weights.Length];
float num = 0f;
for (int i = 0; i < weights.Length; i++)
{
num += weights[i];
array[i] = weights[i] / num;
}
return array;
}
private static bool Ready()
{
//IL_0026: 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_0038: Expected O, but got Unknown
if ((Object)(object)mat != (Object)null)
{
return true;
}
Shader val = Shader.Find("UI/Default");
if ((Object)(object)val == (Object)null)
{
return false;
}
mat = new Material(val)
{
hideFlags = (HideFlags)61
};
if (mat.HasProperty("_ColorMask"))
{
mat.SetFloat("_ColorMask", 14f);
}
return true;
}
private static void Pass(RenderTexture src, RenderTexture dst, bool across)
{
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
Graphics.Blit((Texture)(object)src, dst);
if (Ready())
{
RenderTexture active = RenderTexture.active;
RenderTexture.active = dst;
mat.mainTexture = (Texture)(object)src;
GL.PushMatrix();
GL.LoadOrtho();
mat.SetPass(0);
float num = 1f / (float)((Texture)src).width;
float num2 = 1f / (float)((Texture)src).height;
GL.Begin(7);
for (int i = 1; i < TapAt.Length; i++)
{
float num3 = (across ? (TapAt[i] * num) : 0f);
float num4 = (across ? 0f : (TapAt[i] * num2));
GL.Color(new Color(1f, 1f, 1f, TapAlpha[i]));
GL.TexCoord2(num3, num4);
GL.Vertex3(0f, 0f, 0f);
GL.TexCoord2(num3, 1f + num4);
GL.Vertex3(0f, 1f, 0f);
GL.TexCoord2(1f + num3, 1f + num4);
GL.Vertex3(1f, 1f, 0f);
GL.TexCoord2(1f + num3, num4);
GL.Vertex3(1f, 0f, 0f);
}
GL.End();
GL.PopMatrix();
RenderTexture.active = active;
}
}
private static void Process(Texture src)
{
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: Expected O, but got Unknown
//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_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
int num = Mathf.Max(8, src.width / 4);
int num2 = Mathf.Max(8, src.height / 4);
if ((Object)(object)Result == (Object)null || ((Texture)Result).width != num || ((Texture)Result).height != num2)
{
if ((Object)(object)Result != (Object)null)
{
Result.Release();
Object.Destroy((Object)(object)Result);
}
Result = new RenderTexture(num, num2, 0, (RenderTextureFormat)0)
{
filterMode = (FilterMode)1,
wrapMode = (TextureWrapMode)1,
name = "ezCrosshair_Blur"
};
Object.DontDestroyOnLoad((Object)(object)Result);
}
RenderTexture temporary = RenderTexture.GetTemporary(Mathf.Max(8, src.width / 2), Mathf.Max(8, src.height / 2), 0, (RenderTextureFormat)0);
RenderTexture temporary2 = RenderTexture.GetTemporary(num, num2, 0, (RenderTextureFormat)0);
FilterMode filterMode = src.filterMode;
FilterMode val = (FilterMode)1;
((Texture)temporary2).filterMode = (FilterMode)1;
FilterMode filterMode2 = (((Texture)temporary).filterMode = val);
src.filterMode = filterMode2;
((Texture)temporary2).wrapMode = (TextureWrapMode)1;
Graphics.Blit(src, temporary);
Graphics.Blit((Texture)(object)temporary, Result);
src.filterMode = filterMode;
Pass(Result, temporary2, across: true);
Pass(temporary2, Result, across: false);
Pass(Result, temporary2, across: true);
Pass(temporary2, Result, across: false);
RenderTexture.ReleaseTemporary(temporary);
RenderTexture.ReleaseTemporary(temporary2);
}
}
internal sealed class Menu : MonoBehaviour
{
public static Menu I;
private const float W = 748f;
private const float H = 580f;
private const float Pad = 28f;
private const float CapY = 84f;
private const float TopY = 108f;
private const float ColorCapY = 248f;
private const float ColorY = 272f;
private const float RowsY = 336f;
private const float GridX = 272f;
private const float Gap = 8f;
private const float TileH = 56f;
private const float TileW = 68f;
private const int Columns = 6;
private static readonly Color32[] Swatches = (Color32[])(object)new Color32[7]
{
new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue),
new Color32(byte.MaxValue, (byte)0, (byte)0, byte.MaxValue),
new Color32(byte.MaxValue, byte.MaxValue, (byte)0, byte.MaxValue),
new Color32((byte)0, byte.MaxValue, (byte)0, byte.MaxValue),
new Color32((byte)0, byte.MaxValue, byte.MaxValue, byte.MaxValue),
new Color32((byte)0, (byte)0, byte.MaxValue, byte.MaxValue),
new Color32(byte.MaxValue, (byte)0, byte.MaxValue, byte.MaxValue)
};
private bool _open;
private bool _pauseBefore;
private bool _rebinding;
private Canvas _canvas;
private RawImage _preview;
private TextMeshProUGUI _scaleText;
private RectTransform _tip;
private TextMeshProUGUI _tipText;
private static KeyCode[] _allKeys;
public static bool IsOpen
{
get
{
if ((Object)(object)I != (Object)null)
{
return I._open;
}
return false;
}
}
private void Awake()
{
I = this;
}
private void Update()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
if (_rebinding)
{
WaitForKey();
}
else if (KeyDown(EzCrosshairPlugin.MenuKey.Value) && !Typing())
{
if (_open)
{
Close();
}
else
{
Open();
}
}
}
private void LateUpdate()
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
if (_open)
{
if ((int)Cursor.lockState != 0)
{
Cursor.lockState = (CursorLockMode)0;
}
if (!Cursor.visible)
{
Cursor.visible = true;
}
}
}
public void Open()
{
if (!_open)
{
_open = true;
PauseManager instance = PauseManager.Instance;
_pauseBefore = (Object)(object)instance != (Object)null && instance.pause;
if ((Object)(object)instance != (Object)null)
{
instance.pause = true;
}
Ui.Prepare();
Ui.EnsureEventSystem();
}
Build();
}
public void Close()
{
if (_open)
{
_open = false;
_rebinding = false;
if ((Object)(object)_canvas != (Object)null)
{
Object.Destroy((Object)(object)((Component)_canvas).gameObject);
}
_canvas = null;
PauseManager instance = PauseManager.Instance;
if ((Object)(object)instance != (Object)null)
{
instance.pause = _pauseBefore;
}
}
}
private void Rebuild()
{
if (_open)
{
Build();
}
}
private void Build()
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Expected O, but got Unknown
//IL_0086: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Expected O, but got Unknown
//IL_00c4: 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_00dd: 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_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Expected O, but got Unknown
//IL_0149: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Expected O, but got Unknown
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0205: Expected O, but got Unknown
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0230: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_023d: Unknown result type (might be due to invalid IL or missing references)
//IL_0254: Unknown result type (might be due to invalid IL or missing references)
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_canvas != (Object)null)
{
Object.Destroy((Object)(object)((Component)_canvas).gameObject);
}
_canvas = Ui.MakeCanvas("ezCrosshair Menu", 32001);
RectTransform val = (RectTransform)((Component)_canvas).transform;
Image obj = Ui.Panel((Transform)val, new Color(0f, 0f, 0f, 0f));
Ui.Fill(((Graphic)obj).rectTransform);
((Graphic)obj).raycastTarget = true;
bool flag = Overlay.InMainMenu() || _pauseBefore;
Image obj2 = Ui.Window((Transform)val, flag ? 1f : 0.66f, flag ? Ui.Bg : Ui.GlassColor);
RectTransform rectTransform = ((Graphic)obj2).rectTransform;
Vector2 val2 = default(Vector2);
((Vector2)(ref val2))..ctor(0.5f, 0.5f);
rectTransform.anchorMax = val2;
rectTransform.anchorMin = val2;
rectTransform.sizeDelta = new Vector2(748f, 580f);
((Graphic)obj2).raycastTarget = true;
Ui.At(((TMP_Text)Ui.Label((Transform)(object)rectTransform, "ezCrosshair", 26f, Ui.Txt, (TextAlignmentOptions)4097)).rectTransform, 28f, 16f, 400f, 40f);
Button obj3 = Ui.Btn((Transform)(object)rectTransform, "x", 20f, new UnityAction(Close));
Ui.At((RectTransform)((Component)obj3).transform, 684f, 16f, 40f, 40f);
Ui.Center(obj3);
Preview(rectTransform);
Pictures(rectTransform);
Colors(rectTransform);
float y = 336f;
Row(rectTransform, ref y, "scale", ScaleControl);
Row(rectTransform, ref y, "show while scoped", delegate(RectTransform r)
{
Switch(r, EzCrosshairPlugin.ShowScoped.Value, delegate(bool v)
{
EzCrosshairPlugin.ShowScoped.Value = v;
});
});
Row(rectTransform, ref y, "use this crosshair", delegate(RectTransform r)
{
Switch(r, EzCrosshairPlugin.On.Value, delegate(bool v)
{
EzCrosshairPlugin.On.Value = v;
});
});
Row(rectTransform, ref y, "menu key", delegate(RectTransform r)
{
//IL_000e: 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_003b: Expected O, but got Unknown
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_005f: Expected O, but got Unknown
Button obj4 = Ui.Btn((Transform)(object)r, _rebinding ? "press a key" : KeyLabel(EzCrosshairPlugin.MenuKey.Value), 20f, (UnityAction)delegate
{
_rebinding = true;
Rebuild();
}, _rebinding);
Ui.At((RectTransform)((Component)obj4).transform, 472f, 4f, 220f, 40f);
Ui.Center(obj4);
});
Image val3 = Ui.Panel((Transform)val, Ui.A(Ui.Bg, 0.95f), Ui.RoundSmall);
Ui.Edge(val3, Ui.Tint(0.3f));
_tip = ((Graphic)val3).rectTransform;
val2 = (_tip.anchorMin = (_tip.anchorMax = Vector2.zero));
_tip.pivot = new Vector2(0f, 1f);
_tipText = Ui.Label((Transform)(object)_tip, "", 16f, Ui.Txt, (TextAlignmentOptions)514);
((TMP_Text)_tipText).enableWordWrapping = false;
Ui.Fill(((TMP_Text)_tipText).rectTransform);
((Component)_tip).gameObject.SetActive(false);
}
private void Preview(RectTransform w)
{
//IL_000b: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
Ui.At(((TMP_Text)Ui.Label((Transform)(object)w, "preview", 14f, Ui.Dim, (TextAlignmentOptions)4097)).rectTransform, 28f, 84f, 220f, 20f);
Image val = Ui.Panel((Transform)(object)w, Ui.Tint(0.06f), Ui.RoundSmall);
Ui.At(((Graphic)val).rectTransform, 28f, 108f, 220f, 204f);
Texture2D val2 = EzCrosshair.Pictures.Get(EzCrosshairPlugin.Pick.Value);
if (!((Object)(object)val2 == (Object)null))
{
RawImage val3 = ((Component)Ui.Node("preview", ((Component)val).transform)).gameObject.AddComponent<RawImage>();
val3.texture = (Texture)(object)val2;
((Graphic)val3).color = EzCrosshairPlugin.Tint.Value;
((Graphic)val3).raycastTarget = false;
RectTransform rectTransform = ((Graphic)val3).rectTransform;
Vector2 val4 = default(Vector2);
((Vector2)(ref val4))..ctor(0.5f, 0.5f);
rectTransform.anchorMax = val4;
rectTransform.anchorMin = val4;
rectTransform.anchoredPosition = Vector2.zero;
_preview = val3;
SizePreview();
}
}
private void SizePreview()
{
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Expected O, but got Unknown
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_preview == (Object)null) && !((Object)(object)_preview.texture == (Object)null))
{
Vector2Int val = Overlay.ScreenSize((Texture2D)_preview.texture, EzCrosshairPlugin.Scale.Value);
float num = Mathf.Max(0.01f, (float)Screen.height / 1080f);
((Graphic)_preview).rectTransform.sizeDelta = new Vector2((float)((Vector2Int)(ref val)).x, (float)((Vector2Int)(ref val)).y) / num;
}
}
private void ScaleControl(RectTransform r)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
float num = 692f;
Ui.At((RectTransform)((Component)Ui.MakeSlider((Transform)(object)r, 0f, 2f, EzCrosshairPlugin.Scale.Value, delegate(float v)
{
v = Mathf.Round(v * 20f) / 20f;
if (!(Mathf.Abs(v - EzCrosshairPlugin.Scale.Value) < 0.001f))
{
EzCrosshairPlugin.Scale.Value = v;
if ((Object)(object)_scaleText != (Object)null)
{
((TMP_Text)_scaleText).text = v.ToString("0.00", CultureInfo.InvariantCulture);
}
SizePreview();
}
})).transform, num - 360f, 12f, 240f, 24f);
Image val = Ui.Panel((Transform)(object)r, Ui.Tint(0.14f), Ui.RoundSmall);
((Graphic)val).raycastTarget = true;
Ui.At(((Graphic)val).rectTransform, num - 100f, 4f, 92f, 40f);
TextMeshProUGUI val2 = Ui.Label(((Component)val).transform, "", 18f, Ui.Txt, (TextAlignmentOptions)514);
Ui.Fill(((TMP_Text)val2).rectTransform);
_scaleText = val2;
((Component)val).gameObject.AddComponent<TypeBox>().Init(val, val2, EzCrosshairPlugin.Scale.Value.ToString("0.00", CultureInfo.InvariantCulture), delegate(string text)
{
if (!float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
{
return false;
}
EzCrosshairPlugin.Scale.Value = Mathf.Clamp(result, 0f, 2f);
Rebuild();
return true;
});
}
private void Pictures(RectTransform w)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Expected O, but got Unknown
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Expected O, but got Unknown
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01e1: 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)
Ui.At(((TMP_Text)Ui.Label((Transform)(object)w, "crosshairs", 14f, Ui.Dim, (TextAlignmentOptions)4097)).rectTransform, 272f, 84f, 300f, 20f);
string[] names = EzCrosshairPlugin.Names;
Color value = EzCrosshairPlugin.Tint.Value;
int num = 1;
string[] array = names;
for (int i = 0; i < array.Length; i++)
{
Texture2D val = EzCrosshair.Pictures.Get(array[i]);
if ((Object)(object)val != (Object)null)
{
num = Mathf.Max(num, Mathf.Max(((Texture)val).width, ((Texture)val).height));
}
}
int num2 = Mathf.Max(1, Mathf.FloorToInt(44f / (float)num));
Vector2 val4 = default(Vector2);
for (int j = 0; j < names.Length; j++)
{
string name = names[j];
bool num3 = name == EzCrosshairPlugin.Pick.Value;
float x = 272f + (float)(j % 6) * 76f;
float y = 108f + (float)(j / 6) * 64f;
if (num3)
{
Ui.At(((Graphic)Ui.Accent((Transform)(object)w)).rectTransform, x, y, 68f, 56f);
}
Button val2 = Ui.Btn((Transform)(object)w, null, 0f, (UnityAction)delegate
{
EzCrosshairPlugin.Pick.Value = name;
Rebuild();
});
Ui.At((RectTransform)((Component)val2).transform, x, y, 68f, 56f);
((Component)val2).gameObject.AddComponent<Hover>().Text = name;
Texture2D val3 = EzCrosshair.Pictures.Get(name);
if (!((Object)(object)val3 == (Object)null))
{
RawImage obj = ((Component)Ui.Node("picture", ((Component)val2).transform)).gameObject.AddComponent<RawImage>();
obj.texture = (Texture)(object)val3;
((Graphic)obj).color = value;
((Graphic)obj).raycastTarget = false;
RectTransform rectTransform = ((Graphic)obj).rectTransform;
((Vector2)(ref val4))..ctor(0.5f, 0.5f);
rectTransform.anchorMax = val4;
rectTransform.anchorMin = val4;
rectTransform.sizeDelta = new Vector2((float)(((Texture)val3).width * num2), (float)(((Texture)val3).height * num2));
}
}
}
private void Colors(RectTransform w)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: 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_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
Ui.At(((TMP_Text)Ui.Label((Transform)(object)w, "color", 14f, Ui.Dim, (TextAlignmentOptions)4097)).rectTransform, 272f, 248f, 300f, 20f);
Color32 val = Color32.op_Implicit(EzCrosshairPlugin.Tint.Value);
float num = 272f;
float num2 = 272f;
Color32[] swatches = Swatches;
foreach (Color32 val2 in swatches)
{
Color32 col = val2;
if (val.r == val2.r && val.g == val2.g && val.b == val2.b)
{
Ui.At(((Graphic)Ui.Panel((Transform)(object)w, Ui.Txt, Ui.RoundSmallRing)).rectTransform, num - 4f, num2 - 4f, 48f, 48f);
}
Image obj = Ui.Panel((Transform)(object)w, Color32.op_Implicit(col), Ui.RoundSmall);
((Graphic)obj).raycastTarget = true;
Ui.At(((Graphic)obj).rectTransform, num, num2, 40f, 40f);
Button obj2 = ((Component)obj).gameObject.AddComponent<Button>();
((Selectable)obj2).targetGraphic = null;
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)0;
((Selectable)obj2).navigation = navigation;
((UnityEvent)obj2.onClick).AddListener((UnityAction)delegate
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
EzCrosshairPlugin.Tint.Value = Color32.op_Implicit(col);
Rebuild();
});
num += 48f;
}
Image val3 = Ui.Panel((Transform)(object)w, Ui.Tint(0.14f), Ui.RoundSmall);
((Graphic)val3).raycastTarget = true;
Ui.At(((Graphic)val3).rectTransform, num + 8f, num2, 720f - (num + 8f), 40f);
TextMeshProUGUI val4 = Ui.Label(((Component)val3).transform, "", 18f, Ui.Txt, (TextAlignmentOptions)514);
Ui.Fill(((TMP_Text)val4).rectTransform);
((Component)val3).gameObject.AddComponent<HexBox>().Init(val3, val4, ColorUtility.ToHtmlStringRGB(EzCrosshairPlugin.Tint.Value).ToLowerInvariant(), delegate(string hex)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
Color value = default(Color);
if (ColorUtility.TryParseHtmlString("#" + hex, ref value))
{
EzCrosshairPlugin.Tint.Value = value;
Rebuild();
}
});
}
private static void Row(RectTransform w, ref float y, string label, Action<RectTransform> control)
{
//IL_0006: 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)
Image val = Ui.Panel((Transform)(object)w, Ui.Tint(0.06f), Ui.RoundSmall);
Ui.At(((Graphic)val).rectTransform, 28f, y, 692f, 48f);
TextMeshProUGUI obj = Ui.Label(((Component)val).transform, label, 22f, Ui.Txt, (TextAlignmentOptions)4097);
((TMP_Text)obj).enableWordWrapping = false;
Ui.At(((TMP_Text)obj).rectTransform, 16f, 0f, 400f, 48f);
control(((Graphic)val).rectTransform);
y += 56f;
}
private void Switch(RectTransform r, bool on, Action<bool> set)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Expected O, but got Unknown
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Expected O, but got Unknown
float num = 692f;
Button obj = Ui.Btn((Transform)(object)r, "off", 18f, (UnityAction)delegate
{
set(obj: false);
Rebuild();
}, !on);
Ui.At((RectTransform)((Component)obj).transform, num - 180f, 4f, 84f, 40f);
Ui.Center(obj);
Button obj2 = Ui.Btn((Transform)(object)r, "on", 18f, (UnityAction)delegate
{
set(obj: true);
Rebuild();
}, on);
Ui.At((RectTransform)((Component)obj2).transform, num - 92f, 4f, 84f, 40f);
Ui.Center(obj2);
}
public void ShowTip(string text, Vector2 at)
{
//IL_0022: 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_0066: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_tip == (Object)null))
{
((TMP_Text)_tipText).text = text;
float num = ((TMP_Text)_tipText).GetPreferredValues(text).x + 28f;
_tip.sizeDelta = new Vector2(num, 32f);
((Component)_tip).gameObject.SetActive(true);
((Transform)_tip).SetAsLastSibling();
MoveTip(at);
}
}
public void MoveTip(Vector2 at)
{
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_tip == (Object)null))
{
float num = Mathf.Max(0.01f, (float)Screen.height / 1080f);
_tip.anchoredPosition = at / num + new Vector2(16f, -16f);
}
}
public void HideTip()
{
if ((Object)(object)_tip != (Object)null)
{
((Component)_tip).gameObject.SetActive(false);
}
}
private void WaitForKey()
{
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Invalid comparison between Unknown and I4
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Invalid comparison between Unknown and I4
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Invalid comparison between Unknown and I4
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Invalid comparison between Unknown and I4
//IL_0065: 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)
if (KeyDown((KeyCode)27))
{
_rebinding = false;
Rebuild();
return;
}
if (_allKeys == null)
{
_allKeys = (KeyCode[])Enum.GetValues(typeof(KeyCode));
}
KeyCode[] allKeys = _allKeys;
foreach (KeyCode val in allKeys)
{
if ((int)val != 0 && (int)val != 27 && ((int)val < 323 || (int)val > 329) && (int)val < 330 && KeyDown(val))
{
EzCrosshairPlugin.MenuKey.Value = val;
_rebinding = false;
Rebuild();
break;
}
}
}
private static bool KeyDown(KeyCode k)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
try
{
return UnityInput.Current.GetKeyDown(k);
}
catch
{
return Input.GetKeyDown(k);
}
}
private unsafe static string KeyLabel(KeyCode k)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Invalid comparison between Unknown and I4
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Invalid comparison between Unknown and I4
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Invalid comparison between Unknown and I4
//IL_000a: 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_000f: Expected I4, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected I4, but got Unknown
if ((int)k >= 48 && (int)k <= 57)
{
return (k - 48).ToString();
}
if ((int)k >= 256 && (int)k <= 265)
{
return "num " + (k - 256);
}
return ((object)(*(KeyCode*)(&k))/*cast due to .constrained prefix*/).ToString().ToLowerInvariant();
}
private static bool Typing()
{
EventSystem current = EventSystem.current;
GameObject val = (((Object)(object)current != (Object)null) ? current.currentSelectedGameObject : null);
if ((Object)(object)val != (Object)null)
{
TMP_InputField component = val.GetComponent<TMP_InputField>();
if ((Object)(object)component != (Object)null && component.isFocused)
{
return true;
}
InputField component2 = val.GetComponent<InputField>();
if ((Object)(object)component2 != (Object)null && component2.isFocused)
{
return true;
}
}
PauseManager instance = PauseManager.Instance;
if ((Object)(object)instance != (Object)null && instance.chatting)
{
return !Overlay.InMainMenu();
}
return false;
}
}
internal sealed class Hover : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IPointerMoveHandler
{
public string Text;
public void OnPointerEnter(PointerEventData e)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Menu.I != (Object)null)
{
Menu.I.ShowTip(Text, e.position);
}
}
public void OnPointerMove(PointerEventData e)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Menu.I != (Object)null)
{
Menu.I.MoveTip(e.position);
}
}
public void OnPointerExit(PointerEventData e)
{
if ((Object)(object)Menu.I != (Object)null)
{
Menu.I.HideTip();
}
}
}
internal sealed class TypeBox : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
{
private Image _back;
private TextMeshProUGUI _text;
private string _value;
private string _good;
private Func<string, bool> _use;
private bool _editing;
public void Init(Image back, TextMeshProUGUI text, string start, Func<string, bool> use)
{
_back = back;
_text = text;
_value = (_good = start);
_use = use;
Show();
}
public void OnPointerClick(PointerEventData e)
{
_editing = true;
_value = "";
Show();
}
private void Update()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
if (!_editing)
{
return;
}
if (Input.GetMouseButtonDown(0) && !RectTransformUtility.RectangleContainsScreenPoint(((Graphic)_back).rectTransform, Vector2.op_Implicit(Input.mousePosition), (Camera)null))
{
Finish();
return;
}
string inputString = Input.inputString;
foreach (char c in inputString)
{
switch (c)
{
case '\b':
if (_value.Length > 0)
{
_value = _value.Substring(0, _value.Length - 1);
}
break;
case '\n':
case '\r':
Finish();
return;
default:
if ((char.IsDigit(c) || ((c == '.' || c == ',') && _value.IndexOf('.') < 0)) && _value.Length < 5)
{
_value += ((c == ',') ? '.' : c);
}
break;
}
}
if (Input.GetKeyDown((KeyCode)27))
{
_value = _good;
Finish();
}
else
{
Show();
}
}
private void Finish()
{
_editing = false;
if (_value.Length <= 0 || !(_value != _good) || !_use(_value))
{
_value = _good;
Show();
}
}
private void OnDisable()
{
if (_editing)
{
_editing = false;
_value = _good;
}
}
private void Show()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_back == (Object)null))
{
((Graphic)_back).color = (_editing ? Ui.Tint(0.24f) : Ui.Tint(0.14f));
bool flag = _editing && Mathf.Repeat(Time.unscaledTime, 1f) < 0.5f;
string text = _value + ((!_editing) ? "" : (flag ? "|" : "<alpha=#00>|</alpha>"));
if (((TMP_Text)_text).text != text)
{
((TMP_Text)_text).text = text;
}
}
}
}
internal sealed class HexBox : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
{
private Image _back;
private TextMeshProUGUI _text;
private string _value;
private string _good;
private Action<string> _changed;
private bool _editing;
public void Init(Image back, TextMeshProUGUI text, string start, Action<string> changed)
{
_back = back;
_text = text;
_value = (_good = start);
_changed = changed;
Show();
}
public void OnPointerClick(PointerEventData e)
{
_editing = true;
Show();
}
private void Update()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
if (!_editing)
{
return;
}
if (Input.GetMouseButtonDown(0) && !RectTransformUtility.RectangleContainsScreenPoint(((Graphic)_back).rectTransform, Vector2.op_Implicit(Input.mousePosition), (Camera)null))
{
Finish();
return;
}
string inputString = Input.inputString;
foreach (char c in inputString)
{
switch (c)
{
case '\b':
if (_value.Length > 0)
{
_value = _value.Substring(0, _value.Length - 1);
}
break;
case '\n':
case '\r':
Finish();
return;
default:
if (Uri.IsHexDigit(c) && _value.Length < 6)
{
_value += char.ToLowerInvariant(c);
}
break;
}
}
if (Input.GetKeyDown((KeyCode)27))
{
Finish();
}
else
{
Show();
}
}
private void Finish()
{
_editing = false;
if (_value.Length == 6 && _value != _good)
{
_good = _value;
_changed(_good);
}
else
{
_value = _good;
Show();
}
}
private void OnDisable()
{
if (_editing)
{
Finish();
}
}
private void Show()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)_back == (Object)null))
{
((Graphic)_back).color = (_editing ? Ui.Tint(0.24f) : Ui.Tint(0.14f));
bool flag = _editing && Mathf.Repeat(Time.unscaledTime, 1f) < 0.5f;
string text = "#" + _value + (flag ? "|" : "<alpha=#00>|</alpha>");
if (((TMP_Text)_text).text != text)
{
((TMP_Text)_text).text = text;
}
}
}
}
internal static class Ui
{
public static TMP_FontAsset Font;
public static FontStyles Style = (FontStyles)3;
public static Sprite Round;
public static Sprite RoundSmall;
public static Sprite RoundRing;
public static Sprite RoundSmallRing;
public static readonly Color Txt = Color32.op_Implicit(new Color32((byte)181, (byte)247, (byte)183, byte.MaxValue));
public static readonly Color Bg = Color32.op_Implicit(new Color32((byte)21, (byte)22, (byte)16, byte.MaxValue));
public static readonly Color GlassColor = Color32.op_Implicit(new Color32((byte)12, (byte)13, (byte)9, byte.MaxValue));
public const float GlassAlpha = 0.66f;
public static readonly Color Dim = Mix(0.66f);
private static readonly float[] CornerW = new float[4] { 1.14f, 0.86f, 1.21f, 0.93f };
private static readonly float[] CornerH = new float[4] { 0.93f, 1.14f, 0.86f, 1.07f };
private static readonly Dictionary<TMP_FontAsset, Material> CleanMats = new Dictionary<TMP_FontAsset, Material>();
public static Color Mix(float k)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
return Color.Lerp(Bg, Txt, k);
}
public static Color A(Color c, float a)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
c.a = a;
return c;
}
public static Color Tint(float k)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return A(Txt, k);
}
public static void Prepare()
{
if ((Object)(object)Round == (Object)null)
{
Round = RoundSprite(10);
}
if ((Object)(object)RoundSmall == (Object)null)
{
RoundSmall = RoundSprite(5);
}
if ((Object)(object)RoundRing == (Object)null)
{
RoundRing = RoundSprite(10, 1.5f);
}
if ((Object)(object)RoundSmallRing == (Object)null)
{
RoundSmallRing = RoundSprite(5, 1.25f);
}
FindFont();
}
private static void FindFont()
{
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: 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_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)Font != (Object)null)
{
return;
}
TMP_FontAsset[] array;
try
{
array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>();
}
catch
{
array = (TMP_FontAsset[])(object)new TMP_FontAsset[0];
}
int num = 0;
TMP_FontAsset[] array2 = array;
foreach (TMP_FontAsset val in array2)
{
if (!((Object)(object)val == (Object)null))
{
string text = ((Object)val).name.ToLowerInvariant();
int num2 = 0;
if (text.Contains("gothic") || text.Contains("century"))
{
num2 = 2;
}
if (text.Contains("gothicbi"))
{
num2 = 5;
}
else if (num2 > 0 && text.Contains("bold") && text.Contains("italic"))
{
num2 = 4;
}
else if (num2 > 0 && (text.Contains("bold") || text.Contains("italic")))
{
num2 = 3;
}
if (num2 > num)
{
num = num2;
Font = val;
}
}
}
if ((Object)(object)Font != (Object)null)
{
string text2 = ((Object)Font).name.ToLowerInvariant();
Style = (FontStyles)0;
if (!text2.Contains("gothicbi"))
{
if (!text2.Contains("italic"))
{
Style = (FontStyles)(Style | 2);
}
if (!text2.Contains("bold"))
{
Style = (FontStyles)(Style | 1);
}
}
}
if ((Object)(object)Font == (Object)null)
{
Font = TMP_Settings.defaultFontAsset;
}
}
private static Sprite RoundSprite(int r, float ring = 0f)
{
//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_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Expected O, but got Unknown
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_0268: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
float num = (float)r * CornerW[0];
float num2 = (float)r * CornerW[1];
float num3 = (float)r * CornerW[2];
float num4 = (float)r * CornerW[3];
float num5 = (float)r * CornerH[0];
float num6 = (float)r * CornerH[1];
float num7 = (float)r * CornerH[2];
float num8 = (float)r * CornerH[3];
int num9 = Mathf.CeilToInt(Mathf.Max(num, num4));
int num10 = Mathf.CeilToInt(Mathf.Max(num2, num3));
int num11 = Mathf.CeilToInt(Mathf.Max(num5, num6));
int num12 = Mathf.CeilToInt(Mathf.Max(num8, num7));
int num13 = num9 + num10 + 4;
int num14 = num11 + num12 + 4;
Texture2D val = new Texture2D(num13, num14, (TextureFormat)4, false)
{
wrapMode = (TextureWrapMode)1,
filterMode = (FilterMode)1
};
Color32[] array = (Color32[])(object)new Color32[num13 * num14];
for (int i = 0; i < num14; i++)
{
for (int j = 0; j < num13; j++)
{
float num15 = (float)j + 0.5f;
float num16 = (float)i + 0.5f;
float num17 = ((num15 < num && num16 > (float)num14 - num5) ? InEllipse(num15 - num, num16 - ((float)num14 - num5), num, num5) : ((num15 > (float)num13 - num2 && num16 > (float)num14 - num6) ? InEllipse(num15 - ((float)num13 - num2), num16 - ((float)num14 - num6), num2, num6) : ((num15 > (float)num13 - num3 && num16 < num7) ? InEllipse(num15 - ((float)num13 - num3), num16 - num7, num3, num7) : ((!(num15 < num4) || !(num16 < num8)) ? Mathf.Min(Mathf.Min(num15, (float)num13 - num15), Mathf.Min(num16, (float)num14 - num16)) : InEllipse(num15 - num4, num16 - num8, num4, num8)))));
float num18 = Mathf.Clamp01(num17 + 0.5f);
if (ring > 0f)
{
num18 *= Mathf.Clamp01(ring - num17 + 0.5f);
}
array[i * num13 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num18 * 255f));
}
}
val.SetPixels32(array);
val.Apply();
Object.DontDestroyOnLoad((Object)(object)val);
Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)num13, (float)num14), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)num9, (float)num12, (float)num10, (float)num11));
Object.DontDestroyOnLoad((Object)(object)obj);
return obj;
}
private static float InEllipse(float dx, float dy, float rx, float ry)
{
float num = dx / rx;
float num2 = dy / ry;
float num3 = Mathf.Sqrt(num * num + num2 * num2);
if (num3 < 0.0001f)
{
return Mathf.Min(rx, ry);
}
float num4 = Mathf.Sqrt(num * num / (rx * rx) + num2 * num2 / (ry * ry)) / num3;
return (1f - num3) / num4;
}
public static RectTransform Node(string name, Transform parent)
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
val.transform.SetParent(parent, false);
return (RectTransform)val.transform;
}
public static RectTransform At(RectTransform rt, float x, float y, float w, float h)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: 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_0046: Unknown result type (might be due to invalid IL or missing references)
Vector2 val = default(Vector2);
((Vector2)(ref val))..ctor(0f, 1f);
rt.anchorMax = val;
rt.anchorMin = val;
rt.pivot = new Vector2(0f, 1f);
rt.anchoredPosition = new Vector2(x, 0f - y);
rt.sizeDelta = new Vector2(w, h);
return rt;
}
public static RectTransform Fill(RectTransform rt)
{
//IL_0001: 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_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
rt.anchorMin = Vector2.zero;
rt.anchorMax = Vector2.one;
Vector2 offsetMin = (rt.offsetMax = Vector2.zero);
rt.offsetMin = offsetMin;
return rt;
}
public static Image Panel(Transform parent, Color c, Sprite s = null)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
Image val = ((Component)Node("panel", parent)).gameObject.AddComponent<Image>();
((Graphic)val).color = c;
((Graphic)val).raycastTarget = false;
if ((Object)(object)s != (Object)null)
{
val.sprite = s;
val.type = (Type)1;
}
return val;
}
public static Image Window(Transform parent, float alpha, Color color)
{
//IL_0001: 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_0019: Unknown result type (might be due to invalid IL or missing references)
Image val = Panel(parent, A(color, alpha), Round);
Edge(val, Tint(0.2f), small: false);
if (alpha < 1f)
{
Blur.Behind(val);
}
return val;
}
public static Slider MakeSlider(Transform parent, float min, float max, float val, UnityAction<float> onChange)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: 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_0202: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_0225: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: 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_024f: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
RectTransform val2 = Node("slider", parent);
((Graphic)((Component)val2).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0f);
RectTransform rectTransform = ((Graphic)Panel((Transform)(object)val2, Tint(0.2f), RoundSmall)).rectTransform;
rectTransform.anchorMin = new Vector2(0f, 0.5f);
rectTransform.anchorMax = new Vector2(1f, 0.5f);
rectTransform.sizeDelta = new Vector2(0f, 8f);
RectTransform obj = Node("fill area", (Transform)(object)val2);
obj.anchorMin = new Vector2(0f, 0.5f);
obj.anchorMax = new Vector2(1f, 0.5f);
obj.sizeDelta = new Vector2(0f, 8f);
Image val3 = Panel((Transform)(object)obj, A(Txt, 0.55f), RoundSmall);
((Graphic)val3).rectTransform.sizeDelta = Vector2.zero;
RectTransform obj2 = Node("handle area", (Transform)(object)val2);
Fill(obj2);
obj2.offsetMin = new Vector2(9f, 0f);
obj2.offsetMax = new Vector2(-9f, 0f);
Image val4 = Panel((Transform)(object)obj2, Txt, Round);
((Graphic)val4).raycastTarget = true;
Slider val5 = ((Component)val2).gameObject.AddComponent<Slider>();
val5.fillRect = ((Graphic)val3).rectTransform;
val5.handleRect = ((Graphic)val4).rectTransform;
((Selectable)val5).targetGraphic = (Graphic)(object)val4;
val5.direction = (Direction)0;
val5.minValue = min;
val5.maxValue = max;
val5.value = val;
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)0;
((Selectable)val5).navigation = navigation;
ColorBlock colors = ((Selectable)val5).colors;
((ColorBlock)(ref colors)).normalColor = new Color(1f, 1f, 1f, 0.85f);
((ColorBlock)(ref colors)).highlightedColor = Color.white;
((ColorBlock)(ref colors)).pressedColor = Color.white;
((ColorBlock)(ref colors)).selectedColor = ((ColorBlock)(ref colors)).normalColor;
((Selectable)val5).colors = colors;
((Graphic)val4).CrossFadeColor(((ColorBlock)(ref colors)).normalColor, 0f, true, true);
RectTransform rectTransform2 = ((Graphic)val4).rectTransform;
rectTransform2.anchorMin = new Vector2(rectTransform2.anchorMin.x, 0.5f);
rectTransform2.anchorMax = new Vector2(rectTransform2.anchorMax.x, 0.5f);
rectTransform2.sizeDelta = new Vector2(18f, 18f);
if (onChange != null)
{
((UnityEvent<float>)(object)val5.onValueChanged).AddListener(onChange);
}
return val5;
}
public static Image Edge(Image host, Color c, bool small = true)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
Image obj = Panel(((Component)host).transform, c, small ? RoundSmallRing : RoundRing);
Fill(((Graphic)obj).rectTransform);
return obj;
}
public static Image Accent(Transform parent)
{
//IL_0006: 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)
Image obj = Panel(parent, Tint(0.15f), RoundSmall);
Edge(obj, Tint(0.5f));
return obj;
}
private static Material CleanMaterial(TMP_FontAsset font)
{
//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_005b: Expected O, but got Unknown
if ((Object)(object)font == (Object)null || (Object)(object)((TMP_Asset)font).material == (Object)null)
{
return null;
}
if (CleanMats.TryGetValue(font, out var value) && (Object)(object)value != (Object)null)
{
return value;
}
try
{
value = new Material(((TMP_Asset)font).material)
{
name = ((Object)((TMP_Asset)font).material).name + " (crosshairs clean)"
};
value.DisableKeyword("OUTLINE_ON");
value.DisableKeyword("UNDERLAY_ON");
value.DisableKeyword("UNDERLAY_INNER");
value.DisableKeyword("GLOW_ON");
string[] array = new string[11]
{
"_OutlineWidth", "_OutlineSoftness", "_FaceDilate", "_UnderlayOffsetX", "_UnderlayOffsetY", "_UnderlayDilate", "_UnderlaySoftness", "_GlowPower", "_GlowOuter", "_GlowInner",
"_GlowOffset"
};
foreach (string text in array)
{
if (value.HasProperty(text))
{
value.SetFloat(text, 0f);
}
}
if (value.HasProperty("_Sharpness"))
{
value.SetFloat("_Sharpness", 0.35f);
}
ShaderUtilities.GetShaderPropertyIDs();
ShaderUtilities.UpdateShaderRatios(value);
Object.DontDestroyOnLoad((Object)(object)value);
}
catch
{
value = null;
}
CleanMats[font] = value;
return value;
}
public static TextMeshProUGUI Label(Transform parent, string text, float size, Color c, TextAlignmentOptions align = (TextAlignmentOptions)4097)
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI val = ((Component)Node("text", parent)).gameObject.AddComponent<TextMeshProUGUI>();
if ((Object)(object)Font != (Object)null)
{
((TMP_Text)val).font = Font;
}
Material val2 = CleanMaterial(((TMP_Text)val).font);
if ((Object)(object)val2 != (Object)null)
{
((TMP_Text)val).fontSharedMaterial = val2;
}
((TMP_Text)val).extraPadding = false;
if (size <= 18f)
{
((TMP_Text)val).characterSpacing = 5f;
}
((TMP_Text)val).fontStyle = Style;
((TMP_Text)val).text = text;
((TMP_Text)val).fontSize = size;
((Graphic)val).color = c;
((TMP_Text)val).alignment = align;
((TMP_Text)val).enableWordWrapping = true;
((TMP_Text)val).overflowMode = (TextOverflowModes)1;
((Graphic)val).raycastTarget = false;
return val;
}
public static Button Btn(Transform parent, string text, float size, UnityAction onClick, bool filled = false)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: 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_00a3: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0104: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
Image val = Panel(parent, filled ? Txt : Tint(0.14f), RoundSmall);
((Graphic)val).raycastTarget = true;
Button val2 = ((Component)val).gameObject.AddComponent<Button>();
ColorBlock colors = ((Selectable)val2).colors;
if (filled)
{
((ColorBlock)(ref colors)).normalColor = new Color(1f, 1f, 1f, 0.85f);
((ColorBlock)(ref colors)).highlightedColor = Color.white;
((ColorBlock)(ref colors)).pressedColor = new Color(1f, 1f, 1f, 0.65f);
}
else
{
((ColorBlock)(ref colors)).normalColor = new Color(1f, 1f, 1f, 0f);
((ColorBlock)(ref colors)).highlightedColor = Color.white;
((ColorBlock)(ref colors)).pressedColor = new Color(1f, 1f, 1f, 0.6f);
}
((ColorBlock)(ref colors)).selectedColor = ((ColorBlock)(ref colors)).normalColor;
((ColorBlock)(ref colors)).fadeDuration = 0.06f;
Navigation navigation = default(Navigation);
((Navigation)(ref navigation)).mode = (Mode)0;
((Selectable)val2).navigation = navigation;
((Selectable)val2).targetGraphic = (Graphic)(object)val;
((Selectable)val2).colors = colors;
((Graphic)val).CrossFadeColor(((ColorBlock)(ref colors)).normalColor, 0f, true, true);
if (onClick != null)
{
((UnityEvent)val2.onClick).AddListener(onClick);
}
if (text != null)
{
TextMeshProUGUI obj = Label(((Component)val).transform, text, size, filled ? Bg : Txt, (TextAlignmentOptions)(filled ? 514 : 4097));
((TMP_Text)obj).characterSpacing = 0f;
Fill(((TMP_Text)obj).rectTransform);
((TMP_Text)obj).margin = (Vector4)(filled ? Vector4.zero : new Vector4(16f, 0f, 16f, 0f));
}
return val2;
}
public static void Center(Button b)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
TextMeshProUGUI componentInChildren = ((Component)b).GetComponentInChildren<TextMeshProUGUI>();
if (!((Object)(object)componentInChildren == (Object)null))
{
((TMP_Text)componentInChildren).alignment = (TextAlignmentOptions)514;
((TMP_Text)componentInChildren).margin = Vector4.zero;
}
}
public static Canvas MakeCanvas(string name, int order)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
GameObject val = new GameObject(name);
Object.DontDestroyOnLoad((Object)val);
Canvas val2 = val.AddComponent<Canvas>();
val2.renderMode = (RenderMode)0;
val2.sortingOrder = order;
val2.pixelPerfect = true;
CanvasScaler obj = val.AddComponent<CanvasScaler>();
obj.uiScaleMode = (ScaleMode)1;
obj.referenceResolution = new Vector2(1920f, 1080f);
obj.matchWidthOrHeight = 1f;
val.AddComponent<GraphicRaycaster>();
return val2;
}
public static void EnsureEventSystem()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Expected O, but got Unknown
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)EventSystem.current != (Object)null) && !((Object)(object)Object.FindObjectOfType<EventSystem>() != (Object)null))
{
GameObject val = new GameObject("ezCrosshair EventSystem");
Object.DontDestroyOnLoad((Object)val);
val.AddComponent<EventSystem>();
val.AddComponent<StandaloneInputModule>();
}
}
}
[BepInPlugin("dorsth.straftat.ezcrosshair", "ezCrosshair", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public sealed class EzCrosshairPlugin : BaseUnityPlugin
{
public const string Guid = "dorsth.straftat.ezcrosshair";
public const string Name = "ezCrosshair";
public const string Version = "1.0.0";
internal const string ModMenuGuid = "kestrel.straftat.modmenu";
internal static readonly string[] Names = new string[12]
{
"dot", "square", "circle", "diamond", "dark diamond", "pinhole", "plus", "outlined plus", "chunky plus", "cross",
"star", "brackets"
};
internal static ManualLogSource Log;
internal static ConfigEntry<bool> On;
internal static ConfigEntry<string> Pick;
internal static ConfigEntry<Color> Tint;
internal static ConfigEntry<float> Scale;
internal static ConfigEntry<bool> ShowScoped;
internal static ConfigEntry<KeyCode> MenuKey;
private void Awake()
{
//IL_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
//IL_0084: 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_00d0: Expected O, but got Unknown
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Expected O, but got Unknown
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_018d: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
Log.LogMessage((object)"Dorsth was here");
On = ((BaseUnityPlugin)this).Config.Bind<bool>("Crosshair", "Enabled", true, "Shows your crosshair instead of the game's.");
Pick = ((BaseUnityPlugin)this).Config.Bind<string>("Crosshair", "Crosshair", Names[0], new ConfigDescription("Which crosshair.", (AcceptableValueBase)(object)new AcceptableValueList<string>(Names), Array.Empty<object>()));
Tint = ((BaseUnityPlugin)this).Config.Bind<Color>("Crosshair", "Color", Color.white, "Color of the crosshair. White keeps its own colors; the dark outline stays dark.");
Scale = ((BaseUnityPlugin)this).Config.Bind<float>("Crosshair", "Scale", 1f, new ConfigDescription("Size of the crosshair: 1 is its own size on a 1080p screen.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
ShowScoped = ((BaseUnityPlugin)this).Config.Bind<bool>("Crosshair", "Show While Scoped", false, "Keeps the crosshair on while you look through a scope.");
MenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Keys", "Menu", (KeyCode)283, "Opens the crosshair menu.");
try
{
Harmony val = new Harmony("dorsth.straftat.ezcrosshair");
val.Patch((MethodBase)AccessTools.Method(typeof(Crosshair), "Update", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(EzCrosshairPlugin), "GameCrosshairPostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
val.Patch((MethodBase)AccessTools.Method(typeof(PauseManager), "Update", (Type[])null, (Type[])null), new HarmonyMethod(typeof(EzCrosshairPlugin), "PauseUpdatePrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
catch (Exception ex)
{
Log.LogError((object)("Couldn't hide the game's crosshair: " + ex));
}
((Component)this).gameObject.AddComponent<Overlay>();
((Component)this).gameObject.AddComponent<Menu>();
if (Chainloader.PluginInfos.ContainsKey("kestrel.straftat.modmenu"))
{
try
{
ModMenuPage(((BaseUnityPlugin)this).Config);
}
catch (Exception ex2)
{
Log.LogWarning((object)("Mod Menu page failed: " + ex2.Message));
}
}
}
[MethodImpl(MethodImplOptions.NoInlining)]
private static void ModMenuPage(ConfigFile config)
{
List<ConfigEntryBase> list = new List<ConfigEntryBase>();
foreach (KeyValuePair<ConfigDefinition, ConfigEntryBase> item in config)
{
if ((object)item.Value != MenuKey)
{
list.Add(item.Value);
}
}
ModMenuCustomisation.HideEntries((IEnumerable<ConfigEntryBase>)list);
}
private static bool PauseUpdatePrefix(PauseManager __instance)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
if (!Menu.IsOpen)
{
return true;
}
__instance.pause = true;
if ((int)Cursor.lockState != 0)
{
Cursor.lockState = (CursorLockMode)0;
}
if (!Cursor.visible)
{
Cursor.visible = true;
}
return false;
}
private static void GameCrosshairPostfix(Crosshair __instance)
{
if (On.Value && (Object)(object)__instance.image != (Object)null && ((Behaviour)__instance.image).enabled)
{
((Behaviour)__instance.image).enabled = false;
}
}
}
internal static class Pictures
{
private static readonly Dictionary<string, Texture2D> Loaded = new Dictionary<string, Texture2D>();
public static Texture2D Get(string name)
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
if (Loaded.TryGetValue(name, out var value))
{
return value;
}
value = null;
try
{
string text = Images.Get(name);
if (text != null)
{
value = new Texture2D(2, 2, (TextureFormat)4, false)
{
wrapMode = (TextureWrapMode)1,
name = "ezCrosshair " + name
};
if (!ImageConversion.LoadImage(value, Convert.FromBase64String(text)))
{
Object.Destroy((Object)(object)value);
value = null;
}
else
{
((Texture)value).filterMode = (FilterMode)0;
Object.DontDestroyOnLoad((Object)(object)value);
}
}
else
{
EzCrosshairPlugin.Log.LogWarning((object)("No crosshair called " + name));
}
}
catch (Exception ex)
{
EzCrosshairPlugin.Log.LogError((object)("Couldn't load crosshair " + name + ": " + ex.Message));
}
Loaded[name] = value;
return value;
}
}
internal sealed class Overlay : MonoBehaviour
{
private GameObject _root;
private Canvas _canvas;
private RawImage _image;
private string _shown;
private bool _loggedSize;
private float _scale = -1f;
private int _screenW;
private int _screenH;
private static string _lastWhy;
private static int _sceneHandle = int.MinValue;
private static bool _mainMenu;
private void Make()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Expected O, but got Unknown
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Expected O, but got Unknown
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
_root = new GameObject("ezCrosshair");
Object.DontDestroyOnLoad((Object)(object)_root);
_canvas = _root.AddComponent<Canvas>();
_canvas.renderMode = (RenderMode)0;
_canvas.pixelPerfect = true;
_canvas.sortingOrder = 1;
GameObject val = new GameObject("Crosshair", new Type[1] { typeof(RectTransform) });
val.transform.SetParent(_root.transform, false);
_image = val.AddComponent<RawImage>();
((Graphic)_image).raycastTarget = false;
RectTransform rectTransform = ((Graphic)_image).rectTransform;
Vector2 anchorMin = (rectTransform.anchorMax = Vector2.zero);
rectTransform.anchorMin = anchorMin;
rectTransform.pivot = Vector2.zero;
((Behaviour)_image).enabled = false;
_shown = null;
EzCrosshairPlugin.Log.LogInfo((object)"Crosshair overlay made");
}
private void LateUpdate()
{
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0192: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_023f: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_0290: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: 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_02d0: Unknown result type (might be due to invalid IL or missing references)
bool flag = ShouldShow();
if ((Object)(object)_image == (Object)null)
{
if (!flag)
{
return;
}
Make();
}
if (((Behaviour)_image).enabled != flag)
{
((Behaviour)_image).enabled = flag;
}
if (!flag)
{
return;
}
Canvas canvas = ((Graphic)Crosshair.Instance.image).canvas;
int num = (((Object)(object)canvas != (Object)null) ? canvas.rootCanvas.sortingOrder : 0);
if (_canvas.sortingOrder != num)
{
_canvas.sortingOrder = num;
}
Texture2D val = Pictures.Get(EzCrosshairPlugin.Pick.Value);
if ((Object)(object)val == (Object)null)
{
((Behaviour)_image).enabled = false;
return;
}
if (!_loggedSize)
{
_loggedSize = true;
EzCrosshairPlugin.Log.LogInfo((object)("Crosshair " + EzCrosshairPlugin.Pick.Value + " " + ((Texture)val).width + "x" + ((Texture)val).height + " on a " + Screen.width + "x" + Screen.height + " screen, canvas order " + _canvas.sortingOrder));
}
if ((Object)(object)_image.texture != (Object)(object)val)
{
_image.texture = (Texture)(object)val;
}
Color value = EzCrosshairPlugin.Tint.Value;
if (((Graphic)_image).color != value)
{
((Graphic)_image).color = value;
}
float num2 = Mathf.Clamp(EzCrosshairPlugin.Scale.Value, 0f, 2f);
if (_shown != EzCrosshairPlugin.Pick.Value || num2 != _scale || Screen.width != _screenW || Screen.height != _screenH)
{
_shown = EzCrosshairPlugin.Pick.Value;
_scale = num2;
_screenW = Screen.width;
_screenH = Screen.height;
Vector2Int val2 = ScreenSize(val, num2);
int x = ((Vector2Int)(ref val2)).x;
int y = ((Vector2Int)(ref val2)).y;
RectTransform rectTransform = ((Graphic)_image).rectTransform;
float num3 = ((_canvas.scaleFactor > 0f) ? _canvas.scaleFactor : 1f);
rectTransform.sizeDelta = new Vector2((float)x, (float)y) / num3;
rectTransform.anchoredPosition = new Vector2(Mathf.Floor((float)(Screen.width - x) / 2f), Mathf.Floor((float)(Screen.height - y) / 2f)) / num3;
}
}
public static Vector2Int ScreenSize(Texture2D tex, float scale)
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
float num = scale * (float)Screen.height / 1080f;
return new Vector2Int(Mathf.RoundToInt((float)((Texture)tex).width * num), Mathf.RoundToInt((float)((Texture)tex).height * num));
}
private static bool ShouldShow()
{
string text = WhyHidden();
if (text != _lastWhy)
{
_lastWhy = text;
EzCrosshairPlugin.Log.LogInfo((object)((text == null) ? "Crosshair shown" : ("Crosshair hidden: " + text)));
}
return text == null;
}
private static string WhyHidden()
{
if (!EzCrosshairPlugin.On.Value)
{
return "turned off";
}
Crosshair instance = Crosshair.Instance;
if ((Object)(object)instance == (Object)null || (Object)(object)instance.image == (Object)null)
{
return "no game crosshair yet";
}
if (!((Behaviour)instance).isActiveAndEnabled)
{
return "the game's crosshair is switched off";
}
if ((Object)(object)instance.player == (Object)null)
{
return "no player";
}
if ((Object)(object)((Graphic)instance.image).canvas == (Object)null || !((Behaviour)((Graphic)instance.image).canvas).isActiveAndEnabled)
{
return "the game's HUD is switched off";
}
if (InMainMenu())
{
return "main menu";
}
if ((Object)(object)Camera.main != (Object)null)
{
return "dead or watching";
}
if (instance.canScopeAim && (Object)(object)instance.aimCrosshair != (Object)null && instance.player.isAiming && (Object)(object)instance.image.sprite == (Object)(object)instance.invisibleCrosshair && !EzCrosshairPlugin.ShowScoped.Value)
{
return "scoped";
}
return null;
}
public static bool InMainMenu()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).handle != _sceneHandle)
{
_sceneHandle = ((Scene)(ref activeScene)).handle;
_mainMenu = ((Scene)(ref activeScene)).name == "MainMenu";
}
return _mainMenu;
}
}