Decompiled source of Friendly Clock v1.0.0

BepInEx/plugins/FriendlyClock.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("FriendlyClock")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2a4ecd46c7fc63775456bbd4b080666c3766eb88")]
[assembly: AssemblyProduct("FriendlyClock")]
[assembly: AssemblyTitle("FriendlyClock")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FriendlyClock;

public sealed class DialGraphic : MaskableGraphic
{
	public enum Part
	{
		Face,
		Hand,
		Cap
	}

	public Part part;

	private bool _editMode;

	private int _segments = 12;

	private Texture2D _texture;

	private static readonly Vector2 LightDir = new Vector2(-0.6f, 0.8f);

	private static readonly Color32 Shadow = new Color32((byte)28, (byte)20, (byte)14, byte.MaxValue);

	private static readonly Color32 BronzeDark = new Color32((byte)92, (byte)62, (byte)32, byte.MaxValue);

	private static readonly Color32 BronzeLight = new Color32((byte)196, (byte)146, (byte)84, byte.MaxValue);

	private static readonly Color32 Cream = new Color32((byte)240, (byte)226, (byte)180, byte.MaxValue);

	public override Texture mainTexture
	{
		get
		{
			if (!((Object)(object)_texture != (Object)null))
			{
				return (Texture)(object)Graphic.s_WhiteTexture;
			}
			return (Texture)(object)_texture;
		}
	}

	public void SetTexture(Texture2D texture)
	{
		if ((Object)(object)_texture != (Object)null)
		{
			Object.Destroy((Object)(object)_texture);
		}
		_texture = texture;
		((Graphic)this).SetAllDirty();
	}

	public void SetEditMode(bool enabled)
	{
		if (_editMode != enabled)
		{
			_editMode = enabled;
			((Graphic)this).SetVerticesDirty();
		}
	}

	public void SetSegments(int count)
	{
		count = Mathf.Clamp(count, 2, 48);
		if (_segments != count)
		{
			_segments = count;
			((Graphic)this).SetVerticesDirty();
		}
	}

	protected override void OnPopulateMesh(VertexHelper vh)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: 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)
		vh.Clear();
		Rect rect = ((Graphic)this).rectTransform.rect;
		float width = ((Rect)(ref rect)).width;
		rect = ((Graphic)this).rectTransform.rect;
		float num = Mathf.Min(width, ((Rect)(ref rect)).height) * 0.5f;
		if (!(num <= 0f))
		{
			if ((Object)(object)_texture != (Object)null)
			{
				Textured(vh, num);
			}
			else if (part == Part.Hand)
			{
				Hand(vh, num);
			}
			else if (part == Part.Cap)
			{
				Cap(vh, num);
			}
			else
			{
				Face(vh, num);
			}
		}
	}

	private void Face(VertexHelper vh, float r)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: 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_008c: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: 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_02a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: 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_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f7: 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_0318: Unknown result type (might be due to invalid IL or missing references)
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_032a: Unknown result type (might be due to invalid IL or missing references)
		//IL_033f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		//IL_0351: 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_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		float num = (_editMode ? 1.25f : 1f);
		Ring(vh, r * 1.02f, 0f, new Color32((byte)0, (byte)0, (byte)0, (byte)90), new Color32((byte)0, (byte)0, (byte)0, (byte)90), new Vector2(2f, -2.5f));
		Ring(vh, r, r * 0.965f, Shadow, Shadow, Vector2.zero);
		Ring(vh, r * 0.965f, r * 0.84f, Tint(BronzeDark, num), Tint(BronzeLight, num), Vector2.zero);
		Ring(vh, r * 0.84f, r * 0.815f, Tint(BronzeLight, num), Tint(new Color32((byte)236, (byte)196, (byte)128, byte.MaxValue), num), Vector2.zero);
		Ring(vh, r * 0.815f, 0f, new Color32((byte)18, (byte)18, (byte)24, byte.MaxValue), new Color32((byte)18, (byte)18, (byte)24, byte.MaxValue), Vector2.zero);
		float radius = r * 0.79f;
		int num3;
		float num4;
		float num5;
		Color val;
		float num6;
		float num7;
		float angle;
		float angle2;
		for (int i = 0; i < _segments; num5 = num4, val = ((num3 != 0) ? Color.Lerp(Color32.op_Implicit(new Color32((byte)246, (byte)208, (byte)92, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)204, (byte)90, (byte)56, byte.MaxValue)), num5 * num5) : Color.Lerp(Color32.op_Implicit(new Color32((byte)58, (byte)84, (byte)118, byte.MaxValue)), Color32.op_Implicit(new Color32((byte)26, (byte)38, (byte)68, byte.MaxValue)), num5)), val *= ((i % 2 == 0) ? 1f : 0.92f), val.a = 1f, num6 = (float)i / (float)_segments - 0.25f, num7 = (float)(i + 1) / (float)_segments - 0.25f, angle = Angle(num6 + 0.0022f), angle2 = Angle(num7 - 0.0022f), Quad(vh, Point(r * 0.06f, angle), Point(radius, angle), Point(radius, angle2), Point(r * 0.06f, angle2), Color32.op_Implicit(val), Color32.op_Implicit(val)), i++)
		{
			float num2 = ((float)i + 0.5f) / (float)_segments;
			if (num2 > 0.25f)
			{
				num3 = ((num2 < 0.75f) ? 1 : 0);
				if (num3 != 0)
				{
					num4 = (num2 - 0.25f) / 0.5f;
					continue;
				}
			}
			else
			{
				num3 = 0;
			}
			num4 = Mathf.Repeat(num2 - 0.75f, 1f) / 0.5f;
		}
		Crescent(vh, new Vector2(-0.48f, -0.1f) * r, r * 0.13f, Cream);
		Star(vh, new Vector2(-0.4f, 0.36f) * r, r * 0.055f, Cream);
		Star(vh, new Vector2(-0.2f, 0.52f) * r, r * 0.035f, Cream);
		Star(vh, new Vector2(-0.22f, 0.24f) * r, r * 0.03f, Cream);
		Star(vh, new Vector2(-0.6f, 0.2f) * r, r * 0.03f, Cream);
		for (int j = 0; j < 4; j++)
		{
			Stud(vh, r, (float)j / 4f, num);
		}
	}

	private void Textured(VertexHelper vh, float r)
	{
		//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_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: 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_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_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: 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)
		Color32 val = Color32.op_Implicit(((Graphic)this).color);
		vh.AddVert(new Vector3(0f - r, 0f - r), val, new Vector4(0f, 0f));
		vh.AddVert(new Vector3(0f - r, r), val, new Vector4(0f, 1f));
		vh.AddVert(new Vector3(r, r), val, new Vector4(1f, 1f));
		vh.AddVert(new Vector3(r, 0f - r), val, new Vector4(1f, 0f));
		vh.AddTriangle(0, 1, 2);
		vh.AddTriangle(0, 2, 3);
	}

	private static void Hand(VertexHelper vh, float r)
	{
		//IL_0025: 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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		Vector2 o = default(Vector2);
		((Vector2)(ref o))..ctor(1.5f, -1.5f);
		Color32 c = default(Color32);
		((Color32)(ref c))..ctor((byte)20, (byte)16, (byte)12, (byte)200);
		Arrow(vh, r, o, c);
		Arrow(vh, r, Vector2.zero, Cream);
	}

	private static void Cap(VertexHelper vh, float r)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		Disc(vh, r * 0.13f, new Vector2(1.5f, -1.5f), new Color32((byte)20, (byte)16, (byte)12, (byte)200));
		Disc(vh, r * 0.12f, Vector2.zero, Shadow);
		Disc(vh, r * 0.1f, Vector2.zero, BronzeLight);
		Disc(vh, r * 0.04f, Vector2.zero, Shadow);
	}

	private static void Arrow(VertexHelper vh, float r, Vector2 o, Color32 c)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//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_001e: 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_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: 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_0071: 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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: 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)
		float num = r * 0.028f;
		Quad(vh, o + new Vector2(0f - num, (0f - r) * 0.1f), o + new Vector2(0f - num, r * 0.54f), o + new Vector2(num, r * 0.54f), o + new Vector2(num, (0f - r) * 0.1f), c, c);
		Tri(vh, o + new Vector2((0f - r) * 0.085f, r * 0.5f), o + new Vector2(0f, r * 0.74f), o + new Vector2(r * 0.085f, r * 0.5f), c);
	}

	private static void Stud(VertexHelper vh, float r, float at, float boost)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		Vector2 a = OnClock(r * 0.8f, at);
		Vector2 b = OnClock(r * 1.03f, at - 0.028f);
		Vector2 c = OnClock(r * 1.03f, at + 0.028f);
		Vector2 val = OnClock(r * 1.03f, at);
		Tri(vh, OnClock(r * 0.78f, at), OnClock(r * 1.06f, at - 0.032f), OnClock(r * 1.06f, at + 0.032f), Shadow);
		Tri(vh, a, b, val, Tint(BronzeLight, boost));
		Tri(vh, a, val, c, Tint(BronzeDark, boost));
	}

	private static void Crescent(VertexHelper vh, Vector2 centre, float radius, Color32 c)
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: 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_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val3 = default(Vector2);
		Vector2 val4 = default(Vector2);
		for (int i = 0; i < 16; i++)
		{
			float num = (float)Math.PI * (0.5f + (float)i / 16f);
			float num2 = (float)Math.PI * (0.5f + (float)(i + 1) / 16f);
			Vector2 val = new Vector2(Mathf.Cos(num), Mathf.Sin(num)) * radius;
			Vector2 val2 = new Vector2(Mathf.Cos(num2), Mathf.Sin(num2)) * radius;
			((Vector2)(ref val3))..ctor(val.x * 0.35f, val.y);
			((Vector2)(ref val4))..ctor(val2.x * 0.35f, val2.y);
			Quad(vh, centre + val3, centre + val, centre + val2, centre + val4, c, c);
		}
	}

	private static void Star(VertexHelper vh, Vector2 centre, float size, Color32 c)
	{
		//IL_0009: 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_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		float num = size * 0.22f;
		Diamond(vh, centre, num, size, c);
		Diamond(vh, centre, size, num, c);
	}

	private static void Diamond(VertexHelper vh, Vector2 centre, float halfW, float halfH, Color32 c)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: 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_0023: 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_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: 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_0072: Unknown result type (might be due to invalid IL or missing references)
		Tri(vh, centre + new Vector2(0f, halfH), centre + new Vector2(halfW, 0f), centre + new Vector2(0f - halfW, 0f), c);
		Tri(vh, centre + new Vector2(0f, 0f - halfH), centre + new Vector2(0f - halfW, 0f), centre + new Vector2(halfW, 0f), c);
	}

	private static void Ring(VertexHelper vh, float outer, float inner, Color32 dark, Color32 light, Vector2 o)
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: 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_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//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_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < 96; i++)
		{
			float angle = Angle((float)i / 96f);
			float angle2 = Angle((float)(i + 1) / 96f);
			Color32 ca = Lit(dark, light, angle);
			Color32 cb = Lit(dark, light, angle2);
			Quad(vh, Point(inner, angle) + o, Point(outer, angle) + o, Point(outer, angle2) + o, Point(inner, angle2) + o, ca, cb);
		}
	}

	private static Color32 Lit(Color32 dark, Color32 light, float angle)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		return Color32.Lerp(dark, light, 0.5f + 0.5f * Vector2.Dot(Point(1f, angle), LightDir));
	}

	private static Color32 Tint(Color32 c, float k)
	{
		//IL_0005: 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_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		return new Color32((byte)Mathf.Min(255f, (float)(int)c.r * k), (byte)Mathf.Min(255f, (float)(int)c.g * k), (byte)Mathf.Min(255f, (float)(int)c.b * k), c.a);
	}

	private static void Disc(VertexHelper vh, float radius, Vector2 o, Color32 c)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		Ring(vh, radius, 0f, c, c, o);
	}

	private static float Angle(float fraction)
	{
		return (float)Math.PI / 2f - fraction * (float)Math.PI * 2f;
	}

	private static Vector2 Point(float radius, float angle)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		return new Vector2(Mathf.Cos(angle) * radius, Mathf.Sin(angle) * radius);
	}

	private static Vector2 OnClock(float radius, float fraction)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		return Point(radius, Angle(fraction));
	}

	private static void Tri(VertexHelper vh, Vector2 a, Vector2 b, Vector2 c, Color32 color)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: 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_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		int currentVertCount = vh.currentVertCount;
		vh.AddVert(Vector2.op_Implicit(a), color, Vector4.zero);
		vh.AddVert(Vector2.op_Implicit(b), color, Vector4.zero);
		vh.AddVert(Vector2.op_Implicit(c), color, Vector4.zero);
		vh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2);
	}

	private static void Quad(VertexHelper vh, Vector2 a, Vector2 b, Vector2 c, Vector2 d, Color32 ca, Color32 cb)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: 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_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: 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_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_004a: Unknown result type (might be due to invalid IL or missing references)
		int currentVertCount = vh.currentVertCount;
		vh.AddVert(Vector2.op_Implicit(a), ca, Vector4.zero);
		vh.AddVert(Vector2.op_Implicit(b), ca, Vector4.zero);
		vh.AddVert(Vector2.op_Implicit(c), cb, Vector4.zero);
		vh.AddVert(Vector2.op_Implicit(d), cb, Vector4.zero);
		vh.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2);
		vh.AddTriangle(currentVertCount, currentVertCount + 2, currentVertCount + 3);
	}
}
public enum ClockStyle
{
	Dial,
	Words,
	DialAndWords
}
[BepInPlugin("com.mous.friendlyclock", "Friendly Clock", "1.0.0")]
public class FriendlyClockPlugin : BaseUnityPlugin
{
	public const string PluginGuid = "com.mous.friendlyclock";

