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>())
|
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;
|
||||||
Xy.Y += 4;
|
Xy.Y += 4;
|
||||||
|
DrawSelectionBar(self, xy, Xy, extraBar.GetValue(), extraBar.GetColor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,16 +9,37 @@
|
|||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using System.Linq;
|
||||||
using OpenRA.Traits;
|
using OpenRA.Traits;
|
||||||
|
|
||||||
namespace OpenRA.Mods.RA
|
namespace OpenRA.Mods.RA
|
||||||
{
|
{
|
||||||
class ProductionBarInfo : TraitInfo<ProductionBar> { }
|
class ProductionBarInfo : ITraitInfo
|
||||||
|
{
|
||||||
|
public object Create(ActorInitializer init) { return new ProductionBar( init.self ); }
|
||||||
|
}
|
||||||
|
|
||||||
class ProductionBar : ISelectionBar
|
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:
|
-EmitInfantryOnSell:
|
||||||
RepairsUnits:
|
RepairsUnits:
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ProductionBar:
|
||||||
|
|
||||||
SYRD:
|
SYRD:
|
||||||
InfiltrateForSupportPower:
|
InfiltrateForSupportPower:
|
||||||
@@ -171,6 +172,7 @@ SYRD:
|
|||||||
-EmitInfantryOnSell:
|
-EmitInfantryOnSell:
|
||||||
RepairsUnits:
|
RepairsUnits:
|
||||||
RallyPoint:
|
RallyPoint:
|
||||||
|
ProductionBar:
|
||||||
|
|
||||||
IRON:
|
IRON:
|
||||||
RequiresPower:
|
RequiresPower:
|
||||||
@@ -573,6 +575,7 @@ WEAP:
|
|||||||
Produces: Vehicle
|
Produces: Vehicle
|
||||||
PrimaryBuilding:
|
PrimaryBuilding:
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
|
ProductionBar:
|
||||||
|
|
||||||
FACT:
|
FACT:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
@@ -603,6 +606,8 @@ FACT:
|
|||||||
IntoActor: mcv
|
IntoActor: mcv
|
||||||
Offset:1,1
|
Offset:1,1
|
||||||
Facing: 96
|
Facing: 96
|
||||||
|
ProductionBar:
|
||||||
|
|
||||||
PROC:
|
PROC:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
Buildable:
|
Buildable:
|
||||||
@@ -705,6 +710,7 @@ HPAD:
|
|||||||
BelowUnits:
|
BelowUnits:
|
||||||
Reservable:
|
Reservable:
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
|
ProductionBar:
|
||||||
|
|
||||||
AFLD:
|
AFLD:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
@@ -755,6 +761,8 @@ AFLD:
|
|||||||
Prerequisites: AFLD
|
Prerequisites: AFLD
|
||||||
DropItems: E1,E1,E1,E3,E3
|
DropItems: E1,E1,E1,E3,E3
|
||||||
SelectTargetSound: slcttgt1.aud
|
SelectTargetSound: slcttgt1.aud
|
||||||
|
ProductionBar:
|
||||||
|
|
||||||
POWR:
|
POWR:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
Buildable:
|
Buildable:
|
||||||
@@ -875,6 +883,7 @@ BARR:
|
|||||||
Produces: Infantry
|
Produces: Infantry
|
||||||
PrimaryBuilding:
|
PrimaryBuilding:
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
|
ProductionBar:
|
||||||
|
|
||||||
TENT:
|
TENT:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
@@ -913,6 +922,7 @@ TENT:
|
|||||||
Produces: Infantry
|
Produces: Infantry
|
||||||
PrimaryBuilding:
|
PrimaryBuilding:
|
||||||
IronCurtainable:
|
IronCurtainable:
|
||||||
|
ProductionBar:
|
||||||
|
|
||||||
FIX:
|
FIX:
|
||||||
Inherits: ^Building
|
Inherits: ^Building
|
||||||
|
|||||||
Reference in New Issue
Block a user