Fix the support power SpeechNotifications not being played to the correct player

This commit is contained in:
abcdefg30
2016-09-12 14:42:45 +02:00
parent ed8b62a7fc
commit 08d84c5b90
3 changed files with 18 additions and 16 deletions

View File

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

View File

@@ -93,18 +93,14 @@ namespace OpenRA.Mods.Common.Traits
{ {
base.Activate(self, order, manager); base.Activate(self, order, manager);
if (self.Owner.IsAlliedWith(self.World.RenderPlayer)) var renderPlayer = self.World.RenderPlayer;
{ var isAllied = self.Owner.IsAlliedWith(renderPlayer);
Game.Sound.Play(Info.LaunchSound); Game.Sound.Play(isAllied ? Info.LaunchSound : Info.IncomingSound);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
Info.LaunchSpeechNotification, self.Owner.Faction.InternalName); // IsAlliedWith returns true if renderPlayer is null, so we are safe here.
} var toPlayer = isAllied ? renderPlayer ?? self.Owner : renderPlayer;
else var speech = isAllied ? Info.LaunchSpeechNotification : Info.IncomingSpeechNotification;
{ Game.Sound.PlayNotification(self.World.Map.Rules, toPlayer, "Speech", speech, toPlayer.Faction.InternalName);
Game.Sound.Play(Info.IncomingSound);
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
Info.IncomingSpeechNotification, self.Owner.Faction.InternalName);
}
if (!string.IsNullOrEmpty(info.ActivationSequence)) if (!string.IsNullOrEmpty(info.ActivationSequence))
{ {

View File

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