using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DspFontPatcher")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DspFontPatcher")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("81DF3045-8007-4F6A-AAF6-903139D85B6C")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
namespace DSPMultiDistributor;
[BepInPlugin("Appun.DSP.plugin.MultiDistributor", "DSPMultiDistributor", "0.0.3")]
[HarmonyPatch]
public class Main : BaseUnityPlugin
{
public class LogManager
{
public static ManualLogSource Logger;
}
public void Awake()
{
LogManager.Logger = ((BaseUnityPlugin)this).Logger;
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
}
[HarmonyPrefix]
[HarmonyPatch(typeof(UIDispenserWindow), "_OnClose")]
public static void UIDispenserWindow_OnClose_Prefix2(UIDispenserWindow __instance)
{
GameMain.data.localLoadedPlanetFactory.transport.RefreshDispenserTraffic(0);
}
[HarmonyPostfix]
[HarmonyPatch(typeof(PlanetTransport), "RefreshDispenserTraffic")]
public static void PlanetTransport_RefreshDispenserTraffic_Postfix(PlanetTransport __instance, int keyId)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Invalid comparison between Unknown and I4
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Invalid comparison between Unknown and I4
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Invalid comparison between Unknown and I4
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Invalid comparison between Unknown and I4
for (int i = 1; i < __instance.dispenserCursor; i++)
{
DispenserComponent val = __instance.dispenserPool[i];
if (val == null || val.storage == null || val.id != i || val.filter != 0)
{
continue;
}
if ((int)val.storageMode == 1)
{
for (int j = 0; j < val.storage.size; j++)
{
int filter = val.storage.grids[j].filter;
if (filter <= 0)
{
continue;
}
for (int k = 1; k < __instance.dispenserCursor; k++)
{
DispenserComponent val2 = __instance.dispenserPool[k];
if (val2 != null && val2.id == k && (int)val2.storageMode == 2 && val2.filter == filter)
{
val.AddPair(i, 0, k, 0);
val2.AddPair(i, 0, k, 0);
}
}
}
}
else if ((int)val.storageMode == 2)
{
for (int l = 0; l < val.storage.size; l++)
{
int filter2 = val.storage.grids[l].filter;
if (filter2 <= 0)
{
continue;
}
for (int m = 1; m < __instance.dispenserCursor; m++)
{
DispenserComponent val3 = __instance.dispenserPool[m];
if (val3 != null && val3.id == m && (int)val3.storageMode == 1 && val3.filter == filter2)
{
val.AddPair(m, 0, i, 0);
val3.AddPair(m, 0, i, 0);
}
}
}
}
int logisticCourierCarries = GameMain.history.logisticCourierCarries;
val.OnRematchPairs(__instance.factory, __instance.dispenserPool, keyId, logisticCourierCarries);
}
}
}