示例#1
0
        public void CopyFrom(EmberCell cell)
        {
            // Does foreground, background, glyph, mirror, decorators
            CopyAppearanceFrom(cell);

            ForegroundFov    = cell.ForegroundFov;
            IsVisible        = cell.IsVisible;
            Name             = cell.Name;
            NormalForeground = cell.NormalForeground;
            Position         = cell.Position;
            Walkable         = cell.Walkable;
            BlocksFov        = cell.BlocksFov;
        }
示例#2
0
        public EmberCell[] GetNeighbors(EmberCell cell)
        {
            int x = cell.Position.X;
            int y = cell.Position.Y;

            var points = new List <Point>();

            if (!InBounds(x, y))
            {
                return(Array.Empty <EmberCell>());
            }

            if (InBounds(x + 1, y))
            {
                points.Add(new Point(x + 1, y));
            }
            if (InBounds(x - 1, y))
            {
                points.Add(new Point(x - 1, y));
            }
            if (InBounds(x, y + 1))
            {
                points.Add(new Point(x, y + 1));
            }
            if (InBounds(x, y - 1))
            {
                points.Add(new Point(x, y - 1));
            }
            if (InBounds(x + 1, y + 1))
            {
                points.Add(new Point(x + 1, y + 1));
            }
            if (InBounds(x - 1, y - 1))
            {
                points.Add(new Point(x - 1, y - 1));
            }
            if (InBounds(x + 1, y - 1))
            {
                points.Add(new Point(x + 1, y - 1));
            }
            if (InBounds(x - 1, y + 1))
            {
                points.Add(new Point(x - 1, y + 1));
            }

            return(points.Select(a => GetCell(a)).ToArray());
        }
示例#3
0
        public new EmberCell Clone()
        {
            var cell = new EmberCell()
            {
                ForegroundFov    = this.ForegroundFov,
                IsVisible        = this.IsVisible,
                Name             = this.Name,
                NormalForeground = this.NormalForeground,
                Position         = this.Position,
                Walkable         = this.Walkable,
                BlocksFov        = this.BlocksFov
            };

            // Does foreground, background, glyph, mirror, decorators
            CopyAppearanceTo(cell);
            return(cell);
        }
示例#4
0
        public void SetCell(EmberCell cell, bool calculateEntitiesFov = false)
        {
            var originalCell = Cells[cell.Position.Y * GridSizeX + cell.Position.X];

            // Update the map fov values if the walkable is changed
            bool updateFieldOfView = originalCell.BlocksFov != cell.BlocksFov;

            // Copy the new cell data
            originalCell.CopyFrom(cell);

            if (updateFieldOfView)
            {
                UpdateFieldOfView(cell.Position.X, cell.Position.Y);

                if (calculateEntitiesFov)
                {
                    // Recalculate the fov of all entities
                    EntityManager.RecalculatFieldOfView();
                }
            }
        }