requirements foundation
This commit is contained in:
@@ -82,17 +82,31 @@ namespace Escape_Room_Engine.Engine.Scripts
|
||||
// add puzzles
|
||||
for (var i = 0; i < Utilities.Utilities.RandomInclusive(minPuzzleCount, maxPuzzleCount); i++)
|
||||
{
|
||||
var puzzle = new PuzzleModule(space, puzzleTypes.RandomElement());
|
||||
puzzle.Place(new Vector2Int(
|
||||
Random.Range(0, rrDimensions.width),
|
||||
Random.Range(0, rrDimensions.length)
|
||||
));
|
||||
space.AddModule(puzzle);
|
||||
GeneratePuzzle(space);
|
||||
}
|
||||
|
||||
room.AddSpace(space, exit);
|
||||
}
|
||||
|
||||
private void GeneratePuzzle(Space space)
|
||||
{
|
||||
var puzzle = new PuzzleModule(space, puzzleTypes.RandomElement());
|
||||
|
||||
// place puzzle
|
||||
var placementCandidates = space.rrDimensions.EveryPosition;
|
||||
puzzle._description.PlacementRequirements.ForEach(requirement =>
|
||||
placementCandidates.IntersectWith(requirement.PlacementCandidates(puzzle, space)));
|
||||
if (placementCandidates.Count > 0)
|
||||
{
|
||||
puzzle.Place(placementCandidates.RandomElement());
|
||||
space.AddModule(puzzle);
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Log("Could not find suitable placement for puzzle", LogType.PuzzleGeneration);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Generate space dimensions that fit the required size constraints and cover the position of the entrance.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user