Add observer vision stats.

This commit is contained in:
Matthias Mailänder
2022-10-03 12:55:45 +02:00
committed by abcdefg30
parent e7dcbb3c2d
commit eb897d755e
7 changed files with 219 additions and 116 deletions

View File

@@ -341,6 +341,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var armyText = new CachedTransform<int, string>(i => "$" + i);
template.Get<LabelWidget>("ARMY_VALUE").GetText = () => armyText.Update(stats.ArmyValue);
var visionText = new CachedTransform<int, string>(i => Vision(i));
template.Get<LabelWidget>("VISION").GetText = () => player.Shroud.Disabled ? "100%" : visionText.Update(player.Shroud.RevealedCells);
return template;
}
@@ -569,6 +572,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic
return (world.WorldTick == 0 ? 0 : orders / (world.WorldTick / 1500.0)).ToString("F1");
}
string Vision(int revealedCells)
{
return Math.Ceiling(revealedCells / (float)world.Map.ProjectedCells.Length * 100).ToString("F0") + "%";
}
static Color GetPowerColor(PowerState state)
{
if (state == PowerState.Critical)