diff --git a/OpenRA.Game/Traits/World/ResourceType.cs b/OpenRA.Game/Traits/World/ResourceType.cs index 8b9680bd74..fde8923301 100644 --- a/OpenRA.Game/Traits/World/ResourceType.cs +++ b/OpenRA.Game/Traits/World/ResourceType.cs @@ -24,6 +24,8 @@ namespace OpenRA.Traits public Sprite[][] Sprites; public int PaletteIndex; + + public PipType PipColor = PipType.Yellow; public object Create(ActorInitializer init) { return new ResourceType(this); } } diff --git a/OpenRA.Mods.RA/Harvester.cs b/OpenRA.Mods.RA/Harvester.cs index ae2aef910a..b582143e56 100644 --- a/OpenRA.Mods.RA/Harvester.cs +++ b/OpenRA.Mods.RA/Harvester.cs @@ -11,7 +11,6 @@ using System.Collections.Generic; using System.Drawing; using System.Linq; -using OpenRA.Effects; using OpenRA.Mods.RA.Activities; using OpenRA.Mods.RA.Move; using OpenRA.Mods.RA.Orders; @@ -23,7 +22,6 @@ namespace OpenRA.Mods.RA { public readonly int Capacity = 28; public readonly int PipCount = 7; - public readonly PipType PipColor = PipType.Yellow; public readonly string[] Resources = { }; public readonly decimal FullyLoadedSpeed = .85m; @@ -168,20 +166,27 @@ namespace OpenRA.Mods.RA return; ChooseNewProc(self, proc); + } + + PipType GetPipAt(int i) + { + var n = i * Info.Capacity / Info.PipCount; + + foreach (var rt in contents) + if (n < rt.Value) + return rt.Key.PipColor; + else + n -= rt.Value; + + return PipType.Transparent; } public IEnumerable GetPips(Actor self) { - int numPips = Info.PipCount; - int n = contents.Values.Sum(); - - for (int i = 0; i < numPips; i++) - { - if (n * 1.0f / Info.Capacity > i * 1.0f / numPips) - yield return Info.PipColor; - else - yield return PipType.Transparent; - } + int numPips = Info.PipCount; + + for (int i = 0; i < numPips; i++) + yield return GetPipAt(i); } public IEnumerable ModifyRender(Actor self, IEnumerable r) diff --git a/mods/cnc/rules/system.yaml b/mods/cnc/rules/system.yaml index c3fa8473c1..66ad732eac 100644 --- a/mods/cnc/rules/system.yaml +++ b/mods/cnc/rules/system.yaml @@ -137,6 +137,7 @@ World: SpriteNames: ti1,ti2,ti3,ti4,ti5,ti6,ti7,ti8,ti9,ti10,ti11,ti12 ValuePerUnit: 30 Name: Tiberium + PipColor: Green ResourceType@blue-tib: ResourceType: 2 Palette: terrain @@ -144,6 +145,7 @@ World: SpriteNames: bti1,bti2,bti3,bti4,bti5,bti6,bti7,bti8,bti9,bti10,bti11,bti12 ValuePerUnit: 60 Name: Blue Tiberium + PipColor: Red # todo: add a blue pip. SmudgeLayer@SCORCH: Type:Scorch Types:sc1,sc2,sc3,sc4,sc5,sc6 diff --git a/mods/cnc/rules/vehicles.yaml b/mods/cnc/rules/vehicles.yaml index b19e234ac9..b5eb383a65 100644 --- a/mods/cnc/rules/vehicles.yaml +++ b/mods/cnc/rules/vehicles.yaml @@ -49,7 +49,6 @@ HARV: Harvester: Resources: Tiberium, Blue Tiberium PipCount: 5 - PipColor: Green Capacity: 28 Mobile: Speed: 6 diff --git a/mods/ra/rules/system.yaml b/mods/ra/rules/system.yaml index b66cccdd42..63b68345bb 100644 --- a/mods/ra/rules/system.yaml +++ b/mods/ra/rules/system.yaml @@ -201,12 +201,14 @@ World: SpriteNames: gold01,gold02,gold03,gold04 ValuePerUnit: 25 Name: Ore + PipColor: Yellow ResourceType@gem: ResourceType: 2 Palette: terrain SpriteNames: gem01,gem02,gem03,gem04 ValuePerUnit: 50 Name: Gems + PipColor: Red SmudgeLayer@SCORCH: Type:Scorch Types:sc1,sc2,sc3,sc4,sc5,sc6