Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ShowTicks to Sellable #14287

Merged
merged 1 commit into from Nov 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions OpenRA.Mods.Common/Activities/Sell.cs
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
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