	public const string PluginName = "Friendly Clock";

	public const string PluginVersion = "1.0.0";

	internal const string DefaultWords = "Midnight,Early Morning,Before Dawn,Dawn,Morning,Late Morning,Midday,Afternoon,Evening,Dusk,Night,Late Night";

	private ConfigEntry<bool> _enabled;

	private ConfigEntry<ClockStyle> _style;

	private ConfigEntry<bool> _showDay;

	private ConfigEntry<float> _size;

	private ConfigEntry<float> _fontSize;

	private ConfigEntry<float> _opacity;

	private ConfigEntry<Vector2> _position;

	private ConfigEntry<string> _words;

	private RectTransform _root;

	private DialGraphic _face;

	private static readonly string[] AssetFiles = new string[3] { "clock_face.png", "clock_hand.png", "clock_cap.png" };

	private readonly DialGraphic[] _parts = new DialGraphic[3];

	private readonly DateTime[] _assetStamps = new DateTime[3];

	private float _nextAssetCheck;

	private RectTransform _hand;

	private TextMeshProUGUI _label;

	private bool _dragging;

	private Vector2 _dragOffset;

	private static readonly Func<Texture2D, byte[], bool> LoadImage = (Func<Texture2D, byte[], bool>)Delegate.CreateDelegate(typeof(Func<Texture2D, byte[], bool>), Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule", throwOnError: true).GetMethod("LoadImage", new Type[2]
	{
		typeof(Texture2D),
		typeof(byte[])
	}));

	private void Awake()
	{
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Expected O, but got Unknown
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Expected O, but got Unknown
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Expected O, but got Unknown
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "Enabled", true, "Show the clock.");
		_style = ((BaseUnityPlugin)this).Config.Bind<ClockStyle>("1 - General", "Style", ClockStyle.DialAndWords, "Dial = day/night dial only, Words = fuzzy time of day only, DialAndWords = both.");
		_showDay = ((BaseUnityPlugin)this).Config.Bind<bool>("1 - General", "ShowDayCounter", false, "Show the current day number.");
		_size = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Layout", "Size", 110f, new ConfigDescription("Dial diameter in HUD units.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(48f, 240f), Array.Empty<object>()));
		_fontSize = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Layout", "FontSize", 20f, new ConfigDescription("Font size of the words / day counter.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 40f), Array.Empty<object>()));
		_opacity = ((BaseUnityPlugin)this).Config.Bind<float>("2 - Layout", "Opacity", 0.95f, new ConfigDescription("Overall opacity.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 1f), Array.Empty<object>()));
		_position = ((BaseUnityPlugin)this).Config.Bind<Vector2>("2 - Layout", "Position", new Vector2(0.17f, 0.12f), "Clock center on screen (0..1, x from left, y from bottom). Or open the inventory and drag the clock.");
		_words = ((BaseUnityPlugin)this).Config.Bind<string>("3 - Words", "DayPhases", "Midnight,Early Morning,Before Dawn,Dawn,Morning,Late Morning,Midday,Afternoon,Evening,Dusk,Night,Late Night", "Comma-separated phase names spread evenly across the day, starting at midnight. The dial draws one segment per phase (12 = two hours each; use a count divisible by 4 so sunrise/sunset land on segment edges).");
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Friendly Clock 1.0.0 loaded");
	}

	private void Update()
	{
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: 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_0217: 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_0253: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Hud.instance == (Object)null || (Object)(object)EnvMan.instance == (Object)null || ((Object)(object)_root == (Object)null && !TryCreate()))
		{
			return;
		}
		bool value = _enabled.Value;
		if (((Component)_root).gameObject.activeSelf != value)
		{
			((Component)_root).gameObject.SetActive(value);
		}
		if (value)
		{
			ClockStyle value2 = _style.Value;
			float value3 = _size.Value;
			float num = Mathf.Repeat(EnvMan.instance.GetDayFraction(), 1f);
			bool flag = InventoryGui.IsVisible();
			_root.sizeDelta = new Vector2(value3, value3);
			((Component)_root).GetComponent<CanvasGroup>().alpha = _opacity.Value;
			((Component)_face).gameObject.SetActive(value2 != ClockStyle.Words);
			_face.SetEditMode(flag);
			CheckAssets();
			_face.SetSegments(_words.Value.Split(new char[1] { ',' }).Length);
			((Transform)_hand).localRotation = Quaternion.Euler(0f, 0f, (0f - (num - 0.25f)) * 360f);
			string text = ((value2 == ClockStyle.Dial) ? "" : WordFor(num, _words.Value));
			if (_showDay.Value)
			{
				text = text + ((text == "") ? "" : "\n") + $"<size=80%>Day {EnvMan.instance.GetDay()}</size>";
			}
			if (((TMP_Text)_label).text != text)
			{
				((TMP_Text)_label).text = text;
			}
			((TMP_Text)_label).fontSize = _fontSize.Value;
			RectTransform rectTransform = ((TMP_Text)_label).rectTransform;
			bool flag2 = value2 != ClockStyle.Words;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, flag2 ? 0f : 0.5f);
			rectTransform.anchorMax = val;
			rectTransform.anchorMin = val;
			rectTransform.pivot = new Vector2(0.5f, flag2 ? 1f : 0.5f);
			rectTransform.anchoredPosition = new Vector2(0f, flag2 ? (-4f) : 0f);
			((TMP_Text)_label).verticalAlignment = (VerticalAlignmentOptions)(flag2 ? 256 : 512);
			Drag(flag);
		}
	}

	private void Drag(bool editing)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: 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_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(Input.mousePosition.x / (float)Screen.width, Input.mousePosition.y / (float)Screen.height);
		if (!_dragging && editing && Input.GetMouseButtonDown(0))
		{
			Canvas rootCanvas = ((Component)_root).GetComponentInParent<Canvas>().rootCanvas;
			Camera val2 = (((int)rootCanvas.renderMode == 0) ? null : rootCanvas.worldCamera);
			if (RectTransformUtility.RectangleContainsScreenPoint(((Component)_face).gameObject.activeSelf ? ((Graphic)_face).rectTransform : ((TMP_Text)_label).rectTransform, Vector2.op_Implicit(Input.mousePosition), val2))
			{
				_dragging = true;
				_dragOffset = _position.Value - val;
			}
		}
		Vector2 value = _position.Value;
		if (_dragging)
		{
			((Vector2)(ref value))..ctor(Mathf.Clamp01(val.x + _dragOffset.x), Mathf.Clamp01(val.y + _dragOffset.y));
			if (!editing || !Input.GetMouseButton(0))
			{
				_dragging = false;
				_position.Value = value;
			}
		}
		RectTransform root = _root;
		Vector2 anchorMin = (_root.anchorMax = value);
		root.anchorMin = anchorMin;
		_root.anchoredPosition = Vector2.zero;
	}

	internal static string WordFor(float dayFraction, string words)
	{
		string[] array = words.Split(new char[1] { ',' });
		int num = Mathf.Clamp((int)((float)array.Length * Mathf.Repeat(dayFraction, 1f)), 0, array.Length - 1);
		return array[num].Trim();
	}

	private bool TryCreate()
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Expected O, but got Unknown
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		TMP_Text val = (Object.op_Implicit((Object)(object)Hud.instance.m_statusEffectTemplate) ? ((Component)Hud.instance.m_statusEffectTemplate).GetComponentInChildren<TMP_Text>(true) : null);
		if ((Object)(object)val == (Object)null)
		{
			return false;
		}
		GameObject val2 = new GameObject("FriendlyClock", new Type[2]
		{
			typeof(RectTransform),
			typeof(CanvasGroup)
		});
		_root = (RectTransform)val2.transform;
		((Transform)_root).SetParent(Hud.instance.m_rootObject.transform, false);
		_root.pivot = new Vector2(0.5f, 0.5f);
		CanvasGroup component = val2.GetComponent<CanvasGroup>();
		component.blocksRaycasts = false;
		component.interactable = false;
		_face = Part("Face", (Transform)(object)_root, DialGraphic.Part.Face);
		_hand = ((Graphic)Part("Hand", ((Component)_face).transform, DialGraphic.Part.Hand)).rectTransform;
		Part("Cap", ((Component)_face).transform, DialGraphic.Part.Cap);
		_label = Child<TextMeshProUGUI>("Label", (Transform)(object)_root);
		((TMP_Text)_label).font = val.font;
		((TMP_Text)_label).fontSharedMaterial = val.fontSharedMaterial;
		((TMP_Text)_label).alignment = (TextAlignmentOptions)514;
		((TMP_Text)_label).textWrappingMode = (TextWrappingModes)0;
		((Graphic)_label).color = new Color(0.95f, 0.88f, 0.7f);
		((TMP_Text)_label).rectTransform.sizeDelta = new Vector2(240f, 60f);
		return true;
	}

	private DialGraphic Part(string name, Transform parent, DialGraphic.Part part)
	{
		DialGraphic dialGraphic = Child<DialGraphic>(name, parent);
		dialGraphic.part = part;
		((Graphic)dialGraphic).SetVerticesDirty();
		return _parts[(int)part] = dialGraphic;
	}

	private void CheckAssets()
	{
		//IL_00a0: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Expected O, but got Unknown
		if (Time.unscaledTime < _nextAssetCheck)
		{
			return;
		}
		_nextAssetCheck = Time.unscaledTime + 1f;
		string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
		for (int i = 0; i < AssetFiles.Length; i++)
		{
			string text = Path.Combine(directoryName, AssetFiles[i]);
			DateTime dateTime = (File.Exists(text) ? File.GetLastWriteTimeUtc(text) : default(DateTime));
			if (dateTime == _assetStamps[i])
			{
				continue;
			}
			_assetStamps[i] = dateTime;
			Texture2D val = null;
			if (dateTime != default(DateTime))
			{
				try
				{
					val = new Texture2D(2, 2, (TextureFormat)4, true)
					{
						wrapMode = (TextureWrapMode)1,
						filterMode = (FilterMode)2
					};
					if (!LoadImage(val, File.ReadAllBytes(text)))
					{
						throw new InvalidDataException("not a PNG/JPG");
					}
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Loaded {AssetFiles[i]} ({((Texture)val).width}x{((Texture)val).height})");
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not load " + text + ": " + ex.Message));
					if ((Object)(object)val != (Object)null)
					{
						Object.Destroy((Object)(object)val);
					}
					val = null;
				}
			}
			_parts[i].SetTexture(val);
		}
	}

	private static T Child<T>(string name, Transform parent) where T : Graphic
	{
		//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_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: 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_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_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name, new Type[2]
		{
			typeof(RectTransform),
			typeof(T)
		});
		RectTransform val2 = (RectTransform)val.transform;
		((Transform)val2).SetParent(parent, false);
		val2.anchorMin = Vector2.zero;
		val2.anchorMax = Vector2.one;
		Vector2 offsetMin = (val2.offsetMax = Vector2.zero);
		val2.offsetMin = offsetMin;
		T component = val.GetComponent<T>();
		((Graphic)component).raycastTarget = false;
		return component;
	}

	private void OnDestroy()
	{
		if ((Object)(object)_root != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)_root).gameObject);
		}
	}
}