Skip to content

Commit

Permalink
Fix CashTrickler revealing the location of cloaked actor with its text.
Browse files Browse the repository at this point in the history
  • Loading branch information
MustaphaTR committed Aug 28, 2024
1 parent 5d3a941 commit 6932bc8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion OpenRA.Mods.Common/Traits/CashTrickler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public class CashTricklerInfo : PausableConditionalTraitInfo, IRulesetLoaded
[Desc("Whether to show the cash tick indicators rising from the actor.")]
public readonly bool ShowTicks = true;

[Desc("Show the cash tick indicators even if the unit is invisible due to Cloak trait.")]
public readonly bool ShowTicksWhileCloaked = false;

[Desc("How long to show the cash tick indicator when enabled.")]
public readonly int DisplayDuration = 30;

Expand All @@ -52,6 +55,7 @@ public class CashTrickler : PausableConditionalTrait<CashTricklerInfo>, ITick, I
{
readonly CashTricklerInfo info;
PlayerResources resources;
Cloak[] cloaks;
[Sync]
public int Ticks { get; private set; }

Expand All @@ -65,6 +69,7 @@ public CashTrickler(CashTricklerInfo info)
protected override void Created(Actor self)
{
resources = self.Owner.PlayerActor.Trait<PlayerResources>();
cloaks = self.TraitsImplementing<Cloak>().ToArray();

base.Created(self);
}
Expand Down Expand Up @@ -111,7 +116,7 @@ void ModifyCash(Actor self, int amount)
amount = resources.ChangeCash(amount);
}

if (info.ShowTicks && amount != 0)
if (info.ShowTicks && amount != 0 && (info.ShowTicksWhileCloaked || cloaks.Length == 0 || cloaks.All(c => c.IsVisible(self, self.World.RenderPlayer))))
AddCashTick(self, amount);
}
}
Expand Down

0 comments on commit 6932bc8

Please sign in to comment.