Dungeon.java 文件源码

java
阅读 18 收藏 0 点赞 0 评论 0

项目:Loot-Slash-Conquer 作者:
/**
 * Procedurally generate a dungeon through recursion using a simple 'Procedurally Build' algorithm.
 * @param manager
 * @param world
 * @param startingPos - this position will ALWAYS be the position of the entrance.
 */
public void procedurallyGenerate(TemplateManager manager, World world, BlockPos startingPos, List<DungeonRoomPosition> nextPos)
{
    List<DungeonRoomPosition> nextPos2 = Lists.newArrayList(); // list which will hold the positions to be tried in the NEXT recursion of the method.

    if (roomCount > roomTries) return;
    else
    {
        ArrayList<StructureBoundingBox> roomListCopy = Lists.newArrayList(roomList);

        for (DungeonRoomPosition room : nextPos)
        {   
            // check to make sure rooms don't overlap
            for (StructureBoundingBox existingBB : roomListCopy)
            {
                // if structures don't overlap
                if (!DungeonHelper.checkOverlap(existingBB, room.getBoundingBox()))
                {
                    LootSlashConquer.LOGGER.info("Room generated successfully.");
                    List<DungeonRoomPosition> nextRooms = this.generateRoom(manager, world, room);

                    // copy new generated rooms into bigger list
                    for (DungeonRoomPosition nextRoom : nextRooms)
                    {
                        nextPos2.add(nextRoom);
                    }
                }
                else
                {
                    LootSlashConquer.LOGGER.info("Room failed to generate.");
                }
            }
        }
    }

    roomCount++;
    procedurallyGenerate(manager, world, startingPos, nextPos2);
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号