public static int MinimumFloor(IBuilding building, IVolume inPlan, int pointIndex) { int output = 0; int subjectActualBaseFloor = building.VolumeBaseFloor(inPlan); int subjectActualTopFloor = subjectActualBaseFloor + inPlan.floors; int pointIndexB = (pointIndex + 1) % inPlan.numberOfPoints; Vector2Int p0 = inPlan[pointIndex].position; Vector2Int p1 = inPlan[pointIndexB].position; List <IVolume> aboveVolumeList = building.AllAboveVolumes(inPlan); int volumeCount = building.numberOfVolumes; for (int f = 0; f < volumeCount; f++) { IVolume volume = building[f]; // if(inPlan == volume) continue; int actualBaseFloor = building.VolumeBaseFloor(volume); int actualTopFloor = actualBaseFloor + volume.floors; if (!(subjectActualBaseFloor < actualTopFloor && subjectActualTopFloor > actualBaseFloor)) { continue; //volumes don't affect each other } // if(volume.abovePlans.Contains(inPlan)) continue; if (aboveVolumeList.Contains(volume)) { continue; //this volume is connected above the subject and cannot effect a facade } if (inPlan.AbovePlanList().Contains(volume)) { continue; //this volume is connected above the subject and cannot effect a facade } if (building.AllAboveVolumes(volume).Contains(inPlan)) { continue; //this volume is connected below the subject and cannot effect } // if (building.AllAboveVolumes(inPlan).Contains(volume)) continue;//this volume is connected below the subject and cannot effect // if(inPlan.abovePlans.Contains(volume)) continue; int pointCount = volume.numberOfPoints; for (int p = 0; p < pointCount; p++) { if (volume == inPlan && p == pointIndex)//self connecting plans need to cut off facades { continue; } Vector2Int pB0 = volume[p].position; if (pB0 != p0 && pB0 != p1) { continue; } int pB = (p + 1) % volume.numberOfPoints; Vector2Int pB1 = volume[pB].position; if (pB1 != p0 && pB1 != p1) { continue; } if (output == 0) { output = volume.floors; } else { output = Mathf.Min(volume.floors, output); } } } return(output); }