diff --git a/OpenRA.Mods.RA/Crates/SupportPowerCrateAction.cs b/OpenRA.Mods.RA/Crates/SupportPowerCrateAction.cs index 1934382dcc..f8a9e45b53 100644 --- a/OpenRA.Mods.RA/Crates/SupportPowerCrateAction.cs +++ b/OpenRA.Mods.RA/Crates/SupportPowerCrateAction.cs @@ -15,7 +15,7 @@ namespace OpenRA.Mods.RA.Crates { class SupportPowerCrateActionInfo : CrateActionInfo { - public string Power = null; + public readonly string Power = null; public override object Create(ActorInitializer init) { return new SupportPowerCrateAction(init.self, this); } } diff --git a/OpenRA.Mods.RA/InfiltrateForSonarPulse.cs b/OpenRA.Mods.RA/InfiltrateForSonarPulse.cs deleted file mode 100644 index 6f7ad32bd9..0000000000 --- a/OpenRA.Mods.RA/InfiltrateForSonarPulse.cs +++ /dev/null @@ -1,24 +0,0 @@ -#region Copyright & License Information -/* - * Copyright 2007-2010 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. For more information, - * see LICENSE. - */ -#endregion - -using OpenRA.Traits; - -namespace OpenRA.Mods.RA -{ - class InfiltrateForSonarPulseInfo : TraitInfo { } - - class InfiltrateForSonarPulse : IAcceptSpy - { - public void OnInfiltrate(Actor self, Actor spy) - { - spy.Owner.PlayerActor.Trait().Give(1.0f); - } - } -} diff --git a/OpenRA.Mods.RA/InfiltrateForSupportPower.cs b/OpenRA.Mods.RA/InfiltrateForSupportPower.cs new file mode 100644 index 0000000000..f5a82cca2a --- /dev/null +++ b/OpenRA.Mods.RA/InfiltrateForSupportPower.cs @@ -0,0 +1,38 @@ +#region Copyright & License Information +/* + * Copyright 2007-2010 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. For more information, + * see LICENSE. + */ +#endregion + +using System.Linq; +using OpenRA.Traits; + +namespace OpenRA.Mods.RA +{ + class InfiltrateForSupportPowerInfo : ITraitInfo + { + public readonly string Power = null; + public object Create(ActorInitializer init) { return new InfiltrateForSupportPower(this); } + } + + class InfiltrateForSupportPower : IAcceptSpy + { + InfiltrateForSupportPowerInfo info; + public InfiltrateForSupportPower(InfiltrateForSupportPowerInfo info) + { + this.info = info; + } + + public void OnInfiltrate(Actor self, Actor spy) + { + var p = spy.Owner.PlayerActor.TraitsImplementing() + .FirstOrDefault(sp => sp.GetType().Name == info.Power); + + if (p != null) p.Give(1); + } + } +} diff --git a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj index 46f79ccbfa..82bd858455 100644 --- a/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj +++ b/OpenRA.Mods.RA/OpenRA.Mods.RA.csproj @@ -153,7 +153,7 @@ - + diff --git a/mods/ra/structures.yaml b/mods/ra/structures.yaml index fd12b7fdf5..60cca68653 100644 --- a/mods/ra/structures.yaml +++ b/mods/ra/structures.yaml @@ -52,7 +52,8 @@ GAP: IronCurtainable: SPEN: - InfiltrateForSonarPulse: + InfiltrateForSupportPower: + Power: SonarPulsePower Inherits: ^Building Buildable: BuildPaletteOrder: 30 @@ -88,7 +89,8 @@ SPEN: RallyPoint: SYRD: - InfiltrateForSonarPulse: + InfiltrateForSupportPower: + Power: SonarPulsePower Inherits: ^Building Buildable: BuildPaletteOrder: 40