Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for playing a "LoseNotification" to the old owner through CaptureNotification #11142

Merged
merged 3 commits into from May 26, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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);
}
}
}