Decompiled source of Moveable Suits v1.0.0

MoveableSuits.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoveableSuits.Patches;
using TooManySuits;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("MoreSuits")]
[assembly: IgnoresAccessChecksTo("TooManySuits")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("MasterAli2.MoveableSuits")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+da90b355b151bcdbf359902210fe9695e8816aab")]
[assembly: AssemblyProduct("MoveableSuits")]
[assembly: AssemblyTitle("MasterAli2.MoveableSuits")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 MoveableSuits
{
	[BepInPlugin("MasterAli2.MoveableSuits", "MoveableSuits", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MoveableSuits : BaseUnityPlugin
	{
		private const string _more_suits_guid = "x753.More_Suits";

		private const string _too_many_suits_guid = "TooManySuits";

		public static float xVector = -2.45f;

		public static float yVector = 2.45f;

		public static float zVector = -8.41f;

		public static ConfigEntry<float> rackPosX;

		public static ConfigEntry<float> rackPosY;

		public static ConfigEntry<float> rackPosZ;

		public static ConfigEntry<bool> hideSuitRack;

		public static ConfigEntry<bool> disableSuitCollision;

		public static MoveableSuits Instance { get; private set; } = null;


		internal static ManualLogSource Logger { get; private set; } = null;


		internal static Harmony? Harmony { get; set; }

		public static Vector3 SuitRackPosition
		{
			get
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				return new Vector3(xVector, yVector, zVector);
			}
			set
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				xVector = value.x;
				yVector = value.y;
				zVector = value.z;
			}
		}

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			SetupConfig();
			Patch();
			Logger.LogInfo((object)"MasterAli2.MoveableSuits v1.0.0 has loaded!");
		}

		private void SetupConfig()
		{
			rackPosX = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SuitPosX", -2.45f, "X position of suits");
			rackPosY = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SuitPosY", 2.75f, "Y position of suits");
			rackPosZ = ((BaseUnityPlugin)this).Config.Bind<float>("General", "SuitPosZ", -8.41f, "Z position of suits");
			hideSuitRack = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HideSuitRack", true, "Should the suit rack be hidden?");
			disableSuitCollision = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DisableSuitCollision", false, "Shoud the suits collision be disabled?");
			OnConfigUpdate();
			((BaseUnityPlugin)this).Config.SettingChanged += OnConfigUpdate;
		}

		private void OnConfigUpdate(object sender = null, EventArgs e = null)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			xVector = rackPosX.Value;
			yVector = rackPosY.Value;
			zVector = rackPosZ.Value;
			Logger.LogInfo((object)$"Suit rack position set to: {SuitRackPosition}");
			if (!((Object)(object)StartOfRound.Instance == (Object)null))
			{
				StartOfRound.Instance.PositionSuitsOnRack();
				SuitRack.UpdateCosmetics();
				TooManySuitsPatch.UpdateTMS();
			}
		}

		internal static void Patch()
		{
			//IL_000c: 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_0017: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("MasterAli2.MoveableSuits");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll(typeof(General));
			Harmony.PatchAll(typeof(SuitRack));
			if (Chainloader.PluginInfos.ContainsKey("x753.More_Suits"))
			{
				Logger.LogDebug((object)"MoreSuits detected!");
				Harmony.PatchAll(typeof(MoreSuitsPatch));
			}
			else
			{
				Logger.LogDebug((object)"MoreSuits not detected, skipping");
			}
			if (Chainloader.PluginInfos.ContainsKey("TooManySuits"))
			{
				Logger.LogDebug((object)"TooManySuits detected!");
				Harmony.PatchAll(typeof(TooManySuitsPatch));
			}
			else
			{
				Logger.LogDebug((object)"TooManySuits not detected, skipping");
			}
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MasterAli2.MoveableSuits";

		public const string PLUGIN_NAME = "MoveableSuits";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace MoveableSuits.Patches
{
	internal class General
	{
		[HarmonyPatch(typeof(StartOfRound), "PositionSuitsOnRack")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> ModifySuitUpdate(IEnumerable<CodeInstruction> instructions)
		{
			FieldInfo xVector = AccessTools.Field(typeof(MoveableSuits), "xVector");
			FieldInfo yVector = AccessTools.Field(typeof(MoveableSuits), "yVector");
			FieldInfo zVector = AccessTools.Field(typeof(MoveableSuits), "zVector");
			int founds = 0;
			foreach (CodeInstruction instruction in instructions)
			{
				CodeInstruction val = instruction;
				if (val.opcode == OpCodes.Ldc_R4)
				{
					founds++;
					switch (founds)
					{
					case 1:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)xVector);
						break;
					case 2:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)yVector);
						break;
					case 3:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)zVector);
						break;
					}
				}
				yield return val;
			}
		}

		[HarmonyPatch(typeof(StartOfRound), "SpawnUnlockable")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> ModifySuitSpawn(IEnumerable<CodeInstruction> instructions)
		{
			FieldInfo xVector = AccessTools.Field(typeof(MoveableSuits), "xVector");
			FieldInfo yVector = AccessTools.Field(typeof(MoveableSuits), "yVector");
			FieldInfo zVector = AccessTools.Field(typeof(MoveableSuits), "zVector");
			int founds = 0;
			foreach (CodeInstruction instruction in instructions)
			{
				CodeInstruction val = instruction;
				if (val.opcode == OpCodes.Ldc_R4)
				{
					founds++;
					switch (founds)
					{
					case 2:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)xVector);
						break;
					case 3:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)yVector);
						break;
					case 4:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)zVector);
						break;
					}
				}
				yield return val;
			}
		}
	}
	public class MoreSuitsPatch
	{
		[HarmonyPatch(typeof(StartOfRoundPatch), "PositionSuitsOnRackPatch")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> ModifySuitUpdate(IEnumerable<CodeInstruction> instructions)
		{
			FieldInfo xVector = AccessTools.Field(typeof(MoveableSuits), "xVector");
			FieldInfo yVector = AccessTools.Field(typeof(MoveableSuits), "yVector");
			FieldInfo zVector = AccessTools.Field(typeof(MoveableSuits), "zVector");
			int founds = 0;
			foreach (CodeInstruction instruction in instructions)
			{
				CodeInstruction val = instruction;
				if (val.opcode == OpCodes.Ldc_R4)
				{
					founds++;
					switch (founds)
					{
					case 3:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)xVector);
						break;
					case 4:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)yVector);
						break;
					case 5:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)zVector);
						break;
					}
				}
				yield return val;
			}
		}
	}
	internal class SuitRack
	{
		private static GameObject? SuitRackObject;

		private static GameObject? Shoes;

		[HarmonyPatch(typeof(StartOfRound), "Start")]
		[HarmonyPostfix]
		internal static void UpdateCosmetics()
		{
			if ((Object)(object)GameObject.Find("NurbsPath.002") != (Object)null)
			{
				SuitRackObject = GameObject.Find("NurbsPath.002");
			}
			if ((Object)(object)GameObject.Find("ScavengerModelSuitParts") != (Object)null)
			{
				Shoes = GameObject.Find("ScavengerModelSuitParts");
			}
			GameObject? suitRackObject = SuitRackObject;
			if (suitRackObject != null)
			{
				suitRackObject.SetActive(!MoveableSuits.hideSuitRack.Value);
			}
			GameObject? shoes = Shoes;
			if (shoes != null)
			{
				shoes.SetActive(!MoveableSuits.hideSuitRack.Value);
			}
			UnlockableSuit[] array = Object.FindObjectsOfType<UnlockableSuit>();
			UnlockableSuit[] array2 = array;
			foreach (UnlockableSuit val in array2)
			{
				((Collider)((Component)val).GetComponent<BoxCollider>()).isTrigger = MoveableSuits.disableSuitCollision.Value;
			}
		}
	}
	internal class TooManySuitsPatch
	{
		[HarmonyPatch(typeof(PaginationController), "DisplayCurrentPage")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> ModifySuitUpdate(IEnumerable<CodeInstruction> instructions)
		{
			FieldInfo xVector = AccessTools.Field(typeof(MoveableSuits), "xVector");
			FieldInfo yVector = AccessTools.Field(typeof(MoveableSuits), "yVector");
			FieldInfo zVector = AccessTools.Field(typeof(MoveableSuits), "zVector");
			int founds = 0;
			foreach (CodeInstruction instruction in instructions)
			{
				CodeInstruction val = instruction;
				if (val.opcode == OpCodes.Ldc_R4)
				{
					founds++;
					switch (founds)
					{
					case 3:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)xVector);
						break;
					case 4:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)yVector);
						break;
					case 5:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)zVector);
						break;
					}
				}
				yield return val;
			}
		}

		[HarmonyPatch(typeof(Patches), "StartPatch")]
		[HarmonyTranspiler]
		[HarmonyDebug]
		private static IEnumerable<CodeInstruction> ModifyButtonSpawn(IEnumerable<CodeInstruction> instructions)
		{
			FieldInfo xVector = AccessTools.Field(typeof(MoveableSuits), "xVector");
			FieldInfo yVector = AccessTools.Field(typeof(MoveableSuits), "yVector");
			FieldInfo zVector = AccessTools.Field(typeof(MoveableSuits), "zVector");
			int founds = 0;
			bool add_q = false;
			foreach (CodeInstruction instruction in instructions)
			{
				CodeInstruction val = instruction;
				if (val.opcode == OpCodes.Ldc_R4)
				{
					founds++;
					switch (founds)
					{
					case 4:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)xVector);
						break;
					case 5:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)yVector);
						add_q = true;
						break;
					case 6:
						val = new CodeInstruction(OpCodes.Ldsfld, (object)zVector);
						break;
					}
				}
				yield return val;
				if (add_q)
				{
					yield return new CodeInstruction(OpCodes.Ldc_R4, (object)0.25f);
					yield return new CodeInstruction(OpCodes.Add, (object)null);
					add_q = false;
				}
			}
		}

		public static void UpdateTMS()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			PaginationController val = Object.FindAnyObjectByType<PaginationController>();
			if (!((Object)(object)val == (Object)null))
			{
				AutoParentToShip component = ((Component)val).gameObject.GetComponent<AutoParentToShip>();
				if (!((Object)(object)component == (Object)null))
				{
					component.positionOffset = MoveableSuits.SuitRackPosition;
					component.positionOffset.y += 0.25f;
					component.positionOffset += StartOfRound.Instance.rightmostSuitPosition.forward * 2.0700002f / 2f;
				}
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}