Decompiled source of MirroredParts v1.0.0

MirroredParts.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using WildSkies.Gameplay.Building;
using WildSkies.Gameplay.ShipBuilding;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("MirroredParts")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Nines (Natives)")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MirroredParts")]
[assembly: AssemblyTitle("MirroredParts")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MirroredParts
{
	[BepInPlugin("MirroredParts", "MirroredParts", "1.0.0")]
	public class Plugin : BasePlugin
	{
		internal static ManualLogSource Log;

		internal static Harmony harmonyInstance;

		private static readonly string[] ExcludedParts = new string[9] { "ship.part.core.", "ship.part.helm.", "ship.part.table.map.", "ship.part.decoration.wood.bench.", "ship.part.decoration.wood.stool.", "ship.part.decoration.saborian.stool.", "ship.part.chair.", "ship.part.decoration.bed.", "ship.part.instrument." };

		public override void Load()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			ManualLogSource log = Log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("MirroredParts");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
			}
			log.LogInfo(val);
			harmonyInstance = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
		}

		public override bool Unload()
		{
			Harmony obj = harmonyInstance;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			return true;
		}

		private static float getScale(Vector3 localScale, float x)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			x += 1.6f;
			if (localScale.x == 1f && x < -0.02f)
			{
				return -1f;
			}
			if (localScale.x == -1f && x > 0.02f)
			{
				return 1f;
			}
			return 0f;
		}

		[HarmonyPatch(typeof(ShipFrameBuilder), "UpdateHullObjectDetails")]
		[HarmonyPostfix]
		public static void ShipFrameBuilder_UpdateHullObjectDetails(ShipFrameBuilder __instance, GameObject shipPartGameObject)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			string itemId = shipPartGameObject.GetComponent<BuildableAsset>().Id;
			if (!ExcludedParts.Any((string x) => itemId.StartsWith(x)) && !Object.op_Implicit((Object)(object)shipPartGameObject.GetComponentInChildren<MeshCollider>()))
			{
				Vector3 localScale = shipPartGameObject.transform.localScale;
				float scale = getScale(localScale, shipPartGameObject.transform.localPosition.x);
				if (scale != 0f)
				{
					localScale.x = scale;
					shipPartGameObject.transform.localScale = localScale;
				}
			}
		}

		[HarmonyPatch(typeof(CraftingToolController), "UpdatePlacementStamp")]
		[HarmonyPrefix]
		public static void CraftingToolController_UpdatePlacementStamp(CraftingToolController __instance)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance._placementData.IsLookingAtShip())
			{
				return;
			}
			string itemId = __instance._placementData.SelectedAssetDefinition.ItemId;
			if (!ExcludedParts.Any((string x) => itemId.StartsWith(x)))
			{
				Vector3 localScale = ((Component)__instance._placementData.SelectedAssetController).transform.localScale;
				float scale = getScale(localScale, __instance._placementData.LookAtPoint.Position.x);
				if (scale != 0f)
				{
					localScale.x = scale;
					((Component)__instance._placementData.SelectedAssetController).transform.localScale = localScale;
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "MirroredParts";

		public const string PLUGIN_NAME = "MirroredParts";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}