Migrate Captures.SabotageHPRemoval and Capturable.CaptureThreshold to int percentages

This commit is contained in:
reaperrr
2016-03-24 14:25:00 +01:00
parent 82f23210d9
commit 4894211789
13 changed files with 44 additions and 16 deletions

View File

@@ -736,6 +736,34 @@ namespace OpenRA.Mods.Common.UtilityCommands
}
}
// Migrated Captures and Capturable to use int percentage instead of float
if (engineVersion < 20160325)
{
if (node.Key == "Captures")
{
var sabotageHPRemNode = node.Value.Nodes.FirstOrDefault(x => x.Key == "SabotageHPRemoval");
if (sabotageHPRemNode != null)
{
// The SabotageHPRemoval value is now an int percentage, so multiply the float with 100.
var oldValue = FieldLoader.GetValue<float>("SabotageHPRemoval", sabotageHPRemNode.Value.Value);
var newValue = (int)(oldValue * 100);
sabotageHPRemNode.Value.Value = newValue.ToString();
}
}
if (node.Key == "Capturable")
{
var captThreshNode = node.Value.Nodes.FirstOrDefault(x => x.Key == "CaptureThreshold");
if (captThreshNode != null)
{
// The CaptureThreshold value is now an int percentage, so multiply the float with 100.
var oldValue = FieldLoader.GetValue<float>("CaptureThreshold", captThreshNode.Value.Value);
var newValue = (int)(oldValue * 100);
captThreshNode.Value.Value = newValue.ToString();
}
}
}
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
}
}