Decompiled source of Set Exit Vector v1.0.2

SetExitVector.dll

Decompiled 2 months 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.Configuration;
using BepInEx.Logging;
using CG.Game.SpaceObjects.Controllers;
using CG.Ship.Modules;
using Gameplay.Utilities;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using VoidManager;
using VoidManager.CustomGUI;
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("SetExitVector")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2+2aa51ad7c27ebe04811b5c998beff10bd0cccc7a")]
[assembly: AssemblyProduct("SetExitVector")]
[assembly: AssemblyTitle("Automatically sets the exit vector when the void drive is charged. Host side.")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.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 SetExitVector
{
	[BepInPlugin("18107.SetExitVector", "Set Exit Vector", "1.0.2")]
	[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(), "18107.SetExitVector");
			PluginConfig.BindConfigs(this);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin 18107.SetExitVector is loaded!");
		}
	}
	internal class GUI : ModSettingsMenu
	{
		public override string Name()
		{
			return "Set Exit Vector";
		}

		public override void Draw()
		{
			GUILayout.Label("When charging the Void Drive", Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("Set Exit Vector: " + (PluginConfig.ExitVector.Value ? "Enabled" : "Disabled"), Array.Empty<GUILayoutOption>()))
			{
				PluginConfig.ExitVector.Value = !PluginConfig.ExitVector.Value;
			}
		}
	}
	public class MyPluginInfo
	{
		public const string PLUGIN_GUID = "18107.SetExitVector";

		public const string PLUGIN_NAME = "SetExitVector";

		public const string USERS_PLUGIN_NAME = "Set Exit Vector";

		public const string PLUGIN_VERSION = "1.0.2";

		public const string PLUGIN_DESCRIPTION = "Automatically sets the exit vector when the void drive is charged. Host side.";

		public const string PLUGIN_ORIGINAL_AUTHOR = "18107";

		public const string PLUGIN_AUTHORS = "18107";

		public const string PLUGIN_THUNDERSTORE_ID = "VoidCrewModdingTeam/Set_Exit_Vector";
	}
	internal class PluginConfig
	{
		internal static ConfigEntry<bool> ExitVector;

		internal static ConfigEntry<bool> SideQuestSector;

		internal static ConfigEntry<bool> MissionSector;

		internal static ConfigEntry<bool> ExitSector;

		internal static void BindConfigs(BepinPlugin plugin)
		{
			ExitVector = ((BaseUnityPlugin)plugin).Config.Bind<bool>("SetExitVector", "ExitVector", true, (ConfigDescription)null);
			SideQuestSector = ((BaseUnityPlugin)plugin).Config.Bind<bool>("SetExitVector", "SideQuestSector", true, (ConfigDescription)null);
			MissionSector = ((BaseUnityPlugin)plugin).Config.Bind<bool>("SetExitVector", "MissionSector", true, (ConfigDescription)null);
			ExitSector = ((BaseUnityPlugin)plugin).Config.Bind<bool>("SetExitVector", "ExitSector", true, (ConfigDescription)null);
		}
	}
	[HarmonyPatch(typeof(VoidDriveModule), "SetEngineCharging")]
	internal class VoidDriveModulePatch
	{
		private static void Postfix(VoidDriveModule __instance, VoidJumpSystem ___voidJumpSystem, bool[] ___engineStates)
		{
			if (!PhotonNetwork.IsMasterClient || !PluginConfig.ExitVector.Value || ___voidJumpSystem.IsExitVectorSet() || ((ModifiablePrimitive<int, IntModifier>)(object)__instance.VoidJumpCapable).Value <= 0)
			{
				return;
			}
			for (int i = 0; i < ___engineStates.Length; i++)
			{
				if (!___engineStates[i])
				{
					return;
				}
			}
			___voidJumpSystem.ExitVectorSet(true);
		}
	}
	public class VoidManagerPlugin : VoidPlugin
	{
		public override MultiplayerType MPType => (MultiplayerType)14;

		public override string Author => "18107";

		public override string Description => "Automatically sets the exit vector when the void drive is charged. Host side.";

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

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