split engine configuration from engine

This commit is contained in:
2022-11-10 20:38:32 +01:00
parent 648919cf5a
commit 624f5ae6c6
7 changed files with 80 additions and 38 deletions

View File

@@ -24,31 +24,9 @@ namespace Escape_Room_Engine.Engine.Scripts
}
}
private static Engine _foundEngine;
[BoxGroup("Size")]
[Tooltip("The minimum size that should be allowed for rooms.")]
public Vector2Int minRoomSize;
[BoxGroup("Size")]
[Tooltip("The size of the physical play space available to the engine.")]
public Vector2Int playSpace;
[BoxGroup("Doors")]
[Required]
public DoorModuleDescription spawnDoor;
[BoxGroup("Doors")]
[ValidateInput("IsNotEmpty", "At least one exit door type is required")]
public List<DoorModuleDescription> exitDoorTypes;
[BoxGroup("Puzzles")]
[MinMaxSlider(0, 10)] public Vector2Int puzzleCount;
[BoxGroup("Puzzles")]
public List<PuzzleModuleDescription> puzzleTypes;
[Required] public EngineConfiguration config;
public Material roomMaterial;
public ModuleDescription genericModule;
private int NumberOfRooms => _rooms.Count;
@@ -59,7 +37,7 @@ namespace Escape_Room_Engine.Engine.Scripts
{
_playSpaceOrigin = new GameObject("Play Space Origin");
_playSpaceOrigin.transform.SetParent(transform);
_playSpaceOrigin.transform.localPosition = new Vector3(-playSpace.x / 2f, 0, -playSpace.y / 2f);
_playSpaceOrigin.transform.localPosition = new Vector3(-config.playSpace.x / 2f, 0, -config.playSpace.y / 2f);
}
public void GenerateRoom()
@@ -67,7 +45,7 @@ namespace Escape_Room_Engine.Engine.Scripts
Logger.Log("Generating room...", LogType.RoomGeneration);
// get the last entrance from the newest room or create a spawn passage with no entrance door for where the player will start
var entrance = NumberOfRooms > 0 ? _rooms.Last().exit : new Passage(new DoorModule(null, spawnDoor), true);
var entrance = NumberOfRooms > 0 ? _rooms.Last().exit : new Passage(new DoorModule(null, config.spawnDoor), true);
var room = new Room(entrance);
_rooms.Add(room);
@@ -85,15 +63,15 @@ namespace Escape_Room_Engine.Engine.Scripts
var space = new Space(entrance);
// add exit
var exitDoor = new DoorModule(space, exitDoorTypes.RandomElement());
var exitDoor = new DoorModule(space, config.exitDoorTypes.RandomElement());
if (!space.AddModuleWithRequirements(exitDoor))
throw new Exception("Could not satisfy requirements for exit door.");
var exit = new Passage(exitDoor);
// add puzzles
for (var i = 0; i < Utilities.Utilities.RandomInclusive(puzzleCount.x, puzzleCount.y); i++)
for (var i = 0; i < Utilities.Utilities.RandomInclusive(config.puzzleCount.x, config.puzzleCount.y); i++)
{
space.AddModuleWithRequirements(new PuzzleModule(space, puzzleTypes.RandomElement()));
space.AddModuleWithRequirements(new PuzzleModule(space, config.puzzleTypes.RandomElement()));
}
room.AddSpace(space, exit);