Decompiled source of ScaleableShip v0.0.8

ScaleableShip.dll

Decompiled 8 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 HarmonyLib;
using Microsoft.CodeAnalysis;
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("Assembly-CSharp")]
[assembly: AssemblyCompany("ScaleableShip")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4d95898d78835b54ab1a984d9e45372215d7f1fc")]
[assembly: AssemblyProduct("ScaleableShip")]
[assembly: AssemblyTitle("ScaleableShip")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
		}
	}
}
namespace ScaleableShip
{
	[BepInPlugin("ScaleableShip", "\u200bScaleableShip", "0.0.8")]
	public class ScaleableShip : BaseUnityPlugin
	{
		public enum ConfigType
		{
			None,
			ConvertibleNoRails,
			Convertible,
			BigCentered,
			Defaults
		}

		private ConfigType lastPreset;

		private static GameObject? gameObject;

		public static ConfigEntry<bool> activateMode { get; set; }

		public static ConfigEntry<bool> newMode { get; set; }

		public static ConfigEntry<bool> ignoreRailSettings { get; set; }

		public static ConfigEntry<ConfigType> currentPreset { get; set; }

		public static ConfigEntry<float> shipScaleX { get; set; }

		public static ConfigEntry<float> shipScaleY { get; set; }

		public static ConfigEntry<float> shipScaleZ { get; set; }

		public static ConfigEntry<float> shipPositionX { get; set; }

		public static ConfigEntry<float> shipPositionY { get; set; }

		public static ConfigEntry<float> shipPositionZ { get; set; }

		public static ConfigEntry<float> shipRailScaleX { get; set; }

		public static ConfigEntry<float> shipRailScaleY { get; set; }

		public static ConfigEntry<float> shipRailScaleZ { get; set; }

		public static ConfigEntry<float> shipRailPositionX { get; set; }

		public static ConfigEntry<float> shipRailPositionY { get; set; }

		public static ConfigEntry<float> shipRailPositionZ { get; set; }

		public static ConfigEntry<float> shipRailPostScaleX { get; set; }

		public static ConfigEntry<float> shipRailPostScaleY { get; set; }

		public static ConfigEntry<float> shipRailPostScaleZ { get; set; }

		public static ConfigEntry<float> shipRailPostPositionX { get; set; }

		public static ConfigEntry<float> shipRailPostPositionY { get; set; }

		public static ConfigEntry<float> shipRailPostPositionZ { get; set; }

		public static ConfigEntry<float> catwalkshipScaleX { get; set; }

		public static ConfigEntry<float> catwalkshipScaleY { get; set; }

		public static ConfigEntry<float> catwalkshipScaleZ { get; set; }

		public static ConfigEntry<float> catwalkshipPositionX { get; set; }

		public static ConfigEntry<float> catwalkshipPositionY { get; set; }

		public static ConfigEntry<float> catwalkshipPositionZ { get; set; }

