Decompiled source of RemoveEverything v1.1.1

BepInEx/plugins/RemoveEverything.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("RemoveEverything")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RemoveEverything")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("cea2cd8b-63ce-4094-81f5-fd9313b8cd9d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace RemoveEverything;

[BepInPlugin("cc.lymone.HoL.RemoveEverything", "RemoveEverything", "1.1.0")]
public class RemoveEverything : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <RemoveBuild_Patch>d__4 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public DelBuildMPanel __instance;

		private int <SceneIndex>5__2;

		private HashSet<string> <School>5__3;

		private HashSet<string> <ZhuZhai>5__4;

		private List<string> <BookStr>5__5;

		private int <cnt>5__6;

		private int <a>5__7;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<School>5__3 = null;
			<ZhuZhai>5__4 = null;
			<BookStr>5__5 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0de7: Unknown result type (might be due to invalid IL or missing references)
			string text;
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
			{
				<>1__state = -1;
				<SceneIndex>5__2 = int.Parse(Mainload.SceneID.Split(new char[1] { '|' })[1]);
				<School>5__3 = new HashSet<string>();
				<ZhuZhai>5__4 = new HashSet<string>();
				<BookStr>5__5 = new List<string>();
				for (int k = 0; k < Mainload.CangShuGeData_Now[<SceneIndex>5__2].Count; k++)
				{
					<BookStr>5__5.Add(Mainload.CangShuGeData_Now[<SceneIndex>5__2][k]);
				}
				<cnt>5__6 = 0;
				<a>5__7 = 0;
				goto IL_0e28;
			}
			case 1:
				<>1__state = -1;
				goto IL_0523;
			case 2:
				<>1__state = -1;
				if (<School>5__3.Count > 0)
				{
					for (int l = 0; l < Mainload.MenKe_Now.Count; l++)
					{
						if (<School>5__3.Contains(Mainload.MenKe_Now[l][9].Split(new char[1] { '|' })[1]))
						{
							Mainload.MenKe_Now[l][9] = "0|null|" + Mainload.MenKe_Now[l][9].Split(new char[1] { '|' })[2];
							Mainload.MenKe_Now[l][10] = "0";
						}
					}
					for (int m = 0; m < Mainload.Member_now.Count; m++)
					{
						if (<School>5__3.Contains(Mainload.Member_now[m][3].Split(new char[1] { '|' })[2]))
						{
							Mainload.Member_now[m][3] = Mainload.Member_now[m][3].Split(new char[1] { '|' })[0] + "|" + Mainload.Member_now[m][3].Split(new char[1] { '|' })[1] + "|null|" + Mainload.Member_now[m][3].Split(new char[1] { '|' })[3];
							Mainload.Member_now[m][32] = Mainload.Member_now[m][32].Split(new char[1] { '|' })[0] + "|" + Mainload.Member_now[m][32].Split(new char[1] { '|' })[1] + "|0|0|0|0";
						}
					}
					<>2__current = null;
					<>1__state = 3;
					return true;
				}
				goto IL_0785;
			case 3:
				<>1__state = -1;
				goto IL_0785;
			case 4:
				{
					<>1__state = -1;
					if (<ZhuZhai>5__4.Count > 0)
					{
						for (int i = 0; i < Mainload.Member_now.Count; i++)
						{
							string[] array = Mainload.Member_now[i][3].Split(new char[1] { '|' });
							if (<ZhuZhai>5__4.Contains(array[1]))
							{
								Mainload.Member_now[i][3] = string.Concat(new string[4]
								{
									array[0],
									"|null|",
									array[2],
									"|1"
								});
								array = Mainload.Member_now[i][32].Split(new char[1] { '|' });
								Mainload.Member_now[i][32] = "0|0|" + array[2] + "|" + array[3] + "|" + array[4] + "|" + array[5];
							}
						}
						for (int j = 0; j < Mainload.Member_qu.Count; j++)
						{
							string[] array2 = Mainload.Member_qu[j][4].Split(new char[1] { '|' });
							if (<ZhuZhai>5__4.Contains(array2[1]))
							{
								Mainload.Member_qu[j][4] = string.Concat(new string[4]
								{
									array2[0],
									"|null|",
									array2[2],
									"|1"
								});
								array2 = Mainload.Member_qu[j][22].Split(new char[1] { '|' });
								Mainload.Member_qu[j][22] = "0|0|" + array2[2] + "|" + array2[3] + "|" + array2[4] + "|" + array2[5];
							}
						}
					}
					((MonoBehaviour)__instance).StopCoroutine("OnEnableData");
					((MonoBehaviour)__instance).Invoke("ChangeScene", 0.1f);
					goto IL_0de1;
				}
				IL_01db:
				if (text == "24" || text == "34")
				{
					goto IL_024b;
				}
				goto IL_04f5;
				IL_04f5:
				if (isFastMode.Value && <cnt>5__6 % 50 == 0)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				goto IL_0523;
				IL_01fc:
				if (text == "29")
				{
					goto IL_024b;
				}
				goto IL_04f5;
				IL_0523:
				if (<a>5__7 >= Mainload.BuildInto_m.Count - 1)
				{
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
				goto IL_0de1;
				IL_01c8:
				if (text == "23")
				{
					goto IL_024b;
				}
				goto IL_04f5;
				IL_0e28:
				if (<a>5__7 < Mainload.BuildInto_m.Count)
				{
					<cnt>5__6++;
					text = Mainload.AllBuilddata[int.Parse(Mainload.BuildInto_m[<a>5__7][1])][5];
					if (text != null)
					{
						int length = text.Length;
						if (length == 1)
						{
							switch (text[0])
							{
							case '0':
							case '2':
							case '9':
								break;
							case '3':
							case '4':
								<School>5__3.Add(Mainload.BuildInto_m[<a>5__7][0]);
								FormulaData.RemoveBuildNew("M", <SceneIndex>5__2, <a>5__7, 0, false, false);
								<a>5__7--;
								goto IL_04f5;
							case '5':
								FormulaData.RemoveBuildNew("M", <SceneIndex>5__2, <a>5__7, 0, false, false);
								<a>5__7--;
								goto IL_04f5;
							case '6':
								if (!isSafeRemoveStorage.Value || int.Parse(Mainload.BuildInto_m[<a>5__7][6]) < 0 || int.Parse(Mainload.FamilyData[6]) > FormulaData.MaNum_HorseRoom(int.Parse(Mainload.BuildInto_m[<a>5__7][1]), int.Parse(Mainload.BuildInto_m[<a>5__7][2])))
								{
									FormulaData.RemoveBuildNew("M", <SceneIndex>5__2, <a>5__7, 0, false, false);
									<a>5__7--;
								}
								goto IL_04f5;
							case '7':
								if (!isSafeRemoveStorage.Value || int.Parse(Mainload.BuildInto_m[<a>5__7][6]) < 0 || int.Parse(Mainload.FamilyData[5]) + 10 > FormulaData.CunNum_KuFang(int.Parse(Mainload.BuildInto_m[<a>5__7][1]), int.Parse(Mainload.BuildInto_m[<a>5__7][2])))
								{
									FormulaData.RemoveBuildNew("M", <SceneIndex>5__2, <a>5__7, 0, false, false);
									<a>5__7--;
								}
								goto IL_04f5;
							case '8':
								<ZhuZhai>5__4.Add(Mainload.BuildInto_m[<a>5__7][0]);
								FormulaData.RemoveBuildNew("M", <SceneIndex>5__2, <a>5__7, 0, false, false);
								<a>5__7--;
								goto IL_04f5;
							default:
								goto IL_04f5;
							}
							goto IL_024b;
						}
						if (length == 2)
						{
							switch (text[1])
							{
							case '1':
								break;
							case '2':
								goto IL_01b2;
							case '3':
								goto IL_01c8;
							case '4':
								goto IL_01db;
							case '9':
								goto IL_01fc;
							case '5':
								goto IL_020f;
							case '8':
								goto IL_0222;
							case '0':
								if (text == "10")
								{
									if (int.Parse(Mainload.BuildInto_m[<a>5__7][3]) > 0)
									{
										((Component)((Component)__instance).transform.parent.Find("FastSanPuPanel")).gameObject.SetActive(true);
									}
									FormulaData.RemoveBuildNew("M", <SceneIndex>5__2, <a>5__7, 0, false, false);
									<a>5__7--;
								}
								goto IL_04f5;
							default:
								goto IL_04f5;
							}
							if (text == "21")
							{
								goto IL_024b;
							}
						}
					}
					goto IL_04f5;
				}
				return false;
				IL_01b2:
				if (text == "22")
				{
					goto IL_024b;
				}
				goto IL_04f5;
				IL_0de1:
				if (Input.GetKeyDown(Mainload.FastKey[0]))
				{
					((MonoBehaviour)__instance).StopCoroutine("OnEnableData");
					((MonoBehaviour)__instance).Invoke("ChangeScene", 0.1f);
				}
				<a>5__7++;
				goto IL_0e28;
				IL_0785:
				if (<BookStr>5__5.Count > 0)
				{
					HashSet<string> hashSet = new HashSet<string>();
					Dictionary<string, int> dictionary = new Dictionary<string, int>();
					foreach (string item in <BookStr>5__5)
					{
						List<string> list = item.Split(new char[1] { '|' }).ToList();
						hashSet.Add(list[0]);
						list.RemoveAt(0);
						foreach (string item2 in list)
						{
							if (item2 == "null")
							{
								continue;
							}
							foreach (string item3 in item2.Split(new char[1] { '~' }).ToList())
							{
								string[] array3 = item3.Split(new char[1] { '@' });
								if (int.Parse(array3[1]) > 0)
								{
									if (!dictionary.ContainsKey(array3[0]))
									{
										dictionary[array3[0]] = 0;
									}
									dictionary[array3[0]] += int.Parse(array3[1]);
								}
								if (int.Parse(array3[2]) > 0 && ChangShuGeRemoveStrategy.Value)
								{
									if (!dictionary.ContainsKey(array3[0]))
									{
										dictionary[array3[0]] = 0;
									}
									dictionary[array3[0]] += int.Parse(array3[1]);
								}
							}
						}
					}
					for (int n = 0; n < Mainload.Prop_have.Count; n++)
					{
						if (dictionary.ContainsKey(Mainload.Prop_have[n][0]))
						{
							Mainload.Prop_have[n][1] = (int.Parse(Mainload.Prop_have[n][1]) + dictionary[Mainload.Prop_have[n][0]]).ToString();
							Mainload.FamilyData[5] = (int.Parse(Mainload.FamilyData[5]) - dictionary[Mainload.Prop_have[n][0]]).ToString();
							dictionary.Remove(Mainload.Prop_have[n][0]);
						}
					}
					foreach (KeyValuePair<string, int> item4 in dictionary)
					{
						Mainload.Prop_have.Add(new List<string>
						{
							item4.Key,
							item4.Value.ToString()
						});
						Mainload.FamilyData[5] = (int.Parse(Mainload.FamilyData[5]) - item4.Value).ToString();
					}
					for (int num = 0; num < Mainload.Member_now.Count; num++)
					{
						string[] array4 = Mainload.Member_now[num][19].Split(new char[1] { '~' })[0].Split(new char[1] { '@' });
						if (hashSet.Contains(array4[2]))
						{
							string text2 = array4[0] + "@" + array4[1] + "@null";
							text2 = text2 + "~" + Mainload.Member_now[num][19].Split(new char[1] { '~' })[1];
							Mainload.Member_now[num][19] = text2;
						}
					}
				}
				<>2__current = null;
				<>1__state = 4;
				return true;
				IL_024b:
				FormulaData.RemoveBuildNew("M", <SceneIndex>5__2, <a>5__7, 0, false, false);
				<a>5__7--;
				goto IL_04f5;
				IL_0222:
				if (text == "38")
				{
					goto IL_024b;
				}
				goto IL_04f5;
				IL_020f:
				if (text == "35")
				{
					goto IL_024b;
				}
				goto IL_04f5;
			}
		}

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

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

	[CompilerGenerated]
	private sealed class <Remove_NongZBuild_Patch>d__5 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public DelBuildPanel __instance;

		private int <cnt>5__2;

		private int <a>5__3;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			int num = <>1__state;
			if (num != 0)
			{
				if (num != 1)
				{
					return false;
				}
				<>1__state = -1;
				goto IL_0092;
			}
			<>1__state = -1;
			<cnt>5__2 = 0;
			<a>5__3 = 0;
			goto IL_0137;
			IL_0092:
			if (<a>5__3 >= Mainload.BuildInto_z.Count - 1)
			{
				Mainload.NongZ_now[Mainload.FengdiIndex_click][Mainload.DiXingIndex_click][14] = "null";
				((MonoBehaviour)__instance).StopCoroutine("OnEnableData");
				((MonoBehaviour)__instance).Invoke("ChangeScene", 0.1f);
			}
			if (Input.GetKeyDown(Mainload.FastKey[0]))
			{
				((MonoBehaviour)__instance).StopCoroutine("OnEnableData");
				((MonoBehaviour)__instance).Invoke("ChangeScene", 0.1f);
			}
			<a>5__3++;
			goto IL_0137;
			IL_0137:
			if (<a>5__3 < Mainload.BuildInto_z.Count)
			{
				<cnt>5__2++;
				FormulaData.RemoveBuildNew("Z", Mainload.FengdiIndex_click, Mainload.DiXingIndex_click, <a>5__3, false, false);
				<a>5__3--;
				if (isFastMode.Value && <cnt>5__2 % 50 == 0)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				goto IL_0092;
			}
			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 ConfigEntry<bool> isFastMode;

	private static ConfigEntry<bool> isSafeRemoveStorage;

	private static ConfigEntry<bool> ChangShuGeRemoveStrategy;

	private void Start()
	{
		isFastMode = ((BaseUnityPlugin)this).Config.Bind<bool>("配置 Config", "快速模式 Fast Mode", true, "是否开启快速模式,快速模式清理建筑更快,但是可能导致卡顿。\n卡顿时间小于原本等待时间,根据设备配置不同,需等待片刻。\n同时会影响农庄一键清空。");
		isSafeRemoveStorage = ((BaseUnityPlugin)this).Config.Bind<bool>("配置 Config", "安全移除库存 Safe Remove Storage", false, "是否安全移除仓储(如果为true,将确保仓储和马厩不为负)\n开启此选项可能会导致部分建筑不会被删除\n注意:仓储容量为负不会导致存档损坏,随后补充容量即可");
		ChangShuGeRemoveStrategy = ((BaseUnityPlugin)this).Config.Bind<bool>("配置 Config", "是否强行保留书籍 Force keep the books", true, "切换藏书阁移除时,处理正在借阅书籍的策略\ntrue :强行将书籍纳入库存,但借阅人正常阅读,相当于刷了一本书(微作弊)\nfalse:书籍被赠与借阅者,家族损失该书籍(正常流程)\n");
		isFastMode.Value = !isFastMode.Value;
		AllText.Text_UIA[1451] = new List<string> { "[MOD]清空所有建筑", "[MOD]Clear All Structures" };
		AllText.Text_UIA[1452] = new List<string> { "清空府邸所有建筑后,将不可恢复,确定要清空吗?", "After the building is cleared, it cannot be recovered. Are you sure you want to clear it?" };
		AllText.Text_UIA[1453] = new List<string> { "正在清空所有建筑...", "Clear in Progress..." };
		Harmony.CreateAndPatchAll(typeof(RemoveEverything), (string)null);
	}

	[IteratorStateMachine(typeof(<RemoveBuild_Patch>d__4))]
	[HarmonyPostfix]
	[HarmonyPatch(typeof(DelBuildMPanel), "OnEnableData")]
	public static IEnumerator RemoveBuild_Patch(IEnumerator result, DelBuildMPanel __instance)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RemoveBuild_Patch>d__4(0)
		{
			__instance = __instance
		};
	}

	[IteratorStateMachine(typeof(<Remove_NongZBuild_Patch>d__5))]
	[HarmonyPostfix]
	[HarmonyPatch(typeof(DelBuildPanel), "OnEnableData")]
	public static IEnumerator Remove_NongZBuild_Patch(IEnumerator result, DelBuildPanel __instance)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <Remove_NongZBuild_Patch>d__5(0)
		{
			__instance = __instance
		};
	}
}