Further refactoring of Repair.
This commit is contained in:
@@ -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))
|
||||
{
|
||||
|
||||
@@ -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 { }
|
||||
|
||||
Reference in New Issue
Block a user