		public static void ApplyPresetConfiguration(ConfigType preset)
		{
			switch (preset)
			{
			case ConfigType.ConvertibleNoRails:
				activateMode.Value = true;
				ignoreRailSettings.Value = false;
				newMode.Value = false;
				shipScaleX.Value = 1f;
				shipScaleY.Value = 0.01f;
				shipScaleZ.Value = 1f;
				shipPositionX.Value = -5.25f;
				shipPositionY.Value = 0f;
				shipPositionZ.Value = 0f;
				catwalkshipScaleX.Value = 1f;
				catwalkshipScaleY.Value = 0.01f;
				catwalkshipScaleZ.Value = 1f;
				catwalkshipPositionX.Value = -5.5f;
				catwalkshipPositionY.Value = 0f;
				catwalkshipPositionZ.Value = -8.5f;
				shipRailScaleX.Value = 0f;
				shipRailScaleY.Value = 0f;
				shipRailScaleZ.Value = 0f;
				shipRailPostScaleX.Value = 0f;
				shipRailPostScaleY.Value = 0f;
				shipRailPostScaleZ.Value = 0f;
				break;
			case ConfigType.Convertible:
				activateMode.Value = true;
				ignoreRailSettings.Value = true;
				newMode.Value = false;
				shipScaleX.Value = 1f;
				shipScaleY.Value = 0.01f;
				shipScaleZ.Value = 1f;
				shipPositionX.Value = -5.25f;
				shipPositionY.Value = 0f;
				shipPositionZ.Value = 0f;
				catwalkshipScaleX.Value = 1f;
				catwalkshipScaleY.Value = 0.01f;
				catwalkshipScaleZ.Value = 1f;
				catwalkshipPositionX.Value = -5.5f;
				catwalkshipPositionY.Value = 0f;
				catwalkshipPositionZ.Value = -8.5f;
				break;
			case ConfigType.BigCentered:
				activateMode.Value = true;
				ignoreRailSettings.Value = false;
				newMode.Value = false;
				shipScaleX.Value = 6f;
				shipScaleY.Value = 2f;
				shipScaleZ.Value = 3f;
				shipPositionX.Value = 2f;
				shipPositionY.Value = 2f;
				shipPositionZ.Value = 12.5f;
				catwalkshipScaleX.Value = 5f;
				catwalkshipScaleY.Value = 0.9f;
				catwalkshipScaleZ.Value = 3f;
				catwalkshipPositionX.Value = 0f;
				catwalkshipPositionY.Value = -1f;
				catwalkshipPositionZ.Value = -13f;
				shipRailScaleX.Value = 0f;
				shipRailScaleY.Value = 0f;
				shipRailScaleZ.Value = 0f;
				shipRailPostScaleX.Value = 0f;
				shipRailPostScaleY.Value = 0f;
				shipRailPostScaleZ.Value = 0f;
				break;
			case ConfigType.Defaults:
				activateMode.Value = true;
				ignoreRailSettings.Value = true;
				newMode.Value = false;
				shipScaleX.Value = 1f;
				shipScaleY.Value = 1f;
				shipScaleZ.Value = 1f;
				shipPositionX.Value = -5.25f;
				shipPositionY.Value = 1f;
				shipPositionZ.Value = 0f;
				catwalkshipScaleX.Value = 1f;
				catwalkshipScaleY.Value = 0.01f;
				catwalkshipScaleZ.Value = 1f;
				catwalkshipPositionX.Value = -5.5f;
				catwalkshipPositionY.Value = 0f;
				catwalkshipPositionZ.Value = -8.5f;
				shipRailScaleX.Value = 0f;
				shipRailScaleY.Value = 0f;
				shipRailScaleZ.Value = 0f;
				shipRailPostScaleX.Value = 0f;
				shipRailPostScaleY.Value = 0f;
				shipRailPostScaleZ.Value = 0f;
				break;
			case ConfigType.None:
				break;
			}
		}

