Decompiled source of BetterScoutReport zh v1.0.3

BetterScoutReport_ZH.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreRunDetails;
using Newtonsoft.Json;
using Peak;
using Peak.Network;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BetterScoutReport_ZH")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+beb91238582d60e31105455f250d7a12bd6a2262")]
[assembly: AssemblyProduct("BetterScoutReport_ZH")]
[assembly: AssemblyTitle("BetterScoutReport_ZH")]
[assembly: AssemblyVersion("1.0.3.0")]
[module: RefSafetyRules(11)]
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;
		}
	}
	[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 BetterScoutReport_ZH
{
	internal static class FinalAscentTiming
	{
		private sealed class SaveData
		{
			public Guid RunId { get; set; }

			public List<SplitHistory.Split> Splits { get; set; } = new List<SplitHistory.Split>();
		}

		private static Func<bool>? isActive;

		private static Func<bool> isBuilder = null;

		private static Func<object?> currentStage = null;

		private static Func<IEnumerable> allStages = null;

		private static Func<Campfire, bool> isTerminal = null;

		private static Func<Transform, bool> isRestFire = null;

		private static MethodInfo keyOf = null;

		private static FieldInfo kind = null;

		private static FieldInfo title = null;

		private static FieldInfo next = null;

		private static List<SplitHistory.Split> splits = new List<SplitHistory.Split>();

		private static RunManager? currentRun;

		private static bool finished;

		private static string SavePath => Path.Combine(Application.persistentDataPath, "betterscoutreport-zh-tfa.json");

		internal static bool Active => isActive?.Invoke() ?? false;

		internal static bool Builder
		{
			get
			{
				if (Active)
				{
					return isBuilder();
				}
				return false;
			}
		}

		internal static IReadOnlyList<SplitHistory.Split> Splits => splits;

		private static bool CanRecord
		{
			get
			{
				if (Active && Object.op_Implicit((Object)(object)currentRun) && !finished && MapHandler.Exists)
				{
					return !Quicksave.ShouldUseSaveData;
				}
				return false;
			}
		}

		internal static void Install(Harmony harmony, Assembly assembly)
		{
			Type typeFromHandle = typeof(FinalAscentTiming);
			Type type = Find("FinalAscentSegments");
			Type type2 = Find("FinalAscentStage");
			Delegate obj = AccessTools.PropertyGetter(Find("FinalAscent"), "Active").CreateDelegate(typeof(Func<bool>));
			isBuilder = (Func<bool>)AccessTools.PropertyGetter(Find("FinalAscentBuilder"), "ChainBuild").CreateDelegate(typeof(Func<bool>));
			MethodInfo getCurrentStage = AccessTools.PropertyGetter(type, "CurrentStage");
			MethodInfo getAllStages = Plugin.Method(type, "AllStages");
			currentStage = () => getCurrentStage.Invoke(null, null);
			allStages = () => (IEnumerable)getAllStages.Invoke(null, null);
			isTerminal = (Func<Campfire, bool>)Plugin.Method(type, "IsTerminal").CreateDelegate(typeof(Func<Campfire, bool>));
			isRestFire = (Func<Transform, bool>)Plugin.Method(Find("FinalAscentGrow"), "IsRestPart").CreateDelegate(typeof(Func<Transform, bool>));
			keyOf = Plugin.Method(type, "KeyOf");
			kind = AccessTools.Field(type2, "Kind") ?? throw new MissingFieldException(type2.FullName, "Kind");
			title = AccessTools.Field(type2, "Title") ?? throw new MissingFieldException(type2.FullName, "Title");
			next = AccessTools.Field(type2, "Next") ?? throw new MissingFieldException(type2.FullName, "Next");
			HarmonyMethod val = Plugin.Hook(typeFromHandle, "BeforeGroupChange", 800);
			val.before = new string[1] { "com.CptPICHU.peak.truefinalascent" };
			harmony.Patch((MethodBase)Plugin.Method(typeof(MapHandler), "GoToSegment"), val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)Plugin.Method(type, "AdvanceStage"), Plugin.Hook(typeFromHandle, "BeforeStageChange"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)Plugin.Method(typeof(Campfire), "Light_Rpc"), Plugin.Hook(typeFromHandle, "BeforeTerminalCampfire", 800), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)Plugin.Method(typeof(RunManager), "StartRun"), Plugin.Hook(typeFromHandle, "StartRun"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)Plugin.Method(typeof(RunManager), "SetUpFromQuicksave"), (HarmonyMethod)null, Plugin.Hook(typeFromHandle, "Restore"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)Plugin.Method(typeof(Quicksave), "SaveNow"), (HarmonyMethod)null, Plugin.Hook(typeFromHandle, "Save"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)Plugin.Method(typeof(Character), "RPCEndGame"), Plugin.Hook(typeFromHandle, "Finish"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)Plugin.Method(typeof(Patches), "TrackSegment"), Plugin.Hook(typeFromHandle, "UseScoutTiming"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)Plugin.Method(typeof(Patches), "OnQuicksaveSave"), Plugin.Hook(typeFromHandle, "UseScoutTiming"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			isActive = (Func<bool>)obj;
			Type Find(string name)
			{
				return assembly.GetType("TrueFinalAscent." + name, throwOnError: true);
			}
		}

		private static bool UseScoutTiming()
		{
			return !Active;
		}

		private static void StartRun(RunManager __instance)
		{
			if (!((Object)(object)currentRun == (Object)(object)__instance))
			{
				currentRun = __instance;
				splits.Clear();
				finished = false;
			}
		}

		private static void BeforeGroupChange(Segment __0)
		{
			//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)
			if (CanRecord && __0 > MapHandler.CurrentSegmentNumber)
			{
				Record();
			}
		}

		private static void BeforeStageChange(object __0)
		{
			if (CanRecord && __0 != null)
			{
				Record(__0);
			}
		}

		private static void BeforeTerminalCampfire(Campfire __instance)
		{
			if (CanRecord && isTerminal(__instance) && !isRestFire(((Component)__instance).transform))
			{
				Record();
			}
		}

		private static void Finish()
		{
			if (CanRecord)
			{
				Record(null, ending: true);
				finished = true;
			}
		}

		private static void Record(object? nextFrom = null, bool ending = false)
		{
			try
			{
				object obj = currentStage();
				if (obj == null || (nextFrom != null && (obj != nextFrom || next.GetValue(obj) == null)))
				{
					return;
				}
				float timeSinceRunStarted = currentRun.TimeSinceRunStarted;
				if (!float.IsFinite(timeSinceRunStarted) || timeSinceRunStarted <= 0f)
				{
					return;
				}
				int num = 0;
				foreach (object item in allStages())
				{
					if (item == obj)
					{
						int key = (int)keyOf.Invoke(null, new object[1] { obj });
						string? obj2 = kind.GetValue(obj)?.ToString() ?? "";
						string text = title.GetValue(obj) as string;
						string name = ReportUi.StageName(obj2, text, useFinalAscentNames: true);
						Character localCharacter = Character.localCharacter;
						bool unfinished = ending && Object.op_Implicit((Object)(object)localCharacter) && !Character.CheckWinCondition(localCharacter);
						SplitHistory.Add(splits, num, key, timeSinceRunStarted, name, unfinished);
						break;
					}
					num++;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("未能记录当前分段:" + ex.Message));
			}
		}

		private static void Save(bool __runOriginal)
		{
			if (!__runOriginal || !CanRecord || !NetCode.Session.IsHost || splits.Count == 0)
			{
				return;
			}
			Guid runId = currentRun.RunId;
			if (runId == Guid.Empty)
			{
				return;
			}
			string text = SavePath + ".tmp";
			try
			{
				SaveData saveData = new SaveData
				{
					RunId = runId,
					Splits = splits
				};
				File.WriteAllText(text, JsonConvert.SerializeObject((object)saveData));
				if (File.Exists(SavePath))
				{
					File.Replace(text, SavePath, null);
				}
				else
				{
					File.Move(text, SavePath);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("未能保存分段计时:" + ex.Message));
			}
		}

		private static void Restore(Guid __0, float __1, bool __runOriginal)
		{
			if (!__runOriginal || !Active || !Object.op_Implicit((Object)(object)currentRun) || __0 == Guid.Empty || !File.Exists(SavePath))
			{
				return;
			}
			try
			{
				SaveData saveData = JsonConvert.DeserializeObject<SaveData>(File.ReadAllText(SavePath));
				if (saveData != null && !(saveData.RunId != __0) && saveData.Splits != null)
				{
					int[] route = (from object stage in allStages()
						select (int)keyOf.Invoke(null, new object[1] { stage })).ToArray();
					splits = SplitHistory.Restore(saveData.Splits, route, __1);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("未能恢复分段计时:" + ex.Message));
			}
		}
	}
	[BepInPlugin("aiae.peak.betterscoutreport.zh", "更好的童军汇报 · 简体中文", "1.0.3")]
	[BepInDependency("com.atomic.details", "0.2.8")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		internal const string Id = "aiae.peak.betterscoutreport.zh";

		internal const string FinalAscentId = "com.CptPICHU.peak.truefinalascent";

		private const string ScoutId = "com.atomic.details";

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("aiae.peak.betterscoutreport.zh");
			try
			{
				PluginInfo val2 = Chainloader.PluginInfos["com.atomic.details"];
				if (val2.Metadata.Version != new Version(0, 2, 8))
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"当前 BetterScoutReport 版本未适配,补丁未启用。");
					return;
				}
				ReportUi.Install(val, ((object)val2.Instance).GetType().Assembly);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"童军汇报简体中文已启用。");
			}
			catch (Exception arg)
			{
				val.UnpatchSelf();
				((BaseUnityPlugin)this).Logger.LogError((object)$"加载童军汇报汉化失败:{arg}");
				return;
			}
			if (!Chainloader.PluginInfos.TryGetValue("com.CptPICHU.peak.truefinalascent", out var value))
			{
				return;
			}
			Harmony val3 = new Harmony("aiae.peak.betterscoutreport.zh.tfa");
			try
			{
				if (value.Metadata.Version != new Version(3, 1, 2))
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"当前 True Final Ascent 版本未适配,仍可使用简体中文。");
					return;
				}
				FinalAscentTiming.Install(val3, ((object)value.Instance).GetType().Assembly);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"终极攀登分段计时已启用。");
			}
			catch (Exception arg2)
			{
				val3.UnpatchSelf();
				((BaseUnityPlugin)this).Logger.LogError((object)$"加载终极攀登计时兼容失败:{arg2}");
			}
		}

		internal static MethodInfo Method(Type type, string name)
		{
			return AccessTools.DeclaredMethod(type, name, (Type[])null, (Type[])null) ?? throw new MissingMethodException(type.FullName, name);
		}

		internal static HarmonyMethod Hook(Type type, string name, int priority = 400)
		{
			//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_0014: Expected O, but got Unknown
			return new HarmonyMethod(Method(type, name))
			{
				priority = priority
			};
		}
	}
	internal static class ReportUi
	{
		private const string TimelineTitle = "Panel/Margin/Layout/Window_TIMELINE/Title";

		private const float AscentSubtitleSize = 11f;

		private const float RightPageTitleSize = 22f;

		private const float RightPageRowSize = 14f;

		private static readonly Regex Timeline = new Regex("^TIMELINE \\(DAY: (\\d+)\\) \\((.*)\\)$", RegexOptions.CultureInvariant);

		private static Action<GameObject> trackObject = null;

		private static TMP_FontAsset? chineseFont;

		internal static void Install(Harmony harmony, Assembly assembly)
		{
			Type type = assembly.GetType("MoreRunDetails.UICreator", throwOnError: true);
			Type typeFromHandle = typeof(ReportUi);
			trackObject = (Action<GameObject>)Plugin.Method(type, "TrackObject").CreateDelegate(typeof(Action<GameObject>));
			harmony.Patch((MethodBase)Plugin.Method(type, "CreateOrUpdate"), (HarmonyMethod)null, Plugin.Hook(typeFromHandle, "TranslateReport"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			harmony.Patch((MethodBase)Plugin.Method(type, "PopulateEntries"), Plugin.Hook(typeFromHandle, "PopulateTimeline"), Plugin.Hook(typeFromHandle, "TranslateOriginalRows"), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void TranslateReport(EndScreen __0)
		{
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)__0).transform;
			Transform obj = transform.Find("Panel/Margin/Layout/Window_TIMELINE/Title");
			TMP_Text val = ((obj != null) ? ((Component)obj).GetComponent<TMP_Text>() : null);
			if ((Object)(object)val != (Object)null)
			{
				Match match = Timeline.Match(val.text);
				if (match.Success)
				{
					string value = match.Groups[2].Value;
					value = (value.StartsWith("TERRAIN RANDOMISER SEED: ", StringComparison.Ordinal) ? ("地形随机器种子 " + value.Substring("TERRAIN RANDOMISER SEED: ".Length)) : ((value == "TERRAIN RANDOMISER") ? "地形随机器" : ((!value.StartsWith("Level_", StringComparison.OrdinalIgnoreCase)) ? StageName(value, null, FinalAscentTiming.Active) : ("地图 " + value.Substring(6)))));
					SetText(val, "纪时表(第 " + match.Groups[1].Value + " 天 · " + value + ")");
				}
			}
			Transform obj2 = transform.Find("Panel/Margin/MoreDetailsAscent");
			TMP_Text val2 = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Text>() : null);
			if ((Object)(object)val2 != (Object)null)
			{
				int currentAscent = Ascents.currentAscent;
				string text = ((currentAscent < 0) ? "菜鸟新人" : ((currentAscent == 0) ? "顶峰(天阶 0)" : $"天阶 {currentAscent}"));
				string text2 = val2.text;
				string text3 = ((text2 == "MINI RUN") ? "速通局" : ((!(text2 == "CUSTOM RUN")) ? text : "自定义局"));
				string value2 = text3;
				if (FinalAscentTiming.Active)
				{
					value2 = (FinalAscentTiming.Builder ? "积木" : "终极攀登") + " · " + text;
				}
				SetFixedFontSize(val2, 11f);
				Transform val3 = transform.Find("Panel/Margin/SCOUTING_REPORT");
				if ((Object)(object)val3 != (Object)null)
				{
					val2.transform.localPosition = val3.localPosition + Vector3.down * 16f;
				}
				SetText(val2, value2);
			}
			Transform obj3 = transform.Find("Panel/Margin/MoreDetailsVersionNumber");
			TMP_Text val4 = ((obj3 != null) ? ((Component)obj3).GetComponent<TMP_Text>() : null);
			if ((Object)(object)val4 != (Object)null)
			{
				SetText(val4, val4.text.Replace("GAME ", "游戏 ").Replace("BSR ", "童军汇报 "));
			}
		}

		private static bool PopulateTimeline(GameObject __0, bool __1, out int __state)
		{
			__state = __0.transform.parent.childCount;
			TMP_Text component = __0.GetComponent<TMP_Text>();
			SetFixedFontSize(component, 22f);
			SetText(component, __1 ? "篝火计时" : "各段用时");
			if (!FinalAscentTiming.Active)
			{
				return true;
			}
			CreateStageList(__0, __1);
			__state = -1;
			return false;
		}

		private static void TranslateOriginalRows(GameObject __0, int __state)
		{
			if (__state < 0)
			{
				return;
			}
			Transform parent = __0.transform.parent;
			for (int i = __state; i < parent.childCount; i++)
			{
				Transform child = parent.GetChild(i);
				TMP_Text component = ((Component)child).GetComponent<TMP_Text>();
				if (!((Object)(object)component == (Object)null) && (component.text.Contains(((Object)child).name + " ") || component.text.Contains(((Object)child).name + ":")))
				{
					string newValue = StageName(((Object)child).name, ((Object)child).name);
					SetFixedFontSize(component, 14f);
					SetText(component, component.text.Replace(((Object)child).name, newValue).Replace(" [X]", "(未完成)").Replace(": ", ":"));
				}
			}
		}

		private static void CreateStageList(GameObject title, bool cumulative)
		{
			//IL_0027: 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_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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			TMP_Text component = title.GetComponent<TMP_Text>();
			RectTransform val = Rect("MoreDetails_StageList", title.transform.parent);
			val.sizeDelta = new Vector2(198f, 146f);
			((Transform)val).localPosition = title.transform.localPosition + new Vector3(0f, -26f, 0f);
			((Graphic)((Component)val).gameObject.AddComponent<Image>()).color = new Color(1f, 1f, 1f, 0.001f);
			((Component)val).gameObject.AddComponent<RectMask2D>();
			IReadOnlyList<SplitHistory.Split> splits = FinalAscentTiming.Splits;
			RectTransform val2 = Rect("Rows", (Transform)(object)val);
			val2.sizeDelta = new Vector2(198f, Math.Max(146f, (float)splits.Count * 24f));
			ScrollRect obj = ((Component)val).gameObject.AddComponent<ScrollRect>();
			obj.viewport = val;
			obj.content = val2;
			obj.horizontal = false;
			obj.vertical = (float)splits.Count * 24f > 146f;
			obj.movementType = (MovementType)2;
			obj.scrollSensitivity = 22f;
			Color color = ((Graphic)component).color;
			color.a *= 0.82f;
			if (splits.Count == 0)
			{
				AddLine(val2, "暂无计时记录", 0, color, 198f, 24f);
			}
			for (int i = 0; i < splits.Count; i++)
			{
				SplitHistory.Split split = splits[i];
				float? num = (cumulative ? new float?(split.Time) : split.Duration);
				string arg = (num.HasValue ? FormatTime(num.Value) : "—");
				string text = $"{split.Index + 1}. {split.Name}:{arg}";
				if (split.Died)
				{
					text += "(未完成)";
				}
				AddLine(val2, text, i, color, 198f, 24f);
			}
			trackObject(((Component)val).gameObject);
		}

		private static RectTransform Rect(string name, Transform parent)
		{
			//IL_0014: 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_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_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_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0053: 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_005f: Expected O, but got Unknown
			RectTransform val = (RectTransform)new GameObject(name, new Type[1] { typeof(RectTransform) }).transform;
			((Transform)val).SetParent(parent, false);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 1f);
			val.pivot = val2;
			Vector2 anchorMin = (val.anchorMax = val2);
			val.anchorMin = anchorMin;
			val.anchoredPosition = Vector2.zero;
			return val;
		}

		private static void AddLine(RectTransform content, string label, int index, Color color, float width, float height)
		{
			//IL_0017: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Rect("Stage", (Transform)(object)content);
			obj.anchoredPosition = new Vector2(0f, (0f - height) * (float)index);
			obj.sizeDelta = new Vector2(width - 12f, height);
			TextMeshProUGUI obj2 = ((Component)obj).gameObject.AddComponent<TextMeshProUGUI>();
			((TMP_Text)obj2).fontSize = 14f;
			((TMP_Text)obj2).fontSizeMin = 10f;
			((TMP_Text)obj2).fontSizeMax = 14f;
			((TMP_Text)obj2).enableAutoSizing = true;
			((TMP_Text)obj2).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)obj2).overflowMode = (TextOverflowModes)1;
			((TMP_Text)obj2).alignment = (TextAlignmentOptions)4097;
			((Graphic)obj2).raycastTarget = false;
			((TMP_Text)obj2).richText = false;
			((Graphic)obj2).color = color;
			SetText((TMP_Text)(object)obj2, label);
		}

		private static void SetFixedFontSize(TMP_Text text, float size)
		{
			text.enableAutoSizing = false;
			text.fontSize = size;
		}

		private static string FormatTime(float seconds)
		{
			long num = (long)seconds;
			return string.Format(CultureInfo.InvariantCulture, "{0}:{1:00}:{2:00}", num / 3600, num / 60 % 60, num % 60);
		}

		internal static string StageName(string kind, string? title, bool useFinalAscentNames = false)
		{
			string text = (string.IsNullOrWhiteSpace(title) ? kind : title);
			switch (text.Trim().ToUpperInvariant())
			{
			case "WILISLAND":
				return "岛屿";
			case "THE SHORE":
			case "BEACH":
			case "SHORE":
				return "海岸";
			case "TROPICS":
			case "THE TROPICS":
				return "雨林";
			case "THE ROOTS":
			case "ROOTS":
				return useFinalAscentNames ? "森林" : "森蕈";
			case "ALPINE":
			case "THE ALPINE":
				return "雪山";
			case "MESA":
			case "THE MESA":
				return "方山";
			case "VOLCANO":
			case "CALDERA":
			case "THE CALDERA":
				return "火山口";
			case "THE GLOOM":
			case "GLOOM":
			case "SWAMP":
				return "雾沼";
			case "THEKILN":
			case "KILN":
			case "THE KILN":
				return "熔炉";
			case "CITADEL":
			case "THE CITADEL":
			case "TEMPLE":
				return "城塞";
			case "AREA_VOID":
			case "THE NADIR":
			case "NADIR":
			case "VOID":
				return "天底";
			case "PEAK":
			case "THE PEAK":
				return "顶峰";
			case "":
				return "未知地貌";
			default:
				return text;
			}
		}

		private static void SetText(TMP_Text text, string value)
		{
			if (!Object.op_Implicit((Object)(object)chineseFont))
			{
				FontFallbackSwapper instance = FontFallbackSwapper.instance;
				if (instance != null && (Object)(object)instance.simplifiedChineseFont != (Object)null)
				{
					if ((Object)(object)instance.mainBaseFont != (Object)null)
					{
						chineseFont = Object.Instantiate<TMP_FontAsset>(instance.mainBaseFont);
						((Object)chineseFont).name = "BetterScoutReport_ZH_Font";
						chineseFont.fallbackFontAssetTable = new List<TMP_FontAsset> { instance.simplifiedChineseFont };
					}
					else
					{
						chineseFont = instance.simplifiedChineseFont;
					}
				}
			}
			if ((Object)(object)chineseFont != (Object)null && (Object)(object)chineseFont != (Object)(object)text.font)
			{
				text.font = chineseFont;
				text.fontSharedMaterial = ((TMP_Asset)chineseFont).material;
			}
			text.text = value;
		}
	}
	internal static class SplitHistory
	{
		internal sealed class Split
		{
			public int Index { get; set; }

			public int Key { get; set; }

			public float Time { get; set; }

			public float? Duration { get; set; }

			public string Name { get; set; } = "";

			public bool Died { get; set; }
		}

		internal static bool Add(List<Split> splits, int index, int key, float time, string name, bool unfinished)
		{
			Split split = ((splits.Count == 0) ? null : splits[splits.Count - 1]);
			if (index < 0 || !float.IsFinite(time) || time <= 0f || (split != null && (split.Index >= index || split.Time > time)))
			{
				return false;
			}
			float? duration = ((index == 0) ? new float?(time) : ((split?.Index == index - 1) ? new float?(time - split.Time) : ((float?)null)));
			splits.Add(new Split
			{
				Index = index,
				Key = key,
				Time = time,
				Duration = duration,
				Name = name,
				Died = unfinished
			});
			return true;
		}

		internal static List<Split> Restore(IEnumerable<Split> saved, IReadOnlyList<int> route, float savedTime)
		{
			List<Split> list = new List<Split>();
			if (!float.IsFinite(savedTime) || savedTime <= 0f)
			{
				return list;
			}
			foreach (Split item in saved)
			{
				if (item == null || item.Index < 0 || item.Index >= route.Count || item.Key != route[item.Index] || item.Time > savedTime || !Add(list, item.Index, item.Key, item.Time, item.Name, item.Died))
				{
					break;
				}
			}
			return list;
		}
	}
}