Decompiled source of PdFlIndicator v1.0.0

PdFlIndicator.dll

Decompiled 2 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using FastText;
using FastText.Data;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Reflection;
using Microsoft.CodeAnalysis;
using UnityEngine;
using _K;
using _b;
using ifapp.Game;
using ifapp.Game.Scenes.Game.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("PdFlIndicator")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PdFlIndicator")]
[assembly: AssemblyTitle("PdFlIndicator")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PdFlIndicator
{
	[StructLayout(LayoutKind.Explicit, Size = 40)]
	public struct JudgementRecord
	{
		[FieldOffset(0)]
		public long Id;

		[FieldOffset(8)]
		public double RelativeMs;

		[FieldOffset(16)]
		public double AbsoluteMs;

		[FieldOffset(24)]
		public int Kind;

		[FieldOffset(28)]
		public int Metadata;

		[FieldOffset(32)]
		public byte Result;

		[FieldOffset(33)]
		public byte Finalized;
	}
	public static class NativeJudgementArray
	{
		public const int Stride = 40;

		public static Span<JudgementRecord> View(Il2CppStructArray<_cH> root)
		{
			Span<_cH> span = Il2CppStructArray<_cH>.op_Implicit(root);
			if (span.IsEmpty)
			{
				return Span<JudgementRecord>.Empty;
			}
			return MemoryMarshal.CreateSpan(ref Unsafe.As<_cH, JudgementRecord>(ref MemoryMarshal.GetReference(span)), span.Length);
		}
	}
	public sealed class PdFlBehaviour : MonoBehaviour
	{
		private const float TickSeconds = 0.1f;

		private float _nextTick;

		private ClearStateContainer _csc;

		private FastText _tm;

		private string _shownText;

		private int _exact;

		private int _exactBig;

		private int _exactSmall;

		private int _near;

		private int _brk;

		private int _lastExact = -1;

		private int _lastNear = -1;

		private int _lastBrk = -1;

		private bool _warned;

		private bool _labelWarned;

		private bool _textWarned;

		private FastText _tpl;

		private string _strippedNames;

		private float _diagAt = -1f;

		private Color _curColor = new Color(-1f, 0f, 0f);

		private Color _pdColor;

		private Color _flColor;

		private Color _clrColor;

		private bool _colorsResolved;

		private float[] _nearSince;

		private float[] _brkSince;

		private static ManualLogSource L => Plugin.Log2;

		public PdFlBehaviour(IntPtr p)
			: base(p)
		{
		}//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)


		public void Update()
		{
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime < _nextTick)
			{
				return;
			}
			_nextTick = unscaledTime + 0.1f;
			if (!Plugin.CfgEnabled.Value)
			{
				ApplyText(null);
				return;
			}
			EnsureAnchor();
			if ((Object)(object)_csc == (Object)null)
			{
				ApplyText(null);
				return;
			}
			CountJudgements(unscaledTime);
			ApplyText(BuildText());
			ApplyColor();
			if ((Object)(object)_tm != (Object)null && Object.op_Implicit((Object)(object)_tm))
			{
				FollowAnchor();
			}
			if (_diagAt > 0f && unscaledTime >= _diagAt && Plugin.CfgVerbose.Value)
			{
				_diagAt = -1f;
				Diag();
			}
			if (Plugin.CfgShowCounts.Value && (_exact != _lastExact || _near != _lastNear || _brk != _lastBrk))
			{
				_lastExact = _exact;
				_lastNear = _near;
				_lastBrk = _brk;
				ManualLogSource l = L;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(26, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[pdfl] exact=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_exact);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" near=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_near);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" break=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(_brk);
				}
				l.LogInfo(val);
			}
		}

		private string BuildText()
		{
			string value = ((_brk > 0) ? "" : ((_near <= 0) ? Plugin.CfgPdText.Value : Plugin.CfgFlText.Value));
			string text = Plugin.CfgFormat.Value;
			if (text == null)
			{
				text = "";
			}
			StringBuilder stringBuilder = new StringBuilder(text.Length + 16);
			for (int i = 0; i < text.Length; i++)
			{
				char c = text[i];
				if (c != '$' || i + 1 >= text.Length)
				{
					stringBuilder.Append(c);
					continue;
				}
				if (i + 2 < text.Length && text[i + 2] == 'e')
				{
					switch (text[i + 1])
					{
					case 'b':
						stringBuilder.Append(_exactBig);
						i += 2;
						continue;
					case 's':
						stringBuilder.Append(_exactSmall);
						i += 2;
						continue;
					}
				}
				switch (text[i + 1])
				{
				case '$':
					stringBuilder.Append('$');
					i++;
					break;
				case 's':
					stringBuilder.Append(value);
					i++;
					break;
				case 'e':
					stringBuilder.Append(_exact);
					i++;
					break;
				case 'n':
					stringBuilder.Append(_near);
					i++;
					break;
				case 'b':
					stringBuilder.Append(_brk);
					i++;
					break;
				default:
					stringBuilder.Append(c);
					break;
				}
			}
			string text2 = stringBuilder.ToString().Trim();
			if (text2.Length != 0)
			{
				return text2;
			}
			return null;
		}

		private void ApplyText(string text)
		{
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			if (text == _shownText)
			{
				return;
			}
			_shownText = text;
			bool flag = default(bool);
			try
			{
				if (string.IsNullOrEmpty(text))
				{
					if ((Object)(object)_tm != (Object)null && Object.op_Implicit((Object)(object)_tm))
					{
						((Component)_tm).gameObject.SetActive(false);
					}
					return;
				}
				EnsureLabel();
				if ((Object)(object)_tm == (Object)null)
				{
					return;
				}
				GameObject gameObject = ((Component)_tm).gameObject;
				if (!gameObject.activeSelf)
				{
					gameObject.SetActive(true);
				}
				FollowAnchor();
				_tm.SetTextNonLocalized(text, (UpdateType)0);
				if (Plugin.CfgVerbose.Value)
				{
					ManualLogSource l = L;
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(21, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[pdfl] text = '");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' pos=");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(((Component)_tm).transform.position);
					}
					l.LogInfo(val);
				}
			}
			catch (Exception ex)
			{
				if (!_textWarned)
				{
					_textWarned = true;
					ManualLogSource l2 = L;
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(16, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[pdfl] settext: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
					}
					l2.LogError(val2);
				}
				_shownText = null;
			}
		}

		private void EnsureAnchor()
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//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)
			if ((Object)(object)_csc != (Object)null && Object.op_Implicit((Object)(object)_csc))
			{
				return;
			}
			_csc = null;
			_tm = null;
			_labelWarned = false;
			_colorsResolved = false;
			_curColor = new Color(-1f, 0f, 0f);
			_shownText = null;
			_nearSince = null;
			_brkSince = null;
			try
			{
				_csc = Object.FindObjectOfType<ClearStateContainer>();
			}
			catch (Exception ex)
			{
				ManualLogSource l = L;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(23, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[pdfl] find container: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message);
				}
				l.LogError(val);
			}
		}

		private static bool Usable(FastText f)
		{
			if ((Object)(object)f != (Object)null && (Object)(object)f.fontFamilyAsset != (Object)null && ((Behaviour)f).isActiveAndEnabled)
			{
				return ((Object)((Component)f).gameObject).name.IndexOf("Shadow", StringComparison.OrdinalIgnoreCase) < 0;
			}
			return false;
		}

		private FastText FindTemplate()
		{
			try
			{
				Il2CppArrayBase<FastText> componentsInChildren = ((Component)((Component)_csc).transform.root).GetComponentsInChildren<FastText>(false);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					if (Usable(componentsInChildren[i]))
					{
						return componentsInChildren[i];
					}
				}
			}
			catch
			{
			}
			try
			{
				Il2CppArrayBase<FastText> val = Object.FindObjectsOfType<FastText>();
				for (int j = 0; j < val.Length; j++)
				{
					if (Usable(val[j]))
					{
						return val[j];
					}
				}
			}
			catch
			{
			}
			return null;
		}

		private static Color ParseColor(string hex, Color fallback)
		{
			//IL_007e: 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_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_0082: 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_003d: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (string.IsNullOrEmpty(hex))
				{
					return fallback;
				}
				string h = hex.Trim().TrimStart('#');
				if (h.Length != 6 && h.Length != 8)
				{
					return fallback;
				}
				return new Color(B(0), B(2), B(4), (h.Length == 8) ? B(6) : 1f);
				float B(int i)
				{
					return (float)Convert.ToInt32(h.Substring(i, 2), 16) / 255f;
				}
			}
			catch
			{
				return fallback;
			}
		}

		private void ResolveColors()
		{
			//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)
			//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_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)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_0098: 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_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_00b8: 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_00cd: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			if (!_colorsResolved && !((Object)(object)_csc == (Object)null))
			{
				_colorsResolved = true;
				_pdColor = new Color(0.94f, 0.61f, 1f);
				_flColor = new Color(0.7f, 0.71f, 1f);
				_clrColor = new Color(0.61f, 0.91f, 0.97f);
				_clrColor = ParseColor(Plugin.CfgClearColor.Value, _clrColor);
				_pdColor = ParseColor(Plugin.CfgPdColor.Value, _pdColor);
				_flColor = ParseColor(Plugin.CfgFlColor.Value, _flColor);
				ManualLogSource l = L;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(21, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[pdfl] colors pd=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Color>(_pdColor);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" fl=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Color>(_flColor);
				}
				l.LogInfo(val);
			}
		}

		private void ApplyColor()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//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_004b: 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_003d: 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_005b: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_tm == (Object)null || !Object.op_Implicit((Object)(object)_tm))
			{
				return;
			}
			ResolveColors();
			Color val = ((_brk > 0) ? _clrColor : ((_near > 0) ? _flColor : _pdColor));
			if (val == _curColor)
			{
				return;
			}
			_curColor = val;
			try
			{
				_tm.SetTextColor(val, (UpdateType)0);
			}
			catch (Exception ex)
			{
				ManualLogSource l = L;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(14, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[pdfl] color: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				l.LogError(val2);
			}
		}

		private static string DescText(FastText f)
		{
			//IL_0096: 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_0164: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)f == (Object)null || !Object.op_Implicit((Object)(object)f))
			{
				return "null";
			}
			StringBuilder stringBuilder = new StringBuilder();
			try
			{
				GameObject gameObject = ((Component)f).gameObject;
				Transform transform = gameObject.transform;
				StringBuilder stringBuilder2 = stringBuilder;
				StringBuilder stringBuilder3 = stringBuilder2;
				StringBuilder.AppendInterpolatedStringHandler handler = new StringBuilder.AppendInterpolatedStringHandler(43, 7, stringBuilder2);
				handler.AppendLiteral("'");
				handler.AppendFormatted(((Object)gameObject).name);
				handler.AppendLiteral("' active=");
				handler.AppendFormatted(gameObject.activeInHierarchy);
				handler.AppendLiteral(" layer=");
				handler.AppendFormatted(gameObject.layer);
				handler.AppendLiteral(" pos=");
				handler.AppendFormatted<Vector3>(transform.position);
				handler.AppendLiteral(" lossy=");
				handler.AppendFormatted<Vector3>(transform.lossyScale);
				handler.AppendLiteral(" size=");
				handler.AppendFormatted(f.fontSize);
				handler.AppendLiteral(" text='");
				handler.AppendFormatted(f.GetText());
				handler.AppendLiteral("'");
				stringBuilder3.Append(ref handler);
				MeshRenderer meshRenderer = f.meshRenderer;
				if ((Object)(object)meshRenderer != (Object)null)
				{
					stringBuilder2 = stringBuilder;
					StringBuilder stringBuilder4 = stringBuilder2;
					handler = new StringBuilder.AppendInterpolatedStringHandler(45, 7, stringBuilder2);
					handler.AppendLiteral(" mr.en=");
					handler.AppendFormatted(((Renderer)meshRenderer).enabled);
					handler.AppendLiteral(" vis=");
					handler.AppendFormatted(((Renderer)meshRenderer).isVisible);
					handler.AppendLiteral(" bounds=");
					handler.AppendFormatted<Bounds>(((Renderer)meshRenderer).bounds);
					handler.AppendLiteral(" sortL=");
					handler.AppendFormatted(((Renderer)meshRenderer).sortingLayerID);
					handler.AppendLiteral(" sortO=");
					handler.AppendFormatted(((Renderer)meshRenderer).sortingOrder);
					handler.AppendLiteral(" mat='");
					handler.AppendFormatted(((Object)(object)((Renderer)meshRenderer).sharedMaterial != (Object)null) ? ((Object)((Renderer)meshRenderer).sharedMaterial).name : "null");
					handler.AppendLiteral("' rq=");
					handler.AppendFormatted(((Object)(object)((Renderer)meshRenderer).sharedMaterial != (Object)null) ? ((Renderer)meshRenderer).sharedMaterial.renderQueue : (-1));
					stringBuilder4.Append(ref handler);
				}
				else
				{
					stringBuilder.Append(" mr=null");
				}
				MeshFilter meshFilter = f.meshFilter;
				if ((Object)(object)meshFilter != (Object)null && (Object)(object)meshFilter.sharedMesh != (Object)null)
				{
					stringBuilder2 = stringBuilder;
					StringBuilder stringBuilder5 = stringBuilder2;
					handler = new StringBuilder.AppendInterpolatedStringHandler(7, 1, stringBuilder2);
					handler.AppendLiteral(" verts=");
					handler.AppendFormatted(meshFilter.sharedMesh.vertexCount);
					stringBuilder5.Append(ref handler);
				}
				else
				{
					stringBuilder.Append(" mesh=null");
				}
				Il2CppArrayBase<Component> components = gameObject.GetComponents<Component>();
				stringBuilder.Append(" comps=");
				for (int i = 0; i < components.Length; i++)
				{
					stringBuilder.Append(((MemberInfo)((Object)components[i]).GetIl2CppType()).Name).Append(',');
				}
				if ((Object)(object)transform.parent != (Object)null)
				{
					stringBuilder2 = stringBuilder;
					StringBuilder stringBuilder6 = stringBuilder2;
					handler = new StringBuilder.AppendInterpolatedStringHandler(10, 1, stringBuilder2);
					handler.AppendLiteral(" parent='");
					handler.AppendFormatted(((Object)transform.parent).name);
					handler.AppendLiteral("'");
					stringBuilder6.Append(ref handler);
				}
			}
			catch (Exception ex)
			{
				stringBuilder.Append(" ERR ").Append(ex.Message);
			}
			return stringBuilder.ToString();
		}

		private void Diag()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			ManualLogSource l = L;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[pdfl][diag] stripped=");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(_strippedNames);
			}
			l.LogInfo(val);
			ManualLogSource l2 = L;
			val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[pdfl][diag] tpl  ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DescText(_tpl));
			}
			l2.LogInfo(val);
			ManualLogSource l3 = L;
			val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[pdfl][diag] mine ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(DescText(_tm));
			}
			l3.LogInfo(val);
			try
			{
				ManualLogSource l4 = L;
				val = new BepInExInfoLogInterpolatedStringHandler(38, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[pdfl][diag] csc pos=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(((Component)_csc).transform.position);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" lossy=");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Vector3>(((Component)_csc).transform.lossyScale);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" parent='");
					BepInExInfoLogInterpolatedStringHandler obj = val;
					Transform parent = ((Component)_csc).transform.parent;
					((BepInExLogInterpolatedStringHandler)obj).AppendFormatted<string>((parent != null) ? ((Object)parent).name : null);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("'");
				}
				l4.LogInfo(val);
			}
			catch
			{
			}
		}

		private void FollowAnchor()
		{
			//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_005a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_tm == (Object)null) && !((Object)(object)_csc == (Object)null))
			{
				Transform transform = ((Component)_csc).transform;
				Transform transform2 = ((Component)_tm).transform;
				transform2.position = transform.TransformPoint(new Vector3(0f, Plugin.CfgOffsetY.Value, -0.06f));
				transform2.rotation = transform.rotation;
			}
		}

		private void EnsureLabel()
		{
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Expected O, but got Unknown
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Expected O, but got Unknown
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_tm != (Object)null && Object.op_Implicit((Object)(object)_tm))
			{
				return;
			}
			_tm = null;
			if ((Object)(object)_csc == (Object)null)
			{
				return;
			}
			bool flag = default(bool);
			try
			{
				FastText val = FindTemplate();
				if ((Object)(object)val == (Object)null)
				{
					if (!_labelWarned)
					{
						_labelWarned = true;
						L.LogWarning((object)"[pdfl] no FastText template yet");
					}
					return;
				}
				_strippedNames = "";
				GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)_csc).transform.parent, false);
				((Object)val2).name = "pdfl-label";
				val2.layer = ((Component)_csc).gameObject.layer;
				Transform transform = val2.transform;
				for (int num = transform.childCount - 1; num >= 0; num--)
				{
					Object.DestroyImmediate((Object)(object)((Component)transform.GetChild(num)).gameObject);
				}
				Il2CppArrayBase<Component> components = val2.GetComponents<Component>();
				for (int i = 0; i < components.Length; i++)
				{
					Component val3 = components[i];
					if (!((Object)(object)val3 == (Object)null) && !((Object)(object)((Il2CppObjectBase)val3).TryCast<Transform>() != (Object)null) && !((Object)(object)((Il2CppObjectBase)val3).TryCast<FastText>() != (Object)null) && !((Object)(object)((Il2CppObjectBase)val3).TryCast<MeshFilter>() != (Object)null) && !((Object)(object)((Il2CppObjectBase)val3).TryCast<MeshRenderer>() != (Object)null))
					{
						_strippedNames = _strippedNames + ((MemberInfo)((Object)val3).GetIl2CppType()).Name + ",";
						Object.DestroyImmediate((Object)(object)val3);
					}
				}
				Vector3 lossyScale = ((Component)val).transform.lossyScale;
				Vector3 val4 = (((Object)(object)transform.parent != (Object)null) ? transform.parent.lossyScale : Vector3.one);
				float num2 = Math.Max(0.01f, Plugin.CfgTextScale.Value);
				transform.localScale = new Vector3(lossyScale.x / val4.x * num2, lossyScale.y / val4.y * num2, lossyScale.z / val4.z);
				FastText component = val2.GetComponent<FastText>();
				component.SetAlignment((AlignmentOptions)4, (UpdateType)0);
				component.SetTextColor(Color.white, (UpdateType)0);
				_tm = component;
				_tpl = val;
				_diagAt = Time.unscaledTime + 1.5f;
				FollowAnchor();
				ManualLogSource l = L;
				BepInExInfoLogInterpolatedStringHandler val5 = new BepInExInfoLogInterpolatedStringHandler(55, 4, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[pdfl] label created from template '");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(((Object)((Component)val).gameObject).name);
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("' size=");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<float>(component.fontSize);
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" pos=");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<Vector3>(transform.position);
					((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" scale=");
					((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<Vector3>(transform.lossyScale);
				}
				l.LogInfo(val5);
			}
			catch (Exception ex)
			{
				if (!_labelWarned)
				{
					_labelWarned = true;
					ManualLogSource l2 = L;
					BepInExErrorLogInterpolatedStringHandler val6 = new BepInExErrorLogInterpolatedStringHandler(14, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[pdfl] label: ");
						((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<Exception>(ex);
					}
					l2.LogError(val6);
				}
			}
		}

		private void CountJudgements(float now)
		{
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			_exact = 0;
			_exactBig = 0;
			_exactSmall = 0;
			_near = 0;
			_brk = 0;
			try
			{
				LogicalNotePlayer qe = LogicalNotePlayer._Qe;
				if ((Object)(object)qe == (Object)null)
				{
					return;
				}
				_T ve = qe._ve;
				if (ve == null)
				{
					return;
				}
				Memory<_cH> cd = ve._cd;
				if (cd == null)
				{
					return;
				}
				Object val = cd._object;
				if (val == null)
				{
					return;
				}
				Il2CppStructArray<_cH> val2 = new Il2CppStructArray<_cH>(((Il2CppObjectBase)val).Pointer);
				int index = cd._index;
				int dd = ve._Dd;
				int num = cd._length & 0x7FFFFFFF;
				if (index < 0 || dd <= 0 || dd > 120000 || dd > num || index + dd > ((Il2CppArrayBase<_cH>)(object)val2).Length)
				{
					return;
				}
				if (_nearSince == null || _nearSince.Length < dd)
				{
					_nearSince = new float[dd];
					_brkSince = new float[dd];
				}
				float num2 = Math.Max(0f, Plugin.CfgStable.Value);
				Span<JudgementRecord> span = NativeJudgementArray.View(val2);
				for (int i = 0; i < dd; i++)
				{
					byte result = span[index + i].Result;
					bool num3 = result == 2 || result == 3;
					bool flag = result == 1;
					switch (result)
					{
					case 6:
						_exactBig++;
						break;
					case 4:
					case 5:
						_exactSmall++;
						break;
					}
					if (num3)
					{
						if (_nearSince[i] <= 0f)
						{
							_nearSince[i] = now;
						}
						if (now - _nearSince[i] >= num2)
						{
							_near++;
						}
					}
					else
					{
						_nearSince[i] = 0f;
					}
					if (flag)
					{
						if (_brkSince[i] <= 0f)
						{
							_brkSince[i] = now;
						}
						if (now - _brkSince[i] >= num2)
						{
							_brk++;
						}
					}
					else
					{
						_brkSince[i] = 0f;
					}
				}
				_exact = _exactBig + _exactSmall;
			}
			catch (Exception ex)
			{
				if (!_warned)
				{
					_warned = true;
					ManualLogSource l = L;
					bool flag2 = default(bool);
					BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(14, 1, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[pdfl] count: ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
					}
					l.LogError(val3);
				}
			}
		}
	}
	[BepInPlugin("pdfl.indicator", "PD/FL Indicator", "1.0.0")]
	public sealed class Plugin : BasePlugin
	{
		internal static ManualLogSource Log2;

		internal static ConfigEntry<bool> CfgEnabled;

		internal static ConfigEntry<float> CfgOffsetY;

		internal static ConfigEntry<float> CfgTextScale;

		internal static ConfigEntry<string> CfgPdColor;

		internal static ConfigEntry<string> CfgFlColor;

		internal static ConfigEntry<string> CfgClearColor;

		internal static ConfigEntry<string> CfgFormat;

		internal static ConfigEntry<string> CfgPdText;

		internal static ConfigEntry<string> CfgFlText;

		internal static ConfigEntry<float> CfgStable;

		internal static ConfigEntry<bool> CfgShowCounts;

		internal static ConfigEntry<bool> CfgVerbose;

		public override void Load()
		{
			Log2 = ((BasePlugin)this).Log;
			CfgEnabled = ((BasePlugin)this).Config.Bind<bool>("General", "Enabled", true, "显示顶部状态/判定计数");
			CfgOffsetY = ((BasePlugin)this).Config.Bind<float>("Layout", "OffsetY", -0.35f, "文字相对 clearstate 容器的垂直偏移(容器单位,负值向下)。默认 -0.35 = 回忆值条正下方");
			CfgTextScale = ((BasePlugin)this).Config.Bind<float>("Layout", "TextScale", 0.3f, "文字大小,相对于游戏分数文字的倍数");
			CfgPdColor = ((BasePlugin)this).Config.Bind<string>("Color", "PdColor", "#F09CFF", "PD 时文字颜色(游戏 PERFECT DIVE 粉紫)");
			CfgFlColor = ((BasePlugin)this).Config.Bind<string>("Color", "FlColor", "#B3B5FF", "FL 时文字颜色(游戏 FULL LINK 淡蓝紫)");
			CfgClearColor = ((BasePlugin)this).Config.Bind<string>("Color", "ClearColor", "#9CE8F7", "BREAK 后文字颜色(游戏 DIVE CLEARED 青色)");
			CfgFormat = ((BasePlugin)this).Config.Bind<string>("Text", "Format", "$s $e | $n | $b", "显示格式。$s=状态(PD/FL/空) $e=EXACT 总数 $be=大 EXACT 数 $se=小 EXACT 数 $n=NEAR 数 $b=BREAK 数,$$ 输出一个 $");
			CfgPdText = ((BasePlugin)this).Config.Bind<string>("Text", "PdText", "PD", "没有 NEAR / BREAK 时 $s 的值");
			CfgFlText = ((BasePlugin)this).Config.Bind<string>("Text", "FlText", "FL", "有 NEAR 但没有 BREAK 时 $s 的值");
			CfgStable = ((BasePlugin)this).Config.Bind<float>("Judgement", "StableSeconds", 0.35f, "NEAR/BREAK 需要持续这么久(秒)才计入,用于过滤 hold 的中间态抖动");
			CfgShowCounts = ((BasePlugin)this).Config.Bind<bool>("Debug", "ShowCounts", false, "把计数变化打到日志");
			CfgVerbose = ((BasePlugin)this).Config.Bind<bool>("Debug", "Verbose", false, "状态变化时写日志");
			((BasePlugin)this).AddComponent<PdFlBehaviour>();
			Log2.LogInfo((object)"[pdfl] loaded 1.0.0");
		}
	}
}