Factor silos needed warning to a new trait.

This commit is contained in:
Sean Hunt
2015-12-22 03:33:22 -05:00
parent 23dc6f64ac
commit 8f4ec87b63
9 changed files with 87 additions and 22 deletions

View File

@@ -2764,6 +2764,30 @@ namespace OpenRA.Mods.Common.UtilityCommands
}
}
// Refactored the low resources notification to a separate trait
if (engineVersion < 20151227 && node.Key == "Player")
{
var resourcesNode = node.Value.Nodes.FirstOrDefault(x => x.Key == "PlayerResources");
if (resourcesNode != null)
{
var intervalNode = resourcesNode.Value.Nodes.FirstOrDefault(x => x.Key == "AdviceInterval");
var storageNode = new MiniYamlNode("ResourceStorageWarning", "");
if (intervalNode != null)
{
// The time value is now in seconds, not ticks. We
// divide by 25 ticks per second at Normal.
int oldInterval;
if (int.TryParse(intervalNode.Value.Value, out oldInterval))
storageNode.Value.Nodes.Add(new MiniYamlNode("AdviceInterval", (oldInterval / 25).ToString()));
resourcesNode.Value.Nodes.Remove(intervalNode);
}
node.Value.Nodes.Add(storageNode);
}
}
UpgradeActorRules(engineVersion, ref node.Value.Nodes, node, depth + 1);
}
}