Fixed an issue where some room slots could not be blocked.

修复某些房间槽无法被堵住的问题。
This commit is contained in:
Cold-Mint 2024-09-09 22:22:03 +08:00
parent 1e019339d8
commit 4ae8a5d470
Signed by: Cold-Mint
GPG Key ID: C5A9BF8A98E0CE99
2 changed files with 22 additions and 13 deletions

View File

@ -282,7 +282,10 @@ public static class MapGenerator
continue; continue;
} }
await PlaceRoomAndAddRecord(roomNodeData.Id, roomPlacementData, roomDictionary); if (await PlaceRoomAndAddRecord(roomNodeData.Id, roomPlacementData, roomDictionary))
{
MarkRoomSlot(roomPlacementData);
}
} }
//Place barriers //Place barriers
@ -368,6 +371,24 @@ public static class MapGenerator
barrier.QueueFree(); barrier.QueueFree();
} }
/// <summary>
/// <para>Mark the room slot as matched</para>
/// <para>将房间槽标记为已匹配</para>
/// </summary>
/// <param name="roomPlacementData"></param>
private static void MarkRoomSlot(RoomPlacementData roomPlacementData)
{
if (roomPlacementData.ParentRoomSlot != null)
{
roomPlacementData.ParentRoomSlot.Matched = true;
}
if (roomPlacementData.NewRoomSlot != null)
{
roomPlacementData.NewRoomSlot.Matched = true;
}
}
/// <summary> /// <summary>
/// <para>Place rooms and add mappings</para> /// <para>Place rooms and add mappings</para>
/// <para>放置房间,并增加映射</para> /// <para>放置房间,并增加映射</para>

View File

@ -219,18 +219,6 @@ public class PatchworkRoomPlacementStrategy : IRoomPlacementStrategy
{ {
var index = randomNumberGenerator.Randi() % usableRoomPlacementData.Count; var index = randomNumberGenerator.Randi() % usableRoomPlacementData.Count;
var roomPlacementData = usableRoomPlacementData[(int)index]; var roomPlacementData = usableRoomPlacementData[(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; return roomPlacementData;
} }
} }