Skip to content

Commit

Permalink
Add ShowTicks to sellable
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR committed Nov 3, 2017
1 parent 77feb3f commit e92e7de
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 4 additions & 2 deletions OpenRA.Mods.Common/Activities/Sell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ class Sell : Activity
readonly Health health;
readonly SellableInfo sellableInfo;
readonly PlayerResources playerResources;
bool showTicks;

public Sell(Actor self)
public Sell(Actor self, bool showTicks)
{
this.showTicks = showTicks;
health = self.TraitOrDefault<Health>();
sellableInfo = self.Info.TraitInfo<SellableInfo>();
playerResources = self.Owner.PlayerActor.Trait<PlayerResources>();
Expand All @@ -40,7 +42,7 @@ public override Activity Tick(Actor self)
foreach (var ns in self.TraitsImplementing<INotifySold>())
ns.Sold(self);

if (refund > 0 && self.Owner.IsAlliedWith(self.World.RenderPlayer))
if (showTicks && refund > 0 && self.Owner.IsAlliedWith(self.World.RenderPlayer))
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, self.Owner.Color.RGB, FloatingText.FormatCashTick(refund), 30)));

self.Dispose();
Expand Down
5 changes: 3 additions & 2 deletions OpenRA.Mods.Common/Traits/Sellable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class SellableInfo : ConditionalTraitInfo
{
public readonly int RefundPercent = 50;
public readonly string[] SellSounds = { };
public readonly bool ShowTicks = true;

[Desc("Skip playing (reversed) make animation.")]
public readonly bool SkipMakeAnimation = false;
Expand Down Expand Up @@ -71,12 +72,12 @@ public void Sell(Actor self)
var makeAnimation = self.TraitOrDefault<WithMakeAnimation>();
if (makeAnimation != null)
{
makeAnimation.Reverse(self, new Sell(self), false);
makeAnimation.Reverse(self, new Sell(self, info.ShowTicks), false);
return;
}
}

self.QueueActivity(false, new Sell(self));
self.QueueActivity(false, new Sell(self, info.ShowTicks));
}

public bool IsTooltipVisible(Player forPlayer)
Expand Down

0 comments on commit e92e7de

Please sign in to comment.