Decompiled source of NoSapsuckerMod v1.0.5

NoFckgKiwi.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using NoKiwiP.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NoFckgKiwi")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoFckgKiwi")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("db0e3a9f-2715-4f6f-a2a1-53e32748fc42")]
[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 NoKiwiP
{
	[BepInPlugin("skvqq.NoSapsucker", "No Sapsucker", "1.0.5")]
	public class NoFkngKiwi : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("skvqq.NoSapsucker");

		internal static ManualLogSource mls;

		private void Awake()
		{
			mls = ((BaseUnityPlugin)this).Logger;
			mls.LogInfo((object)"Ребята, я в шоке. Мой код был полностью исправлен нейросетью, я ща застрелюсь");
			Type typeFromHandle = typeof(KiwiSpawn);
			Type typeFromHandle2 = typeof(StartRoundPatch);
			try
			{
				harmony.PatchAll(typeFromHandle);
				mls.LogInfo((object)"KiwiSpawn патч успешно зарегистрирован");
				MethodInfo methodInfo = AccessTools.Method(typeof(StartOfRound), "SetPlanetsMold", (Type[])null, (Type[])null);
				if (methodInfo != null)
				{
					harmony.PatchAll(typeFromHandle2);
					mls.LogInfo((object)"StartRoundPatch патч успешно зарегистрирован");
				}
				else
				{
					mls.LogWarning((object)"Метод StartOfRound.SetPlanetsMold не найден! Патч не применён.");
				}
			}
			catch (Exception arg)
			{
				mls.LogError((object)$"Ошибка при патчинге: {arg}");
			}
		}
	}
}
namespace NoKiwiP.Patches
{
	[HarmonyPatch(typeof(RoundManager))]
	public class KiwiSpawn
	{
		[HarmonyPatch("LoadNewLevelWait")]
		[HarmonyPostfix]
		private static void RemoveKiwiEnemy(ref SelectableLevel ___currentLevel)
		{
			if (___currentLevel?.OutsideEnemies == null)
			{
				return;
			}
			for (int num = ___currentLevel.OutsideEnemies.Count - 1; num >= 0; num--)
			{
				if (___currentLevel.OutsideEnemies[num]?.enemyType?.enemyName == "GiantKiwi")
				{
					___currentLevel.OutsideEnemies.RemoveAt(num);
					NoFkngKiwi.mls.LogInfo((object)"GiantKiwi удалён из списка врагов");
				}
			}
		}
	}
	[HarmonyPatch(typeof(StartOfRound))]
	public class StartRoundPatch
	{
		[HarmonyPatch("SetPlanetsMold")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> FixMoldCheck(IEnumerable<CodeInstruction> instructions)
		{
			List<CodeInstruction> list = new List<CodeInstruction>(instructions);
			bool flag = false;
			for (int i = 0; i < list.Count - 2; i++)
			{
				if (list[i + 1].opcode == OpCodes.Callvirt && list[i + 1].operand.ToString().Contains("NetworkBehaviour.get_IsServer"))
				{
					list.RemoveRange(i, 3);
					flag = true;
					NoFkngKiwi.mls.LogInfo((object)"Transpiler успешно модифицировал метод");
					break;
				}
			}
			if (!flag)
			{
				NoFkngKiwi.mls.LogWarning((object)"Не удалось найти IL-код для патчинга");
			}
			return list.AsEnumerable();
		}
	}
}