Resolved an issue where the room slots were not used but marked as matching when generating a map with multiple forks, resulting in no forks being generated.

解决生成多岔道的地图时,房间槽未使用但被标记为匹配,导致无法生成岔道的问题。
This commit is contained in:
Cold-Mint 2024-05-27 23:10:56 +08:00
parent 0c0adf3a25
commit ea319f032e
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
3 changed files with 31 additions and 6 deletions

View File

@ -35,6 +35,7 @@ offset_bottom = 32.0
text = "level_graph_editor" text = "level_graph_editor"
[node name="CreateOrEditorPanel" type="Panel" parent="."] [node name="CreateOrEditorPanel" type="Panel" parent="."]
visible = false
layout_mode = 1 layout_mode = 1
anchors_preset = 15 anchors_preset = 15
anchor_right = 1.0 anchor_right = 1.0

View File

@ -19,4 +19,16 @@ public class RoomPlacementData
/// <para>放置的房间模板</para> /// <para>放置的房间模板</para>
/// </summary> /// </summary>
public Room? Room { get; set; } public Room? Room { get; set; }
/// <summary>
/// <para>Parent room slot</para>
/// <para>父级房间的插槽</para>
/// </summary>
public RoomSlot? ParentRoomSlot { get; set; }
/// <summary>
/// <para>A slot for the new room</para>
/// <para>新房间的插槽</para>
/// </summary>
public RoomSlot? NewRoomSlot { get; set; }
} }

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks; using System.Threading.Tasks;
using ColdMint.scripts.debug;
using ColdMint.scripts.levelGraphEditor; using ColdMint.scripts.levelGraphEditor;
using ColdMint.scripts.map.dateBean; using ColdMint.scripts.map.dateBean;
using ColdMint.scripts.map.interfaces; using ColdMint.scripts.map.interfaces;
@ -169,7 +168,9 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy
var roomPlacementData = new RoomPlacementData var roomPlacementData = new RoomPlacementData
{ {
Room = newRoom, Room = newRoom,
Position = position Position = position,
ParentRoomSlot = mainRoomSlot,
NewRoomSlot = newRoomSlot
}; };
useableRoomPlacementData.Add(roomPlacementData); useableRoomPlacementData.Add(roomPlacementData);
} }
@ -181,7 +182,20 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy
else else
{ {
var index = randomNumberGenerator.Randi() % useableRoomPlacementData.Count; var index = randomNumberGenerator.Randi() % useableRoomPlacementData.Count;
return useableRoomPlacementData[(int)index]; var roomPlacementData = useableRoomPlacementData[(int)index];
//Be sure to mark its slot as a match when you use it.
//一定要在使用时,将其插槽标记为匹配。
if (roomPlacementData.ParentRoomSlot != null)
{
roomPlacementData.ParentRoomSlot.Matched = true;
}
if (roomPlacementData.NewRoomSlot != null)
{
roomPlacementData.NewRoomSlot.Matched = true;
}
return roomPlacementData;
} }
} }
@ -287,8 +301,6 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy
continue; continue;
} }
mainRoomSlot.Matched = true;
newRoomSlot.Matched = true;
outMainRoomSlot = mainRoomSlot; outMainRoomSlot = mainRoomSlot;
outNewRoomSlot = newRoomSlot; outNewRoomSlot = newRoomSlot;
return Task.FromResult(true); return Task.FromResult(true);