#95 LimitedAmmo pip count should be configurable

This commit is contained in:
Chris Forbes
2010-02-22 20:56:26 +13:00
parent bc9b623e0b
commit c2ac8ad096

View File

@@ -25,6 +25,7 @@ namespace OpenRa.Traits
class LimitedAmmoInfo : ITraitInfo class LimitedAmmoInfo : ITraitInfo
{ {
public readonly int Ammo = 0; public readonly int Ammo = 0;
public readonly int PipCount = 0;
public object Create(Actor self) { return new LimitedAmmo(self); } public object Create(Actor self) { return new LimitedAmmo(self); }
} }
@@ -53,9 +54,10 @@ namespace OpenRa.Traits
public IEnumerable<PipType> GetPips(Actor self) public IEnumerable<PipType> GetPips(Actor self)
{ {
var maxAmmo = self.Info.Traits.Get<LimitedAmmoInfo>().Ammo; var info = self.Info.Traits.Get<LimitedAmmoInfo>();
return Graphics.Util.MakeArray(maxAmmo, var pips = info.PipCount != 0 ? info.PipCount : info.Ammo;
i => ammo > i ? PipType.Green : PipType.Transparent); return Graphics.Util.MakeArray(pips,
i => (ammo * pips) / info.Ammo > i ? PipType.Green : PipType.Transparent);
} }
} }
} }