Remove fp from building refund calculation.

This commit is contained in:
Paul Chote
2011-01-02 12:11:38 +13:00
parent f659f55801
commit 38df0a28cd
3 changed files with 11 additions and 8 deletions

View File

@@ -23,13 +23,15 @@ namespace OpenRA.Mods.RA.Buildings
void DoSell(Actor self)
{
var h = self.TraitOrDefault<Health>();
var bi = self.Info.Traits.Get<BuildingInfo>();
var pr = self.Owner.PlayerActor.Trait<PlayerResources>();
var csv = self.Info.Traits.GetOrDefault<CustomSellValueInfo>();
var cost = csv != null ? csv.Value : self.Info.Traits.Get<ValuedInfo>().Cost;
var health = self.TraitOrDefault<Health>();
var refundFraction = self.Info.Traits.Get<BuildingInfo>().RefundPercent * (health == null ? 1f : health.HPFraction);
self.Owner.PlayerActor.Trait<PlayerResources>().GiveCash((int)(refundFraction * cost));
var refund = (cost * bi.RefundPercent * (h == null ? 1 : h.HP)) / (100 * (h == null ? 1 : h.MaxHP));
pr.GiveCash(refund);
foreach (var ns in self.TraitsImplementing<INotifySold>())
ns.Sold(self);