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))
{

View File

@@ -14,9 +14,9 @@ namespace OpenRA.Mods.RA
{
public class RepairsUnitsInfo : TraitInfo<RepairsUnits>
{
public readonly float URepairPercent = 0.2f;
public readonly int URepairStep = 10;
public readonly int Interval = 24;
public readonly int ValuePercentage = 20; // charge 20% of the unit value to fully repair
public readonly int HpPerStep = 10;
public readonly int Interval = 24; // Ticks
}
public class RepairsUnits { }