From 83a40e5039dc0cc2e78721fe9d9af0abd43bb417 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 29 Mar 2010 19:25:28 +1300 Subject: [PATCH] RemoveActor impl in Shroud trait --- OpenRA.Game/Traits/World/Shroud.cs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/OpenRA.Game/Traits/World/Shroud.cs b/OpenRA.Game/Traits/World/Shroud.cs index e15ab3908a..8db62c4abb 100644 --- a/OpenRA.Game/Traits/World/Shroud.cs +++ b/OpenRA.Game/Traits/World/Shroud.cs @@ -32,6 +32,7 @@ namespace OpenRA.Traits { Map map; int[,] visibleCells; + Dictionary vis = new Dictionary(); public Shroud(Actor self, ShroudInfo info) { @@ -44,11 +45,25 @@ namespace OpenRA.Traits class ActorVisibility { - int range; - int2[] vis; + public int range; + public int2[] vis; } - void AddActor(Actor a) { } - void RemoveActor(Actor a) { } + void AddActor(Actor a) + { + if (a.Owner != a.Owner.World.LocalPlayer) return; + } + + void RemoveActor(Actor a) + { + ActorVisibility v; + if (!vis.TryGetValue(a, out v)) return; + + foreach (var p in v.vis) + foreach (var q in a.World.FindTilesInCircle(p, v.range)) + --visibleCells[q.X, q.Y]; + + vis.Remove(a); + } } }