Code format and add storage multiplier
This commit is contained in:
@@ -19,6 +19,7 @@ namespace CaptainOfIndustry {
|
||||
public static ConfigEntry<int> cargoShipCapacityMultiplier;
|
||||
public static ConfigEntry<float> excavatorMiningAreaMultiplier;
|
||||
public static ConfigEntry<float> vehicleSpeedMultiplier;
|
||||
public static ConfigEntry<float> storageCapacityMultiplier;
|
||||
|
||||
public void Awake() {
|
||||
excavatorCapacityMultiplier = Config.Bind("General", "Excavator Capacity Multiplier", 1, new ConfigDescription("Excavator Capacity Multiplier"));
|
||||
@@ -26,6 +27,7 @@ namespace CaptainOfIndustry {
|
||||
cargoShipCapacityMultiplier = Config.Bind("General", "Cargo Ship Capacity Multiplier", 1, new ConfigDescription("Cargo Ship Capacity Multiplier"));
|
||||
excavatorMiningAreaMultiplier = Config.Bind("General", "Excavator Mining Area Multiplier", 1f, new ConfigDescription("Excavator Mining Area Multiplier"));
|
||||
vehicleSpeedMultiplier = Config.Bind("General", "Vehicle Speed Multiplier", 1f, new ConfigDescription("Vehicle Speed Multiplier"));
|
||||
storageCapacityMultiplier = Config.Bind("General", "Storage Capacity Multiplier", 1f, new ConfigDescription("Storage Capacity Multiplier"));
|
||||
|
||||
// shootingSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch();
|
||||
// energyGenMultiplier.SettingChanged += (sender, args) => GeneratorPropertiesManager.DoPatch();
|
||||
|
@@ -1,9 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using HarmonyLib;
|
||||
using Mafi;
|
||||
using Mafi.Core.Buildings.Cargo.Ships.Modules;
|
||||
using Mafi.Core.Buildings.Storages;
|
||||
using Mafi.Core.Entities.Dynamic;
|
||||
using Mafi.Core.Entities.Static;
|
||||
using Mafi.Core.Entities.Static.Layout;
|
||||
using Mafi.Core.Map;
|
||||
using Mafi.Core.Products;
|
||||
using Mafi.Core.Prototypes;
|
||||
@@ -29,6 +33,14 @@ namespace CaptainOfIndustry {
|
||||
Console.WriteLine("IndustrialCyka: New truck capacity: {0}", quantity);
|
||||
}
|
||||
|
||||
// [HarmonyPrefix]
|
||||
// [HarmonyPatch(typeof(StorageProtoBuilder.State), "SetCapacity")]
|
||||
// static void storageCapacityMultiplier(ref int capacity) {
|
||||
// Console.WriteLine("IndustrialCyka: Old storage capacity: {0}", capacity);
|
||||
// capacity = (int)(capacity * Main.storageCapacityMultiplier.Value);
|
||||
// Console.WriteLine("IndustrialCyka: New storage capacity: {0}", capacity);
|
||||
// }
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CargoShipModuleProto), MethodType.Constructor,
|
||||
new[] {
|
||||
@@ -74,13 +86,41 @@ namespace CaptainOfIndustry {
|
||||
Traverse maxBackwardsSpeedField = traverse.Field("m_maxBackwardsSpeed");
|
||||
Traverse maxAccelerationField = traverse.Field("m_maxAcceleration");
|
||||
|
||||
Console.WriteLine("IndustrialCyka: Old speeds: (F) {0}, (B) {1}, (A) {2}", maxForwardsSpeedField.GetValue(), maxBackwardsSpeedField.GetValue(), maxAccelerationField.GetValue());
|
||||
Console.WriteLine("IndustrialCyka: Old speeds: (F) {0}, (B) {1}, (A) {2}", maxForwardsSpeedField.GetValue(),
|
||||
maxBackwardsSpeedField.GetValue(), maxAccelerationField.GetValue());
|
||||
|
||||
maxForwardsSpeedField.SetValue((Fix32) maxForwardsSpeedField.GetValue() * speedMulti);
|
||||
maxBackwardsSpeedField.SetValue((Fix32) maxBackwardsSpeedField.GetValue() * speedMulti);
|
||||
maxAccelerationField.SetValue((Fix32) maxAccelerationField.GetValue() * speedMulti);
|
||||
maxForwardsSpeedField.SetValue((Fix32)maxForwardsSpeedField.GetValue() * speedMulti);
|
||||
maxBackwardsSpeedField.SetValue((Fix32)maxBackwardsSpeedField.GetValue() * speedMulti);
|
||||
maxAccelerationField.SetValue((Fix32)maxAccelerationField.GetValue() * speedMulti);
|
||||
|
||||
Console.WriteLine("IndustrialCyka: New speeds: (F) {0}, (B) {1}, (A) {2}", maxForwardsSpeedField.GetValue(), maxBackwardsSpeedField.GetValue(), maxAccelerationField.GetValue());
|
||||
Console.WriteLine("IndustrialCyka: New speeds: (F) {0}, (B) {1}, (A) {2}", maxForwardsSpeedField.GetValue(),
|
||||
maxBackwardsSpeedField.GetValue(), maxAccelerationField.GetValue());
|
||||
}
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(StorageBaseProto), MethodType.Constructor,
|
||||
new[] {
|
||||
typeof(StaticEntityProto.ID),
|
||||
typeof(Proto.Str),
|
||||
typeof(EntityLayout),
|
||||
typeof(Quantity),
|
||||
typeof(EntityCosts),
|
||||
typeof(LayoutEntityProto.Gfx),
|
||||
typeof(Quantity),
|
||||
typeof(Duration),
|
||||
typeof(IEnumerable<Tag>)
|
||||
})]
|
||||
static void storageCapacityMultiplier(StorageProto __instance) {
|
||||
Console.WriteLine("IndustrialCyka: Old storage capacity: {0}", __instance.Capacity.Value);
|
||||
Console.WriteLine("IndustrialCyka: Old storage transfer limit: {0}", __instance.TransferLimit.Value);
|
||||
Traverse traverse = Traverse.Create(__instance);
|
||||
|
||||
traverse.Field("Capacity").SetValue(new Quantity((int)(__instance.Capacity.Value * Main.storageCapacityMultiplier.Value)));
|
||||
traverse.Field("TransferLimit").SetValue(new Quantity(10000));
|
||||
traverse.Field("TransferLimitDuration").SetValue(Duration.FromTicks(1));
|
||||
|
||||
Console.WriteLine("IndustrialCyka: New storage capacity: {0}", __instance.Capacity.Value);
|
||||
Console.WriteLine("IndustrialCyka: New storage transfer limit: {0}", __instance.TransferLimit.Value);
|
||||
}
|
||||
|
||||
// Could not make this work either... idk why... Doesn't make sense...
|
||||
|
Reference in New Issue
Block a user