make ProductionBar actually work for all RA stuff
This commit is contained in:
@@ -53,9 +53,13 @@ namespace OpenRA.Traits
|
||||
|
||||
foreach (var extraBar in self.TraitsImplementing<ISelectionBar>())
|
||||
{
|
||||
DrawSelectionBar(self, xy, Xy, extraBar.GetValue(), extraBar.GetColor());
|
||||
var value = extraBar.GetValue();
|
||||
if (value != 0)
|
||||
{
|
||||
xy.Y += 4;
|
||||
Xy.Y += 4;
|
||||
DrawSelectionBar(self, xy, Xy, extraBar.GetValue(), extraBar.GetColor());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -9,16 +9,37 @@
|
||||
#endregion
|
||||
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using OpenRA.Traits;
|
||||
|
||||
namespace OpenRA.Mods.RA
|
||||
{
|
||||
class ProductionBarInfo : TraitInfo<ProductionBar> { }
|
||||
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<ProductionQueue>();
|
||||
if (queue == null)
|
||||
{
|
||||
var produces = self.Trait<Production>().Info.Produces;
|
||||
queue = self.Owner.PlayerActor.TraitsImplementing<ProductionQueue>()
|
||||
.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; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user