Added checks to make sure cash can't be < 0.

This commit is contained in:
GSonderling
2018-05-07 10:42:38 +00:00
committed by reaperrr
parent b8fd4abc4a
commit bf4dbd9b80
9 changed files with 28 additions and 35 deletions

View File

@@ -51,19 +51,8 @@ namespace OpenRA.Mods.Common.Traits
return;
var resources = newOwner.PlayerActor.Trait<PlayerResources>();
var amount = info.Amount;
if (amount < 0)
{
// Check whether the amount of cash to be removed would exceed available player cash, in that case only remove all the player cash
amount = Math.Min(resources.Cash + resources.Resources, -amount);
resources.TakeCash(amount);
// For correct cash tick display
amount = -amount;
}
else
resources.GiveCash(amount);
var amount = resources.ChangeCash(info.Amount);
if (!info.ShowTicks)
return;