Add more things to the Combat tab
This commit is contained in:
@@ -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<UpdatesPlayerStatistics> { }
|
||||
|
||||
public class UpdatesPlayerStatistics : INotifyKilled
|
||||
{
|
||||
public void Killed(Actor self, AttackInfo e)
|
||||
{
|
||||
var attackerStats = e.Attacker.Owner.PlayerActor.Trait<PlayerStatistics>();
|
||||
var defenderStats = self.Owner.PlayerActor.Trait<PlayerStatistics>();
|
||||
if (self.HasTrait<Building>())
|
||||
{
|
||||
attackerStats.BuildingsKilled++;
|
||||
defenderStats.BuildingsDead++;
|
||||
}
|
||||
if (self.HasTrait<IMove>())
|
||||
{
|
||||
attackerStats.UnitsKilled++;
|
||||
defenderStats.UnitsDead++;
|
||||
}
|
||||
if (self.HasTrait<Valued>())
|
||||
{
|
||||
var cost = self.Info.Traits.Get<ValuedInfo>().Cost;
|
||||
attackerStats.KillsCost += cost;
|
||||
defenderStats.DeathsCost += cost;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user