Decompiled source of Compact Crafting Upgrades v1.0.0

plugins/CompactCraftingUpgrades/CompactCraftingUpgrades.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 OctoberJemini.CompactCraftingUpgrades
{
	[BepInPlugin("OctoberJemini.CompactCraftingUpgrades", "Compact Crafting Upgrades", "1.0.0")]
	[BepInIncompatibility("DeathWizsh.CraftingStationTweakz")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Id = "OctoberJemini.CompactCraftingUpgrades";

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> Spacing;

		private Harmony harmony;

		private void Awake()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Use custom spacing for crafting station upgrades. False restores the game's spacing check.");
			Spacing = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MinimumUpgradeSpacing", 0.5f, new ConfigDescription("Minimum distance in meters between station upgrades. 0 removes this spacing check. Does not bypass collisions, station connection range, or other building rules.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2f), Array.Empty<object>()));
			harmony = new Harmony("OctoberJemini.CompactCraftingUpgrades");
			harmony.PatchAll(typeof(Plugin).Assembly);
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Upgrade spacing: " + Spacing.Value + " m. Station ranges and bonuses are unchanged."));
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch(typeof(StationExtension), "OtherExtensionInRange", new Type[] { typeof(float) })]
	internal static class UpgradeSpacingPatch
	{
		private static void Prefix(ref float __0)
		{
			if (Plugin.Enabled.Value)
			{
				float value = Plugin.Spacing.Value;
				if (!float.IsNaN(value) && !float.IsInfinity(value))
				{
					__0 = Math.Max(0f, Math.Min(2f, value));
				}
			}
		}
	}
}