diff --git a/OpenRA.Game/Traits/Targetable.cs b/OpenRA.Game/Traits/Targetable.cs index bff4a27307..ffd5a533a2 100644 --- a/OpenRA.Game/Traits/Targetable.cs +++ b/OpenRA.Game/Traits/Targetable.cs @@ -20,15 +20,15 @@ namespace OpenRA.Traits public virtual object Create( ActorInitializer init ) { return new Targetable(this); } } - public class Targetable : ITargetable + public class Targetable { - TargetableInfo Info; + protected TargetableInfo Info; public Targetable(TargetableInfo info) { Info = info; } - public string[] TargetTypes + public virtual string[] TargetTypes { get { return Info.TargetTypes;} } diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index ac4fbd1725..fd4613e248 100644 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -48,7 +48,6 @@ namespace OpenRA.Traits public interface IResolveOrder { void ResolveOrder(Actor self, Order order); } public interface IOrderCursor { string CursorForOrder(Actor self, Order order); } public interface IOrderVoice { string VoicePhraseForOrder(Actor self, Order order); } - public interface ITargetable { string[] TargetTypes { get; } } public interface INotifySold { void Selling( Actor self ); void Sold( Actor self ); } public interface INotifyDamage { void Damaged(Actor self, AttackInfo e); } diff --git a/OpenRA.Mods.RA/Combat.cs b/OpenRA.Mods.RA/Combat.cs index 2b02b2367c..9700bf0771 100755 --- a/OpenRA.Mods.RA/Combat.cs +++ b/OpenRA.Mods.RA/Combat.cs @@ -162,8 +162,8 @@ namespace OpenRA.Mods.RA } public static bool WeaponValidForTarget(WeaponInfo weapon, Actor target) - { - var targetable = target.TraitOrDefault(); + { + var targetable = target.TraitOrDefault(); if (targetable == null || !weapon.ValidTargets.Intersect(targetable.TargetTypes).Any()) return false; diff --git a/OpenRA.Mods.RA/TargetableAircraft.cs b/OpenRA.Mods.RA/TargetableAircraft.cs index a64693ad31..822190ca9e 100644 --- a/OpenRA.Mods.RA/TargetableAircraft.cs +++ b/OpenRA.Mods.RA/TargetableAircraft.cs @@ -15,25 +15,25 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - public class TargetableAircraftInfo : TargetableInfo + public class TargetableAircraftInfo : TargetableInfo, ITraitPrerequisite { public readonly string[] GroundedTargetTypes = { }; public override object Create(ActorInitializer init) { return new TargetableAircraft(init.self, this); } } - public class TargetableAircraft : ITargetable + public class TargetableAircraft : Targetable { - TargetableAircraftInfo Info; Aircraft Aircraft; public TargetableAircraft(Actor self, TargetableAircraftInfo info) + : base(info) { - Info = info; Aircraft = self.Trait(); } - public string[] TargetTypes + public override string[] TargetTypes { - get { return (Aircraft.Altitude > 0) ? Info.TargetTypes : Info.GroundedTargetTypes; } + get { return (Aircraft.Altitude > 0) ? ((TargetableAircraftInfo)Info).TargetTypes + : ((TargetableAircraftInfo)Info).GroundedTargetTypes; } } } } diff --git a/OpenRA.Mods.RA/TargetableCloaked.cs b/OpenRA.Mods.RA/TargetableCloaked.cs index f86a14471d..5e3461e50e 100644 --- a/OpenRA.Mods.RA/TargetableCloaked.cs +++ b/OpenRA.Mods.RA/TargetableCloaked.cs @@ -12,26 +12,25 @@ using OpenRA.Traits; namespace OpenRA.Mods.RA { - public class TargetableCloakedInfo : ITraitInfo, ITraitPrerequisite + public class TargetableCloakedInfo : TargetableInfo, ITraitPrerequisite { - public readonly string[] TargetTypes = {}; public readonly string[] CloakedTargetTypes = {}; - public object Create( ActorInitializer init ) { return new TargetableCloaked(init.self, this); } + public override object Create( ActorInitializer init ) { return new TargetableCloaked(init.self, this); } } - public class TargetableCloaked : ITargetable + public class TargetableCloaked : Targetable { - TargetableCloakedInfo Info; Cloak Cloak; public TargetableCloaked(Actor self, TargetableCloakedInfo info) + : base(info) { - Info = info; Cloak = self.Trait(); } - public string[] TargetTypes + public override string[] TargetTypes { - get { return (Cloak.Cloaked) ? Info.CloakedTargetTypes : Info.TargetTypes;} + get { return (Cloak.Cloaked) ? ((TargetableCloakedInfo)Info).CloakedTargetTypes + : ((TargetableCloakedInfo)Info).TargetTypes;} } } }