Decompiled source of BlackBox cn v1.0.0

blackboxcn.dll

Decompiled 5 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("blackboxcn")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("blackboxcn")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("230de607-2e44-411d-9009-eb84a7543d63")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("BlackBox.Chinese.Patch", "BlackBox Chinese Patch", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class BlackBoxChinesePatch : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <DelayedInit>d__2 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public BlackBoxChinesePatch <>4__this;

		private Type <monitorTestType>5__1;

		private MethodInfo <setTextMethod>5__2;

		private Exception <e>5__3;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <DelayedInit>d__2(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<monitorTestType>5__1 = null;
			<setTextMethod>5__2 = null;
			<e>5__3 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(3f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				try
				{
					<monitorTestType>5__1 = Type.GetType("Blackbox.MonitorTest");
					if (<monitorTestType>5__1 == null)
					{
						<monitorTestType>5__1 = <>4__this.FindMonitorTestClass();
						if (<monitorTestType>5__1 == null)
						{
							((BaseUnityPlugin)<>4__this).Logger.LogError((object)"[BlackBox中文补丁] 未找到MonitorTest类!");
							return false;
						}
					}
					<setTextMethod>5__2 = <monitorTestType>5__1.GetMethod("setText", BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public, null, new Type[2]
					{
						typeof(string),
						typeof(bool)
					}, null);
					if (<setTextMethod>5__2 == null)
					{
						<setTextMethod>5__2 = <monitorTestType>5__1.GetMethod("setText", BindingFlags.IgnoreCase | BindingFlags.Instance | BindingFlags.Public, null, new Type[1] { typeof(string) }, null);
					}
					if (<setTextMethod>5__2 != null)
					{
						new Harmony("BlackBox.Chinese.Patch").Patch((MethodBase)<setTextMethod>5__2, new HarmonyMethod(typeof(BlackBoxChinesePatch).GetMethod("SetText_Prefix", BindingFlags.Static | BindingFlags.NonPublic)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
						((BaseUnityPlugin)<>4__this).Logger.LogInfo((object)"[BlackBox中文补丁] 汉化补丁加载成功!");
					}
					else
					{
						((BaseUnityPlugin)<>4__this).Logger.LogError((object)"[BlackBox中文补丁] 未找到setText方法!");
					}
					<monitorTestType>5__1 = null;
					<setTextMethod>5__2 = null;
				}
				catch (Exception ex)
				{
					<e>5__3 = ex;
					((BaseUnityPlugin)<>4__this).Logger.LogError((object)("[BlackBox中文补丁] 初始化异常:" + <e>5__3.Message));
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private static readonly Dictionary<string, string> TextMap;

	private void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"[BlackBox中文补丁] 启动,延迟3秒初始化...");
		((MonoBehaviour)this).StartCoroutine(DelayedInit());
	}

	[IteratorStateMachine(typeof(<DelayedInit>d__2))]
	private IEnumerator DelayedInit()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <DelayedInit>d__2(0)
		{
			<>4__this = this
		};
	}

	private Type FindMonitorTestClass()
	{
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly in assemblies)
		{
			try
			{
				Type[] types = assembly.GetTypes();
				foreach (Type type in types)
				{
					if (type.Name == "MonitorTest" && type.IsSubclassOf(typeof(MonoBehaviour)))
					{
						return type;
					}
				}
			}
			catch
			{
			}
		}
		return null;
	}

	private static bool SetText_Prefix(ref string text)
	{
		if (string.IsNullOrEmpty(text))
		{
			return true;
		}
		foreach (KeyValuePair<string, string> item in TextMap)
		{
			text = text.Replace(item.Key, item.Value);
		}
		return true;
	}

	static BlackBoxChinesePatch()
	{
		Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
		dictionary["DAMAGE DONE TO ITEMS"] = "物品损坏列表(疯狂指责)";
		dictionary["DESTROYED"] = "已销毁";
		dictionary["TOTAL"] = "总计";
		dictionary["LEFT"] = "剩余";
		dictionary["UNKNOWN"] = "未知来源";
		dictionary["EXTRACTED"] = "已提取";
		dictionary["ITEM(S)"] = " 件";
		dictionary["LOST"] = "损失";
		dictionary["IN VALUE WITH"] = "价值包含";
		dictionary["ITEM(S) DESTROYED"] = "件物品已销毁";
		dictionary["DISCOVERED"] = "已发现";
		dictionary["OUT OF"] = "件,总计";
		dictionary["DAMAGE DONE TO ITEMS:\n\n"] = "物品损坏列表(疯狂指责):\n\n";
		dictionary["DESTROYED"] = "已销毁";
		dictionary["Total: "] = "总计:";
		dictionary[" left"] = " 剩余";
		dictionary["Unknown "] = " 未知来源";
		dictionary["Extracted "] = " 已提取";
		dictionary[" item(s))\n"] = " 件)\n";
		dictionary["Lost "] = " 损失";
		dictionary[" in value with "] = " 价值包含 ";
		dictionary[" item(s) destroyed.\n"] = " 件物品已销毁。\n";
		dictionary["Discovered "] = " 已发现 ";
		dictionary[" out of "] = " 件,总计 ";
		TextMap = dictionary;
	}
}