-- Each vert has a position and a list of rooms attached to it. -- The position of a vert is either a final_position or a list of suggested_positions. -- Each rendered room has a list of the verts that shape it, indexed by which corner the vert is. -- 1. Start with the central vertex as the one at the top left of center_room. It has final_position set. -- 2. Find all rooms that share it, in order. -- 3. Add adjacent verts equally spaced in a circle around it, attached to the rooms that use them. -- If multiple adjacent verts have final_position set, verts between them are apaced along the arc between. -- If only one adjacent vert has final_position set, it is treated as the beginning and end of the arc. -- If no adjacent vert has final_position set (should only occur for first vert), the arc starts at -y, -- because we start with the top_left corner. -- Positions added to verts are added to the list of suggested_positions. -- 4. Repeat 2 and 3 for all verts that have final_position set that have not already been processed. -- 5. Calculate final_position for all verts that do not have it set by averaging all suggested_positions. -- 6. If the calculated final_position is greater than room_width * 2 distance from any suggested_positions, mark -- the room as having unsettable_final_position. Otherwise, set final_position. -- 6. Repeat 4 and 5 until they do not process any verts. -- To determine the rooms that share a vert: -- 1. Start with the first room that is attached to the vert. -- 2. Find which corner the vert is. -- 3. Do one of the following, depending on the corner: (Navigates clockwise around the vert) -- 3a. If the vert is the top_left corner, exit through the left. -- 3b. If the vert is the top_right corner, exit through the top. -- 3c. If the vert is the bottom_right corner, exit through the right. -- 3d. If the vert is the bottom_left corner, exit through the bottom. -- 4. Add the next room to the list and the vert to the room. -- 5. Repeat 2 through 4 until you return to the starting room. -- To determine which corner a vert is in a newly entered room: -- 1. Switch based on the rot of the connection the room was entered through, and the side of the room that was -- exited, using the fact that navigation proceeds clockwise. -- Rendering: -- Iterate through rendered_rooms, adding lines between their verts to the line list. -- When adding a vert with unsettable_final_position, use the suggested_position that is closest to the first vert -- in the room with final_position set. -- If all verts for a room have unsettable_final_position, pick the pair of suggested_positions for top_left and -- top_right that are closest and pretend they have final_position set. -- Place the 4 lines of the room the player is in in their own list. -- Place the 4 lines of the room the cursor is on in their own list. -- Render line lists.