Fix improperly loading prod multiplier
This commit is contained in:
@@ -179,30 +179,8 @@ namespace InfectionFreeZone {
|
||||
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}");
|
||||
}
|
||||
};
|
||||
productionProfitMultiplier.SettingChanged += delegate { UpdateProductionProfitMultiplierDict(); };
|
||||
UpdateProductionProfitMultiplierDict();
|
||||
|
||||
towerEchoSelectionDebug = Config.Bind("General", "Tower Echo Selection Debug", false);
|
||||
towerEchoSelection = Config.Bind("General", "Tower Echo Selection", false);
|
||||
@@ -218,6 +196,31 @@ namespace InfectionFreeZone {
|
||||
Logger.LogInfo("Patched " + method.Name);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateProductionProfitMultiplierDict() {
|
||||
Main.productionProfitMultiplierDict.Clear();
|
||||
var str = productionProfitMultiplier.Value;
|
||||
if (str == "")
|
||||
return;
|
||||
var split = str.Split(',');
|
||||
foreach (var s in split) {
|
||||
if (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 (productionProfitMultiplierDebug.Value)
|
||||
Console.WriteLine($"Added {resourceID} with multiplier {multiplier}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch]
|
||||
|
Reference in New Issue
Block a user