Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of HandyClock v1.0.2
HandyClock.dll
Decompiled 2 days agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("HandyClock")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2")] [assembly: AssemblyProduct("HandyClock")] [assembly: AssemblyTitle("HandyClock")] [assembly: AssemblyVersion("1.0.2.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace HandyClock { public sealed class ClockDragHandle : MonoBehaviour { private RectTransform _rectTransform; private RectTransform _parentRect; private Func<bool>? _canDrag; private Func<Vector2, Vector2>? _clamp; private Action<Vector2>? _save; private Vector2 _pointerOffset; private bool _dragging; public void Configure(Func<bool> canDrag, Func<Vector2, Vector2> clamp, Action<Vector2> save) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown _rectTransform = (RectTransform)((Component)this).transform; _parentRect = (RectTransform)((Component)this).transform.parent; _canDrag = canDrag; _clamp = clamp; _save = save; } private void Update() { bool mouseButton = Input.GetMouseButton(0); if (!_dragging && Input.GetMouseButtonDown(0)) { Func<bool>? canDrag = _canDrag; if (canDrag != null && canDrag() && IsPointerOverClock()) { BeginDrag(); } } if (_dragging && mouseButton) { ContinueDrag(); } if (_dragging && !mouseButton) { EndDrag(); } } private bool IsPointerOverClock() { //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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) Vector2 val = default(Vector2); if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(_rectTransform, Vector2.op_Implicit(Input.mousePosition), (Camera)null, ref val)) { return false; } Rect rect = _rectTransform.rect; float width = ((Rect)(ref rect)).width; rect = _rectTransform.rect; float num = Mathf.Min(width, ((Rect)(ref rect)).height) * 0.5f; return ((Vector2)(ref val)).sqrMagnitude <= num * num; } private void BeginDrag() { //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_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) if (TryGetPointerInParent(out var pointerPosition)) { _pointerOffset = _rectTransform.anchoredPosition - pointerPosition; _dragging = true; } } private void ContinueDrag() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (TryGetPointerInParent(out var pointerPosition)) { Vector2 val = pointerPosition + _pointerOffset; _rectTransform.anchoredPosition = _clamp?.Invoke(val) ?? val; } } private bool TryGetPointerInParent(out Vector2 pointerPosition) { //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) return RectTransformUtility.ScreenPointToLocalPointInRectangle(_parentRect, Vector2.op_Implicit(Input.mousePosition), (Camera)null, ref pointerPosition); } private void EndDrag() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) _dragging = false; _save?.Invoke(_rectTransform.anchoredPosition); } private void OnDisable() { if (_dragging) { EndDrag(); } } } public sealed class ClockFaceGraphic : MaskableGraphic, ICanvasRaycastFilter { private const int FaceSegments = 96; private const int RingSegments = 128; private bool _editMode; public void SetEditMode(bool enabled) { if (_editMode != enabled) { _editMode = enabled; ((Graphic)this).SetVerticesDirty(); } } public bool IsRaycastLocationValid(Vector2 screenPoint, Camera eventCamera) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(((Graphic)this).rectTransform, screenPoint, eventCamera, ref val)) { return false; } float sqrMagnitude = ((Vector2)(ref val)).sqrMagnitude; Rect rect = ((Graphic)this).rectTransform.rect; float width = ((Rect)(ref rect)).width; rect = ((Graphic)this).rectTransform.rect; return sqrMagnitude <= Mathf.Pow(Mathf.Min(width, ((Rect)(ref rect)).height) * 0.5f, 2f); } protected override void OnPopulateMesh(VertexHelper vertexHelper) { //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) //IL_005b: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) vertexHelper.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)) { AddRing(vertexHelper, num * 0.99f, num * 0.91f, new Color32((byte)12, (byte)10, (byte)9, (byte)150), 128, new Vector2(1.5f, -2f)); AddRing(vertexHelper, num * 0.98f, num * 0.85f, _editMode ? new Color32((byte)235, (byte)190, (byte)92, byte.MaxValue) : new Color32((byte)172, (byte)124, (byte)57, byte.MaxValue), 128, Vector2.zero); AddTriangleBorderPattern(vertexHelper, num, _editMode); AddRing(vertexHelper, num * 0.87f, num * 0.79f, new Color32((byte)42, (byte)32, (byte)27, byte.MaxValue), 128, Vector2.zero); float num2 = num * 0.79f; for (int i = 0; i < 96; i++) { float startFraction = (float)i / 96f; float endFraction = (float)(i + 1) / 96f; float hour = ((float)i + 0.5f) / 96f * 24f; AddSector(vertexHelper, 0f, num2, startFraction, endFraction, PhaseColor(hour)); } AddRing(vertexHelper, num2, num2 * 0.955f, new Color32((byte)236, (byte)207, (byte)137, (byte)38), 128, Vector2.zero); for (int j = 0; j < 12; j++) { float fraction = (float)j / 12f; float halfWidth = ((j % 3 == 0) ? (num * 0.025f) : (num * 0.014f)); float outerRadius = num * 0.81f; float innerRadius = ((j % 3 == 0) ? (num * 0.69f) : (num * 0.73f)); AddRadialMark(vertexHelper, fraction, innerRadius, outerRadius, halfWidth, new Color32((byte)38, (byte)31, (byte)28, (byte)170)); } } } private static Color32 PhaseColor(float hour) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_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_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_0044: 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_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00cc: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0171: 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_0185: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) Color val = Color32.op_Implicit(new Color32((byte)35, (byte)48, (byte)76, byte.MaxValue)); Color val2 = Color32.op_Implicit(new Color32((byte)25, (byte)35, (byte)60, byte.MaxValue)); Color val3 = Color32.op_Implicit(new Color32((byte)173, (byte)91, (byte)86, byte.MaxValue)); Color val4 = Color32.op_Implicit(new Color32((byte)224, (byte)181, (byte)70, byte.MaxValue)); Color val5 = Color32.op_Implicit(new Color32((byte)241, (byte)203, (byte)91, byte.MaxValue)); Color val6 = Color32.op_Implicit(new Color32((byte)112, (byte)69, (byte)91, byte.MaxValue)); Color val7 = ((hour < 4.5f) ? Color.Lerp(val, val2, Mathf.Abs(hour - 2.25f) / 2.25f * 0.35f) : ((hour < 5.5f) ? Color.Lerp(val, val3, hour - 4.5f) : ((hour < 7f) ? Color.Lerp(val3, val4, (hour - 5.5f) / 1.5f) : ((hour < 12f) ? Color.Lerp(val4, val5, (hour - 7f) / 5f) : ((hour < 17f) ? Color.Lerp(val5, val4, (hour - 12f) / 5f) : ((hour < 18.5f) ? Color.Lerp(val4, val3, (hour - 17f) / 1.5f) : ((hour < 20f) ? Color.Lerp(val3, val6, (hour - 18.5f) / 1.5f) : ((!(hour < 21f)) ? val : Color.Lerp(val6, val, hour - 20f))))))))); return Color32.op_Implicit(val7); } private static void AddSector(VertexHelper helper, float innerRadius, float outerRadius, float startFraction, float endFraction, Color32 color) { //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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //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_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_004c: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_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_0052: Unknown result type (might be due to invalid IL or missing references) float angle = (float)Math.PI / 2f - startFraction * (float)Math.PI * 2f; float angle2 = (float)Math.PI / 2f - endFraction * (float)Math.PI * 2f; Vector2 b = PointOnCircle(outerRadius, angle); Vector2 c = PointOnCircle(outerRadius, angle2); Vector2 a = PointOnCircle(innerRadius, angle); Vector2 d = PointOnCircle(innerRadius, angle2); AddQuad(helper, a, b, c, d, color); } private static void AddRing(VertexHelper helper, float outerRadius, float innerRadius, Color32 color, int segments, Vector2 offset) { //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) //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_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_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_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_0063: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_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_007b: 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_007e: 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) for (int i = 0; i < segments; i++) { float angle = (float)Math.PI / 2f - (float)i / (float)segments * (float)Math.PI * 2f; float angle2 = (float)Math.PI / 2f - (float)(i + 1) / (float)segments * (float)Math.PI * 2f; Vector2 a = PointOnCircle(innerRadius, angle) + offset; Vector2 b = PointOnCircle(outerRadius, angle) + offset; Vector2 c = PointOnCircle(outerRadius, angle2) + offset; Vector2 d = PointOnCircle(innerRadius, angle2) + offset; AddQuad(helper, a, b, c, d, color); } } private static void AddTriangleBorderPattern(VertexHelper helper, float radius, bool editMode) { //IL_003e: 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_0043: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: 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_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) Color32 color = default(Color32); ((Color32)(ref color))..ctor((byte)76, (byte)48, (byte)27, (byte)245); Color32 color2 = (editMode ? new Color32(byte.MaxValue, (byte)218, (byte)125, (byte)245) : new Color32((byte)211, (byte)154, (byte)70, (byte)225)); for (int i = 0; i < 24; i++) { float num = ((float)i + 0.5f) / 24f; float num2 = 0.012916666f; AddTriangle(helper, PointOnClock(radius * 0.952f, num - num2), PointOnClock(radius * 0.885f, num), PointOnClock(radius * 0.952f, num + num2), color); AddTriangle(helper, PointOnClock(radius * 0.933f, num - num2 * 0.56f), PointOnClock(radius * 0.902f, num), PointOnClock(radius * 0.933f, num + num2 * 0.56f), color2); } for (int j = 0; j < 4; j++) { float center = (float)j / 4f; AddTriangleMedallion(helper, radius, center, editMode); } } private static void AddTriangleMedallion(VertexHelper helper, float radius, float center, bool editMode) { //IL_003b: 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_0040: 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_0075: 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_009c: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_0110: 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_0136: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) Color32 color = default(Color32); ((Color32)(ref color))..ctor((byte)39, (byte)27, (byte)20, byte.MaxValue); Color32 color2 = (editMode ? new Color32((byte)235, (byte)190, (byte)92, byte.MaxValue) : new Color32((byte)161, (byte)105, (byte)48, byte.MaxValue)); Color32 color3 = default(Color32); ((Color32)(ref color3))..ctor((byte)224, (byte)174, (byte)85, byte.MaxValue); AddTriangle(helper, PointOnClock(radius * 1.045f, center), PointOnClock(radius * 0.835f, center - 0.038f), PointOnClock(radius * 0.835f, center + 0.038f), color); AddTriangle(helper, PointOnClock(radius * 1.005f, center), PointOnClock(radius * 0.858f, center - 0.03f), PointOnClock(radius * 0.858f, center + 0.03f), color2); AddTriangle(helper, PointOnClock(radius * 0.964f, center), PointOnClock(radius * 0.882f, center - 0.019f), PointOnClock(radius * 0.882f, center + 0.019f), color); AddTriangle(helper, PointOnClock(radius * 0.938f, center), PointOnClock(radius * 0.895f, center - 0.011f), PointOnClock(radius * 0.895f, center + 0.011f), color3); } private static void AddRadialMark(VertexHelper helper, float fraction, float innerRadius, float outerRadius, float halfWidth, Color32 color) { //IL_0027: 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_0034: 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_0042: 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_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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0076: Unknown result type (might be due to invalid IL or missing references) float num = (float)Math.PI / 2f - fraction * (float)Math.PI * 2f; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(Mathf.Cos(num), Mathf.Sin(num)); Vector2 val2 = new Vector2(0f - val.y, val.x) * halfWidth; AddQuad(helper, val * innerRadius - val2, val * outerRadius - val2, val * outerRadius + val2, val * innerRadius + val2, color); } private static Vector2 PointOnCircle(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 PointOnClock(float radius, float fraction) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) float angle = (float)Math.PI / 2f - fraction * (float)Math.PI * 2f; return PointOnCircle(radius, angle); } private static void AddTriangle(VertexHelper helper, Vector2 a, Vector2 b, Vector2 c, Color32 color) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0018: 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_0024: 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_0032: 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_0040: 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_0046: 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) int currentVertCount = helper.currentVertCount; UIVertex simpleVert = UIVertex.simpleVert; simpleVert.color = color; simpleVert.position = Vector2.op_Implicit(a); helper.AddVert(simpleVert); simpleVert.position = Vector2.op_Implicit(b); helper.AddVert(simpleVert); simpleVert.position = Vector2.op_Implicit(c); helper.AddVert(simpleVert); helper.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2); } private static void AddQuad(VertexHelper helper, Vector2 a, Vector2 b, Vector2 c, Vector2 d, Color32 color) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0018: 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_0024: 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_0032: 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_0040: 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_0046: 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_0054: 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_0061: Unknown result type (might be due to invalid IL or missing references) int currentVertCount = helper.currentVertCount; UIVertex simpleVert = UIVertex.simpleVert; simpleVert.color = color; simpleVert.position = Vector2.op_Implicit(a); helper.AddVert(simpleVert); simpleVert.position = Vector2.op_Implicit(b); helper.AddVert(simpleVert); simpleVert.position = Vector2.op_Implicit(c); helper.AddVert(simpleVert); simpleVert.position = Vector2.op_Implicit(d); helper.AddVert(simpleVert); helper.AddTriangle(currentVertCount, currentVertCount + 1, currentVertCount + 2); helper.AddTriangle(currentVertCount, currentVertCount + 2, currentVertCount + 3); } } [BepInPlugin("monok.handyclock", "Handy Clock", "1.0.2")] public sealed class HandyClockPlugin : BaseUnityPlugin { public const string PluginGuid = "monok.handyclock"; public const string PluginName = "Handy Clock"; public const string PluginVersion = "1.0.2"; private const float ReferenceWidth = 1920f; private const float ReferenceHeight = 1080f; private const float EdgePadding = 8f; private ConfigEntry<bool> _enabled; private ConfigEntry<float> _clockSize; private ConfigEntry<float> _opacity; private ConfigEntry<float> _positionX; private ConfigEntry<float> _positionY; private GameObject? _canvasObject; private GameObject? _clockObject; private RectTransform? _canvasRect; private RectTransform? _clockRect; private CanvasGroup? _canvasGroup; private ClockFaceGraphic? _face; private RectTransform? _handShadow; private RectTransform? _hand; private Sprite? _circleSprite; private Texture2D? _circleTexture; private bool _inventoryWasOpen; private int _lastScreenWidth; private int _lastScreenHeight; private void Awake() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown _enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Show the radial in-game clock."); _clockSize = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Size", 116f, new ConfigDescription("Clock diameter in UI pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(72f, 220f), Array.Empty<object>())); _opacity = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Opacity", 0.96f, new ConfigDescription("Overall clock opacity.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 1f), Array.Empty<object>())); _positionX = ((BaseUnityPlugin)this).Config.Bind<float>("Position", "X", 330f, "Clock center from the left edge at 1920x1080 reference scale."); _positionY = ((BaseUnityPlugin)this).Config.Bind<float>("Position", "Y", 132f, "Clock center from the bottom edge at 1920x1080 reference scale."); _clockSize.SettingChanged += OnAppearanceChanged; _opacity.SettingChanged += OnAppearanceChanged; _positionX.SettingChanged += OnPositionChanged; _positionY.SettingChanged += OnPositionChanged; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Handy Clock 1.0.2 loaded"); } private void Update() { //IL_012c: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) bool flag = (Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)Hud.instance != (Object)null; if ((Object)(object)_canvasObject == (Object)null && flag) { CreateUi(); } if ((Object)(object)_clockObject == (Object)null || (Object)(object)_canvasGroup == (Object)null) { return; } bool flag2 = flag && Hud.instance.IsVisible() && !Hud.IsUserHidden(); bool flag3 = _enabled.Value && flag2; if (_clockObject.activeSelf != flag3) { _clockObject.SetActive(flag3); } if (!flag3) { return; } bool flag4 = IsInventoryOpen(); if (flag4 != _inventoryWasOpen) { _inventoryWasOpen = flag4; _face?.SetEditMode(flag4); } if (_lastScreenWidth != Screen.width || _lastScreenHeight != Screen.height) { _lastScreenWidth = Screen.width; _lastScreenHeight = Screen.height; ClampClockToCanvas(); } if (!((Object)(object)EnvMan.instance == (Object)null)) { float num = Mathf.Repeat(EnvMan.instance.GetDayFraction(), 1f); Quaternion localRotation = Quaternion.Euler(0f, 0f, (0f - num) * 360f); if ((Object)(object)_handShadow != (Object)null) { ((Transform)_handShadow).localRotation = localRotation; } if ((Object)(object)_hand != (Object)null) { ((Transform)_hand).localRotation = localRotation; } } } private void CreateUi() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Expected O, but got Unknown //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0294: 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_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d3: Unknown result type (might be due to invalid IL or missing references) _canvasObject = new GameObject("HandyClockCanvas", new Type[4] { typeof(RectTransform), typeof(Canvas), typeof(CanvasScaler), typeof(GraphicRaycaster) }); Object.DontDestroyOnLoad((Object)(object)_canvasObject); Canvas component = _canvasObject.GetComponent<Canvas>(); component.renderMode = (RenderMode)0; component.sortingOrder = 30; CanvasScaler component2 = _canvasObject.GetComponent<CanvasScaler>(); component2.uiScaleMode = (ScaleMode)1; component2.referenceResolution = new Vector2(1920f, 1080f); component2.screenMatchMode = (ScreenMatchMode)0; component2.matchWidthOrHeight = 0.5f; _canvasRect = _canvasObject.GetComponent<RectTransform>(); _canvasGroup = _canvasObject.AddComponent<CanvasGroup>(); _canvasGroup.interactable = true; _canvasGroup.blocksRaycasts = false; _canvasGroup.alpha = _opacity.Value; _clockObject = new GameObject("HandyClock", new Type[3] { typeof(RectTransform), typeof(ClockFaceGraphic), typeof(ClockDragHandle) }); _clockObject.transform.SetParent(_canvasObject.transform, false); _clockRect = _clockObject.GetComponent<RectTransform>(); _clockRect.anchorMin = Vector2.zero; _clockRect.anchorMax = Vector2.zero; _clockRect.pivot = new Vector2(0.5f, 0.5f); _face = _clockObject.GetComponent<ClockFaceGraphic>(); ((Graphic)_face).raycastTarget = false; _clockObject.GetComponent<ClockDragHandle>().Configure(IsInventoryOpen, ClampPosition, SavePosition); CreateHand("HandShadow", Color32.op_Implicit(new Color32((byte)20, (byte)17, (byte)15, (byte)230)), 5.2f, 0.455f, new Vector2(1.2f, -1.2f), out _handShadow); CreateHand("TimeHand", Color32.op_Implicit(new Color32((byte)242, (byte)219, (byte)152, byte.MaxValue)), 2.5f, 0.455f, Vector2.zero, out _hand); _circleSprite = CreateCircleSprite(out _circleTexture); CreateCap("CenterCapShadow", 0.13f, Color32.op_Implicit(new Color32((byte)20, (byte)16, (byte)14, (byte)245)), new Vector2(1f, -1f)); CreateCap("CenterCap", 0.095f, Color32.op_Implicit(new Color32((byte)218, (byte)169, (byte)74, byte.MaxValue)), Vector2.zero); ApplyAppearance(); ApplyConfiguredPosition(); _lastScreenWidth = 0; _lastScreenHeight = 0; } private void CreateHand(string name, Color color, float width, float lengthRatio, Vector2 offset, out RectTransform handTransform) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown //IL_0054: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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) GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(_clockObject.transform, false); handTransform = val.GetComponent<RectTransform>(); handTransform.anchorMin = new Vector2(0.5f, 0.5f); handTransform.anchorMax = new Vector2(0.5f, 0.5f); handTransform.pivot = new Vector2(0.5f, 0f); handTransform.anchoredPosition = offset; handTransform.sizeDelta = new Vector2(width, _clockSize.Value * lengthRatio); Image component = val.GetComponent<Image>(); ((Graphic)component).color = color; ((Graphic)component).raycastTarget = false; } private void CreateCap(string name, float sizeRatio, Color color, Vector2 offset) { //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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_009a: 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) GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(_clockObject.transform, false); RectTransform component = val.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = offset; float num = _clockSize.Value * sizeRatio; component.sizeDelta = new Vector2(num, num); Image component2 = val.GetComponent<Image>(); component2.sprite = _circleSprite; ((Graphic)component2).color = color; ((Graphic)component2).raycastTarget = false; } private static Sprite CreateCircleSprite(out Texture2D texture) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0026: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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_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) texture = new Texture2D(48, 48, (TextureFormat)4, false) { name = "HandyClockCircle", filterMode = (FilterMode)1, wrapMode = (TextureWrapMode)1 }; Color[] array = (Color[])(object)new Color[2304]; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(23.5f, 23.5f); float num = 23.039999f; for (int i = 0; i < 48; i++) { for (int j = 0; j < 48; j++) { float num2 = Vector2.Distance(new Vector2((float)j, (float)i), val); float num3 = Mathf.Clamp01(num - num2 + 0.5f); array[i * 48 + j] = new Color(1f, 1f, 1f, num3); } } texture.SetPixels(array); texture.Apply(false, true); return Sprite.Create(texture, new Rect(0f, 0f, 48f, 48f), new Vector2(0.5f, 0.5f), 100f); } private bool IsInventoryOpen() { if ((Object)(object)InventoryGui.instance != (Object)null) { return InventoryGui.IsVisible(); } return false; } private Vector2 ClampPosition(Vector2 requested) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_canvasRect == (Object)null || (Object)(object)_clockRect == (Object)null) { return requested; } Rect rect = _clockRect.rect; float num = ((Rect)(ref rect)).width * 0.5f; Rect rect2 = _canvasRect.rect; return new Vector2(Mathf.Clamp(requested.x, num + 8f, ((Rect)(ref rect2)).width - num - 8f), Mathf.Clamp(requested.y, num + 8f, ((Rect)(ref rect2)).height - num - 8f)); } private void ClampClockToCanvas() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_clockRect != (Object)null) { _clockRect.anchoredPosition = ClampPosition(_clockRect.anchoredPosition); } } private void SavePosition(Vector2 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_004a: 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) Vector2 val = ClampPosition(position); if ((Object)(object)_clockRect != (Object)null) { _clockRect.anchoredPosition = val; } _positionX.Value = Mathf.Round(val.x * 10f) / 10f; _positionY.Value = Mathf.Round(val.y * 10f) / 10f; ((BaseUnityPlugin)this).Config.Save(); } private void OnAppearanceChanged(object sender, EventArgs args) { ApplyAppearance(); } private void OnPositionChanged(object sender, EventArgs args) { ApplyConfiguredPosition(); } private void ApplyAppearance() { //IL_0023: 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_009b: 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_00fa: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_clockRect == (Object)null)) { float value = _clockSize.Value; _clockRect.sizeDelta = new Vector2(value, value); if ((Object)(object)_canvasGroup != (Object)null) { _canvasGroup.alpha = _opacity.Value; } if ((Object)(object)_handShadow != (Object)null) { _handShadow.sizeDelta = new Vector2(5.2f, value * 0.455f); } if ((Object)(object)_hand != (Object)null) { _hand.sizeDelta = new Vector2(2.5f, value * 0.455f); } Transform obj = ((Transform)_clockRect).Find("CenterCapShadow"); RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null); if (val != null) { float num = value * 0.13f; val.sizeDelta = new Vector2(num, num); } Transform obj2 = ((Transform)_clockRect).Find("CenterCap"); RectTransform val2 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null); if (val2 != null) { float num2 = value * 0.095f; val2.sizeDelta = new Vector2(num2, num2); } ClockFaceGraphic? face = _face; if (face != null) { ((Graphic)face).SetVerticesDirty(); } ClampClockToCanvas(); } } private void ApplyConfiguredPosition() { //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) if ((Object)(object)_clockRect != (Object)null) { _clockRect.anchoredPosition = ClampPosition(new Vector2(_positionX.Value, _positionY.Value)); } } private void OnDestroy() { if ((Object)(object)_canvasObject != (Object)null) { Object.Destroy((Object)(object)_canvasObject); } if ((Object)(object)_circleSprite != (Object)null) { Object.Destroy((Object)(object)_circleSprite); } if ((Object)(object)_circleTexture != (Object)null) { Object.Destroy((Object)(object)_circleTexture); } } } }