Decompiled source of Build Anywhere v1.2.0

BuildAnywhere.dll

Decompiled 11 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.Logging;
using BuildAnywhereMod.Patches;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BuildAnywhere")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("DLL for Lethal Company that lets you ship build anywhere.")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+fd744da55508b79bba33a5ff56b543a4e840ba50")]
[assembly: AssemblyProduct("BuildAnywhere")]
[assembly: AssemblyTitle("BuildAnywhere")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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 BuildAnywhere
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BuildAnywhere";

		public const string PLUGIN_NAME = "BuildAnywhere";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace BuildAnywhereMod
{
	[BepInPlugin("Vegasx.BuildAnywhere", "Build Anywhere", "1.0.0")]
	public class BuildAnywhere : BaseUnityPlugin
	{
		private const string modGUID = "Vegasx.BuildAnywhere";

		private const string modName = "Build Anywhere";

		private const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Vegasx.BuildAnywhere");

		private static BuildAnywhere Instance;

		internal ManualLogSource mls;

		private void Awake()
		{
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			harmony.PatchAll(typeof(ShipBuildModeManagerPatch));
			harmony.PatchAll(typeof(AlwaysCanBuildPatch));
			harmony.PatchAll(typeof(PlaceShipObjectPatch));
			mls = Logger.CreateLogSource("Vegasx.BuildAnywhere");
			mls.LogInfo((object)"Build Anywhere has awoken.");
		}
	}
}
namespace BuildAnywhereMod.Patches
{
	[HarmonyPatch(typeof(ShipBuildModeManager), "PlaceShipObject")]
	internal class PlaceShipObjectPatch
	{
		private static void Postfix(ref Vector3 placementPosition, ref Vector3 placementRotation, ref PlaceableShipObject placeableObject, ref bool placementSFX)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			Vector3 rotationOffset = placeableObject.parentObject.rotationOffset;
			StartOfRound.Instance.suckingFurnitureOutOfShip = false;
			StartOfRound.Instance.unlockablesList.unlockables[placeableObject.unlockableID].placedPosition = placementPosition;
			StartOfRound.Instance.unlockablesList.unlockables[placeableObject.unlockableID].placedRotation = placementRotation;
			StartOfRound.Instance.unlockablesList.unlockables[placeableObject.unlockableID].hasBeenMoved = true;
			if ((Object)(object)placeableObject.parentObjectSecondary != (Object)null)
			{
				Vector3 position = ((Component)placeableObject.parentObjectSecondary).transform.position;
				Quaternion rotation = ((Component)placeableObject.parentObjectSecondary).transform.rotation;
				Quaternion val = Quaternion.Euler(placementRotation) * Quaternion.Inverse(((Component)placeableObject.mainMesh).transform.rotation);
				((Component)placeableObject.parentObjectSecondary).transform.rotation = val * ((Component)placeableObject.parentObjectSecondary).transform.rotation;
				placeableObject.parentObjectSecondary.position = placementPosition + (((Component)placeableObject.parentObjectSecondary).transform.position - ((Component)placeableObject.mainMesh).transform.position) + (((Component)placeableObject.mainMesh).transform.position - ((Component)placeableObject.placeObjectCollider).transform.position);
			}
			else if ((Object)(object)placeableObject.parentObject != (Object)null)
			{
				Vector3 positionOffset = placeableObject.parentObject.positionOffset;
				Quaternion rotation2 = ((Component)placeableObject.parentObject).transform.rotation;
				Quaternion val2 = Quaternion.Euler(placementRotation) * Quaternion.Inverse(((Component)placeableObject.mainMesh).transform.rotation);
				AutoParentToShip parentObject = placeableObject.parentObject;
				Quaternion val3 = val2 * ((Component)placeableObject.parentObject).transform.rotation;
				parentObject.rotationOffset = ((Quaternion)(ref val3)).eulerAngles;
				((Component)placeableObject.parentObject).transform.rotation = val2 * ((Component)placeableObject.parentObject).transform.rotation;
				placeableObject.parentObject.positionOffset = StartOfRound.Instance.elevatorTransform.InverseTransformPoint(placementPosition + (((Component)placeableObject.parentObject).transform.position - ((Component)placeableObject.mainMesh).transform.position) + (((Component)placeableObject.mainMesh).transform.position - ((Component)placeableObject.placeObjectCollider).transform.position));
			}
		}
	}
	[HarmonyPatch(typeof(ShipBuildModeManager), "PlayerMeetsConditionsToBuild")]
	internal class AlwaysCanBuildPatch
	{
		private static bool Prefix(ref bool __result, ref PlayerControllerB ___player)
		{
			if (___player.inSpecialInteractAnimation || ___player.activatingItem)
			{
				return true;
			}
			__result = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(ShipBuildModeManager))]
	internal class ShipBuildModeManagerPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void BuildAnywhereCanConfirm(ref bool ___CanConfirmPosition, ref MeshRenderer ___ghostObjectRenderer, ref Material ___ghostObjectGreen, ref PlaceableShipObject ___placingObject, ref bool ___InBuildMode)
		{
			if (___InBuildMode)
			{
				___CanConfirmPosition = true;
				((Renderer)___ghostObjectRenderer).sharedMaterial = ___ghostObjectGreen;
				___placingObject.AllowPlacementOnWalls = true;
				___placingObject.AllowPlacementOnCounters = true;
			}
		}
	}
}