BuildPalette tooltips show build time (+ in red if in low power)

This commit is contained in:
alzeih
2010-06-14 00:18:36 +12:00
parent fbeadb9869
commit 3ac0ca6a65
4 changed files with 32 additions and 16 deletions

View File

@@ -65,10 +65,7 @@ namespace OpenRA.Traits
{
var unit = Rules.Info[order.TargetString];
var ui = unit.Traits.Get<BuildableInfo>();
var time = ui.Cost
* self.Owner.PlayerActor.Info.Traits.Get<ProductionQueueInfo>().BuildSpeed /* todo: country-specific build speed bonus */
* (25 * 60) /* frames per min */ /* todo: build acceleration, if we do that */
/ 1000;
var time = GetBuildTime(self, order.TargetString);
if (!Rules.TechTree.BuildableItems(order.Player, unit.Category).Contains(order.TargetString))
return; /* you can't build that!! */
@@ -107,6 +104,20 @@ namespace OpenRA.Traits
}
}
}
public static int GetBuildTime(Actor self, String unitString)
{
var unit = Rules.Info[unitString];
if (unit == null || ! unit.Traits.Contains<BuildableInfo>())
return 0;
var ui = unit.Traits.Get<BuildableInfo>();
var time = ui.Cost
* self.Owner.PlayerActor.Info.Traits.Get<ProductionQueueInfo>().BuildSpeed /* todo: country-specific build speed bonus */
* (25 * 60) /* frames per min */ /* todo: build acceleration, if we do that */
/ 1000;
return (int) time;
}
// Key: Production category.
// TODO: sync this