From 624ea81c3a48e4a6d7ccb41df4d5f901df3a9af0 Mon Sep 17 00:00:00 2001 From: Mustafa Alperen Seki Date: Wed, 5 Sep 2018 15:37:50 +0300 Subject: [PATCH] Add logic to reveal cloaked units, when they are only units left. I'm not sure about IPositionable check but that was the easiest way to get it ignore upgrades, generals powers and player actor. --- OpenRA.Mods.Common/Traits/Cloak.cs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/Cloak.cs b/OpenRA.Mods.Common/Traits/Cloak.cs index d83a46ba25ff..920db1656af3 100644 --- a/OpenRA.Mods.Common/Traits/Cloak.cs +++ b/OpenRA.Mods.Common/Traits/Cloak.cs @@ -58,6 +58,9 @@ public class CloakInfo : ConditionalTraitInfo [GrantedConditionReference] [Desc("The condition to grant to self while cloaked.")] public readonly string CloakedCondition = null; + + [Desc("This units uncloaks if only units of the player are cloakable.")] + public readonly bool UncloakWhenAlone = true; public override object Create(ActorInitializer init) { return new Cloak(this); } } @@ -187,6 +190,9 @@ public bool IsVisible(Actor self, Player viewer) if (!Cloaked || self.Owner.IsAlliedWith(viewer)) return true; + if ((Info.UncloakWhenAlone && !self.World.Actors.Where(a => a.Owner == self.Owner && a.IsInWorld && a.TraitsImplementing().Any() && !a.TraitsImplementing().Where(t => !t.IsTraitDisabled).Any()).Any())) + return true; + return self.World.ActorsWithTrait().Any(a => !a.Trait.IsTraitDisabled && a.Actor.Owner.IsAlliedWith(viewer) && Info.CloakTypes.Overlaps(a.Trait.Info.CloakTypes) && (self.CenterPosition - a.Actor.CenterPosition).LengthSquared <= a.Trait.Info.Range.LengthSquared);