allow AppearsOnRadar to use Location rather than OccupiedCells, for things that don't occupy any cells

This commit is contained in:
Chris Forbes
2010-10-11 18:54:13 +13:00
parent a2205e9031
commit 9c0e3ac4c9
3 changed files with 21 additions and 5 deletions

View File

@@ -15,17 +15,30 @@ using OpenRA.Traits;
namespace OpenRA.Mods.RA namespace OpenRA.Mods.RA
{ {
public class AppearsOnRadarInfo : TraitInfo<AppearsOnRadar> {} public class AppearsOnRadarInfo : TraitInfo<AppearsOnRadar>
{
public readonly bool UseLocation = false;
}
public class AppearsOnRadar : IRadarSignature public class AppearsOnRadar : IRadarSignature
{ {
AppearsOnRadarInfo info;
IOccupySpace Space; IOccupySpace Space;
public IEnumerable<int2> RadarSignatureCells(Actor self) public IEnumerable<int2> RadarSignatureCells(Actor self)
{
if (info == null)
info = self.Info.Traits.Get<AppearsOnRadarInfo>();
if (info.UseLocation)
return new int2[] { self.Location };
else
{ {
if (Space == null) if (Space == null)
Space = self.Trait<IOccupySpace>(); Space = self.Trait<IOccupySpace>();
return Space.OccupiedCells(); return Space.OccupiedCells();
} }
}
public Color RadarSignatureColor(Actor self) public Color RadarSignatureColor(Actor self)
{ {

View File

@@ -58,6 +58,7 @@
^Helicopter: ^Helicopter:
AppearsOnRadar: AppearsOnRadar:
UseLocation: yes
Targetable: Targetable:
TargetTypes: Air TargetTypes: Air
Selectable: Selectable:
@@ -135,6 +136,7 @@
^Plane: ^Plane:
AppearsOnRadar: AppearsOnRadar:
UseLocation: yes
Selectable: Selectable:
Voice: GenericVoice Voice: GenericVoice
Targetable: Targetable:

View File

@@ -104,6 +104,7 @@
^Plane: ^Plane:
AppearsOnRadar: AppearsOnRadar:
UseLocation: yes
Selectable: Selectable:
Voice: GenericVoice Voice: GenericVoice
TargetableAircraft: TargetableAircraft: