Remove fp from building refund calculation.
This commit is contained in:
@@ -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"};
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
@@ -82,7 +83,7 @@ namespace OpenRA.Mods.RA
|
||||
if (amount > 0)
|
||||
{
|
||||
Ore -= amount;
|
||||
PlayerResources.GiveOre (amount);
|
||||
PlayerResources.GiveOre(amount);
|
||||
}
|
||||
nextProcessTime = (PlayerPower.PowerState == PowerState.Normal)?
|
||||
Info.ProcessTick : Info.LowPowerProcessTick ;
|
||||
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user