		private void Awake()
		{
			activateMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "Enabled", true, "Enables the mod.");
			currentPreset = ((BaseUnityPlugin)this).Config.Bind<ConfigType>("Options", "Current Preset", ConfigType.None, "Preset configurations");
			ignoreRailSettings = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "Ignore Rail Settings", true, "If this is checked keep the railing the way it is.");
			newMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Options", "New Mode", false, "Enables the new mode which scales everything, only uses Ship Scale values.");
			shipScaleX = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Scale X", 1f, "X Coordinates\n Left/Right");
			shipScaleY = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Scale Y", 1f, "Y Coordinates\n Up/Down");
			shipScaleZ = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Scale Z", 1f, "Z Coordinates\n Front/Back");
			shipPositionX = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Position X", -5.25f, "X Coordinates\n Left/Right");
			shipPositionY = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Position Y", 1f, "Y Coordinates\n Up/Down");
			shipPositionZ = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Position Z", 0f, "Z Coordinates\n Front/Back");
			catwalkshipScaleX = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Catwalk Scale X", 1f, "X Coordinates\n Left/Right");
			catwalkshipScaleY = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Catwalk Scale Y", 0.01f, "Y Coordinates\n Up/Down");
			catwalkshipScaleZ = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Catwalk Scale Z", 1f, "Z Coordinates\n Front/Back");
			catwalkshipPositionX = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Catwalk Position X", -5.5f, "X Coordinates\n Left/Right");
			catwalkshipPositionY = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Catwalk Position Y", 0f, "Y Coordinates\n Up/Down");
			catwalkshipPositionZ = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Catwalk Position Z", -8.5f, "Z Coordinates\n Front/Back");
			shipRailScaleX = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Rail Scale X", 0f, "X Coordinates\n Left/Right");
			shipRailScaleY = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Rail Scale Y", 0f, "Y Coordinates\n Up/Down");
			shipRailScaleZ = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Rail Scale Z", 0f, "Z Coordinates\n Front/Back");
			shipRailPositionX = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Rail Position X", 0f, "X Coordinates\n Left/Right");
			shipRailPositionY = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Rail Position Y", 0f, "Y Coordinates\n Up/Down");
			shipRailPositionZ = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Rail Position Z", 0f, "Z Coordinates\n Front/Back");
			shipRailPostScaleX = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Rail Post Scale X", 0f, "X Coordinates\n Left/Right");
			shipRailPostScaleY = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Rail Post Scale Y", 0f, "Y Coordinates\n Up/Down");
			shipRailPostScaleZ = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Rail Post Scale Z", 0f, "Z Coordinates\n Front/Back");
			shipRailPostPositionX = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Rail Post Position X", 0f, "X Coordinates\n Left/Right");
			shipRailPostPositionY = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Rail Post Position Y", 0f, "Y Coordinates\n Up/Down");
			shipRailPostPositionZ = ((BaseUnityPlugin)this).Config.Bind<float>("Options", "Ship Rail Post Position Z", 0f, "Z Coordinates\n Front/Back");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ScaleableShip is loaded!");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			lastPreset = currentPreset.Value;
		}

		private void Update()
		{
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			if (!activateMode.Value)
			{
				return;
			}
			if (newMode.Value)
			{
				if ((Object)(object)StartOfRound.Instance != (Object)null && (Object)(object)StartOfRound.Instance.elevatorTransform != (Object)null)
				{
					((Component)StartOfRound.Instance.elevatorTransform).transform.localScale = new Vector3(shipScaleZ.Value, shipScaleX.Value, shipScaleY.Value);
				}
			}
			else
			{
				GameObject val = GameObject.Find("ShipInside");
				if ((Object)(object)val != (Object)null)
				{
					val.transform.localScale = new Vector3(shipScaleZ.Value, shipScaleX.Value, shipScaleY.Value);
					val.transform.localPosition = new Vector3(shipPositionZ.Value, shipPositionY.Value, shipPositionX.Value);
				}
				GameObject val2 = GameObject.Find("ShipInside.001");
				if ((Object)(object)val2 != (Object)null)
				{
					val2.transform.localScale = new Vector3(shipScaleZ.Value, shipScaleX.Value, shipScaleY.Value);
					val2.transform.localPosition = new Vector3(shipPositionZ.Value, shipPositionY.Value, shipPositionX.Value);
				}
				GameObject val3 = GameObject.Find("ShipHull");
				if ((Object)(object)val3 != (Object)null)
				{
					val3.transform.localScale = new Vector3(shipScaleZ.Value, shipScaleX.Value, shipScaleY.Value);
					val3.transform.localPosition = new Vector3(shipPositionZ.Value, shipPositionY.Value, shipPositionX.Value);
				}
				GameObject val4 = GameObject.Find("CatwalkShip");
				if ((Object)(object)val4 != (Object)null)
				{
					val4.transform.localScale = new Vector3(catwalkshipScaleZ.Value, catwalkshipScaleX.Value, catwalkshipScaleY.Value);
					val4.transform.localPosition = new Vector3(catwalkshipPositionZ.Value, catwalkshipPositionY.Value, catwalkshipPositionX.Value);
				}
			}
			if (!ignoreRailSettings.Value)
			{
				GameObject val5 = GameObject.Find("ShipRails");
				if ((Object)(object)val5 != (Object)null)
				{
					val5.transform.localScale = new Vector3(shipRailScaleZ.Value, shipRailScaleY.Value, shipRailScaleX.Value);
					val5.transform.localPosition = new Vector3(shipRailPositionZ.Value, shipRailPositionY.Value, shipRailPositionX.Value);
				}
				GameObject val6 = GameObject.Find("ShipRailPosts");
				if ((Object)(object)val6 != (Object)null)
				{
					val6.transform.localScale = new Vector3(shipRailPostScaleZ.Value, shipRailPostScaleX.Value, shipRailPostScaleY.Value);
					val6.transform.localPosition = new Vector3(shipRailPostPositionZ.Value, shipRailPostPositionY.Value, shipRailPostPositionX.Value);
				}
			}
			if (currentPreset.Value != lastPreset)
			{
				lastPreset = currentPreset.Value;
				ApplyPresetConfiguration(currentPreset.Value);
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}