Merge pull request #11989 from abcdefg30/launchDetection

Fix the support power SpeechNotifications not being played to the correct player
This commit is contained in:
Oliver Brakmann
2016-09-12 19:12:28 +02:00
committed by GitHub
4 changed files with 15 additions and 23 deletions

View File

@@ -127,11 +127,7 @@ namespace OpenRA.Mods.Common.Traits
self.World.AddFrameEndTask(w =>
{
var isAllied = self.Owner.IsAlliedWith(self.World.RenderPlayer);
Game.Sound.Play(isAllied ? Info.LaunchSound : Info.IncomingSound);
var speech = isAllied ? Info.LaunchSpeechNotification : Info.IncomingSpeechNotification;
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", speech, self.Owner.Faction.InternalName);
PlayLaunchSounds();
Actor distanceTestActor = null;
for (var i = -info.SquadSize / 2; i <= info.SquadSize / 2; i++)

View File

@@ -92,19 +92,7 @@ namespace OpenRA.Mods.Common.Traits
public override void Activate(Actor self, Order order, SupportPowerManager manager)
{
base.Activate(self, order, manager);
if (self.Owner.IsAlliedWith(self.World.RenderPlayer))
{
Game.Sound.Play(Info.LaunchSound);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
Info.LaunchSpeechNotification, self.Owner.Faction.InternalName);
}
else
{
Game.Sound.Play(Info.IncomingSound);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
Info.IncomingSpeechNotification, self.Owner.Faction.InternalName);
}
PlayLaunchSounds();
if (!string.IsNullOrEmpty(info.ActivationSequence))
{

View File

@@ -120,5 +120,17 @@ namespace OpenRA.Mods.Common.Traits
Info.RadarPingDuration);
}
}
public virtual void PlayLaunchSounds()
{
var renderPlayer = Self.World.RenderPlayer;
var isAllied = Self.Owner.IsAlliedWith(renderPlayer);
Game.Sound.Play(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);
}
}
}

View File

@@ -153,11 +153,7 @@ namespace OpenRA.Mods.RA.Traits
self.World.AddFrameEndTask(w =>
{
var isAllied = self.Owner.IsAlliedWith(self.World.RenderPlayer);
Game.Sound.Play(isAllied ? Info.LaunchSound : Info.IncomingSound);
var speech = isAllied ? Info.LaunchSpeechNotification : Info.IncomingSpeechNotification;
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", speech, self.Owner.Faction.InternalName);
PlayLaunchSounds();
Actor distanceTestActor = null;