From cafd50ef4372faa5cf1967e1d3e7956e283d4fa0 Mon Sep 17 00:00:00 2001 From: reaperrr Date: Tue, 25 Oct 2016 15:56:12 +0200 Subject: [PATCH] Make RevealsShroud and CreatesShroud use stances Instead of hardcoded (!)IsAlliedWith checks. --- OpenRA.Mods.Common/Traits/CreatesShroud.cs | 15 ++++++++++++--- OpenRA.Mods.Common/Traits/RevealsShroud.cs | 15 ++++++++++++--- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/CreatesShroud.cs b/OpenRA.Mods.Common/Traits/CreatesShroud.cs index eb291a0243..4b6bb0af60 100644 --- a/OpenRA.Mods.Common/Traits/CreatesShroud.cs +++ b/OpenRA.Mods.Common/Traits/CreatesShroud.cs @@ -9,22 +9,31 @@ */ #endregion +using OpenRA.Traits; + namespace OpenRA.Mods.Common.Traits { public class CreatesShroudInfo : AffectsShroudInfo { + [Desc("Stance the watching player needs to see the generated shroud.")] + public readonly Stance ValidStances = Stance.Neutral | Stance.Enemy; + public override object Create(ActorInitializer init) { return new CreatesShroud(init.Self, this); } } public class CreatesShroud : AffectsShroud { + readonly CreatesShroudInfo info; + public CreatesShroud(Actor self, CreatesShroudInfo info) - : base(self, info) { } + : base(self, info) { this.info = info; } protected override void AddCellsToPlayerShroud(Actor self, Player p, PPos[] uv) { - if (!self.Owner.IsAlliedWith(p)) - p.Shroud.AddProjectedShroudGeneration(this, uv); + if (!info.ValidStances.HasStance(p.Stances[self.Owner])) + return; + + p.Shroud.AddProjectedShroudGeneration(this, uv); } protected override void RemoveCellsFromPlayerShroud(Actor self, Player p) { p.Shroud.RemoveShroudGeneration(this); } diff --git a/OpenRA.Mods.Common/Traits/RevealsShroud.cs b/OpenRA.Mods.Common/Traits/RevealsShroud.cs index 4d904dbe03..059e2d390c 100644 --- a/OpenRA.Mods.Common/Traits/RevealsShroud.cs +++ b/OpenRA.Mods.Common/Traits/RevealsShroud.cs @@ -9,22 +9,31 @@ */ #endregion +using OpenRA.Traits; + namespace OpenRA.Mods.Common.Traits { public class RevealsShroudInfo : AffectsShroudInfo { + [Desc("Stance the watching player needs to see the shroud removed.")] + public readonly Stance ValidStances = Stance.Ally; + public override object Create(ActorInitializer init) { return new RevealsShroud(init.Self, this); } } public class RevealsShroud : AffectsShroud { + readonly RevealsShroudInfo info; + public RevealsShroud(Actor self, RevealsShroudInfo info) - : base(self, info) { } + : base(self, info) { this.info = info; } protected override void AddCellsToPlayerShroud(Actor self, Player p, PPos[] uv) { - if (self.Owner.IsAlliedWith(p)) - p.Shroud.AddProjectedVisibility(this, uv); + if (!info.ValidStances.HasStance(p.Stances[self.Owner])) + return; + + p.Shroud.AddProjectedVisibility(this, uv); } protected override void RemoveCellsFromPlayerShroud(Actor self, Player p) { p.Shroud.RemoveVisibility(this); }