Decompiled source of jiancai wangge skills v1.0.0

BepInEx\plugins\jiancai_wangge_skills.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.SceneManagement;
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("jiancai_wangge_skills")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("建材王哥游戏技巧提示 Mod")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+694d9aff18ab0039311524efcc8404e3b589cd43")]
[assembly: AssemblyProduct("jiancai_wangge_skills")]
[assembly: AssemblyTitle("jiancai_wangge_skills")]
[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 jiancai_wangge_skills
{
	[BepInPlugin("jiancai_wangge.jiancai_wangge_skills", "jiancai_wangge_skills", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private const float BOX_LEFT = 0.3125f;

		private const float BOX_RIGHT = 65f / 96f;

		private const float BOX_TOP = 35f / 54f;

		private const float BOX_BOTTOM = 43f / 54f;

		private const string MESSAGES_FILE = "jiancai_wangge_skills_messages.cfg";

		private const string STATE_FILE = "jiancai_wangge_skills_state.cfg";

		private const string DEFAULT_TEXT = "你好世界";

		private static readonly string[] CJKFonts = new string[7] { "Microsoft YaHei", "SimHei", "SimSun", "FangSong", "KaiTi", "Noto Sans SC", "Source Han Sans SC" };

		internal static List<string> Messages = new List<string>();

		internal static bool StartVisible = true;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"jiancai_wangge_skills v1.0.0 已加载!");
			LoadMessages();
			StartVisible = ShouldStartVisible();
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private static bool ShouldStartVisible()
		{
			string path = Path.Combine(Paths.ConfigPath, "jiancai_wangge_skills_state.cfg");
			try
			{
				if (File.Exists(path) && DateTime.TryParse(File.ReadAllText(path).Trim(), out var result) && result.Date == DateTime.Now.Date)
				{
					return false;
				}
			}
			catch
			{
			}
			return true;
		}

		internal static void SaveToggleState(bool visible)
		{
			string path = Path.Combine(Paths.ConfigPath, "jiancai_wangge_skills_state.cfg");
			try
			{
				if (!visible)
				{
					File.WriteAllText(path, DateTime.Now.ToString("O"));
				}
				else
				{
					File.Delete(path);
				}
			}
			catch
			{
			}
		}

		private void LoadMessages()
		{
			string text = Path.Combine(Paths.ConfigPath, "jiancai_wangge_skills_messages.cfg");
			if (!File.Exists(text))
			{
				string[] array = new string[3] { "你好世界,这是第一条消息", "按 < 和 > 键切换消息 | 按 M 键关闭", "编辑 BepInEx/config/jiancai_wangge_skills_messages.cfg 自定义内容" };
				File.WriteAllLines(text, array, Encoding.UTF8);
				Messages.AddRange(array);
				Log.LogWarning((object)("消息文件不存在,已创建默认文件: " + text));
				return;
			}
			string[] array2 = File.ReadAllLines(text, Encoding.UTF8);
			for (int i = 0; i < array2.Length; i++)
			{
				string text2 = array2[i].Trim();
				if (!string.IsNullOrEmpty(text2))
				{
					Messages.Add(text2);
				}
			}
			if (Messages.Count == 0)
			{
				Messages.Add("你好世界");
				Log.LogWarning((object)"消息文件为空,使用默认消息。");
			}
			Log.LogInfo((object)$"已加载 {Messages.Count} 条消息: {text}");
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (!((Object)(object)GameObject.Find("jiancai_skills_Canvas") != (Object)null))
			{
				CreateUI();
			}
		}

		private void CreateUI()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_0070: 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_00a2: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: 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_0193: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: 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_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0330: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Expected O, but got Unknown
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_045c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0526: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Expected O, but got Unknown
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_058f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0606: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_061b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			Font cJKFont = GetCJKFont();
			Log.LogInfo((object)(((Object)(object)cJKFont != (Object)null) ? ("使用字体: " + ((Object)cJKFont).name) : "未找到中文字体!"));
			GameObject val = new GameObject("jiancai_skills_Canvas");
			Object.DontDestroyOnLoad((Object)(object)val);
			Canvas obj = val.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 999;
			CanvasScaler obj2 = val.AddComponent<CanvasScaler>();
			obj2.uiScaleMode = (ScaleMode)1;
			obj2.referenceResolution = new Vector2(1920f, 1080f);
			obj2.screenMatchMode = (ScreenMatchMode)0;
			obj2.matchWidthOrHeight = 1f;
			((Behaviour)val.AddComponent<GraphicRaycaster>()).enabled = false;
			GameObject val2 = new GameObject("TextBoxGroup");
			val2.transform.SetParent(val.transform, false);
			RectTransform obj3 = val2.AddComponent<RectTransform>();
			obj3.anchorMin = Vector2.zero;
			obj3.anchorMax = Vector2.one;
			obj3.offsetMin = Vector2.zero;
			obj3.offsetMax = Vector2.zero;
			GameObject val3 = new GameObject("TextBoxPanel");
			val3.transform.SetParent(val2.transform, false);
			RectTransform obj4 = val3.AddComponent<RectTransform>();
			obj4.anchorMin = new Vector2(0.3125f, 11f / 54f);
			obj4.anchorMax = new Vector2(65f / 96f, 0.35185188f);
			obj4.offsetMin = Vector2.zero;
			obj4.offsetMax = Vector2.zero;
			((Graphic)val3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.6f);
			val3.AddComponent<Mask>().showMaskGraphic = true;
			GameObject val4 = new GameObject("ScrollingText");
			val4.transform.SetParent(val3.transform, false);
			RectTransform obj5 = val4.AddComponent<RectTransform>();
			obj5.anchorMin = new Vector2(0f, 0.5f);
			obj5.anchorMax = new Vector2(1f, 0.5f);
			obj5.pivot = new Vector2(0.5f, 0.5f);
			obj5.sizeDelta = new Vector2(0f, 100f);
			Text val5 = val4.AddComponent<Text>();
			val5.font = cJKFont;
			val5.fontSize = 28;
			((Graphic)val5).color = new Color(0.992f, 0.624f, 0.275f);
			val5.alignment = (TextAnchor)4;
			val5.horizontalOverflow = (HorizontalWrapMode)0;
			val5.verticalOverflow = (VerticalWrapMode)1;
			val5.text = ((Messages.Count > 0) ? Messages[0] : "你好世界");
			GameObject val6 = new GameObject("LeftHint");
			val6.transform.SetParent(val3.transform, false);
			RectTransform obj6 = val6.AddComponent<RectTransform>();
			obj6.anchorMin = new Vector2(0f, 0f);
			obj6.anchorMax = new Vector2(0f, 0f);
			obj6.pivot = new Vector2(0f, 0f);
			obj6.anchoredPosition = new Vector2(8f, 4f);
			obj6.sizeDelta = new Vector2(130f, 24f);
			Text obj7 = val6.AddComponent<Text>();
			obj7.font = cJKFont;
			obj7.fontSize = 16;
			((Graphic)obj7).color = new Color(0.992f, 0.624f, 0.275f, 0.6f);
			obj7.alignment = (TextAnchor)3;
			obj7.text = "按 < 上一条";
			GameObject val7 = new GameObject("RightHint");
			val7.transform.SetParent(val3.transform, false);
			RectTransform obj8 = val7.AddComponent<RectTransform>();
			obj8.anchorMin = new Vector2(1f, 0f);
			obj8.anchorMax = new Vector2(1f, 0f);
			obj8.pivot = new Vector2(1f, 0f);
			obj8.anchoredPosition = new Vector2(-8f, 4f);
			obj8.sizeDelta = new Vector2(130f, 24f);
			Text val8 = val7.AddComponent<Text>();
			val8.font = cJKFont;
			val8.fontSize = 16;
			((Graphic)val8).color = new Color(0.992f, 0.624f, 0.275f, 0.6f);
			val8.alignment = (TextAnchor)5;
			val8.text = "按 > 下一条";
			GameObject val9 = new GameObject("HeaderLabel");
			val9.transform.SetParent(val3.transform, false);
			RectTransform obj9 = val9.AddComponent<RectTransform>();
			obj9.anchorMin = new Vector2(0.5f, 0f);
			obj9.anchorMax = new Vector2(0.5f, 0f);
			obj9.pivot = new Vector2(0.5f, 0f);
			obj9.anchoredPosition = new Vector2(0f, 4f);
			obj9.sizeDelta = new Vector2(280f, 24f);
			((Graphic)val9.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.5f);
			GameObject val10 = new GameObject("HeaderText");
			val10.transform.SetParent(val9.transform, false);
			RectTransform obj10 = val10.AddComponent<RectTransform>();
			obj10.anchorMin = Vector2.zero;
			obj10.anchorMax = Vector2.one;
			obj10.offsetMin = Vector2.zero;
			obj10.offsetMax = Vector2.zero;
			Text obj11 = val10.AddComponent<Text>();
			obj11.font = cJKFont;
			obj11.fontSize = 16;
			((Graphic)obj11).color = new Color(0.992f, 0.624f, 0.275f);
			obj11.alignment = (TextAnchor)4;
			obj11.text = "M 关闭建材王哥的整合包技巧";
			GameObject val11 = new GameObject("BookReminderPanel");
			val11.transform.SetParent(val.transform, false);
			val11.SetActive(false);
			RectTransform obj12 = val11.AddComponent<RectTransform>();
			obj12.anchorMin = new Vector2(1f, 0f);
			obj12.anchorMax = new Vector2(1f, 0f);
			obj12.pivot = new Vector2(1f, 0f);
			obj12.anchoredPosition = new Vector2(-16f, 14f);
			obj12.sizeDelta = new Vector2(260f, 28f);
			GameObject val12 = new GameObject("BookReminderText");
			val12.transform.SetParent(val11.transform, false);
			RectTransform obj13 = val12.AddComponent<RectTransform>();
			obj13.anchorMin = Vector2.zero;
			obj13.anchorMax = Vector2.one;
			obj13.offsetMin = Vector2.zero;
			obj13.offsetMax = Vector2.zero;
			Text obj14 = val12.AddComponent<Text>();
			obj14.font = cJKFont;
			obj14.fontSize = 16;
			((Graphic)obj14).color = new Color(0.992f, 0.624f, 0.275f);
			obj14.alignment = (TextAnchor)4;
			obj14.text = "M 查看建材王哥的整合包技巧";
			MessageController messageController = val.AddComponent<MessageController>();
			messageController.uiText = val5;
			messageController.rightHintText = val8;
			messageController.scrollSpeed = 40f;
			messageController.textBoxGroup = val2;
			messageController.bookReminder = val11;
			messageController.isTextBoxVisible = StartVisible;
		}

		private static Font GetCJKFont()
		{
			string[] cJKFonts = CJKFonts;
			for (int i = 0; i < cJKFonts.Length; i++)
			{
				Font val = Font.CreateDynamicFontFromOSFont(cJKFonts[i], 28);
				if ((Object)(object)val != (Object)null && val.HasCharacter('好'))
				{
					return val;
				}
				Object.Destroy((Object)(object)val);
			}
			return null;
		}

		private static Texture2D CreateBookIcon(int w, int h)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(w, h, (TextureFormat)4, false);
			((Texture)val).filterMode = (FilterMode)1;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
			Color c = default(Color);
			((Color)(ref c))..ctor(0.992f, 0.624f, 0.275f, 1f);
			for (int i = 0; i < w; i++)
			{
				for (int j = 0; j < h; j++)
				{
					val.SetPixel(i, j, val2);
				}
			}
			int num = w / 2;
			int num2 = 4;
			int num3 = w - 5;
			int num4 = h / 4;
			int num5 = h - 2;
			int num6 = h - 6;
			DrawLine(val, num, num4, num2, num6, c);
			DrawLine(val, num2, num6, num2, num5, c);
			DrawLine(val, num2, num5, num, num5, c);
			DrawLine(val, num, num4, num3, num6, c);
			DrawLine(val, num3, num6, num3, num5, c);
			DrawLine(val, num, num5, num3, num5, c);
			DrawVLine(val, num, num4, num5, c);
			for (int k = num4 + 4; k < num5 - 3; k += 3)
			{
				DrawHLine(val, num2 + 2, k, num - 2, c);
			}
			for (int l = num4 + 4; l < num5 - 3; l += 3)
			{
				DrawHLine(val, num + 2, l, num3 - 2, c);
			}
			int num7 = num - 1;
			for (int m = num4 + 2; m < num4 + h / 3; m++)
			{
				val.SetPixel(num7, m, new Color(0.992f, 0.35f, 0.25f, 0.85f));
			}
			val.SetPixel(num7 - 1, num4 + h / 3, new Color(0.992f, 0.35f, 0.25f, 0.85f));
			val.SetPixel(num7 + 1, num4 + h / 3, new Color(0.992f, 0.35f, 0.25f, 0.85f));
			val.Apply();
			return val;
		}

		private static void DrawLine(Texture2D tex, int x0, int y0, int x1, int y1, Color c)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Abs(x1 - x0);
			int num2 = ((x0 < x1) ? 1 : (-1));
			int num3 = -Mathf.Abs(y1 - y0);
			int num4 = ((y0 < y1) ? 1 : (-1));
			int num5 = num + num3;
			while (true)
			{
				if (x0 >= 0 && x0 < ((Texture)tex).width && y0 >= 0 && y0 < ((Texture)tex).height)
				{
					tex.SetPixel(x0, y0, c);
				}
				if (x0 != x1 || y0 != y1)
				{
					int num6 = 2 * num5;
					if (num6 >= num3)
					{
						num5 += num3;
						x0 += num2;
					}
					if (num6 <= num)
					{
						num5 += num;
						y0 += num4;
					}
					continue;
				}
				break;
			}
		}

		private static void DrawHLine(Texture2D tex, int x0, int y, int x1, Color c)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			for (int i = x0; i < x1; i++)
			{
				tex.SetPixel(i, y, c);
			}
		}

		private static void DrawVLine(Texture2D tex, int x, int y0, int y1, Color c)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			for (int i = y0; i <= y1; i++)
			{
				tex.SetPixel(x, i, c);
			}
		}
	}
	public class MessageController : MonoBehaviour
	{
		public Text uiText;

		public Text rightHintText;

		public float scrollSpeed = 40f;

		public GameObject textBoxGroup;

		public GameObject bookReminder;

		private RectTransform textRect;

		private RectTransform panelRect;

		private int currentIndex;

		private float textHeight;

		private float boxHeight;

		private bool initialized;

		public bool isTextBoxVisible = true;

		private bool needsScroll;

		private const float AUTO_INTERVAL = 10f;

		private float timeRemaining = 10f;

		private void Start()
		{
			//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)
			textRect = ((Component)uiText).GetComponent<RectTransform>();
			panelRect = ((Component)((Transform)textRect).parent).GetComponent<RectTransform>();
			Rect rect = panelRect.rect;
			boxHeight = ((Rect)(ref rect)).height;
			textBoxGroup.SetActive(isTextBoxVisible);
			bookReminder.SetActive(!isTextBoxVisible);
			ShowMessage(0);
			initialized = true;
		}

		private void Update()
		{
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			if (!initialized)
			{
				return;
			}
			if (Keyboard.current != null && ((ButtonControl)Keyboard.current.mKey).wasPressedThisFrame)
			{
				isTextBoxVisible = !isTextBoxVisible;
				textBoxGroup.SetActive(isTextBoxVisible);
				bookReminder.SetActive(!isTextBoxVisible);
				Plugin.SaveToggleState(isTextBoxVisible);
			}
			if (!isTextBoxVisible)
			{
				return;
			}
			if (Keyboard.current != null && ((ButtonControl)Keyboard.current.commaKey).wasPressedThisFrame)
			{
				ShowMessage(currentIndex - 1);
			}
			if (Keyboard.current != null && ((ButtonControl)Keyboard.current.periodKey).wasPressedThisFrame)
			{
				ShowMessage(currentIndex + 1);
			}
			timeRemaining -= Time.deltaTime;
			if (timeRemaining <= 0f)
			{
				ShowMessage(currentIndex + 1);
			}
			UpdateCountdown();
			if (needsScroll)
			{
				textHeight = uiText.preferredHeight;
				Vector2 anchoredPosition = textRect.anchoredPosition;
				anchoredPosition.y += scrollSpeed * Time.deltaTime;
				if (anchoredPosition.y > boxHeight / 2f + textHeight / 2f)
				{
					anchoredPosition.y = (0f - boxHeight) / 2f - textHeight / 2f;
				}
				textRect.anchoredPosition = anchoredPosition;
			}
		}

		private void UpdateCountdown()
		{
			if ((Object)(object)rightHintText != (Object)null)
			{
				rightHintText.text = $"按 > 下一条 · {Mathf.CeilToInt(timeRemaining)}s";
			}
		}

		private void ShowMessage(int index)
		{
			//IL_00b0: 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)
			if (Plugin.Messages.Count != 0)
			{
				currentIndex = (index % Plugin.Messages.Count + Plugin.Messages.Count) % Plugin.Messages.Count;
				uiText.text = Plugin.Messages[currentIndex];
				timeRemaining = 10f;
				float preferredHeight = uiText.preferredHeight;
				needsScroll = preferredHeight > boxHeight;
				if (needsScroll)
				{
					textRect.anchoredPosition = new Vector2(0f, (0f - boxHeight) / 2f - preferredHeight / 2f);
				}
				else
				{
					textRect.anchoredPosition = Vector2.zero;
				}
				Plugin.Log.LogInfo((object)$"切换到消息 [{currentIndex + 1}/{Plugin.Messages.Count}] scroll={needsScroll}: {Plugin.Messages[currentIndex]}");
			}
		}
	}
	internal static class PluginInfo
	{
		public const string PLUGIN_GUID = "jiancai_wangge.jiancai_wangge_skills";

		public const string PLUGIN_NAME = "jiancai_wangge_skills";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}