diff --git a/OpenRA.Mods.RA/DemoTruck.cs b/OpenRA.Mods.RA/DemoTruck.cs index 0835c05c1d..c6540b800b 100644 --- a/OpenRA.Mods.RA/DemoTruck.cs +++ b/OpenRA.Mods.RA/DemoTruck.cs @@ -29,7 +29,7 @@ namespace OpenRA.Mods.RA { get { - yield return new TargetTypeOrderTargeter("DetonateAttack", "DetonateAttack", 5, "attack", true, false) { ForceAttack = false }; + yield return new TargetTypeOrderTargeter(new[] { "DetonateAttack" }, "DetonateAttack", 5, "attack", true, false) { ForceAttack = false }; yield return new DeployOrderTargeter("Detonate", 5); } } diff --git a/OpenRA.Mods.RA/Disguise.cs b/OpenRA.Mods.RA/Disguise.cs index 8c59a53be7..cf8c58374c 100644 --- a/OpenRA.Mods.RA/Disguise.cs +++ b/OpenRA.Mods.RA/Disguise.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.RA [Desc("Overrides the default ToolTip when this actor is disguised (aids in deceiving enemy players).")] class DisguiseToolTipInfo : TooltipInfo, Requires { - public override object Create (ActorInitializer init) { return new DisguiseToolTip(init.self, this); } + public override object Create(ActorInitializer init) { return new DisguiseToolTip(init.self, this); } } class DisguiseToolTip : IToolTip @@ -76,7 +76,7 @@ namespace OpenRA.Mods.RA { get { - yield return new TargetTypeOrderTargeter("Disguise", "Disguise", 7, "ability", true, true) { ForceAttack = false }; + yield return new TargetTypeOrderTargeter(new[] { "Disguise" }, "Disguise", 7, "ability", true, true) { ForceAttack = false }; } } @@ -135,6 +135,6 @@ namespace OpenRA.Mods.RA public void Attacking(Actor self, Target target, Armament a, Barrel barrel) { DisguiseAs(self, null); } } - class IgnoresDisguiseInfo : TraitInfo {} - class IgnoresDisguise {} + class IgnoresDisguiseInfo : TraitInfo { } + class IgnoresDisguise { } } \ No newline at end of file diff --git a/OpenRA.Mods.RA/InfiltrateForCash.cs b/OpenRA.Mods.RA/InfiltrateForCash.cs index ad6a109152..9fff6af29f 100644 --- a/OpenRA.Mods.RA/InfiltrateForCash.cs +++ b/OpenRA.Mods.RA/InfiltrateForCash.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 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, @@ -15,7 +15,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { [Desc("This structure can be infiltrated causing funds to be stolen.")] - class InfiltrateForCashInfo : ITraitInfo, Requires + class InfiltrateForCashInfo : ITraitInfo { public readonly int Percentage = 50; public readonly int Minimum = 500; @@ -26,7 +26,7 @@ namespace OpenRA.Mods.RA class InfiltrateForCash : IAcceptInfiltrator { - InfiltrateForCashInfo info; + readonly InfiltrateForCashInfo info; public InfiltrateForCash(InfiltrateForCashInfo info) { this.info = info; } diff --git a/OpenRA.Mods.RA/InfiltrateForExploration.cs b/OpenRA.Mods.RA/InfiltrateForExploration.cs index ca35243319..a8d0593720 100644 --- a/OpenRA.Mods.RA/InfiltrateForExploration.cs +++ b/OpenRA.Mods.RA/InfiltrateForExploration.cs @@ -12,7 +12,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class InfiltrateForExplorationInfo : TraitInfo, Requires { } + class InfiltrateForExplorationInfo : TraitInfo { } class InfiltrateForExploration : IAcceptInfiltrator { diff --git a/OpenRA.Mods.RA/InfiltrateForSupportPower.cs b/OpenRA.Mods.RA/InfiltrateForSupportPower.cs index fa7ba8ae1c..fbf3b9a96e 100644 --- a/OpenRA.Mods.RA/InfiltrateForSupportPower.cs +++ b/OpenRA.Mods.RA/InfiltrateForSupportPower.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2011 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 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, @@ -13,24 +13,25 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class InfiltrateForSupportPowerInfo : ITraitInfo, Requires + class InfiltrateForSupportPowerInfo : ITraitInfo { [ActorReference] public readonly string Proxy = null; + public object Create(ActorInitializer init) { return new InfiltrateForSupportPower(this); } } class InfiltrateForSupportPower : IAcceptInfiltrator { - InfiltrateForSupportPowerInfo Info; + readonly InfiltrateForSupportPowerInfo info; public InfiltrateForSupportPower(InfiltrateForSupportPowerInfo info) { - Info = info; + this.info = info; } public void OnInfiltrate(Actor self, Actor infiltrator) { - infiltrator.World.AddFrameEndTask(w => w.CreateActor(Info.Proxy, new TypeDictionary + infiltrator.World.AddFrameEndTask(w => w.CreateActor(info.Proxy, new TypeDictionary { new OwnerInit(infiltrator.Owner) })); diff --git a/OpenRA.Mods.RA/Infiltrates.cs b/OpenRA.Mods.RA/Infiltrates.cs index 7ff8330d77..efcefed314 100644 --- a/OpenRA.Mods.RA/Infiltrates.cs +++ b/OpenRA.Mods.RA/Infiltrates.cs @@ -1,6 +1,6 @@ #region Copyright & License Information /* - * Copyright 2007-2012 The OpenRA Developers (see AUTHORS) + * Copyright 2007-2014 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, @@ -17,31 +17,27 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - class InfiltratableInfo : TraitInfo - { - public string Type = null; - } - - class Infiltratable { } - class InfiltratesInfo : ITraitInfo { - public string[] Types = { "Cash", "SupportPower", "Exploration" }; + public readonly string[] Types = { }; public object Create(ActorInitializer init) { return new Infiltrates(this); } } - + class Infiltrates : IIssueOrder, IResolveOrder, IOrderVoice { - public readonly InfiltratesInfo Info; + readonly InfiltratesInfo info; public Infiltrates(InfiltratesInfo info) { - Info = info; + this.info = info; + } + + public IEnumerable Orders + { + get { yield return new TargetTypeOrderTargeter(info.Types, "Infiltrate", 7, "enter", true, false); } } - public IEnumerable Orders { get { yield return new InfiltratorOrderTargeter(Info.Types); } } - public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued) { if (order.OrderID != "Infiltrate") @@ -49,16 +45,18 @@ namespace OpenRA.Mods.RA if (target.Type == TargetType.FrozenActor) return new Order(order.OrderID, self, queued) { ExtraData = target.FrozenActor.ID }; - + return new Order(order.OrderID, self, queued) { TargetActor = target.Actor }; } - + bool IsValidOrder(Actor self, Order order) { // Not targeting an actor if (order.ExtraData == 0 && order.TargetActor == null) return false; + ActorInfo ai; + if (order.ExtraData != 0) { // Targeted an actor under the fog @@ -70,20 +68,21 @@ namespace OpenRA.Mods.RA if (frozen == null) return false; - var ii = frozen.Info.Traits.GetOrDefault(); - return ii != null && Info.Types.Contains(ii.Type); + ai = frozen.Info; } + else + ai = order.TargetActor.Info; - var i = order.TargetActor.Info.Traits.GetOrDefault(); - return i != null && Info.Types.Contains(i.Type); + var i = ai.Traits.GetOrDefault(); + return i != null && i.GetTargetTypes().Intersect(info.Types).Any(); } public string VoicePhraseForOrder(Actor self, Order order) { return order.OrderString == "Infiltrate" && IsValidOrder(self, order) - ? "Attack" : null; + ? "Attack" : null; } - + public void ResolveOrder(Actor self, Order order) { if (order.OrderString != "Infiltrate" || !IsValidOrder(self, order)) @@ -99,41 +98,5 @@ namespace OpenRA.Mods.RA self.SetTargetLine(target, Color.Red); self.QueueActivity(new Enter(target.Actor, new Infiltrate(target.Actor))); } - - class InfiltratorOrderTargeter : UnitOrderTargeter - { - string[] infiltrationTypes; - - public InfiltratorOrderTargeter(string[] infiltrationTypes) - : base("Infiltrate", 7, "enter", true, false) - { - ForceAttack = false; - this.infiltrationTypes = infiltrationTypes; - } - - public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) - { - var info = target.Info.Traits.GetOrDefault(); - if (info == null) - return false; - - if (!infiltrationTypes.Contains(info.Type)) - cursor = "enter-blocked"; - - return true; - } - - public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor) - { - var info = target.Info.Traits.GetOrDefault(); - if (info == null) - return false; - - if (!infiltrationTypes.Contains(info.Type)) - cursor = "enter-blocked"; - - return true; - } - } } } diff --git a/OpenRA.Mods.RA/MadTank.cs b/OpenRA.Mods.RA/MadTank.cs index 8de684e6c8..b33e64e0e0 100644 --- a/OpenRA.Mods.RA/MadTank.cs +++ b/OpenRA.Mods.RA/MadTank.cs @@ -78,7 +78,7 @@ namespace OpenRA.Mods.RA { get { - yield return new TargetTypeOrderTargeter("DetonateAttack", "DetonateAttack", 5, "attack", true, false) { ForceAttack = false }; + yield return new TargetTypeOrderTargeter(new[] { "DetonateAttack" }, "DetonateAttack", 5, "attack", true, false) { ForceAttack = false }; yield return new DeployOrderTargeter("Detonate", 5); } } diff --git a/OpenRA.Mods.RA/Orders/UnitOrderTargeter.cs b/OpenRA.Mods.RA/Orders/UnitOrderTargeter.cs index 659e0dfe84..fc13a7141e 100755 --- a/OpenRA.Mods.RA/Orders/UnitOrderTargeter.cs +++ b/OpenRA.Mods.RA/Orders/UnitOrderTargeter.cs @@ -66,22 +66,22 @@ namespace OpenRA.Mods.RA.Orders public class TargetTypeOrderTargeter : UnitOrderTargeter { - string targetType; + readonly string[] targetTypes; - public TargetTypeOrderTargeter(string targetType, string order, int priority, string cursor, bool targetEnemyUnits, bool targetAllyUnits) + public TargetTypeOrderTargeter(string[] targetTypes, string order, int priority, string cursor, bool targetEnemyUnits, bool targetAllyUnits) : base(order, priority, cursor, targetEnemyUnits, targetAllyUnits) { - this.targetType = targetType; + this.targetTypes = targetTypes; } public override bool CanTargetActor(Actor self, Actor target, TargetModifiers modifiers, ref string cursor) { - return target.TraitsImplementing().Any(t => t.TargetTypes.Contains(targetType)); + return target.TraitsImplementing().Any(t => t.TargetTypes.Intersect(targetTypes).Any()); } public override bool CanTargetFrozenActor(Actor self, FrozenActor target, TargetModifiers modifiers, ref string cursor) { - return target.Info.Traits.WithInterface().Any(t => t.GetTargetTypes().Contains(targetType)); + return target.Info.Traits.WithInterface().Any(t => t.GetTargetTypes().Intersect(targetTypes).Any()); } } } diff --git a/mods/ra/rules/infantry.yaml b/mods/ra/rules/infantry.yaml index 16987d1b30..f1acd4ae88 100644 --- a/mods/ra/rules/infantry.yaml +++ b/mods/ra/rules/infantry.yaml @@ -226,7 +226,7 @@ SPY: TakeCover: Disguise: Infiltrates: - Types: Cash, SupportPower, Exploration + Types: SpyInfiltrate -AutoTarget: -RenderInfantry: RenderDisguise: diff --git a/mods/ra/rules/structures.yaml b/mods/ra/rules/structures.yaml index f80f07fecf..7656a2388d 100644 --- a/mods/ra/rules/structures.yaml +++ b/mods/ra/rules/structures.yaml @@ -81,8 +81,6 @@ GAP: SPEN: Inherits: ^Building - Infiltratable: - Type: SupportPower InfiltrateForSupportPower: Proxy: powerproxy.sonarpulse Valued: @@ -96,7 +94,7 @@ SPEN: Prerequisites: anypower, ~structures.soviet, ~techlevel.low Hotkey: y TargetableBuilding: - TargetTypes: Ground, Water + TargetTypes: Ground, Water, C4, DetonateAttack, SpyInfiltrate Building: Power: -30 Footprint: xxx xxx xxx @@ -137,8 +135,6 @@ SPEN: SYRD: Inherits: ^Building - Infiltratable: - Type: SupportPower InfiltrateForSupportPower: Proxy: powerproxy.sonarpulse Buildable: @@ -152,7 +148,7 @@ SYRD: Name: Shipyard Description: Produces and repairs ships\nand transports. TargetableBuilding: - TargetTypes: Ground, Water + TargetTypes: Ground, Water, C4, DetonateAttack, SpyInfiltrate Building: Power: -30 Footprint: xxx xxx xxx @@ -384,6 +380,8 @@ DOME: Power: -40 Footprint: xx xx Dimensions: 2,2 + TargetableBuilding: + TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate RequiresPower: CanPowerDown: DisabledOverlay: @@ -396,8 +394,6 @@ DOME: Bib: ProvidesRadar: IronCurtainable: - Infiltratable: - Type: Exploration InfiltrateForExploration: DetectCloaked: Range: 10 @@ -768,6 +764,8 @@ PROC: Power: -30 Footprint: _x_ xxx x== Dimensions: 3,3 + TargetableBuilding: + TargetTypes: Ground, C4, DetonateAttack, SpyInfiltrate Health: HP: 900 Armor: @@ -788,8 +786,6 @@ PROC: InitialActivity: FindResources SpawnOffset: 1,2 Facing: 64 - Infiltratable: - Type: Cash InfiltrateForCash: Percentage: 50 Minimum: 500 diff --git a/mods/ts/rules/infantry.yaml b/mods/ts/rules/infantry.yaml index 830b3637a4..584bd57640 100644 --- a/mods/ts/rules/infantry.yaml +++ b/mods/ts/rules/infantry.yaml @@ -298,7 +298,7 @@ CHAMSPY: TakeCover: Disguise: Infiltrates: - Types: Cash, SupportPower, Exploration + Types: SpyInfiltrate -AutoTarget: -RenderInfantry: RenderDisguise: diff --git a/mods/ts/rules/structures.yaml b/mods/ts/rules/structures.yaml index 6cd3ee7ffa..f98f2af529 100644 --- a/mods/ts/rules/structures.yaml +++ b/mods/ts/rules/structures.yaml @@ -623,8 +623,6 @@ GARADR: RequiresPower: CanPowerDown: ProvidesRadar: - Infiltratable: - Type: Exploration InfiltrateForExploration: DetectCloaked: Range: 10 @@ -634,6 +632,8 @@ GARADR: WithIdleOverlay@DISH: Sequence: idle-dish PauseOnLowPower: yes + TargetableBuilding: + TargetTypes: Ground, C4, SpyInfiltrate NARADR: Inherits: ^Building @@ -661,8 +661,6 @@ NARADR: RequiresPower: CanPowerDown: ProvidesRadar: - Infiltratable: - Type: Exploration InfiltrateForExploration: DetectCloaked: Range: 10 @@ -672,6 +670,8 @@ NARADR: WithIdleOverlay@DISH: Sequence: idle-dish PauseOnLowPower: yes + TargetableBuilding: + TargetTypes: Ground, C4, SpyInfiltrate GATECH: Inherits: ^Building