Add additional notification support to infiltration.

This commit is contained in:
Matthias Mailänder
2020-03-18 15:59:02 +01:00
committed by atlimit8
parent 2c7a56625c
commit 73a2b59c2c
7 changed files with 91 additions and 5 deletions

View File

@@ -34,7 +34,11 @@ namespace OpenRA.Mods.Cnc.Traits
[NotificationReference("Speech")] [NotificationReference("Speech")]
[Desc("Sound the victim will hear when they get robbed.")] [Desc("Sound the victim will hear when they get robbed.")]
public readonly string Notification = null; public readonly string InfiltratedNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
[Desc("Whether to show the cash tick indicators rising from the actor.")] [Desc("Whether to show the cash tick indicators rising from the actor.")]
public readonly bool ShowTicks = true; public readonly bool ShowTicks = true;
@@ -63,8 +67,11 @@ namespace OpenRA.Mods.Cnc.Traits
targetResources.TakeCash(toTake); targetResources.TakeCash(toTake);
spyResources.GiveCash(toGive); spyResources.GiveCash(toGive);
if (info.Notification != null) if (info.InfiltratedNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.Notification, self.Owner.Faction.InternalName); Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName);
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
if (info.ShowTicks) if (info.ShowTicks)
self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, infiltrator.Owner.Color, FloatingText.FormatCashTick(toGive), 30))); self.World.AddFrameEndTask(w => w.Add(new FloatingText(self.CenterPosition, infiltrator.Owner.Color, FloatingText.FormatCashTick(toGive), 30)));

View File

@@ -21,6 +21,14 @@ namespace OpenRA.Mods.Cnc.Traits
{ {
public readonly BitSet<TargetableType> Types = default(BitSet<TargetableType>); public readonly BitSet<TargetableType> Types = default(BitSet<TargetableType>);
[NotificationReference("Speech")]
[Desc("Sound the victim will hear when they get sabotaged.")]
public readonly string InfiltratedNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
public object Create(ActorInitializer init) { return new InfiltrateForExploration(init.Self, this); } public object Create(ActorInitializer init) { return new InfiltrateForExploration(init.Self, this); }
} }
@@ -38,6 +46,12 @@ namespace OpenRA.Mods.Cnc.Traits
if (!info.Types.Overlaps(types)) if (!info.Types.Overlaps(types))
return; return;
if (info.InfiltratedNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName);
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
infiltrator.Owner.Shroud.Explore(self.Owner.Shroud); infiltrator.Owner.Shroud.Explore(self.Owner.Shroud);
var preventReset = self.Owner.PlayerActor.TraitsImplementing<IPreventsShroudReset>() var preventReset = self.Owner.PlayerActor.TraitsImplementing<IPreventsShroudReset>()
.Any(p => p.PreventShroudReset(self)); .Any(p => p.PreventShroudReset(self));

View File

@@ -19,8 +19,17 @@ namespace OpenRA.Mods.Cnc.Traits
{ {
public readonly BitSet<TargetableType> Types = default(BitSet<TargetableType>); public readonly BitSet<TargetableType> Types = default(BitSet<TargetableType>);
[Desc("Measured in ticks.")]
public readonly int Duration = 25 * 20; public readonly int Duration = 25 * 20;
[NotificationReference("Speech")]
[Desc("Sound the victim will hear when they get sabotaged.")]
public readonly string InfiltratedNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
public object Create(ActorInitializer init) { return new InfiltrateForPowerOutage(init.Self, this); } public object Create(ActorInitializer init) { return new InfiltrateForPowerOutage(init.Self, this); }
} }
@@ -40,6 +49,12 @@ namespace OpenRA.Mods.Cnc.Traits
if (!info.Types.Overlaps(types)) if (!info.Types.Overlaps(types))
return; return;
if (info.InfiltratedNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName);
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
playerPower.TriggerPowerOutage(info.Duration); playerPower.TriggerPowerOutage(info.Duration);
} }

