Decompiled source of Booster v0.1.0

Booster.dll

Decompiled 5 days 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 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")]
[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("id107.booster", "Booster", "0.1.0")]
	[BepInProcess("Void Crew.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class BepinPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "id107.booster");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin id107.booster is loaded!");
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "id107.booster";

		public const string PLUGIN_NAME = "Booster";

		public const string USERS_PLUGIN_NAME = "Booster";

		public const string PLUGIN_VERSION = "0.1.0";

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

		public const string PLUGIN_ORIGINAL_AUTHOR = "18107";

		public const string PLUGIN_AUTHORS = "18107, Dragon";

		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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			__state = __instance.BoosterThrustPower;
			if (VoidManagerPlugin.Enabled)
			{
				__instance.BoosterThrustPower = __instance.EngineThrustPower + (float)BoostersActive * (__instance.BoosterThrustPower - __instance.EngineThrustPower);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("ApplyForce")]
		private static void ApplyForcePostfix(ShipEngine __instance, Vector3 __state)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (VoidManagerPlugin.Enabled)
			{
				__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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Invalid comparison between Unknown and I4
			if (!VoidManagerPlugin.Enabled || (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 static bool Enabled { get; private set; }

		public override MultiplayerType MPType => (MultiplayerType)14;

		public override string Author => "18107, Dragon";

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

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

		public override SessionChangedReturn OnSessionChange(SessionChangedInput input)
		{
			//IL_0001: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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)
			Enabled = input.HostHasMod;
			SessionChangedReturn result = default(SessionChangedReturn);
			result.SetMod_Session = true;
			return result;
		}
	}
}