Added checks to make sure cash can't be < 0.
This commit is contained in:
@@ -34,14 +34,14 @@ namespace OpenRA.Mods.Common.Activities
|
||||
if (target.IsDead)
|
||||
return;
|
||||
|
||||
target.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(payload);
|
||||
var donated = target.Owner.PlayerActor.Trait<PlayerResources>().ChangeCash(payload);
|
||||
|
||||
var exp = self.Owner.PlayerActor.TraitOrDefault<PlayerExperience>();
|
||||
if (exp != null && target.Owner != self.Owner)
|
||||
exp.GiveExperience(experience);
|
||||
|
||||
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
|
||||
self.World.AddFrameEndTask(w => w.Add(new FloatingText(target.CenterPosition, target.Owner.Color.RGB, FloatingText.FormatCashTick(payload), 30)));
|
||||
self.World.AddFrameEndTask(w => w.Add(new FloatingText(target.CenterPosition, target.Owner.Color.RGB, FloatingText.FormatCashTick(donated), 30)));
|
||||
|
||||
foreach (var nct in target.TraitsImplementing<INotifyCashTransfer>())
|
||||
nct.OnAcceptingCash(target, self);
|
||||
|
||||
@@ -40,7 +40,7 @@ namespace OpenRA.Mods.Common.Activities
|
||||
var hp = health != null ? (long)health.HP : 1L;
|
||||
var maxHP = health != null ? (long)health.MaxHP : 1L;
|
||||
var refund = (int)((sellValue * sellableInfo.RefundPercent * hp) / (100 * maxHP));
|
||||
playerResources.GiveCash(refund);
|
||||
refund = playerResources.ChangeCash(refund);
|
||||
|
||||
foreach (var ns in self.TraitsImplementing<INotifySold>())
|
||||
ns.Sold(self);
|
||||
|
||||
Reference in New Issue
Block a user