Decompiled source of NoAutoTakeoff v1.0.0

NoAutoTakeoff.dll

Decompiled 2 hours ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NoAutoTakeoff")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoAutoTakeoff")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4be2d2b1-eb96-4999-a5ce-960c82851190")]
[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 NoAutoTakeoff;

[BepInPlugin("com.spoomich.noautotakeoff", "No Auto Takeoff", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	private static bool _warningShown;

	private static GameObject _warningTextObject;

	private static Text _warningText;

	private static float _warningTimer;

	private static bool _dawnCleanupDone;

	private void Awake()
	{
		Harmony.CreateAndPatchAll(typeof(NoAutoTakeoffPatch), (string)null);
		Debug.Log((object)"[NoAutoTakeoff] Мод загружен! Автопилот отключен.");
	}

	private void Update()
	{
		TimeOfDay val = Object.FindObjectOfType<TimeOfDay>();
		RoundManager val2 = Object.FindObjectOfType<RoundManager>();
		if ((Object)(object)val != (Object)null)
		{
			if (val.globalTime >= 1430f && val.globalTime <= 1450f && !_warningShown)
			{
				ShowWarning();
				_warningShown = true;
			}
			else if (val.globalTime < 1400f || val.globalTime > 1500f)
			{
				_warningShown = false;
			}
			if (val.globalTime >= 360f && val.globalTime <= 390f)
			{
				if (!_dawnCleanupDone && (Object)(object)val2 != (Object)null)
				{
					RemoveAllEnemies(val2);
					_dawnCleanupDone = true;
					Debug.Log((object)"[NoAutoTakeoff] Враги удалены на рассвете!");
				}
			}
			else
			{
				_dawnCleanupDone = false;
			}
		}
		if (_warningTimer > 0f)
		{
			_warningTimer -= Time.deltaTime;
			if (_warningTimer <= 0f)
			{
				HideWarning();
			}
		}
	}

	private void RemoveAllEnemies(RoundManager roundManager)
	{
		if (roundManager.SpawnedEnemies == null)
		{
			return;
		}
		for (int num = roundManager.SpawnedEnemies.Count - 1; num >= 0; num--)
		{
			if ((Object)(object)roundManager.SpawnedEnemies[num] != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)roundManager.SpawnedEnemies[num]).gameObject);
			}
		}
		roundManager.SpawnedEnemies.Clear();
	}

	private void ShowWarning()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Expected O, but got Unknown
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: 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_012a: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_warningTextObject == (Object)null)
		{
			Canvas val = Object.FindObjectOfType<Canvas>();
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			_warningTextObject = new GameObject("AutoTakeoffWarning");
			_warningTextObject.transform.SetParent(((Component)val).transform);
			_warningText = _warningTextObject.AddComponent<Text>();
			_warningText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			_warningText.fontSize = 24;
			_warningText.fontStyle = (FontStyle)1;
			((Graphic)_warningText).color = new Color(1f, 0.2f, 0.2f, 1f);
			_warningText.alignment = (TextAnchor)4;
			RectTransform component = _warningTextObject.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 0f);
			component.pivot = new Vector2(0.5f, 0f);
			component.anchoredPosition = new Vector2(0f, 50f);
			component.sizeDelta = new Vector2(0f, 100f);
		}
		_warningText.text = "ВНИМАНИЕ! АВТОПИЛОТ ОТКЛЮЧЁН. ДЛЯ ВЗЛЁТА ИСПОЛЬЗУЙТЕ РЫЧАГ.";
		_warningTextObject.SetActive(true);
		_warningTimer = 5f;
		Debug.Log((object)"[NoAutoTakeoff] Предупреждение отображено.");
	}

	private void HideWarning()
	{
		if ((Object)(object)_warningTextObject != (Object)null)
		{
			_warningTextObject.SetActive(false);
		}
	}
}
[HarmonyPatch]
public class NoAutoTakeoffPatch
{
	[HarmonyPatch(typeof(StartOfRound), "ShipHasLeft")]
	[HarmonyPrefix]
	private static bool BlockShipLeave()
	{
		Debug.Log((object)"[NoAutoTakeoff] Взлёт заблокирован!");
		return false;
	}

	[HarmonyPatch(typeof(StartOfRound), "AutoTakeoff")]
	[HarmonyPrefix]
	private static bool BlockAutoTakeoff()
	{
		Debug.Log((object)"[NoAutoTakeoff] Автопилот заблокирован!");
		return false;
	}

	[HarmonyPatch(typeof(StartOfRound), "ShipLeaveEarly")]
	[HarmonyPrefix]
	private static bool BlockEarlyLeave()
	{
		Debug.Log((object)"[NoAutoTakeoff] Досрочный отлёт заблокирован!");
		return false;
	}

	[HarmonyPatch(typeof(StartOfRound), "ShipLeaveWhenQuotaMet")]
	[HarmonyPrefix]
	private static bool BlockQuotaLeave()
	{
		Debug.Log((object)"[NoAutoTakeoff] Отлёт по квоте заблокирован!");
		return false;
	}

	[HarmonyPatch(typeof(StartOfRound), "ShipLeave")]
	[HarmonyPrefix]
	private static bool BlockShipLeaveCommand()
	{
		Debug.Log((object)"[NoAutoTakeoff] Команда отлёта заблокирована!");
		return false;
	}
}