diff --git a/OpenRA.Game/Traits/Selectable.cs b/OpenRA.Game/Traits/Selectable.cs index f985deee49..6f88851916 100644 --- a/OpenRA.Game/Traits/Selectable.cs +++ b/OpenRA.Game/Traits/Selectable.cs @@ -53,9 +53,13 @@ namespace OpenRA.Traits foreach (var extraBar in self.TraitsImplementing()) { - DrawSelectionBar(self, xy, Xy, extraBar.GetValue(), extraBar.GetColor()); - xy.Y += 4; - Xy.Y += 4; + var value = extraBar.GetValue(); + if (value != 0) + { + xy.Y += 4; + Xy.Y += 4; + DrawSelectionBar(self, xy, Xy, extraBar.GetValue(), extraBar.GetColor()); + } } } diff --git a/OpenRA.Mods.RA/ProductionBar.cs b/OpenRA.Mods.RA/ProductionBar.cs index ab2b162d29..5bb279041f 100644 --- a/OpenRA.Mods.RA/ProductionBar.cs +++ b/OpenRA.Mods.RA/ProductionBar.cs @@ -9,16 +9,37 @@ #endregion using System.Drawing; +using System.Linq; using OpenRA.Traits; namespace OpenRA.Mods.RA { - class ProductionBarInfo : TraitInfo { } + class ProductionBarInfo : ITraitInfo + { + public object Create(ActorInitializer init) { return new ProductionBar( init.self ); } + } class ProductionBar : ISelectionBar { - public float GetValue() { return .5f; } + Actor self; + public ProductionBar(Actor self) { this.self = self; } - public Color GetColor() { return Color.CadetBlue; } + public float GetValue() + { + var queue = self.TraitOrDefault(); + if (queue == null) + { + var produces = self.Trait().Info.Produces; + queue = self.Owner.PlayerActor.TraitsImplementing() + .First(q => produces.Contains(q.Info.Type)); + } + + if (queue == null || queue.CurrentItem() == null) + return 0f; + + return 1 - (float)queue.CurrentItem().RemainingCost / queue.CurrentItem().TotalCost; + } + + public Color GetColor() { return Color.SkyBlue; } } } diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index 4448d26a59..8e459fb94b 100755 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -116,6 +116,7 @@ SPEN: -EmitInfantryOnSell: RepairsUnits: RallyPoint: + ProductionBar: SYRD: InfiltrateForSupportPower: @@ -171,6 +172,7 @@ SYRD: -EmitInfantryOnSell: RepairsUnits: RallyPoint: + ProductionBar: IRON: RequiresPower: @@ -573,6 +575,7 @@ WEAP: Produces: Vehicle PrimaryBuilding: IronCurtainable: + ProductionBar: FACT: Inherits: ^Building @@ -603,6 +606,8 @@ FACT: IntoActor: mcv Offset:1,1 Facing: 96 + ProductionBar: + PROC: Inherits: ^Building Buildable: @@ -705,6 +710,7 @@ HPAD: BelowUnits: Reservable: IronCurtainable: + ProductionBar: AFLD: Inherits: ^Building @@ -755,6 +761,8 @@ AFLD: Prerequisites: AFLD DropItems: E1,E1,E1,E3,E3 SelectTargetSound: slcttgt1.aud + ProductionBar: + POWR: Inherits: ^Building Buildable: @@ -875,6 +883,7 @@ BARR: Produces: Infantry PrimaryBuilding: IronCurtainable: + ProductionBar: TENT: Inherits: ^Building @@ -913,6 +922,7 @@ TENT: Produces: Infantry PrimaryBuilding: IronCurtainable: + ProductionBar: FIX: Inherits: ^Building