Some fixes to Cloak.IsVisible()
This commit is contained in:
@@ -123,14 +123,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (!Cloaked || self.Owner.IsAlliedWith(viewer))
|
||||
return true;
|
||||
|
||||
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;
|
||||
});
|
||||
return self.World.ActorsWithTrait<DetectCloaked>().Any(a => a.Actor.Owner.IsAlliedWith(viewer)
|
||||
&& Info.CloakTypes.Intersect(a.Trait.Info.CloakTypes).Any()
|
||||
&& (self.CenterPosition - a.Actor.CenterPosition).Length <= WRange.FromCells(a.Trait.Info.Range).Range);
|
||||
}
|
||||
|
||||
public Color RadarColorOverride(Actor self)
|
||||
|
||||
@@ -13,14 +13,24 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits
|
||||
{
|
||||
[Desc("Actor can reveal Cloak actors in a specified range.")]
|
||||
public class DetectCloakedInfo : TraitInfo<DetectCloaked>
|
||||
public class DetectCloakedInfo : ITraitInfo
|
||||
{
|
||||
[Desc("Specific cloak classifications I can reveal.")]
|
||||
public readonly string[] CloakTypes = { "Cloak" };
|
||||
|
||||
[Desc("Measured in cells.")]
|
||||
public readonly int Range = 5;
|
||||
|
||||
public object Create(ActorInitializer init) { return new DetectCloaked(this); }
|
||||
}
|
||||
|
||||
public class DetectCloaked { }
|
||||
public class DetectCloaked
|
||||
{
|
||||
public readonly DetectCloakedInfo Info;
|
||||
|
||||
public DetectCloaked(DetectCloakedInfo info)
|
||||
{
|
||||
Info = info;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
public virtual bool TargetableBy(Actor self, Actor viewer)
|
||||
{
|
||||
if (cloak == null || !cloak.Cloaked)
|
||||
if (cloak == null)
|
||||
return true;
|
||||
|
||||
return cloak.IsVisible(self, viewer.Owner);
|
||||
|
||||
Reference in New Issue
Block a user