//Hallway Segments are equal, if their positions are equal
    public override bool Equals(object obj)
    {
        if (obj == null)
        {
            return(false);
        }
        if (ReferenceEquals(this, obj))
        {
            return(true);
        }
        if (obj.GetType() != typeof(HallwaySegment))
        {
            return(false);
        }
        HallwaySegment other = (HallwaySegment)obj;

        return(center == other.center);
    }
 private void PrepareHallwaySegments(bool searchForAdjacents)
 {
     foreach (List <Square> squares in hallwayPaths)
     {
         foreach (Square square in squares)
         {
             GridPosition gridPosition = grid.Grid [square.GridX, square.GridY];
             if (searchForAdjacents)
             {
                 SearchForIndirectAdjacents(gridPosition);
             }
             HallwaySegment newSegment = new HallwaySegment(gridPosition);
             if (!hallwaySegments.Contains(newSegment))
             {
                 hallwaySegments.Add(newSegment);
             }
         }
     }
 }