fixed bug where cloakable units were not targetable when uncloaked. removed ITargetable interface in favor of using the Targetable trait. fixed warnings in child classes of Targetable.

This commit is contained in:
pdovy
2010-10-10 23:09:17 -05:00
committed by Chris Forbes
parent a904047a16
commit e883e63c87
5 changed files with 18 additions and 20 deletions

View File

@@ -162,8 +162,8 @@ namespace OpenRA.Mods.RA
}
public static bool WeaponValidForTarget(WeaponInfo weapon, Actor target)
{
var targetable = target.TraitOrDefault<ITargetable>();
{
var targetable = target.TraitOrDefault<Targetable>();
if (targetable == null || !weapon.ValidTargets.Intersect(targetable.TargetTypes).Any())
return false;

View File

@@ -15,25 +15,25 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
public class TargetableAircraftInfo : TargetableInfo
public class TargetableAircraftInfo : TargetableInfo, ITraitPrerequisite<AircraftInfo>
{
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<Aircraft>();
}
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; }
}
}
}

View File

@@ -12,26 +12,25 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA
{
public class TargetableCloakedInfo : ITraitInfo, ITraitPrerequisite<CloakInfo>
public class TargetableCloakedInfo : TargetableInfo, ITraitPrerequisite<CloakInfo>
{
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<Cloak>();
}
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;}
}
}
}