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; return;
var attackerStats = e.Attacker.Owner.PlayerActor.Trait<PlayerStatistics>(); var attackerStats = e.Attacker.Owner.PlayerActor.Trait<PlayerStatistics>();
var defenderStats = self.Owner.PlayerActor.Trait<PlayerStatistics>();
if (self.Info.HasTraitInfo<BuildingInfo>()) if (self.Info.HasTraitInfo<BuildingInfo>())
{ {
attackerStats.BuildingsKilled++; attackerStats.BuildingsKilled++;
defenderStats.BuildingsDead++; playerStats.BuildingsDead++;
} }
else if (self.Info.HasTraitInfo<IPositionableInfo>()) else if (self.Info.HasTraitInfo<IPositionableInfo>())
{ {
attackerStats.UnitsKilled++; attackerStats.UnitsKilled++;
defenderStats.UnitsDead++; playerStats.UnitsDead++;
} }
attackerStats.KillsCost += cost; attackerStats.KillsCost += cost;
defenderStats.DeathsCost += cost; playerStats.DeathsCost += cost;
if (includedInArmyValue) if (includedInArmyValue)
{ {
defenderStats.ArmyValue -= cost; playerStats.ArmyValue -= cost;
includedInArmyValue = false; includedInArmyValue = false;
playerStats.Units[actorName].Count--; playerStats.Units[actorName].Count--;
} }