From 6b325ff7db270af883835740cbe55ace1711af71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Majdand=C5=BEi=C4=87?= Date: Tue, 30 Apr 2024 16:45:47 +0200 Subject: [PATCH] Make pipe throughput speedifier --- .../CaptainOfIndustry/Class1.cs | 2 + .../CaptainOfIndustry/Patches.cs | 55 ++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/Projects/CaptainOfIndustry/CaptainOfIndustry/Class1.cs b/Projects/CaptainOfIndustry/CaptainOfIndustry/Class1.cs index 236249e..5ecde4b 100644 --- a/Projects/CaptainOfIndustry/CaptainOfIndustry/Class1.cs +++ b/Projects/CaptainOfIndustry/CaptainOfIndustry/Class1.cs @@ -25,6 +25,7 @@ namespace CaptainOfIndustry { public static ConfigEntry worldMineSpeedMultiplier; public static ConfigEntry housingCapacityMultiplier; public static ConfigEntry dumpDelayMultiplier; + public static ConfigEntry transportSpeedMultiplier; public void Awake() { excavatorCapacityMultiplier = Config.Bind("General", "Excavator Capacity Multiplier", 1, new ConfigDescription("Excavator Capacity Multiplier")); @@ -40,6 +41,7 @@ namespace CaptainOfIndustry { worldMineSpeedMultiplier = Config.Bind("General", "World Mine Speed Multiplier", 1f, new ConfigDescription("World Mine Speed Multiplier")); housingCapacityMultiplier = Config.Bind("General", "Housing Capacity Multiplier", 1f, new ConfigDescription("Housing Capacity Multiplier")); dumpDelayMultiplier = Config.Bind("General", "Dump Delay Multiplier", 1f, new ConfigDescription("Dump Delay Multiplier")); + transportSpeedMultiplier = Config.Bind("General", "Transport Speed Multiplier", 1f, new ConfigDescription("Transport Speed Multiplier")); // shootingSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch(); // energyGenMultiplier.SettingChanged += (sender, args) => GeneratorPropertiesManager.DoPatch(); diff --git a/Projects/CaptainOfIndustry/CaptainOfIndustry/Patches.cs b/Projects/CaptainOfIndustry/CaptainOfIndustry/Patches.cs index 6a1325d..3271309 100644 --- a/Projects/CaptainOfIndustry/CaptainOfIndustry/Patches.cs +++ b/Projects/CaptainOfIndustry/CaptainOfIndustry/Patches.cs @@ -18,8 +18,10 @@ using Mafi.Core.Entities.Static.Layout; using Mafi.Core.Factory.Machines; using Mafi.Core.Factory.Transports; using Mafi.Core.Population; +using Mafi.Core.Ports.Io; using Mafi.Core.Products; using Mafi.Core.Prototypes; +using Mafi.Core.Terrain; using Mafi.Core.World.Entities; namespace CaptainOfIndustry { @@ -369,7 +371,6 @@ namespace CaptainOfIndustry { (int)(__instance.Capacity * Main.housingCapacityMultiplier.Value); } - // ublic StackerProto(StaticEntityProto.ID id, Proto.Str strings, EntityLayout layout, EntityCosts costs, Electricity consumedPowerPerTick, ThicknessTilesI minDumpOffset, RelTile3i dumpHeadRelPos, Duration dumpDelay, Duration dumpPeriod, StackerProto.Gfx graphics, ThicknessTilesI defaultDumpOffset, IEnumerable tags = null) [HarmonyPostfix] [HarmonyPatch(typeof(StackerProto), MethodType.Constructor, new[] { @@ -391,5 +392,57 @@ namespace CaptainOfIndustry { new Duration(Math.Max((int)(__instance.DumpDelay.Ticks * Main.dumpDelayMultiplier.Value), 1)); Traverse.Create(__instance).Field("DumpDelay").SetValue(newDelay); } + + + [HarmonyPrefix] + [HarmonyPatch(typeof(TransportProto), MethodType.Constructor, new[] { + typeof(StaticEntityProto.ID), + typeof(Proto.Str), + typeof(ThicknessTilesF), + typeof(Quantity), + typeof(RelTile1f), + typeof(RelTile1f), + typeof(RelTile1i), + typeof(bool), + typeof(bool), + typeof(Option), + typeof(RelTile1i), + typeof(IoPortShapeProto), + typeof(Electricity), + typeof(Percent), + typeof(bool), + typeof(bool), + typeof(EntityCosts), + typeof(RelTile1i), + typeof(Duration), + typeof(Option), + typeof(VirtualProductProto), + typeof(Quantity), + typeof(TransportProto.Gfx), + })] + static void transportSpeedMultiplier(ref StaticEntityProto.ID id, ref Proto.Str strings, + ref ThicknessTilesF surfaceRelativeHeight, ref Quantity maxQuantityPerTransportedProduct, + ref RelTile1f transportedProductsSpacing, ref RelTile1f speedPerTick, ref RelTile1i zStepLength, + ref bool needsPillarsAtGround, ref bool canBeBuried, + ref Option tileSurfaceWhenOnGround, ref RelTile1i maxPillarSupportRadius, + ref IoPortShapeProto portsShape, ref Electricity baseElectricityCost, ref Percent cornersSharpnessPercent, + ref bool allowMixedProducts, ref bool isBuildable, ref EntityCosts costs, ref RelTile1i lengthPerCost, + ref Duration constructionDurationPerProduct, ref Option nextTier, + ref VirtualProductProto maintenanceProduct, Quantity maintenancePerTile, ref TransportProto.Gfx graphics) { + if (TransportPillarProto.MAX_PILLAR_HEIGHT.Value < 25) + typeof(TransportPillarProto).GetField("MAX_PILLAR_HEIGHT").SetValue(null, new ThicknessTilesI(25)); + if (IoPort.MAX_TRANSFER_PER_TICK.Value < 10000) + typeof(IoPort).GetField("MAX_TRANSFER_PER_TICK").SetValue(null, new Quantity(10000)); + + maxQuantityPerTransportedProduct *= 1000; + maxQuantityPerTransportedProduct = maxQuantityPerTransportedProduct.Min(new Quantity(10000)); + Console.WriteLine("maxQuantityPerTransportedProduct {0}", maxQuantityPerTransportedProduct); + + speedPerTick *= 10; + transportedProductsSpacing = speedPerTick; + zStepLength = RelTile1i.One; + canBeBuried = true; + maxPillarSupportRadius = new RelTile1i(8); + } } }