mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Cell ofssets
This commit is contained in:
parent
1e6c7e7f4e
commit
13ac8e4f2f
5 changed files with 136 additions and 17 deletions
|
|
@ -125,7 +125,7 @@ public partial class RogueliteRoomManager : Node2D
|
|||
nextPos += new Vector2I(0, exit);
|
||||
|
||||
_connections.Add(new RoomConnection(currentPos, nextPos));
|
||||
|
||||
//+ new Vector2I(0, roomToSpawn.Size.Y -1)
|
||||
// Reset X offset
|
||||
//nextPos = new Vector2I(0, nextPos.Y);
|
||||
|
||||
|
|
|
|||
|
|
@ -97,28 +97,35 @@ public partial class Minimap : CanvasLayer
|
|||
|
||||
private void DrawRoomConnections(List<RoomConnection> connections, Vector2I minGrid, Vector2 baseOffset)
|
||||
{
|
||||
int spacing = (int)Separation;
|
||||
|
||||
foreach (var connection in connections)
|
||||
{
|
||||
// Skip if either room is missing
|
||||
if (!RoomGrid.ContainsKey(connection.From) || !RoomGrid.ContainsKey(connection.To))
|
||||
continue;
|
||||
|
||||
// // Calculate center positions of each room
|
||||
// Vector2 from = baseOffset + ((connection.From - minGrid) * (CellSize + (int)Separation)) + new Vector2(CellSize / 2f, CellSize / 2f);
|
||||
// Vector2 to = baseOffset + ((connection.To - minGrid) * (CellSize + (int)Separation)) + new Vector2(CellSize / 2f, Separation / 2f);
|
||||
|
||||
// Get relative positions of the two rooms
|
||||
Vector2 fromPos = baseOffset + ((connection.From - minGrid) * (CellSize + (int)Separation));
|
||||
Vector2 toPos = baseOffset + ((connection.To - minGrid) * (CellSize + (int)Separation));
|
||||
// Convert grid coordinates to local minimap grid (relative to min)
|
||||
Vector2I fromGrid = connection.From - minGrid;
|
||||
Vector2I toGrid = connection.To - minGrid;
|
||||
|
||||
// Determine direction between rooms (assumes adjacent rooms only)
|
||||
Vector2 delta = (toPos - fromPos).Normalized();
|
||||
// Center of the From cell in pixels
|
||||
Vector2 fromCenter = baseOffset
|
||||
+ fromGrid * (CellSize + spacing)
|
||||
+ new Vector2(CellSize / 2f, CellSize / 2f);
|
||||
|
||||
// Midpoint between rooms, where the gap is
|
||||
Vector2 gapCenter = (fromPos + toPos) * 0.5f + new Vector2(CellSize / 2f, CellSize / 2f);
|
||||
// Center of the To cell in pixels
|
||||
Vector2 toCenter = baseOffset
|
||||
+ toGrid * (CellSize + spacing)
|
||||
+ new Vector2(CellSize / 2f, CellSize / 2f);
|
||||
|
||||
// The gap center between rooms
|
||||
Vector2 gapCenter = (fromCenter + toCenter) * 0.5f;
|
||||
|
||||
// Short line inside the separation gap
|
||||
Vector2 delta = (toCenter - fromCenter).Normalized();
|
||||
Vector2 halfGap = delta * (spacing / 2f);
|
||||
|
||||
// Calculate endpoints of the connection line (centered in gap)
|
||||
Vector2 halfGap = delta * (Separation / 2f);
|
||||
Vector2 lineStart = gapCenter - halfGap;
|
||||
Vector2 lineEnd = gapCenter + halfGap;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue