private Vector3 GetRoomEdgePoint(Room room, LayerPath p)
 {
     if (room is CircleRoom)
     {
         CircleRoom c = (CircleRoom)room;
         return(GenerationUtility.CircleLineIntersection(p.Start.Position, p.End.Position, c.Position, c.Radius));
     }
     else
     {
         Vector3       tl, tr, bl, br;
         RectangleRoom rect = (RectangleRoom)room;
         rect.BoxBounds(out tl, out tr, out bl, out br);
         return(GenerationUtility.BoxLineIntersection(p.Start.Position, p.End.Position, tl, tr, bl, br));
     }
 }
Esempio n. 2
0
        public void FillBox(Vector3 tl, Vector3 tr, Vector3 bl, Vector3 br)
        {
            if (this.Reserved)
            {
                return;
            }

            bool topLeft     = GenerationUtility.PointInBox(this.TopLeft.Position, tl, tr, bl, br);
            bool topRight    = GenerationUtility.PointInBox(this.TopRight.Position, tl, tr, bl, br);
            bool bottomLeft  = GenerationUtility.PointInBox(this.BottomLeft.Position, tl, tr, bl, br);
            bool bottomRight = GenerationUtility.PointInBox(this.BottomRight.Position, tl, tr, bl, br);

            if (topLeft)
            {
                this.TopLeft.Filled = true;
            }
            if (topRight)
            {
                this.TopRight.Filled = true;
            }
            if (bottomLeft)
            {
                this.BottomLeft.Filled = true;
            }
            if (bottomRight)
            {
                this.BottomRight.Filled = true;
            }

            if (topLeft || topRight || bottomLeft || bottomRight)
            {
                this.Filled = true;
            }

            if (!this.Filled)
            {
                return; // square is empty so work is done
            }
            if (GenerationUtility.CheckBoxLineIntersection(this.TopLeft.Position, this.TopRight.Position, tl, tr, bl, br))
            {
                this.Top.Filled = true;
                this.Top.SetPosition(
                    GenerationUtility.BoxLineIntersection(this.TopLeft.Position, this.TopRight.Position, tl, tr, bl, br));
            }

            if (GenerationUtility.CheckBoxLineIntersection(this.BottomLeft.Position, this.BottomRight.Position, tl, tr, bl, br))
            {
                this.Bottom.Filled = true;
                this.Bottom.SetPosition(
                    GenerationUtility.BoxLineIntersection(this.BottomLeft.Position, this.BottomRight.Position, tl, tr, bl, br));
            }

            if (GenerationUtility.CheckBoxLineIntersection(this.TopLeft.Position, this.BottomLeft.Position, tl, tr, bl, br))
            {
                this.Left.Filled = true;
                this.Left.SetPosition(
                    GenerationUtility.BoxLineIntersection(this.TopLeft.Position, this.BottomLeft.Position, tl, tr, bl, br));
            }

            if (GenerationUtility.CheckBoxLineIntersection(this.TopRight.Position, this.BottomRight.Position, tl, tr, bl, br))
            {
                this.Right.Filled = true;
                this.Right.SetPosition(
                    GenerationUtility.BoxLineIntersection(this.TopRight.Position, this.BottomRight.Position, tl, tr, bl, br));
            }
        }