diff --git a/OpenRA.Mods.RA/Player/PlayerStatistics.cs b/OpenRA.Mods.RA/Player/PlayerStatistics.cs index 6309c7e8ee..1d9d43fc20 100644 --- a/OpenRA.Mods.RA/Player/PlayerStatistics.cs +++ b/OpenRA.Mods.RA/Player/PlayerStatistics.cs @@ -9,6 +9,7 @@ #endregion using System.Linq; +using OpenRA.Mods.RA.Buildings; using OpenRA.Traits; namespace OpenRA.Mods.RA @@ -22,6 +23,14 @@ namespace OpenRA.Mods.RA { World world; Player player; + public double MapControl; + public int OrderCount; + public int KillsCost; + public int DeathsCost; + public int UnitsKilled; + public int UnitsDead; + public int BuildingsKilled; + public int BuildingsDead; public PlayerStatistics(Actor self) { @@ -29,8 +38,6 @@ namespace OpenRA.Mods.RA player = self.Owner; } - public double MapControl; - void UpdateMapControl() { var total = (double)world.Map.Bounds.Width * world.Map.Bounds.Height; @@ -49,8 +56,6 @@ namespace OpenRA.Mods.RA } } - public int OrderCount; - public void ResolveOrder(Actor self, Order order) { switch (order.OrderString) @@ -73,4 +78,31 @@ namespace OpenRA.Mods.RA OrderCount++; } } + + public class UpdatesPlayerStatisticsInfo : TraitInfo { } + + public class UpdatesPlayerStatistics : INotifyKilled + { + public void Killed(Actor self, AttackInfo e) + { + var attackerStats = e.Attacker.Owner.PlayerActor.Trait(); + var defenderStats = self.Owner.PlayerActor.Trait(); + if (self.HasTrait()) + { + attackerStats.BuildingsKilled++; + defenderStats.BuildingsDead++; + } + if (self.HasTrait()) + { + attackerStats.UnitsKilled++; + defenderStats.UnitsDead++; + } + if (self.HasTrait()) + { + var cost = self.Info.Traits.Get().Cost; + attackerStats.KillsCost += cost; + defenderStats.DeathsCost += cost; + } + } + } } diff --git a/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs b/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs index a9cc43eb23..3f8597d8bd 100644 --- a/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs +++ b/OpenRA.Mods.RA/Widgets/Logic/ObserverStatsLogic.cs @@ -159,6 +159,12 @@ namespace OpenRA.Mods.RA.Widgets.Logic var stats = player.PlayerActor.Trait(); template.Get("CONTROL").GetText = () => MapControl(stats.MapControl); + template.Get("KILLS_COST").GetText = () => "$" + stats.KillsCost.ToString(); + template.Get("DEATHS_COST").GetText = () => "$" + stats.DeathsCost.ToString(); + template.Get("UNITS_KILLED").GetText = () => stats.UnitsKilled.ToString(); + template.Get("UNITS_DEAD").GetText = () => stats.UnitsDead.ToString(); + template.Get("BUILDINGS_KILLED").GetText = () => stats.BuildingsKilled.ToString(); + template.Get("BUILDINGS_DEAD").GetText = () => stats.BuildingsDead.ToString(); return template; } diff --git a/mods/ra/chrome/ingame.yaml b/mods/ra/chrome/ingame.yaml index 88f072964f..b784b4fd61 100644 --- a/mods/ra/chrome/ingame.yaml +++ b/mods/ra/chrome/ingame.yaml @@ -445,7 +445,7 @@ Container@OBSERVER_ROOT: Height:25 Font:Bold Text:Earned/min - Label@POWER_HEADER + Label@POWER_HEADER: X:425 Y:40 Width:80 @@ -503,28 +503,28 @@ Container@OBSERVER_ROOT: Height:25 Font:Bold Text:Earned/min - Label@ASSETS_HEADER + Label@ASSETS_HEADER: X:425 Y:40 Width:60 Height:25 Font:Bold Text:Assets - Label@EARNED_HEADER + Label@EARNED_HEADER: X:505 Y:40 Width:60 Height:25 Font:Bold Text:Earned - Label@SPENT_HEADER + Label@SPENT_HEADER: X:585 Y:40 Width:60 Height:25 Font:Bold Text:Spent - Label@HARVESTERS_HEADER + Label@HARVESTERS_HEADER: X:665 Y:40 Width:60 @@ -545,7 +545,7 @@ Container@OBSERVER_ROOT: Height:25 Font:Bold Text:Player - Label@PRODUCTION_HEADER + Label@PRODUCTION_HEADER: X:245 Y:40 Width:320 @@ -579,6 +579,52 @@ Container@OBSERVER_ROOT: Height:25 Font:Bold Text:Control + Label@KILLS_COST_HEADER: + X:325 + Y:40 + Width:60 + Height:25 + Font:Bold + Text:Kills + Label@DEATHS_COST_HEADER: + X:405 + Y:40 + Width:60 + Height:25 + Font:Bold + Text:Deaths + Label@UNITS_KILLED_HEADER: + X:505 + Y:40 + Width:40 + Height:25 + Font:Bold + Text:Units Killed + Align:Right + Label@UNITS_DEAD_HEADER: + X:605 + Y:40 + Width:40 + Height:25 + Font:Bold + Text:Units Dead + Align:Right + Label@BUILDINGS_KILLED_HEADER: + X:725 + Y:40 + Width:40 + Height:25 + Font:Bold + Text:Bld Destroyed + Align:Right + Label@BUILDINGS_DEAD_HEADER: + X:825 + Y:40 + Width:40 + Height:25 + Font:Bold + Text:Bld Lost + Align:Right ScrollPanel@PLAYER_STATS_PANEL: X:25 Y:70 @@ -748,11 +794,45 @@ Container@OBSERVER_ROOT: Width:160 Height:PARENT_BOTTOM Font:Bold - Label@CONTROL + Label@CONTROL: X:215 Y:0 Width:60 Height:PARENT_BOTTOM + Label@KILLS_COST: + X:295 + Y:0 + Width:60 + Height:PARENT_BOTTOM + Label@DEATHS_COST: + X:375 + Y:0 + Width:60 + Height:PARENT_BOTTOM + Label@UNITS_KILLED: + X:475 + Y:0 + Width:40 + Height:PARENT_BOTTOM + Align:Right + Label@UNITS_DEAD: + X:575 + Y:0 + Width:40 + Height:PARENT_BOTTOM + Align:Right + Label@BUILDINGS_KILLED: + X:695 + Y:0 + Width:40 + Height:PARENT_BOTTOM + Align:Right + Label@BUILDINGS_DEAD: + X:795 + Y:0 + Width:40 + Height:PARENT_BOTTOM + Align:Right Background@FMVPLAYER: Width:WINDOW_RIGHT Height:WINDOW_BOTTOM diff --git a/mods/ra/rules/defaults.yaml b/mods/ra/rules/defaults.yaml index 27753b9455..ca796d077d 100644 --- a/mods/ra/rules/defaults.yaml +++ b/mods/ra/rules/defaults.yaml @@ -32,6 +32,7 @@ GpsDot: String:Vehicle WithSmoke: + UpdatesPlayerStatistics: ^Tank: AppearsOnRadar: @@ -67,6 +68,7 @@ GpsDot: String:Vehicle WithSmoke: + UpdatesPlayerStatistics: ^Infantry: AppearsOnRadar: @@ -114,6 +116,7 @@ RepairableNear: Buildings: hosp CloseEnough: 1 + UpdatesPlayerStatistics: ^Ship: AppearsOnRadar: @@ -141,6 +144,7 @@ GpsDot: String:Ship WithSmoke: + UpdatesPlayerStatistics: ^Plane: AppearsOnRadar: @@ -169,6 +173,7 @@ GivesBounty: GpsDot: String:Plane + UpdatesPlayerStatistics: ^Helicopter: Inherits: ^Plane @@ -210,6 +215,7 @@ Sellable: AcceptsSupplies: GivesBounty: + UpdatesPlayerStatistics: ^Wall: AppearsOnRadar: @@ -242,6 +248,7 @@ ProximityCaptor: Types:Wall Sellable: + UpdatesPlayerStatistics: ^TechBuilding: Inherits: ^Building