This commit is contained in:
2026-06-26 00:21:29 +07:00
parent 5d1af952b1
commit 4fa3fb2c15
16 changed files with 221 additions and 2011 deletions

View File

@@ -48,7 +48,7 @@ namespace Hallucinate.GameSetup.Maze
}
}
public IEnumerator GenerateStepByStep(MazeGrid grid, float interval)
public IEnumerator GenerateStepByStep(MazeGrid grid, int cellsPerFrame)
{
InitializeNoise(grid);
@@ -75,7 +75,7 @@ namespace Hallucinate.GameSetup.Maze
}
}
yield return GenerateRecursiveStepByStep(grid, 5, 5, interval);
yield return GenerateRecursiveStepByStep(grid, 5, 5, cellsPerFrame);
}
private void InitializeNoise(MazeGrid grid)
@@ -127,7 +127,7 @@ namespace Hallucinate.GameSetup.Maze
}
}
private IEnumerator GenerateRecursiveStepByStep(MazeGrid grid, int x, int z, float interval)
private IEnumerator GenerateRecursiveStepByStep(MazeGrid grid, int x, int z, int cellsPerFrame)
{
if (!grid.IsInBounds(x, z)) yield break;
if (GetNoiseAt(x, z, grid.Width) < CorridorThreshold) yield break;
@@ -136,7 +136,12 @@ namespace Hallucinate.GameSetup.Maze
if (grid.CountSquareNeighbours(x, z, MazeCellType.Corridor) >= DeadEndNeighbourThreshold) yield break;
grid.SetCell(x, z, MazeCellType.Processing);
if (interval > 0) yield return new WaitForSeconds(interval);
MazeManager.cellsProcessedThisFrame++;
if (MazeManager.cellsProcessedThisFrame >= cellsPerFrame)
{
MazeManager.cellsProcessedThisFrame = 0;
yield return null;
}
grid.SetCell(x, z, MazeCellType.Corridor);
@@ -145,7 +150,7 @@ namespace Hallucinate.GameSetup.Maze
foreach (var dir in shuffledDirs)
{
yield return GenerateRecursiveStepByStep(grid, x + dir.x, z + dir.z, interval);
yield return GenerateRecursiveStepByStep(grid, x + dir.x, z + dir.z, cellsPerFrame);
}
}
}