Removes map control from player statistics for performance reasons

This commit is contained in:
reaperrr
2015-04-03 18:25:26 +02:00
parent a8bf90f8b2
commit e25247f259
4 changed files with 25 additions and 65 deletions

View File

@@ -25,7 +25,6 @@ namespace OpenRA.Mods.Common.Traits
World world; World world;
Player player; Player player;
public double MapControl;
public int OrderCount; public int OrderCount;
public int EarnedThisMinute public int EarnedThisMinute
@@ -54,18 +53,6 @@ namespace OpenRA.Mods.Common.Traits
player = self.Owner; player = self.Owner;
} }
void UpdateMapControl()
{
var total = (double)world.Map.Bounds.Width * world.Map.Bounds.Height;
MapControl = world.Actors
.Where(a => !a.IsDead && a.IsInWorld && a.Owner == player && a.HasTrait<RevealsShroud>())
.SelectMany(a => world.Map.FindTilesInCircle(
a.Location,
a.Trait<RevealsShroud>().Range.Clamp(WRange.Zero, WRange.FromCells(Map.MaxTilesInCircleRange)).Range / 1024))
.Distinct()
.Count() / total;
}
void UpdateEarnedThisMinute() void UpdateEarnedThisMinute()
{ {
EarnedSamples.Enqueue(EarnedThisMinute); EarnedSamples.Enqueue(EarnedThisMinute);
@@ -76,10 +63,8 @@ namespace OpenRA.Mods.Common.Traits
public void Tick(Actor self) public void Tick(Actor self)
{ {
if (self.World.WorldTick % 1500 == 1) if (world.WorldTick % 1500 == 1)
UpdateEarnedThisMinute(); UpdateEarnedThisMinute();
if (self.World.WorldTick % 250 == 0)
UpdateMapControl();
} }
public void ResolveOrder(Actor self, Order order) public void ResolveOrder(Actor self, Order order)

View File

@@ -199,7 +199,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
var stats = player.PlayerActor.TraitOrDefault<PlayerStatistics>(); var stats = player.PlayerActor.TraitOrDefault<PlayerStatistics>();
if (stats == null) return template; if (stats == null) return template;
template.Get<LabelWidget>("CONTROL").GetText = () => MapControl(stats.MapControl);
template.Get<LabelWidget>("KILLS_COST").GetText = () => "$" + stats.KillsCost; template.Get<LabelWidget>("KILLS_COST").GetText = () => "$" + stats.KillsCost;
template.Get<LabelWidget>("DEATHS_COST").GetText = () => "$" + stats.DeathsCost; template.Get<LabelWidget>("DEATHS_COST").GetText = () => "$" + stats.DeathsCost;
template.Get<LabelWidget>("UNITS_KILLED").GetText = () => stats.UnitsKilled.ToString(); template.Get<LabelWidget>("UNITS_KILLED").GetText = () => stats.UnitsKilled.ToString();

View File

@@ -193,29 +193,22 @@ Background@INGAME_OBSERVERSTATS_BG:
Height: 25 Height: 25
Font: Bold Font: Bold
Text: Player Text: Player
Label@CONTROL_HEADER:
X: 235
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Control
Label@KILLS_COST_HEADER: Label@KILLS_COST_HEADER:
X: 315 X: 235
Y: 40 Y: 40
Width: 60 Width: 60
Height: 25 Height: 25
Font: Bold Font: Bold
Text: Kills Text: Kills
Label@DEATHS_COST_HEADER: Label@DEATHS_COST_HEADER:
X: 395 X: 315
Y: 40 Y: 40
Width: 60 Width: 60
Height: 25 Height: 25
Font: Bold Font: Bold
Text: Deaths Text: Deaths
Label@UNITS_KILLED_HEADER: Label@UNITS_KILLED_HEADER:
X: 495 X: 415
Y: 40 Y: 40
Width: 40 Width: 40
Height: 25 Height: 25
@@ -223,7 +216,7 @@ Background@INGAME_OBSERVERSTATS_BG:
Text: Units Killed Text: Units Killed
Align: Right Align: Right
Label@UNITS_DEAD_HEADER: Label@UNITS_DEAD_HEADER:
X: 595 X: 515
Y: 40 Y: 40
Width: 40 Width: 40
Height: 25 Height: 25
@@ -231,7 +224,7 @@ Background@INGAME_OBSERVERSTATS_BG:
Text: Units Lost Text: Units Lost
Align: Right Align: Right
Label@BUILDINGS_KILLED_HEADER: Label@BUILDINGS_KILLED_HEADER:
X: 715 X: 635
Y: 40 Y: 40
Width: 40 Width: 40
Height: 25 Height: 25
@@ -239,7 +232,7 @@ Background@INGAME_OBSERVERSTATS_BG:
Text: Bldg Killed Text: Bldg Killed
Align: Right Align: Right
Label@BUILDINGS_DEAD_HEADER: Label@BUILDINGS_DEAD_HEADER:
X: 815 X: 735
Y: 40 Y: 40
Width: 40 Width: 40
Height: 25 Height: 25
@@ -440,41 +433,36 @@ Background@INGAME_OBSERVERSTATS_BG:
Width: 160 Width: 160
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Font: Bold Font: Bold
Label@CONTROL: Label@KILLS_COST:
X: 215 X: 215
Y: 0 Y: 0
Width: 60 Width: 60
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Label@KILLS_COST: Label@DEATHS_COST:
X: 295 X: 295
Y: 0 Y: 0
Width: 60 Width: 60
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Label@DEATHS_COST:
X: 375
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@UNITS_KILLED: Label@UNITS_KILLED:
X: 475 X: 395
Y: 0 Y: 0
Width: 40 Width: 40
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Align: Right Align: Right
Label@UNITS_DEAD: Label@UNITS_DEAD:
X: 575 X: 495
Y: 0 Y: 0
Width: 40 Width: 40
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Align: Right Align: Right
Label@BUILDINGS_KILLED: Label@BUILDINGS_KILLED:
X: 695 X: 615
Y: 0 Y: 0
Width: 40 Width: 40
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Align: Right Align: Right
Label@BUILDINGS_DEAD: Label@BUILDINGS_DEAD:
X: 795 X: 715
Y: 0 Y: 0
Width: 40 Width: 40
Height: PARENT_BOTTOM Height: PARENT_BOTTOM

View File

@@ -193,29 +193,22 @@ Background@INGAME_OBSERVERSTATS_BG:
Height: 25 Height: 25
Font: Bold Font: Bold
Text: Player Text: Player
Label@CONTROL_HEADER:
X: 245
Y: 40
Width: 60
Height: 25
Font: Bold
Text: Control
Label@KILLS_COST_HEADER: Label@KILLS_COST_HEADER:
X: 325 X: 245
Y: 40 Y: 40
Width: 60 Width: 60
Height: 25 Height: 25
Font: Bold Font: Bold
Text: Kills Text: Kills
Label@DEATHS_COST_HEADER: Label@DEATHS_COST_HEADER:
X: 405 X: 325
Y: 40 Y: 40
Width: 60 Width: 60
Height: 25 Height: 25
Font: Bold Font: Bold
Text: Deaths Text: Deaths
Label@UNITS_KILLED_HEADER: Label@UNITS_KILLED_HEADER:
X: 505 X: 425
Y: 40 Y: 40
Width: 40 Width: 40
Height: 25 Height: 25
@@ -223,7 +216,7 @@ Background@INGAME_OBSERVERSTATS_BG:
Text: Units Killed Text: Units Killed
Align: Right Align: Right
Label@UNITS_DEAD_HEADER: Label@UNITS_DEAD_HEADER:
X: 605 X: 525
Y: 40 Y: 40
Width: 40 Width: 40
Height: 25 Height: 25
@@ -231,7 +224,7 @@ Background@INGAME_OBSERVERSTATS_BG:
Text: Units Lost Text: Units Lost
Align: Right Align: Right
Label@BUILDINGS_KILLED_HEADER: Label@BUILDINGS_KILLED_HEADER:
X: 725 X: 645
Y: 40 Y: 40
Width: 40 Width: 40
Height: 25 Height: 25
@@ -239,7 +232,7 @@ Background@INGAME_OBSERVERSTATS_BG:
Text: Bldg Killed Text: Bldg Killed
Align: Right Align: Right
Label@BUILDINGS_DEAD_HEADER: Label@BUILDINGS_DEAD_HEADER:
X: 825 X: 745
Y: 40 Y: 40
Width: 40 Width: 40
Height: 25 Height: 25
@@ -440,41 +433,36 @@ Background@INGAME_OBSERVERSTATS_BG:
Width: 160 Width: 160
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Font: Bold Font: Bold
Label@CONTROL: Label@KILLS_COST:
X: 215 X: 215
Y: 0 Y: 0
Width: 60 Width: 60
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Label@KILLS_COST: Label@DEATHS_COST:
X: 295 X: 295
Y: 0 Y: 0
Width: 60 Width: 60
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Label@DEATHS_COST:
X: 375
Y: 0
Width: 60
Height: PARENT_BOTTOM
Label@UNITS_KILLED: Label@UNITS_KILLED:
X: 475 X: 395
Y: 0 Y: 0
Width: 40 Width: 40
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Align: Right Align: Right
Label@UNITS_DEAD: Label@UNITS_DEAD:
X: 575 X: 495
Y: 0 Y: 0
Width: 40 Width: 40
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Align: Right Align: Right
Label@BUILDINGS_KILLED: Label@BUILDINGS_KILLED:
X: 695 X: 615
Y: 0 Y: 0
Width: 40 Width: 40
Height: PARENT_BOTTOM Height: PARENT_BOTTOM
Align: Right Align: Right
Label@BUILDINGS_DEAD: Label@BUILDINGS_DEAD:
X: 795 X: 715
Y: 0 Y: 0
Width: 40 Width: 40
Height: PARENT_BOTTOM Height: PARENT_BOTTOM