Remove defenderStats look-up from UpdatePlayerStatistics

playerStats is updated on owner change,
so it should always be identical to the removed defenderStats.
This commit is contained in:
reaperrr
2020-09-05 01:24:25 +02:00
committed by abcdefg30
parent 1a77f7320b
commit c8afa4a2a8

View File

@@ -235,23 +235,22 @@ namespace OpenRA.Mods.Common.Traits
return;
var attackerStats = e.Attacker.Owner.PlayerActor.Trait<PlayerStatistics>();
var defenderStats = self.Owner.PlayerActor.Trait<PlayerStatistics>();
if (self.Info.HasTraitInfo<BuildingInfo>())
{
attackerStats.BuildingsKilled++;
defenderStats.BuildingsDead++;
playerStats.BuildingsDead++;
}
else if (self.Info.HasTraitInfo<IPositionableInfo>())
{
attackerStats.UnitsKilled++;
defenderStats.UnitsDead++;
playerStats.UnitsDead++;
}
attackerStats.KillsCost += cost;
defenderStats.DeathsCost += cost;
playerStats.DeathsCost += cost;
if (includedInArmyValue)
{
defenderStats.ArmyValue -= cost;
playerStats.ArmyValue -= cost;
includedInArmyValue = false;
playerStats.Units[actorName].Count--;
}