Add support for transient text notifications matching speech notifications

This commit is contained in:
Ivaylo Draganov
2022-01-08 18:28:25 +02:00
committed by Paul Chote
parent 9f723be65a
commit 24b9482cc1
50 changed files with 372 additions and 46 deletions

View File

@@ -71,6 +71,8 @@ namespace OpenRA.Mods.Cnc.Activities
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech",
infiltrates.Info.Notification, self.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(infiltrates.Info.TextNotification, self.Owner);
if (infiltrates.Info.EnterBehaviour == EnterBehaviour.Dispose)
self.Dispose();
else if (infiltrates.Info.EnterBehaviour == EnterBehaviour.Suicide)

View File

@@ -37,10 +37,16 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Sound the victim will hear when they get robbed.")]
public readonly string InfiltratedNotification = null;
[Desc("Text notification the victim will see when they get robbed.")]
public readonly string InfiltratedTextNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
[Desc("Text notification the perpetrator will see after successful infiltration.")]
public readonly string InfiltrationTextNotification = null;
[Desc("Whether to show the cash tick indicators rising from the actor.")]
public readonly bool ShowTicks = true;
@@ -74,6 +80,9 @@ namespace OpenRA.Mods.Cnc.Traits
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(info.InfiltratedTextNotification, self.Owner);
TextNotificationsManager.AddTransientLine(info.InfiltrationTextNotification, infiltrator.Owner);
if (info.ShowTicks)
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, infiltrator.Owner.Color, FloatingText.FormatCashTick(toGive), 30)));
}

View File

@@ -26,10 +26,16 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Sound the victim will hear when they get sabotaged.")]
public readonly string InfiltratedNotification = null;
[Desc("Text notification the victim will see when they get sabotaged.")]
public readonly string InfiltratedTextNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
[Desc("Text notification the perpetrator will see after successful infiltration.")]
public readonly string InfiltrationTextNotification = null;
public override object Create(ActorInitializer init) { return new InfiltrateForExploration(this); }
}
@@ -53,6 +59,9 @@ namespace OpenRA.Mods.Cnc.Traits
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(info.InfiltratedTextNotification, self.Owner);
TextNotificationsManager.AddTransientLine(info.InfiltrationTextNotification, infiltrator.Owner);
infiltrator.Owner.Shroud.Explore(self.Owner.Shroud);
var preventReset = self.Owner.PlayerActor.TraitsImplementing<IPreventsShroudReset>()
.Any(p => p.PreventShroudReset(self));

View File

@@ -27,10 +27,16 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Sound the victim will hear when they get sabotaged.")]
public readonly string InfiltratedNotification = null;
[Desc("Text notification the victim will see when they get sabotaged.")]
public readonly string InfiltratedTextNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
[Desc("Text notification the perpetrator will see after successful infiltration.")]
public readonly string InfiltrationTextNotification = null;
public override object Create(ActorInitializer init) { return new InfiltrateForPowerOutage(init.Self, this); }
}
@@ -56,6 +62,9 @@ namespace OpenRA.Mods.Cnc.Traits
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(info.InfiltratedTextNotification, self.Owner);
TextNotificationsManager.AddTransientLine(info.InfiltrationTextNotification, infiltrator.Owner);
playerPower.TriggerPowerOutage(info.Duration);
}

View File

@@ -28,10 +28,16 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Sound the victim will hear when technology gets stolen.")]
public readonly string InfiltratedNotification = null;
[Desc("Text notification the victim will see when technology gets stolen.")]
public readonly string InfiltratedTextNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
[Desc("Text notification the perpetrator will see after successful infiltration.")]
public readonly string InfiltrationTextNotification = null;
public override object Create(ActorInitializer init) { return new InfiltrateForSupportPower(this); }
}
@@ -55,6 +61,9 @@ namespace OpenRA.Mods.Cnc.Traits
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(info.InfiltratedTextNotification, self.Owner);
TextNotificationsManager.AddTransientLine(info.InfiltrationTextNotification, infiltrator.Owner);
infiltrator.World.AddFrameEndTask(w => w.CreateActor(info.Proxy, new TypeDictionary
{
new OwnerInit(infiltrator.Owner)

View File

@@ -22,13 +22,19 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly BitSet<TargetableType> Types = default(BitSet<TargetableType>);
[NotificationReference("Speech")]
[Desc("Sound the victim will hear when technology gets stolen.")]
[Desc("Sound the victim will hear when they get sabotaged.")]
public readonly string InfiltratedNotification = null;
[Desc("Text notification the victim will see when they get sabotaged.")]
public readonly string InfiltratedTextNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
[Desc("Text notification the perpetrator will see after successful infiltration.")]
public readonly string InfiltrationTextNotification = null;
public override object Create(ActorInitializer init) { return new InfiltrateForSupportPowerReset(this); }
}
@@ -52,6 +58,9 @@ namespace OpenRA.Mods.Cnc.Traits
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
TextNotificationsManager.AddTransientLine(info.InfiltratedTextNotification, self.Owner);
TextNotificationsManager.AddTransientLine(info.InfiltrationTextNotification, infiltrator.Owner);
var manager = self.Owner.PlayerActor.Trait<SupportPowerManager>();
var powers = manager.GetPowersForActor(self).Where(sp => !sp.Disabled);
foreach (var power in powers)

View File

@@ -41,6 +41,9 @@ namespace OpenRA.Mods.Cnc.Traits
[Desc("Notification to play when a target is infiltrated.")]
public readonly string Notification = null;
[Desc("Text notification to display when a target is infiltrated.")]
public readonly string TextNotification = null;
[Desc("Experience to grant to the infiltrating player.")]
public readonly int PlayerExperience = 0;