Decompiled source of NoSunkenDefeat v1.0.1

NoSunkenDefeat.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Fusion;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("NoSunkenDefeat")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("Sunken submarine is no longer cause of defeat.")]
[assembly: AssemblyTitle("NoSunkenDefeat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 NoFootstepsSouns
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "NoSunkenDefeat";

		public const string PLUGIN_NAME = "Sunken submarine is no longer cause of defeat.";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace NoSunkenDefeat
{
	[BepInPlugin("drbruhman.NoSunkenDefeat", "NoSunkenDefeat", "1.0.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			Harmony val = new Harmony("drbruhman.NoSunkenDefeat");
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Start Patching");
			val.Patch((MethodBase)typeof(CMD_BattleManager).GetMethod("ProcessBattle", AccessTools.all), new HarmonyMethod(typeof(Plugin).GetMethod("processBattle")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)typeof(CMD_Network).GetMethod("RPC_EndBattle", AccessTools.all), new HarmonyMethod(typeof(Plugin).GetMethod("endBattle")), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			Logger.LogInfo((object)"NoSunkenDefeat is loaded.");
		}

		public static bool endBattle(BattleConclusion P_conclusion, RpcInfo P_info = default(RpcInfo))
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			if ((int)P_conclusion == 1 || P_conclusion - 3 <= 3)
			{
				return true;
			}
			return false;
		}

		public static bool processBattle(CMD_BattleManager __instance)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: 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_0268: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)CMD_ShipManager.Instance.playerShip == (Object)null)
			{
				return false;
			}
			RectTransform mineOffensiveSource = CMD_UI.Instance.mineOffensiveSource;
			((Transform)mineOffensiveSource).eulerAngles = ((Transform)mineOffensiveSource).eulerAngles + new Vector3(0f, 0f, 12.5f * Time.deltaTime);
			RectTransform mineDefensiveSource = CMD_UI.Instance.mineDefensiveSource;
			((Transform)mineDefensiveSource).eulerAngles = ((Transform)mineDefensiveSource).eulerAngles + new Vector3(0f, 0f, 2.5f * Time.deltaTime);
			float submarineWaterPercent = CMD_ShipManager.Instance.playerShip.E_submarineDamage.submarineWaterPercent;
			float num = 0f;
			if ((Object)(object)CMD_ShipManager.Instance.enemyShip != (Object)null)
			{
				num = CMD_ShipManager.Instance.enemyShip.E_submarineDamage.submarineWaterPercent;
			}
			if (__instance.battlingLeviathan)
			{
				num = 1f - CMD_ShipManager.Instance.enemyShip.leviathanHealth * 0.01f;
			}
			((Transform)CMD_UI.Instance.waterDisplay_Player).localScale = new Vector3(Mathf.Clamp(submarineWaterPercent * 1.25f, 0f, 1f), 1f, 1f);
			((Transform)CMD_UI.Instance.waterDisplay_Layout_Player).localScale = new Vector3(Mathf.Clamp(submarineWaterPercent * 1.25f, 0f, 1f), 1f, 1f);
			if (!__instance.battlingLeviathan)
			{
				((Transform)CMD_UI.Instance.waterDisplay_Enemy).localScale = new Vector3(Mathf.Clamp(num * 1.25f, 0f, 1f), 1f, 1f);
			}
			else
			{
				((Transform)CMD_UI.Instance.waterDisplay_Enemy).localScale = new Vector3(1f - num, 1f, 1f);
			}
			if (!__instance.battleInProgress && !CMD.Instance.gameOver)
			{
				return false;
			}
			if (CMD_Network.Instance.network.HasStateAuthority)
			{
				if (!__instance.battlingLeviathan && num > 0.8f)
				{
					CMD_Network.Instance.RPC_EndBattle((BattleConclusion)1, default(RpcInfo));
				}
				if (__instance.battlingLeviathan && num > 1f)
				{
					CMD_Network.Instance.RPC_EndBattle((BattleConclusion)1, default(RpcInfo));
					return false;
				}
			}
			return false;
		}
	}
}