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

View File

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

View File

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