Decompiled source of FarExtensions v1.0.0

FarExtensions.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
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(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[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 OblitusEs.FarExtensions
{
	[BepInPlugin("OblitusEs.FarExtensions", "FarExtensions", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "OblitusEs.FarExtensions";

		public const string PluginName = "FarExtensions";

		public const string PluginVersion = "1.0.0";

		internal static ConfigEntry<float> MaxStationDistance;

		internal static ConfigEntry<bool> RemoveSpacingRule;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			MaxStationDistance = ((BaseUnityPlugin)this).Config.Bind<float>("General", "MaxStationDistance", 30f, new ConfigDescription("How far (in meters) a crafting station extension may be from its station and still count. Vanilla is roughly 5 for most extensions. Values below an extension's vanilla distance are ignored.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 100f), Array.Empty<object>()));
			RemoveSpacingRule = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "RemoveSpacingRule", true, "If true, extensions can be placed right next to each other (no 'not enough space' check).");
			_harmony = new Harmony("OblitusEs.FarExtensions");
			_harmony.PatchAll();
		}

		private void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	[HarmonyPatch(typeof(StationExtension), "Awake")]
	internal static class StationExtension_Awake_Patch
	{
		private static void Postfix(StationExtension __instance)
		{
			__instance.m_maxStationDistance = Mathf.Max(__instance.m_maxStationDistance, Plugin.MaxStationDistance.Value);
		}
	}
	[HarmonyPatch(typeof(StationExtension), "OtherExtensionInRange")]
	internal static class StationExtension_OtherExtensionInRange_Patch
	{
		private static bool Prefix(ref bool __result)
		{
			if (!Plugin.RemoveSpacingRule.Value)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
}