Decompiled source of StationReach v1.0.1

StationReach.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.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StationReach")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StationReach")]
[assembly: AssemblyTitle("StationReach")]
[assembly: AssemblyVersion("1.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 StationReach
{
	[BepInPlugin("com.Azura.stationreach", "StationReach", "1.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.Azura.stationreach";

		public const string PluginName = "StationReach";

		public const string PluginVersion = "1.0.1";

		public static ConfigEntry<float> Multiplicateur;

		public static ConfigEntry<bool> ZoneBase;

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			Multiplicateur = ((BaseUnityPlugin)this).Config.Bind<float>("General", "RangeMultiplier", 3f, new ConfigDescription("Multiplier of the crafting stations' build range (3 = three times the original range).\nMultiplicateur de la portée de construction des établis (3 = trois fois la portée d'origine).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
			ZoneBase = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ScaleBaseArea", true, "true = the station's base area (where monsters do not spawn) grows with the range, like in the vanilla game.\ntrue = la zone « base » de l'établi (sans apparition de monstres) grandit avec la portée, comme dans le jeu.");
			new Harmony("com.Azura.stationreach").PatchAll();
			bool flag = PlayerPrefs.GetString("language", "") == "French";
			((BaseUnityPlugin)this).Logger.LogInfo((object)(flag ? string.Format("{0} v{1} chargé : portée des établis x{2}.", "StationReach", "1.0.1", Multiplicateur.Value) : string.Format("{0} v{1} loaded: crafting station range x{2}.", "StationReach", "1.0.1", Multiplicateur.Value)));
		}
	}
	[HarmonyPatch(typeof(CraftingStation), "Start")]
	public static class CraftingStation_Start_Patch
	{
		public static void Prefix(CraftingStation __instance)
		{
			float value = Plugin.Multiplicateur.Value;
			if (!(value <= 1.0001f))
			{
				__instance.m_rangeBuild *= value;
				__instance.m_extraRangePerLevel *= value;
				CircleProjector val = (((Object)(object)__instance.m_areaMarker != (Object)null) ? __instance.m_areaMarker.GetComponent<CircleProjector>() : null);
				if ((Object)(object)val != (Object)null)
				{
					val.m_nrOfSegments = Mathf.Clamp(Mathf.RoundToInt((float)val.m_nrOfSegments * value), 8, 400);
				}
			}
		}
	}
	[HarmonyPatch(typeof(CraftingStation), "GetExtensions")]
	public static class CraftingStation_GetExtensions_Patch
	{
		private static readonly FieldRef<CraftingStation, float> Portee = AccessTools.FieldRefAccess<CraftingStation, float>("m_buildRange");

		public static void Postfix(CraftingStation __instance)
		{
			float value = Plugin.Multiplicateur.Value;
			if (Plugin.ZoneBase.Value || value <= 1.0001f || (Object)(object)__instance.m_effectAreaCollider == (Object)null)
			{
				return;
			}
			float num = Portee.Invoke(__instance) / value;
			Collider effectAreaCollider = __instance.m_effectAreaCollider;
			SphereCollider val = (SphereCollider)(object)((effectAreaCollider is SphereCollider) ? effectAreaCollider : null);
			if (val != null && !Mathf.Approximately(val.radius, num))
			{
				val.radius = num;
				return;
			}
			Collider effectAreaCollider2 = __instance.m_effectAreaCollider;
			CapsuleCollider val2 = (CapsuleCollider)(object)((effectAreaCollider2 is CapsuleCollider) ? effectAreaCollider2 : null);
			if (val2 != null && !Mathf.Approximately(val2.radius, num))
			{
				val2.radius = num;
			}
		}
	}
}