Further refactoring of Repair.

This commit is contained in:
Paul Chote
2011-01-05 13:29:38 +13:00
parent 40b0408ce7
commit 22bf9e7aff
2 changed files with 5 additions and 7 deletions

View File

@@ -33,10 +33,8 @@ namespace OpenRA.Mods.RA.Activities
var repairsUnits = host.Info.Traits.Get<RepairsUnitsInfo>();
var unitCost = self.Info.Traits.Get<ValuedInfo>().Cost;
var hpToRepair = Math.Min(host.Info.Traits.Get<RepairsUnitsInfo>().URepairStep, health.MaxHP - health.HP);
var costPerHp = (repairsUnits.URepairPercent * unitCost) / health.MaxHP;
var fullRepairCost = (int)(repairsUnits.URepairPercent * unitCost);
var cost = fullRepairCost * hpToRepair / health.MaxHP;
var hpToRepair = Math.Min(repairsUnits.HpPerStep, health.MaxHP - health.HP);
var cost = (hpToRepair * unitCost * repairsUnits.ValuePercentage) / (health.MaxHP * 100);
if (!self.Owner.PlayerActor.Trait<PlayerResources>().TakeCash(cost))
{