fix #772 -- GivesBounty uses Actor.GetSellValue

This commit is contained in:
Chris Forbes
2011-05-11 07:55:07 +12:00
parent 0807f4ca8d
commit 3bbcbf4701
4 changed files with 19 additions and 8 deletions

View File

@@ -21,4 +21,18 @@ namespace OpenRA.Mods.RA.Buildings
}
public class CustomSellValue { }
public static class CustomSellValueExts
{
public static int GetSellValue( this Actor a )
{
var csv = a.Info.Traits.GetOrDefault<CustomSellValueInfo>();
if (csv != null) return csv.Value;
var valued = a.Info.Traits.GetOrDefault<ValuedInfo>();
if (valued != null) return valued.Cost;
return 0;
}
}
}

View File

@@ -52,8 +52,7 @@ namespace OpenRA.Mods.RA.Buildings
if (remainingTicks == 0)
{
var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();
var buildingValue = csv != null ? csv.Value : self.Info.Traits.Get<ValuedInfo>().Cost;
var buildingValue = self.GetSellValue();
var hpToRepair = Math.Min(Info.RepairStep, Health.MaxHP - Health.HP);
var cost = (hpToRepair * Info.RepairPercent * buildingValue) / (Health.MaxHP * 100);