Implement custom autosave
Because the built in one goes only as low as 10 min I want 10 second
This commit is contained in:
@@ -28,7 +28,7 @@ namespace CykaOfIndustry {
|
|||||||
public static ConfigEntry<float> dumpDelayMultiplier;
|
public static ConfigEntry<float> dumpDelayMultiplier;
|
||||||
public static ConfigEntry<float> transportSpeedMultiplier;
|
public static ConfigEntry<float> transportSpeedMultiplier;
|
||||||
public static ConfigEntry<float> shipyardCargoMultiplier;
|
public static ConfigEntry<float> shipyardCargoMultiplier;
|
||||||
|
public static ConfigEntry<int> autosaveInterval;
|
||||||
public static ConfigEntry<bool> debugMode;
|
public static ConfigEntry<bool> debugMode;
|
||||||
|
|
||||||
public void Awake() {
|
public void Awake() {
|
||||||
@@ -65,7 +65,8 @@ namespace CykaOfIndustry {
|
|||||||
new ConfigDescription("Transport Speed Multiplier"));
|
new ConfigDescription("Transport Speed Multiplier"));
|
||||||
shipyardCargoMultiplier = Config.Bind("General", "Shipyard Cargo Multiplier", 1f,
|
shipyardCargoMultiplier = Config.Bind("General", "Shipyard Cargo Multiplier", 1f,
|
||||||
new ConfigDescription("Shipyard Cargo Multiplier"));
|
new ConfigDescription("Shipyard Cargo Multiplier"));
|
||||||
|
autosaveInterval = Config.Bind("General", "Autosave Interval", 1,
|
||||||
|
new ConfigDescription("Autosave Interval in minutes"));
|
||||||
debugMode = Config.Bind("General", "Debug Mode", false, new ConfigDescription("Debug Mode"));
|
debugMode = Config.Bind("General", "Debug Mode", false, new ConfigDescription("Debug Mode"));
|
||||||
|
|
||||||
// shootingSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch();
|
// shootingSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch();
|
||||||
|
@@ -21,6 +21,7 @@ using Mafi.Core.Population;
|
|||||||
using Mafi.Core.Ports.Io;
|
using Mafi.Core.Ports.Io;
|
||||||
using Mafi.Core.Products;
|
using Mafi.Core.Products;
|
||||||
using Mafi.Core.Prototypes;
|
using Mafi.Core.Prototypes;
|
||||||
|
using Mafi.Core.SaveGame;
|
||||||
using Mafi.Core.Terrain;
|
using Mafi.Core.Terrain;
|
||||||
using Mafi.Core.Vehicles.Excavators;
|
using Mafi.Core.Vehicles.Excavators;
|
||||||
using Mafi.Core.World.Entities;
|
using Mafi.Core.World.Entities;
|
||||||
@@ -504,6 +505,21 @@ namespace CykaOfIndustry {
|
|||||||
Traverse.Create(__instance).Field("CargoCapacity").SetValue(new Quantity(
|
Traverse.Create(__instance).Field("CargoCapacity").SetValue(new Quantity(
|
||||||
(int)(__instance.CargoCapacity.Value * Main.shipyardCargoMultiplier.Value)));
|
(int)(__instance.CargoCapacity.Value * Main.shipyardCargoMultiplier.Value)));
|
||||||
}
|
}
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(SaveManager), "isTimeForAutoSave")]
|
||||||
|
static void autosaveInterval(ref bool __result, SaveManager __instance) {
|
||||||
|
if (Main.autosaveInterval.Value <= 0) {
|
||||||
|
__result = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var trav = Traverse.Create(__instance);
|
||||||
|
var lastSaveTime = trav.Field("m_lastSaveTime").GetValue<long>();
|
||||||
|
var num = (Environment.TickCount - lastSaveTime).Abs() / 1000L;
|
||||||
|
if (Main.debugMode.Value)
|
||||||
|
Console.WriteLine("IndustrialCyka: Autosave interval: {0}", num);
|
||||||
|
__result = num > Main.autosaveInterval.Value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(typeof(Excavator), "MineMixedAt")]
|
[HarmonyPatch(typeof(Excavator), "MineMixedAt")]
|
||||||
|
Reference in New Issue
Block a user