diff --git a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs index 881df0428a..184b65591a 100644 --- a/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs +++ b/OpenRA.Mods.Common/Traits/SupportPowers/SupportPower.cs @@ -44,7 +44,8 @@ namespace OpenRA.Mods.Common.Traits public readonly string IncomingSound = null; public readonly string IncomingSpeechNotification = null; - public readonly bool DisplayTimer = false; + [Desc("Defines to which players the timer is shown.")] + public readonly Stance DisplayTimerStances = Stance.None; [Desc("Palette used for the icon.")] [PaletteReference] public readonly string IconPalette = "chrome"; diff --git a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs index 23945801e4..bd9038fd87 100644 --- a/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SupportPowerTimerWidget.cs @@ -16,6 +16,7 @@ using System.Linq; using OpenRA.Graphics; using OpenRA.Mods.Common.Traits; using OpenRA.Primitives; +using OpenRA.Traits; using OpenRA.Widgets; namespace OpenRA.Mods.Common.Widgets @@ -36,7 +37,7 @@ namespace OpenRA.Mods.Common.Widgets powers = world.ActorsWithTrait() .Where(p => !p.Actor.IsDead && !p.Actor.Owner.NonCombatant) .SelectMany(s => s.Trait.Powers.Values) - .Where(p => p.Instances.Any() && p.Info.DisplayTimer && !p.Disabled); + .Where(p => p.Instances.Any() && p.Info.DisplayTimerStances != Stance.None && !p.Disabled); // Timers in replays should be synced to the effective game time, not the playback time. timestep = world.Timestep; @@ -46,7 +47,14 @@ namespace OpenRA.Mods.Common.Widgets public override void Tick() { - texts = powers.Select(p => + var displayedPowers = powers.Where(p => + { + var owner = p.Instances[0].Self.Owner; + var viewer = owner.World.RenderPlayer ?? owner.World.LocalPlayer; + return viewer == null || p.Info.DisplayTimerStances.HasStance(owner.Stances[viewer]); + }); + + texts = displayedPowers.Select(p => { var time = WidgetUtils.FormatTime(p.RemainingTime, false, timestep); var text = Format.F(p.Info.Description, time);