Add support for superweapon detected sounds.

This commit is contained in:
Matthias Mailänder
2021-11-21 10:55:25 +01:00
committed by reaperrr
parent c51327c4cc
commit c9022bcb73
2 changed files with 18 additions and 1 deletions

View File

@@ -253,6 +253,7 @@ namespace OpenRA
return PlayerRelationship.Neutral;
}
/// <summary> returns true if player is null </summary>
public bool IsAlliedWith(Player p)
{
return RelationshipWith(p) == PlayerRelationship.Ally;

View File

@@ -47,6 +47,11 @@ namespace OpenRA.Mods.Common.Traits
public readonly bool StartFullyCharged = false;
public readonly string[] Prerequisites = { };
public readonly string DetectedSound = null;
[NotificationReference("Speech")]
public readonly string DetectedSpeechNotification = null;
public readonly string BeginChargeSound = null;
[NotificationReference("Speech")]
@@ -137,6 +142,18 @@ namespace OpenRA.Mods.Common.Traits
this.info = info;
}
protected override void Created(Actor self)
{
base.Created(self);
var renderPlayer = self.World.RenderPlayer;
if (renderPlayer != null && renderPlayer != self.Owner)
{
Game.Sound.Play(SoundType.UI, Info.DetectedSound);
Game.Sound.PlayNotification(self.World.Map.Rules, renderPlayer, "Speech", info.DetectedSpeechNotification, renderPlayer.Faction.InternalName);
}
}
public virtual SupportPowerInstance CreateInstance(string key, SupportPowerManager manager)
{
return new SupportPowerInstance(key, info, manager);
@@ -185,7 +202,6 @@ namespace OpenRA.Mods.Common.Traits
var isAllied = Self.Owner.IsAlliedWith(renderPlayer);
Game.Sound.Play(SoundType.UI, isAllied ? Info.LaunchSound : Info.IncomingSound);
// IsAlliedWith returns true if renderPlayer is null, so we are safe here.
var toPlayer = isAllied ? renderPlayer ?? Self.Owner : renderPlayer;
var speech = isAllied ? Info.LaunchSpeechNotification : Info.IncomingSpeechNotification;
Game.Sound.PlayNotification(Self.World.Map.Rules, toPlayer, "Speech", speech, toPlayer.Faction.InternalName);