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; }
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()); }
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); }
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(); } } }