public static bool IsEmpty(this LineChar @this) => @this.IsNone() || [email protected]() && [email protected]();
public override char GetChar(LineChar charCenter, LineChar charLeft, LineChar charTop, LineChar charRight, LineChar charBottom) { if (charCenter.IsEmpty()) { return('\0'); } // 0 connections if (charLeft.IsNone() && charTop.IsNone() && charRight.IsNone() && charBottom.IsNone()) { return(GetSimpleChar(charCenter, MapSimple)); } bool connectLeft = charCenter.IsHorizontal() && charLeft.IsHorizontal(); bool connectTop = charCenter.IsVertical() && charTop.IsVertical(); bool connectRight = charCenter.IsHorizontal() && charRight.IsHorizontal(); bool connectBottom = charCenter.IsVertical() && charBottom.IsVertical(); // 1 connection if ((connectLeft ? 1 : 0) + (connectTop ? 1 : 0) + (connectRight ? 1 : 0) + (connectBottom ? 1 : 0) <= 1) { return(GetSimpleChar(charCenter, MapSimple)); } // 4 connections if (connectLeft && connectTop && connectRight && connectBottom) { return(GetChar(charCenter, MapLeftTopRightBottom)); } // 3 connections if (connectLeft && connectTop && connectRight) { return(GetChar(charCenter, MapLeftTopRight)); } if (connectLeft && connectTop && connectBottom) { return(GetChar(charCenter, MapLeftTopBottom)); } if (connectLeft && connectRight && connectBottom) { return(GetChar(charCenter, MapLeftRightBottom)); } if (connectTop && connectRight && connectBottom) { return(GetChar(charCenter, MapTopRightBottom)); } // 2 connections if (connectTop && connectLeft) { return(GetChar(charCenter, MapTopLeft)); } if (connectTop && connectRight) { return(GetChar(charCenter, MapTopRight)); } if (connectBottom && connectRight) { return(GetChar(charCenter, MapBottomRight)); } if (connectBottom && connectLeft) { return(GetChar(charCenter, MapBottomLeft)); } if ((connectLeft && connectRight) || (connectTop && connectBottom)) { return(GetSimpleChar(charCenter, MapSimple)); } throw GetCharException(charCenter, charLeft, charTop, charRight, charBottom); }