View File

@@ -23,6 +23,14 @@ namespace OpenRA.Mods.Cnc.Traits
public readonly BitSet<TargetableType> Types = default(BitSet<TargetableType>); public readonly BitSet<TargetableType> Types = default(BitSet<TargetableType>);
[NotificationReference("Speech")]
[Desc("Sound the victim will hear when technology gets stolen.")]
public readonly string InfiltratedNotification = null;
[NotificationReference("Speech")]
[Desc("Sound the perpetrator will hear after successful infiltration.")]
public readonly string InfiltrationNotification = null;
public object Create(ActorInitializer init) { return new InfiltrateForSupportPower(this); } public object Create(ActorInitializer init) { return new InfiltrateForSupportPower(this); }
} }
@@ -40,6 +48,12 @@ namespace OpenRA.Mods.Cnc.Traits
if (!info.Types.Overlaps(types)) if (!info.Types.Overlaps(types))
return; return;
if (info.InfiltratedNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.InfiltratedNotification, self.Owner.Faction.InternalName);
if (info.InfiltrationNotification != null)
Game.Sound.PlayNotification(self.World.Map.Rules, infiltrator.Owner, "Speech", info.InfiltrationNotification, infiltrator.Owner.Faction.InternalName);
infiltrator.World.AddFrameEndTask(w => w.CreateActor(info.Proxy, new TypeDictionary infiltrator.World.AddFrameEndTask(w => w.CreateActor(info.Proxy, new TypeDictionary
{ {
new OwnerInit(infiltrator.Owner) new OwnerInit(infiltrator.Owner)

View File

@@ -0,0 +1,35 @@
#region Copyright & License Information
/*
* Copyright 2007-2020 The OpenRA Developers (see AUTHORS)
* This file is part of OpenRA, which is free software. It is made
* available to you under the terms of the GNU General Public License
* as published by the Free Software Foundation, either version 3 of
* the License, or (at your option) any later version. For more
* information, see COPYING.
*/
#endregion
using System.Collections.Generic;
namespace OpenRA.Mods.Common.UpdateRules.Rules
{
class RenameInfiltrationNotifications : UpdateRule
{
public override string Name { get { return "Renamed InfiltrateForCash Notification to InfiltratedNotification."; } }
public override string Description
{
get
{
return "The InfiltrateForCash Notification has been renamed to be in line with new notification properties added.";
}
}
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNode actorNode)
{
foreach (var rp in actorNode.ChildrenMatching("InfiltrateForCash"))
rp.RenameChildrenMatching("Notification", "InfiltratedNotification");
yield break;
}
}
}

View File

@@ -80,6 +80,7 @@ namespace OpenRA.Mods.Common.UpdateRules
// Bleed only changes here // Bleed only changes here
new AddPipDecorationTraits(), new AddPipDecorationTraits(),
new ModernizeDecorationTraits(), new ModernizeDecorationTraits(),
new RenameInfiltrationNotifications(),
}) })
}; };

View File

@@ -1221,7 +1221,7 @@ PROC:
InfiltrateForCash: InfiltrateForCash:
Percentage: 50 Percentage: 50
Types: SpyInfiltrate, ThiefInfiltrate Types: SpyInfiltrate, ThiefInfiltrate
Notification: CreditsStolen InfiltratedNotification: CreditsStolen
WithBuildingBib: WithBuildingBib:
WithIdleOverlay@TOP: WithIdleOverlay@TOP:
RequiresCondition: !build-incomplete RequiresCondition: !build-incomplete
@@ -1283,7 +1283,7 @@ SILO:
InfiltrateForCash: InfiltrateForCash:
Percentage: 50 Percentage: 50
Types: ThiefInfiltrate Types: ThiefInfiltrate
Notification: CreditsStolen InfiltratedNotification: CreditsStolen
WithBuildingBib: WithBuildingBib:
HasMinibib: true HasMinibib: true
-WithSpriteBody: -WithSpriteBody: