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

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.RA.Buildings
public readonly string Footprint = "x";
public readonly int2 Dimensions = new int2(1, 1);
public readonly bool Unsellable = false;
public readonly float RefundPercent = 0.5f;
public readonly int RefundPercent = 50;
public readonly string[] BuildSounds = {"placbldg.aud", "build5.aud"};
public readonly string[] SellSounds = {"cashturn.aud"};

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

View File

@@ -74,7 +74,8 @@ namespace OpenRA.Mods.RA
if (!Info.LocalStorage)
return;
if (--nextProcessTime <= 0) {
if (--nextProcessTime <= 0)
{
// Convert resources to cash
int amount = Math.Min (Ore, Info.ProcessAmount);
amount = Math.Min (amount, PlayerResources.OreCapacity - PlayerResources.Ore);
@@ -125,7 +126,7 @@ namespace OpenRA.Mods.RA
if (!Info.LocalStorage)
return null;
return Graphics.Util.MakeArray (Info.PipCount, i => (Ore * 1f / Info.Capacity > i * 1f / Info.PipCount) ? Info.PipColor : PipType.Transparent);
return Graphics.Util.MakeArray (Info.PipCount, i => (Ore * Info.PipCount > i * Info.Capacity) ? Info.PipColor : PipType.Transparent);
}
public bool ShouldExplode(Actor self) { return Ore > 0; }