harvesters show colors for each resource type

This commit is contained in:
Chris Forbes
2010-12-05 12:10:52 +13:00
parent 94715a1561
commit 3f47715c36
5 changed files with 23 additions and 13 deletions

View File

@@ -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<PipType> 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<Renderable> ModifyRender(Actor self, IEnumerable<Renderable> r)