Decompiled source of Booster v0.0.1

Booster.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
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 CG.Ship.Modules;
using Gameplay.Ship;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using VoidManager;
using VoidManager.MPModChecks;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Booster")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: AssemblyInformationalVersion("0.0.1+e6c20ca52785e519f35d4efa14d4fe9d85027936")]
[assembly: AssemblyProduct("Booster")]
[assembly: AssemblyTitle("Allows multiple boosts to be activated at the same time with diminishing returns. Session Mod.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 Booster
{
	[BepInPlugin("18107.Booster", "Booster", "0.0.1")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BepinPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		public static bool HostHasMod { get; private set; }

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "18107.Booster");
			Events.Instance.JoinedRoom += UpdateHost;
			Events.Instance.ClientModlistRecieved += UpdateHost;
			Events.Instance.MasterClientSwitched += UpdateHost;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin 18107.Booster is loaded!");
		}

		private void UpdateHost(object sender, EventArgs e)
		{
			if (PhotonNetwork.IsMasterClient)
			{
				HostHasMod = true;
			}
			else
			{
				HostHasMod = NetworkedPeerManager.Instance.NetworkedPeerHasMod(PhotonNetwork.MasterClient, "18107.Booster");
			}
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "18107.Booster";

		public const string PLUGIN_NAME = "Booster";

		public const string USERS_PLUGIN_NAME = "Booster";

		public const string PLUGIN_VERSION = "0.0.1";

		public const string PLUGIN_DESCRIPTION = "Allows multiple boosts to be activated at the same time with diminishing returns. Session Mod.";

		public const string PLUGIN_ORIGINAL_AUTHOR = "18107";

		public const string PLUGIN_AUTHORS = "18107";

		public const string PLUGIN_THUNDERSTORE_ID = "VoidCrewModdingTeam/Booster";
	}
	[HarmonyPatch(typeof(ShipEngine))]
	internal class ShipEnginePatch
	{
		public static int BoostersActive { get; private set; }

		[HarmonyPrefix]
		[HarmonyPatch("SetBooster")]
		private static void SetBooster()
		{
			BoostersActive++;
		}

		[HarmonyPrefix]
		[HarmonyPatch("ClearBooster")]
		private static bool ClearBooster()
		{
			BoostersActive--;
			if (BoostersActive == 0)
			{
				return true;
			}
			return false;
		}

		[HarmonyPrefix]
		[HarmonyPatch("ApplyForce")]
		private static void ApplyForcePrefix(ShipEngine __instance, out Vector3 __state)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			__state = __instance.BoosterThrustPower;
			__instance.BoosterThrustPower = __instance.EngineThrustPower + (float)BoostersActive * (__instance.BoosterThrustPower - __instance.EngineThrustPower);
		}

		[HarmonyPostfix]
		[HarmonyPatch("ApplyForce")]
		private static void ApplyForcePostfix(ShipEngine __instance, Vector3 __state)
		{
			//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)
			__instance.BoosterThrustPower = __state;
		}
	}
	[HarmonyPatch(typeof(ThrusterBoosterController))]
	internal class ThrusterBoosterControllerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("GetReadiedBooster")]
		private static void GetReadiedBooster(List<ThrusterBooster> ____thrusterBoosters, ref int index, ref ThrusterBooster __result)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			if ((Object)(object)__result != (Object)null)
			{
				return;
			}
			for (int i = 0; i < ____thrusterBoosters.Count; i++)
			{
				if ((int)____thrusterBoosters[i].GetCurrentState() == 2)
				{
					index = i;
					__result = ____thrusterBoosters[i];
					break;
				}
			}
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)20;

		public override string Author => "18107";

		public override string Description => "Allows multiple boosts to be activated at the same time with diminishing returns. Session Mod.";

		public override string ThunderstoreID => "VoidCrewModdingTeam/Booster";
	}
}