public override SpaceBuilder Align(IntVector2 direction, int amount) { if (direction == Directions.Up) { _leftEnd.Y = amount - _height; _center.Y = amount - _height; _rightEnd.Y = amount - _height; } else if (direction == Directions.Right) { _rightEnd.X = amount; _alignment = CorridorAlignment.StartFromRight; // We have to enforce this boundary } else if (direction == Directions.Down) { _leftEnd.Y = amount; _center.Y = amount; _rightEnd.Y = amount; } else if (direction == Directions.Left) { _leftEnd.X = Mathf.Max(_leftEnd.X, amount); _alignment = CorridorAlignment.StartFromLeft; // We have to enforce this boundary } else { throw new System.ArgumentException($" Expected a cardinal direction. Cannot operate on {direction}."); } Rebuild(); return(this); }
public CorridorBuilder SetStartingPoint(IntVector2 startingPoint, CorridorAlignment alignment) { switch (alignment) { case CorridorAlignment.StartFromLeft: _leftEnd = startingPoint; break; case CorridorAlignment.StartFromCenter: _center = startingPoint; break; case CorridorAlignment.StartFromRight: _rightEnd = startingPoint; break; } _alignment = alignment; Rebuild(); return(this); }