Exemple #1
0
        public void HideActor(Actor a, int range)
        {
            if (a.Owner.World.LocalPlayer == null ||
                a.Owner.Stances[a.Owner.World.LocalPlayer] == Stance.Ally)
            {
                return;
            }

            var v = new ActorVisibility
            {
                vis = GetVisOrigins(a).ToArray()
            };

            foreach (var p in v.vis)
            {
                foreach (var q in FindVisibleTiles(a.World, p, range))
                {
                    exploredCells[q.X, q.Y] = visibleCells[q.X, q.Y] > 0;
                }
            }

            if (!Disabled)
            {
                Dirty();
            }
        }
Exemple #2
0
        public void AddActor(Actor a)
        {
            if (!a.HasTrait <RevealsShroud>() || !a.Owner.IsAlliedWith(self.Owner))
            {
                return;
            }

            ActorVisibility v = a.Sight;

            if (v.range == 0)
            {
                return;
            }

            foreach (var p in v.vis)
            {
                foreach (var q in FindVisibleTiles(a.World, p, v.range))
                {
                    ++visibleCells[q.X, q.Y];
                    exploredCells[q.X, q.Y] = true;
                    foggedCells[q.X, q.Y]   = true;
                }

                var box = new Rectangle(p.X - v.range, p.Y - v.range, 2 * v.range + 1, 2 * v.range + 1);
                ExploredBounds = Rectangle.Union(ExploredBounds, box);
            }

            Invalidate();
        }
Exemple #3
0
        public void RemoveActor(Actor a)
        {
            ActorVisibility v = a.Sight;

            if (!a.Owner.IsAlliedWith(self.Owner))
            {
                if (a.HasTrait <CreatesShroud>())
                {
                    foreach (var p in v.vis)
                    {
                        foreach (var q in FindVisibleTiles(a.World, p, v.range))
                        {
                            foggedCells[q.X, q.Y] = exploredCells[q.X, q.Y];
                        }
                    }
                }
                return;
            }

            if (!a.HasTrait <RevealsShroud>())
            {
                return;
            }

            foreach (var p in v.vis)
            {
                foreach (var q in FindVisibleTiles(a.World, p, v.range))
                {
                    --visibleCells[q.X, q.Y];
                }
            }

            Invalidate();
        }
Exemple #4
0
        void AddActor(Actor a)
        {
            if (!a.HasTrait <RevealsShroud>())
            {
                return;
            }

            if (a.Owner.World.LocalPlayer == null ||
                a.Owner.Stances[a.Owner.World.LocalPlayer] != Stance.Ally)
            {
                return;
            }

            if (vis.ContainsKey(a))
            {
                Game.Debug("Warning: Actor {0}:{1} at {2} bad vis".F(a.Info.Name, a.ActorID, a.Location));
                RemoveActor(a);
            }

            var v = new ActorVisibility
            {
                range = a.Trait <RevealsShroud>().RevealRange,
                vis   = GetVisOrigins(a).ToArray()
            };

            if (v.range == 0)
            {
                return;                                         // don't bother for things that can't see
            }
            foreach (var p in v.vis)
            {
                foreach (var q in FindVisibleTiles(a.World, p, v.range))
                {
                    ++visibleCells[q.X, q.Y];
                    exploredCells[q.X, q.Y] = true;
                }

                var box = new Rectangle(p.X - v.range, p.Y - v.range, 2 * v.range + 1, 2 * v.range + 1);
                exploredBounds = (exploredBounds.HasValue) ? Rectangle.Union(exploredBounds.Value, box) : box;
            }

            vis[a] = v;

            if (!Disabled)
            {
                Dirty();
            }
        }
Exemple #5
0
        public void UnhideActor(Actor a, ActorVisibility v, int range)
        {
            if (a.Owner.IsAlliedWith(self.Owner) || v == null)
            {
                return;
            }

            foreach (var p in v.vis)
            {
                foreach (var q in FindVisibleTiles(a.World, p, range))
                {
                    foggedCells[q.X, q.Y] = exploredCells[q.X, q.Y];
                }
            }

            Invalidate();
        }
Exemple #6
0
        public void HideActor(Actor a, int range)
        {
            if (a.Owner.IsAlliedWith(self.Owner))
            {
                return;
            }

            var v = new ActorVisibility
            {
                vis = GetVisOrigins(a).ToArray()
            };

            foreach (var p in v.vis)
            {
                foreach (var q in FindVisibleTiles(a.World, p, range))
                {
                    foggedCells[q.X, q.Y] = visibleCells[q.X, q.Y] > 0;
                }
            }

            Invalidate();
        }
Exemple #7
0
		public void HideActor(Actor a, int range)
		{
			if (a.Owner.World.LocalPlayer == null
				|| a.Owner.Stances[a.Owner.World.LocalPlayer] == Stance.Ally) return;

			var v = new ActorVisibility
			{
				vis = GetVisOrigins(a).ToArray()
			};

			foreach (var p in v.vis)
				foreach (var q in FindVisibleTiles(a.World, p, range))
					exploredCells[q.X, q.Y] = visibleCells[q.X, q.Y] > 0;

			if (!Disabled)
				Dirty();
		}
Exemple #8
0
        public void UnhideActor(Actor a, ActorVisibility v, int range)
        {
            if (a.Owner.IsAlliedWith(self.Owner) || v == null)
                return;

             		foreach (var p in v.vis)
                foreach (var q in FindVisibleTiles(a.World, p, range))
                    foggedCells[q.X, q.Y] = exploredCells[q.X, q.Y];

            Invalidate();
        }
Exemple #9
0
        public void HideActor(Actor a, int range)
        {
            if (a.Owner.IsAlliedWith(self.Owner))
                return;

            var v = new ActorVisibility
            {
                vis = GetVisOrigins(a).ToArray()
            };

            foreach (var p in v.vis)
                foreach (var q in FindVisibleTiles(a.World, p, range))
                    foggedCells[q.X, q.Y] = visibleCells[q.X, q.Y] > 0;

            Invalidate();
        }
Exemple #10
0
		public void UnhideActor(Actor a, ActorVisibility v, int range) {
	 		if (a.Owner.World.LocalPlayer == null
				|| a.Owner.Stances[a.Owner.World.LocalPlayer] == Stance.Ally) return;

			if (v == null)
				return;

	 		foreach (var p in v.vis)
				foreach (var q in FindVisibleTiles(a.World, p, range))
					foggedCells[q.X, q.Y] = exploredCells[q.X, q.Y];

	 		if (!Disabled)
				Dirty();
		}