From 8206c3c45320b44738a95cebaf2d128080c49cc7 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 14 Jun 2015 14:12:22 +0100 Subject: [PATCH] Enable VisibilityType for shroud revealing. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit VisibilityType.Footprint reveals from each footprint cell. VisibilityType.CenterPosition reveals from the actor’s CenterPosition only (as the original games did). --- OpenRA.Game/Traits/World/Shroud.cs | 15 --------------- OpenRA.Mods.Common/Traits/RevealsShroud.cs | 14 +++++++++++--- 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index 473a1731b4..b9abb70567 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -183,21 +183,6 @@ namespace OpenRA.Traits } } - // TODO: Actor vis will be split into separate cases for - // "cells that I reveal from" and "cells that reveal me" - public static IEnumerable GetVisOrigins(Actor a) - { - var ios = a.OccupiesSpace; - if (ios != null) - { - var cells = ios.OccupiedCells(); - if (cells.Any()) - return cells.Select(c => c.First); - } - - return new[] { a.World.Map.CellContaining(a.CenterPosition) }; - } - public void Explore(World world, IEnumerable cells) { var changed = new HashSet(); diff --git a/OpenRA.Mods.Common/Traits/RevealsShroud.cs b/OpenRA.Mods.Common/Traits/RevealsShroud.cs index 0c5ba61cf0..1994bb3c49 100644 --- a/OpenRA.Mods.Common/Traits/RevealsShroud.cs +++ b/OpenRA.Mods.Common/Traits/RevealsShroud.cs @@ -18,6 +18,10 @@ namespace OpenRA.Mods.Common.Traits { public readonly WRange Range = WRange.Zero; + [Desc("Possible values are CenterPosition (measure range from the center) and ", + "Footprint (measure range from the footprint)")] + public readonly VisibilityType Type = VisibilityType.Footprint; + public virtual object Create(ActorInitializer init) { return new RevealsShroud(init.Self, this); } } @@ -51,9 +55,13 @@ namespace OpenRA.Mods.Common.Traits if (range == WRange.Zero) return NoCells; - return Shroud.GetVisOrigins(self) - .SelectMany(c => Shroud.CellsInRange(map, c, range)) - .Distinct().ToArray(); + if (info.Type == VisibilityType.Footprint) + return self.OccupiesSpace.OccupiedCells() + .SelectMany(kv => Shroud.CellsInRange(map, kv.First, range)) + .Distinct().ToArray(); + + return Shroud.CellsInRange(map, self.CenterPosition, range) + .ToArray(); } public void Tick(Actor self)