using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; 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("FreeStuff Update")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FreeStuff Update")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("839354aa-33ce-4b32-a5a4-470c7c2ba9a3")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace FreeSplitter; [BepInPlugin("com.yourname.freesplitter", "Free Splitter", "1.0.0")] public class Plugin : BaseUnityPlugin { private void Awake() { ((BaseUnityPlugin)this).Logger.LogInfo((object)"Free Splitter loaded!"); Harmony.CreateAndPatchAll(typeof(FreeSplitterPatch), (string)null); } } [HarmonyPatch] public class FreeSplitterPatch { [HarmonyPrefix] [HarmonyPatch(typeof(CargoTraffic), "UpdateSplitter")] public static bool UpdateSplitter_Prefix(CargoTraffic __instance, ref SplitterComponent sp) { return HandleSplitter(__instance, ref sp); } [HarmonyPrefix] [HarmonyPatch(typeof(CargoTraffic), "UpdateSplitterAsync")] public static bool UpdateSplitterAsync_Prefix(CargoTraffic __instance, ref SplitterComponent sp) { return HandleSplitter(__instance, ref sp); } private static bool HandleSplitter(CargoTraffic __instance, ref SplitterComponent sp) { if (sp.input0 == 0 && sp.input1 == 0 && sp.input2 == 0 && sp.input3 == 0 && sp.outFilter > 0) { if (sp.output0 != 0) { CargoPath cargoPath = __instance.GetCargoPath(__instance.beltPool[sp.output0].segPathId); if (cargoPath != null && cargoPath.pathLength > 10) { int num = cargoPath.TestBlankAtHead(); if (num >= 0) { int num2 = __instance.container.AddCargo((short)sp.outFilter, (byte)1, (byte)0); cargoPath.InsertCargoAtHeadDirect(num2, num); } } } return false; } return true; } }