Decompiled source of LogisticsBotExpansion v1.0.0

LogisticsBotExpansion.dll

Decompiled a month 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.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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 LogisticsBotExpansion
{
	public static class DispenserPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(RecipeProto), "InitFractionatorNeeds")]
		public static void InitFractionatorNeedsPostfix()
		{
			ItemProto[] dataArray = ((ProtoSet<ItemProto>)(object)LDB.items).dataArray;
			for (int i = 0; i < dataArray.Length; i++)
			{
				if (dataArray[i].prefabDesc != null && dataArray[i].prefabDesc.isDispenser)
				{
					dataArray[i].prefabDesc.dispenserMaxCourierCount = Plugin.MaxLogisticsBotCount.Value;
				}
			}
		}
	}
	[BepInPlugin("com.leo.dsp.LogisticsBotExpansion", "LogisticsBotExpansion", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.leo.dsp.LogisticsBotExpansion";

		public const string PluginName = "LogisticsBotExpansion";

		public const string PluginVersion = "1.0.0";

		public static ConfigEntry<int> MaxLogisticsBotCount;

		private Harmony _harmony;

		public void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			MaxLogisticsBotCount = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxLogisticsBotCount", 100, "Maximum number of logistics bots per Logistics Distributor");
			_harmony = new Harmony("com.leo.dsp.LogisticsBotExpansion");
			_harmony.PatchAll(typeof(DispenserPatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} {1} loaded. Max bots: {2}", "LogisticsBotExpansion", "1.0.0", MaxLogisticsBotCount.Value));
		}

		public void OnDestroy()
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}