Decompiled source of CTRL to Place buildings instantly v1.0.1

PlaceBuildingsInstantly.dll

Decompiled 6 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 Eremite;
using Eremite.Buildings;
using Eremite.Services;
using Eremite.View.HUD;
using Eremite.View.HUD.Construction;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine.InputSystem;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("PlaceBuildingsInstantly")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Simplifies the building process by placing buildings completed.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+bd89d0f481d355330b5b27813289f091b6c84140")]
[assembly: AssemblyProduct("PlaceBuildingsInstantly")]
[assembly: AssemblyTitle("PlaceBuildingsInstantly")]
[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 PlaceBuildingsInstantly
{
	public sealed class MBHelper : GameMB
	{
		public static IGameSaveService _GameSaveService => MB.GameSaveService;

		public static BuildingsService _BuildingsService => (BuildingsService)GameMB.BuildingsService;

		public static ConstructionService _ConstructionService => (ConstructionService)GameMB.ConstructionService;
	}
	[BepInPlugin("PlaceBuildingsInstantly", "PlaceBuildingsInstantly", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Plugin Instance;

		private Harmony harmony;

		private bool _removeBuilding;

		private Building _cachedBuildingToRemove;

		public static ManualLogSource Log => ((BaseUnityPlugin)Instance).Logger;

		private void Awake()
		{
			Instance = this;
			harmony = Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin PlaceBuildingsInstantly is loaded!");
		}

		[HarmonyPatch(typeof(BuildingsPanel), "PlacingFinished")]
		[HarmonyPrefix]
		private static bool HookPlacingFinishedPrefix(BuildingsPanel __instance)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			Instance._removeBuilding = false;
			IBuildingRequest currentRequest = __instance.currentRequest;
			BuildingRequest val = (BuildingRequest)(object)((currentRequest is BuildingRequest) ? currentRequest : null);
			if (val == null)
			{
				return true;
			}
			Building currentBuilding = val.currentBuilding;
			if (!Keyboard.current.ctrlKey.isPressed)
			{
				return true;
			}
			Log.LogInfo((object)$"Skippping construction process for building {currentBuilding}");
			new BuildingCreator().CreateCompletedBuilding(currentBuilding.BuildingModel, currentBuilding.BuildingState.field, currentBuilding.BuildingState.rotation);
			Instance._removeBuilding = true;
			Instance._cachedBuildingToRemove = currentBuilding;
			return true;
		}

		[HarmonyPatch(typeof(BuildingsPanel), "PlacingFinished")]
		[HarmonyPostfix]
		private static void HookPlacingFinishedPostfix()
		{
			if (Instance._removeBuilding)
			{
				Building cachedBuildingToRemove = Instance._cachedBuildingToRemove;
				if (cachedBuildingToRemove != null)
				{
					cachedBuildingToRemove.Remove(false);
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "PlaceBuildingsInstantly";

		public const string PLUGIN_NAME = "PlaceBuildingsInstantly";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}