make InfiltrateForSonarPulse work for any support power

This commit is contained in:
Chris Forbes
2010-08-24 17:35:38 +12:00
parent 18a06eb3bf
commit 79ced35010
5 changed files with 44 additions and 28 deletions

View File

@@ -15,7 +15,7 @@ namespace OpenRA.Mods.RA.Crates
{ {
class SupportPowerCrateActionInfo : CrateActionInfo class SupportPowerCrateActionInfo : CrateActionInfo
{ {
public string Power = null; public readonly string Power = null;
public override object Create(ActorInitializer init) { return new SupportPowerCrateAction(init.self, this); } public override object Create(ActorInitializer init) { return new SupportPowerCrateAction(init.self, this); }
} }

View File

@@ -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<InfiltrateForSonarPulse> { }
class InfiltrateForSonarPulse : IAcceptSpy
{
public void OnInfiltrate(Actor self, Actor spy)
{
spy.Owner.PlayerActor.Trait<SonarPulsePower>().Give(1.0f);
}
}
}

View File

@@ -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<SupportPower>()
.FirstOrDefault(sp => sp.GetType().Name == info.Power);
if (p != null) p.Give(1);
}
}
}

View File

@@ -153,7 +153,7 @@
<Compile Include="Effects\SatelliteLaunch.cs" /> <Compile Include="Effects\SatelliteLaunch.cs" />
<Compile Include="EngineerCapture.cs" /> <Compile Include="EngineerCapture.cs" />
<Compile Include="SupportPowers\GpsPower.cs" /> <Compile Include="SupportPowers\GpsPower.cs" />
<Compile Include="InfiltrateForSonarPulse.cs" /> <Compile Include="InfiltrateForSupportPower.cs" />
<Compile Include="IronCurtainable.cs" /> <Compile Include="IronCurtainable.cs" />
<Compile Include="SupportPowers\IronCurtainPower.cs" /> <Compile Include="SupportPowers\IronCurtainPower.cs" />
<Compile Include="PaletteFromFile.cs" /> <Compile Include="PaletteFromFile.cs" />

View File

@@ -52,7 +52,8 @@ GAP:
IronCurtainable: IronCurtainable:
SPEN: SPEN:
InfiltrateForSonarPulse: InfiltrateForSupportPower:
Power: SonarPulsePower
Inherits: ^Building Inherits: ^Building
Buildable: Buildable:
BuildPaletteOrder: 30 BuildPaletteOrder: 30
@@ -88,7 +89,8 @@ SPEN:
RallyPoint: RallyPoint:
SYRD: SYRD:
InfiltrateForSonarPulse: InfiltrateForSupportPower:
Power: SonarPulsePower
Inherits: ^Building Inherits: ^Building
Buildable: Buildable:
BuildPaletteOrder: 40 BuildPaletteOrder: 40