public bool CanBeSeen(MapPoint from, MapPoint to, bool throughEntities = false, WorldObject except = null) { if (from == null || to == null) { return(false); } if (from == to) { return(true); } var occupiedCells = new short[0]; if (!throughEntities) { occupiedCells = Objects.Where(x => x.BlockSight && x != except).Select(x => x.Cell.Id).ToArray(); } var line = new LineSet(from, to); return(!(from point in line.EnumerateValidPoints().Skip(1) where to.CellId != point.CellId let cell = Cells[point.CellId] where !cell.LineOfSight || !throughEntities && Array.IndexOf(occupiedCells, point.CellId) != -1 select point).Any()); }
public bool CanBeSeen(short from, short to, bool throughEntities = false) { if (from == to) { return(true); } var occupiedCells = new short[0]; if (!throughEntities) { occupiedCells = GetAllFighters(true).FindAll(x => x.BlockSight).Select(x => x.CellId).ToArray(); } var line = new LineSet(new MapPoint(from), new MapPoint(to)); var list = line.EnumerateValidPoints().Skip(1); return(!(from point in list where to != point.CellId let cell = point.CellId where !Map.LineOfSight(cell) || !throughEntities && Array.IndexOf(occupiedCells, point.CellId) != -1 select point).Any()); }