Skip to content

Commit

Permalink
Merge pull request #11142 from abcdefg30/captureOld
Browse files Browse the repository at this point in the history
Add support for playing a "LoseNotification" to the old owner through CaptureNotification
  • Loading branch information
Mailaender committed May 26, 2016
2 parents 2a27c32 + af3d8d4 commit d787f40
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions OpenRA.Mods.Common/Traits/Sound/CaptureNotification.cs
Expand Up @@ -15,27 +15,36 @@ namespace OpenRA.Mods.Common.Traits.Sound
{
public class CaptureNotificationInfo : ITraitInfo
{
[Desc("The speech notification to play to the new owner.")]
public readonly string Notification = "BuildingCaptured";

[Desc("Specifies if Notification is played with the voice of the new owners faction.")]
public readonly bool NewOwnerVoice = true;

[Desc("The speech notification to play to the old owner.")]
public readonly string LoseNotification = null;

[Desc("Specifies if LoseNotification is played with the voice of the new owners faction.")]
public readonly bool LoseNewOwnerVoice = false;

public object Create(ActorInitializer init) { return new CaptureNotification(this); }
}

public class CaptureNotification : INotifyCapture
{
CaptureNotificationInfo info;
readonly CaptureNotificationInfo info;
public CaptureNotification(CaptureNotificationInfo info)
{
this.info = info;
}

public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
{
if (captor.World.LocalPlayer != captor.Owner)
return;

var faction = info.NewOwnerVoice ? newOwner.Faction.InternalName : oldOwner.Faction.InternalName;
Game.Sound.PlayNotification(self.World.Map.Rules, captor.World.LocalPlayer, "Speech", info.Notification, faction);
Game.Sound.PlayNotification(self.World.Map.Rules, newOwner, "Speech", info.Notification, faction);

var loseFaction = info.LoseNewOwnerVoice ? newOwner.Faction.InternalName : oldOwner.Faction.InternalName;
Game.Sound.PlayNotification(self.World.Map.Rules, oldOwner, "Speech", info.LoseNotification, loseFaction);
}
}
}

0 comments on commit d787f40

Please sign in to comment.