public IQPathTileScript[] GetNeighbours() { if (this.neighbours != null) { return(this.neighbours); } List <HexScript> neighbours = new List <HexScript>(); neighbours.Add(HexMap.GetHexAt(C + 1, R + 0)); neighbours.Add(HexMap.GetHexAt(C + -1, R + 0)); neighbours.Add(HexMap.GetHexAt(C + 0, R + +1)); neighbours.Add(HexMap.GetHexAt(C + 0, R + -1)); neighbours.Add(HexMap.GetHexAt(C + +1, R + -1)); neighbours.Add(HexMap.GetHexAt(C + -1, R + +1)); List <HexScript> neighbours2 = new List <HexScript>(); // This is an alternative to the code below // this.neighbours = neighbours.Where(hex => hex != null).ToArray(); foreach (HexScript h in neighbours) { if (h != null) { neighbours2.Add(h); } } this.neighbours = neighbours2.ToArray(); return(this.neighbours); }