Add support for transient text notifications matching speech notifications
This commit is contained in:
committed by
Paul Chote
parent
9f723be65a
commit
24b9482cc1
@@ -53,36 +53,50 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string DetectedSpeechNotification = null;
|
||||
|
||||
public readonly string DetectedTextNotification = null;
|
||||
|
||||
public readonly string BeginChargeSound = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string BeginChargeSpeechNotification = null;
|
||||
|
||||
public readonly string BeginChargeTextNotification = null;
|
||||
|
||||
public readonly string EndChargeSound = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string EndChargeSpeechNotification = null;
|
||||
|
||||
public readonly string EndChargeTextNotification = null;
|
||||
|
||||
public readonly string SelectTargetSound = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string SelectTargetSpeechNotification = null;
|
||||
|
||||
public readonly string SelectTargetTextNotification = null;
|
||||
|
||||
public readonly string InsufficientPowerSound = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string InsufficientPowerSpeechNotification = null;
|
||||
|
||||
public readonly string InsufficientPowerTextNotification = null;
|
||||
|
||||
public readonly string LaunchSound = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string LaunchSpeechNotification = null;
|
||||
|
||||
public readonly string LaunchTextNotification = null;
|
||||
|
||||
public readonly string IncomingSound = null;
|
||||
|
||||
[NotificationReference("Speech")]
|
||||
public readonly string IncomingSpeechNotification = null;
|
||||
|
||||
public readonly string IncomingTextNotification = null;
|
||||
|
||||
[Desc("Defines to which players the timer is shown.")]
|
||||
public readonly PlayerRelationship DisplayTimerRelationships = PlayerRelationship.None;
|
||||
|
||||
@@ -147,11 +161,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
base.Created(self);
|
||||
|
||||
var renderPlayer = self.World.RenderPlayer;
|
||||
if (renderPlayer != null && renderPlayer != self.Owner)
|
||||
var player = self.World.LocalPlayer;
|
||||
if (player != null && player != self.Owner)
|
||||
{
|
||||
Game.Sound.Play(SoundType.UI, Info.DetectedSound);
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, renderPlayer, "Speech", info.DetectedSpeechNotification, renderPlayer.Faction.InternalName);
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, player, "Speech", info.DetectedSpeechNotification, player.Faction.InternalName);
|
||||
TextNotificationsManager.AddTransientLine(info.DetectedTextNotification, player);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,6 +180,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Game.Sound.PlayToPlayer(SoundType.UI, self.Owner, Info.BeginChargeSound);
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
|
||||
Info.BeginChargeSpeechNotification, self.Owner.Faction.InternalName);
|
||||
|
||||
TextNotificationsManager.AddTransientLine(Info.BeginChargeTextNotification, self.Owner);
|
||||
}
|
||||
|
||||
public virtual void Charged(Actor self, string key)
|
||||
@@ -173,6 +190,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
|
||||
Info.EndChargeSpeechNotification, self.Owner.Faction.InternalName);
|
||||
|
||||
TextNotificationsManager.AddTransientLine(Info.EndChargeTextNotification, self.Owner);
|
||||
|
||||
foreach (var notify in self.TraitsImplementing<INotifySupportPower>())
|
||||
notify.Charged(self);
|
||||
}
|
||||
@@ -199,13 +218,19 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public virtual void PlayLaunchSounds()
|
||||
{
|
||||
var renderPlayer = Self.World.RenderPlayer;
|
||||
var isAllied = Self.Owner.IsAlliedWith(renderPlayer);
|
||||
var localPlayer = Self.World.LocalPlayer;
|
||||
|
||||
if (localPlayer == null || localPlayer.Spectating)
|
||||
return;
|
||||
|
||||
var isAllied = Self.Owner.IsAlliedWith(localPlayer);
|
||||
Game.Sound.Play(SoundType.UI, isAllied ? Info.LaunchSound : Info.IncomingSound);
|
||||
|
||||
var toPlayer = isAllied ? renderPlayer ?? Self.Owner : renderPlayer;
|
||||
var toPlayer = isAllied ? localPlayer ?? Self.Owner : localPlayer;
|
||||
var speech = isAllied ? Info.LaunchSpeechNotification : Info.IncomingSpeechNotification;
|
||||
Game.Sound.PlayNotification(Self.World.Map.Rules, toPlayer, "Speech", speech, toPlayer.Faction.InternalName);
|
||||
|
||||
TextNotificationsManager.AddTransientLine(isAllied ? Info.LaunchTextNotification : Info.IncomingTextNotification, toPlayer);
|
||||
}
|
||||
|
||||
public IEnumerable<CPos> CellsMatching(CPos location, char[] footprint, CVec dimensions)
|
||||
|
||||
Reference in New Issue
Block a user