-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add doors during level generation #41
Conversation
7233dd6
to
3a057e7
Compare
3a057e7
to
0fda83c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no test scene :(
The test scene is GridSystem. At the time I did not yet know that I should create my own new scene. |
I don't thinkg |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently, doors are placed at every room for every direction they allow the player to go, period. This is not very flexible. How do you envision that your code will be used later? I expect that not every room needs to have doors from the beginning.
aplib.net-demo/Assets/Prefabs/Environment/Interactables/Door.prefab
Outdated
Show resolved
Hide resolved
Old (closed) PR: #39 |
It is actually, see https://www.conventionalcommits.org/en/v1.0.0/#summary. |
@@ -193,6 +193,7 @@ private void PlaceDoors(int x, int z, Room room) | |||
{ | |||
// # Calculate where the door should be placed | |||
|
|||
// North is in the negative x direction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see that that is how you coded the door placement, but why? I oriented all the prefabs and tile to have North be positive X.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the grid is generated with north in the negative x direction.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Some small nitpicks.
{ | ||
PlaceTile(x, z, _grid[x, z].Tile); | ||
} | ||
for (int x = 0; x < _grid.Width; x++) PlaceTile(x, z, _grid[x, z].Tile); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: could also remove the brackets of the other for loop.
private void PlaceDoors(int x, int z, Room room) | ||
{ | ||
Vector3 roomPosition = new(x * _tileSizeX, 0, z * _tileSizeZ); | ||
// Get (half of) the depth of the door model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit
// Get (half of) the depth of the door model | |
// Get (half of) the depth of the door model. |
Vector3 roomPosition = new(x * _tileSizeX, 0, z * _tileSizeZ); | ||
// Get (half of) the depth of the door model | ||
float doorDepthExtend = _doorRenderer.bounds.extents.z; | ||
// Calculate the distance from the room center to where a door should be placed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit
// Calculate the distance from the room center to where a door should be placed | |
// Calculate the distance from the room center to where a door should be placed. |
// # Calculate where the door should be placed | ||
|
||
// North is in the negative x direction |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit
// # Calculate where the door should be placed | |
// North is in the negative x direction | |
// # Calculate where the door should be placed. | |
// North is in the negative x direction. |
float doorDepthExtend = _doorRenderer.bounds.extents.z; | ||
// Calculate the distance from the room center to where a door should be placed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit
float doorDepthExtend = _doorRenderer.bounds.extents.z; | |
// Calculate the distance from the room center to where a door should be placed | |
float doorDepthExtend = _doorRenderer.bounds.extents.z; | |
// Calculate the distance from the room center to where a door should be placed |
Vector3 roomPosition = new(x * _tileSizeX, 0, z * _tileSizeZ); | ||
// Get (half of) the depth of the door model |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit
Vector3 roomPosition = new(x * _tileSizeX, 0, z * _tileSizeZ); | |
// Get (half of) the depth of the door model | |
Vector3 roomPosition = new(x * _tileSizeX, 0, z * _tileSizeZ); | |
// Get (half of) the depth of the door model |
// # Calculate the rotation the door should have | ||
|
||
// The `RotateLeft` here is because the rotation of the grid and the rotation of the door model do not | ||
// line up |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit
// # Calculate the rotation the door should have | |
// The `RotateLeft` here is because the rotation of the grid and the rotation of the door model do not | |
// line up | |
// # Calculate the rotation the door should have. | |
// The `RotateLeft` here is because the rotation of the grid and the rotation of the door model do not | |
// line up. |
Quaternion relativeDoorRotation = Quaternion.Euler(0, direction.RotateLeft().RotationDegrees(), 0); | ||
Quaternion doorRotation = roomRotation * relativeDoorRotation; | ||
|
||
// # Spawn the door |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit
// # Spawn the door | |
// # Spawn the door. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the reason for the markdown header syntax? In other comments as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be a problem with the door placement, see Discord thread "fix: change boundary conditions for wave function collapse"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem I mentioned earlier is not with the door placement.
🎉 This PR is included in version 3.5.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Description
This PR adds automatic placement of doors during level generation. The doors are placed when a room is placed, based on the available directions of that room. Each door gets a unique ID which we will use in the future to match doors with keys.
Testability
There is no level generation yet, but there is a hard-coded level in the
TempFillFunction
in GridPlacer.cs.You can play this level in the GridSystem scene. The rooms should have the correct doors placed according to the hard-coded values in
TempFillFunction
. The doors should open when approached by the player.Checklist