Add CloakTypes to prevent ships from detecting cloaked non-submarine units etc

This commit is contained in:
ScottNZ
2014-03-10 21:29:12 +13:00
parent 5df88cb186
commit 15019d5b06
3 changed files with 15 additions and 3 deletions

View File

@@ -29,6 +29,8 @@ namespace OpenRA.Mods.RA
public readonly string UncloakSound = null;
public readonly string Palette = "cloak";
public readonly string[] CloakTypes = { "Cloak" };
public object Create(ActorInitializer init) { return new Cloak(init.self, this); }
}
@@ -109,9 +111,14 @@ namespace OpenRA.Mods.RA
if (!Cloaked || self.Owner.IsAlliedWith(viewer))
return true;
var centerPosition = self.CenterPosition;
return self.World.ActorsWithTrait<DetectCloaked>().Any(a => a.Actor.Owner.IsAlliedWith(viewer) &&
(centerPosition - a.Actor.CenterPosition).Length < WRange.FromCells(a.Actor.Info.Traits.Get<DetectCloakedInfo>().Range).Range);
return self.World.ActorsWithTrait<DetectCloaked>().Any(a =>
{
var dc = a.Actor.Info.Traits.Get<DetectCloakedInfo>();
return a.Actor.Owner.IsAlliedWith(viewer)
&& Info.CloakTypes.Intersect(dc.CloakTypes).Any()
&& (self.CenterPosition - a.Actor.CenterPosition).Length <= WRange.FromCells(dc.Range).Range;
});
}
public Color RadarColorOverride(Actor self)

View File

@@ -14,6 +14,7 @@ namespace OpenRA.Mods.RA
{
class DetectCloakedInfo : TraitInfo<DetectCloaked>
{
public readonly string[] CloakTypes = { "Cloak" };
public readonly int Range = 5;
}

View File

@@ -26,6 +26,7 @@ SS:
CloakedTargetTypes: Underwater
RenderUnit:
Cloak:
CloakTypes: Underwater
InitialDelay: 0
CloakDelay: 50
CloakSound: subshow1.aud
@@ -71,6 +72,7 @@ MSUB:
TargetTypes: Ground, Water
CloakedTargetTypes: Underwater
Cloak:
CloakTypes: Underwater
InitialDelay: 0
CloakDelay: 100
CloakSound: subshow1.aud
@@ -131,6 +133,7 @@ DD:
IronCurtainable:
RepairableNear:
DetectCloaked:
CloakTypes: Underwater
Range: 4
RenderDetectionCircle:
@@ -265,6 +268,7 @@ PT:
IronCurtainable:
RepairableNear:
DetectCloaked:
CloakTypes: Underwater
Range: 4
RenderDetectionCircle: