Add production multiplier
Actually a setpoint
This commit is contained in:
@@ -8,11 +8,13 @@ using Controllers;
|
|||||||
using Controllers.CharacterLogic;
|
using Controllers.CharacterLogic;
|
||||||
using Controllers.Time;
|
using Controllers.Time;
|
||||||
using Controllers.Weather;
|
using Controllers.Weather;
|
||||||
|
using Data.Resorces;
|
||||||
using GameCustomization;
|
using GameCustomization;
|
||||||
using Gameplay;
|
using Gameplay;
|
||||||
using Gameplay.Buildings;
|
using Gameplay.Buildings;
|
||||||
using Gameplay.GameResources;
|
using Gameplay.GameResources;
|
||||||
using Gameplay.InGameResources;
|
using Gameplay.InGameResources;
|
||||||
|
using Gameplay.Production;
|
||||||
using Gameplay.Rebuilding;
|
using Gameplay.Rebuilding;
|
||||||
using Gameplay.Rebuilding.Walls;
|
using Gameplay.Rebuilding.Walls;
|
||||||
using Gameplay.Scavenge;
|
using Gameplay.Scavenge;
|
||||||
@@ -96,6 +98,10 @@ namespace InfectionFreeZone {
|
|||||||
public static ConfigEntry<float> rotationTimestepMultiplier;
|
public static ConfigEntry<float> rotationTimestepMultiplier;
|
||||||
public static ConfigEntry<float> sunsetHourOffset;
|
public static ConfigEntry<float> sunsetHourOffset;
|
||||||
|
|
||||||
|
public static ConfigEntry<bool> productionProfitMultiplierDebug;
|
||||||
|
public static ConfigEntry<string> productionProfitMultiplier;
|
||||||
|
public static Dictionary<ResourceID, float> productionProfitMultiplierDict;
|
||||||
|
|
||||||
public void Awake() {
|
public void Awake() {
|
||||||
resourceMultiplierDebug = Config.Bind("General", "Resource Multiplier Debug", false);
|
resourceMultiplierDebug = Config.Bind("General", "Resource Multiplier Debug", false);
|
||||||
resourceMultiplier = Config.Bind("General", "Resource Multiplier", 1f);
|
resourceMultiplier = Config.Bind("General", "Resource Multiplier", 1f);
|
||||||
@@ -159,6 +165,35 @@ namespace InfectionFreeZone {
|
|||||||
rotationTimestepMultiplier = Config.Bind("General", "Rotation Timestep Multiplier", 1f);
|
rotationTimestepMultiplier = Config.Bind("General", "Rotation Timestep Multiplier", 1f);
|
||||||
sunsetHourOffset = Config.Bind("General", "Sunset Hour Offset", 0f);
|
sunsetHourOffset = Config.Bind("General", "Sunset Hour Offset", 0f);
|
||||||
|
|
||||||
|
productionProfitMultiplierDebug = Config.Bind("General", "Production Profit Multiplier Debug", false);
|
||||||
|
productionProfitMultiplier =
|
||||||
|
Config.Bind("General", "Production Profit Multiplier (Resource ID: multiplier)", "");
|
||||||
|
productionProfitMultiplierDict = new Dictionary<ResourceID, float>();
|
||||||
|
productionProfitMultiplier.SettingChanged += delegate(object sender, EventArgs e) {
|
||||||
|
productionProfitMultiplierDict.Clear();
|
||||||
|
var str = productionProfitMultiplier.Value;
|
||||||
|
if (str == "")
|
||||||
|
return;
|
||||||
|
var split = str.Split(',');
|
||||||
|
foreach (var s in split) {
|
||||||
|
if (Main.productionProfitMultiplierDebug.Value)
|
||||||
|
Console.WriteLine($"Parsing {s}");
|
||||||
|
var split2 = s.Split(':');
|
||||||
|
if (split2.Length != 2)
|
||||||
|
continue;
|
||||||
|
var success = Enum.TryParse<ResourceID>(split2[0], out var resourceID);
|
||||||
|
if (!success) {
|
||||||
|
Console.WriteLine($"Failed to parse {split2[0]} as a resource ID");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
var multiplier = float.Parse(split2[1]);
|
||||||
|
productionProfitMultiplierDict.Add(resourceID, multiplier);
|
||||||
|
if (Main.productionProfitMultiplierDebug.Value)
|
||||||
|
Console.WriteLine($"Added {resourceID} with multiplier {multiplier}");
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
Logger.LogInfo("Cyka mod loaded");
|
Logger.LogInfo("Cyka mod loaded");
|
||||||
HarmonyFileLog.Enabled = true;
|
HarmonyFileLog.Enabled = true;
|
||||||
Harmony harmony = new Harmony(pluginGuid);
|
Harmony harmony = new Harmony(pluginGuid);
|
||||||
@@ -508,5 +543,29 @@ namespace InfectionFreeZone {
|
|||||||
|
|
||||||
__result += Main.sunsetHourOffset.Value;
|
__result += Main.sunsetHourOffset.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ProductionWork), "ProduceResources")]
|
||||||
|
public static void PrefixProduceResources(List<ProductionDataPart> productionDataParts) {
|
||||||
|
if (Main.productionProfitMultiplierDict.Count == 0)
|
||||||
|
return;
|
||||||
|
if (productionDataParts.Count == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
for (var i = 0; i < productionDataParts.Count; i++) {
|
||||||
|
var productionDataPart = productionDataParts[i];
|
||||||
|
if (Main.productionProfitMultiplierDebug.Value)
|
||||||
|
Console.WriteLine(
|
||||||
|
$"Production data part is {productionDataPart.type} x {productionDataPart.amount}");
|
||||||
|
if (Main.productionProfitMultiplierDict.TryGetValue(productionDataPart.type, out var setpoint)) {
|
||||||
|
if (Main.productionProfitMultiplierDebug.Value)
|
||||||
|
Console.WriteLine($"Production data part has setpoint {setpoint}");
|
||||||
|
productionDataPart.amount = (int)setpoint;
|
||||||
|
if (Main.productionProfitMultiplierDebug.Value)
|
||||||
|
Console.WriteLine(
|
||||||
|
$"Production data part modified to {productionDataPart.type} x {productionDataPart.amount}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user