Add components for opening / closing doors and door behavior preview #139
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New feature implementation
Implemented feature
This PR builds on top of #138 and closes #76. The door behavior is currently more of a "teleport to destination" rather than smoothly open or close but doors can be commanded and their states read.
Screencast.from.2023-06-23.15-36-37.webm
Implementation description
To avoid dependency on physics engines the transforms for door opening / closing are currently done manually.
A
DoorComand
andDoorState
component have been added, they are mostly the same but whileDoorCommand
is onlyOpen
orClose
,DoorState
has an additionalMoving
variant.Since doors effectively teleport right now this state is never reached, however all the infrastructure is in place to populate that once a door's transform is detected to be neither fully open nor fully closed.
There are some TODOs in place for better system ordering, had to hack around to avoid off-by-one-frame glitches, however since we will need to pretty much rewrite our whole state / system pipeline when migrating to bevy 0.10+ I didn't put too much effort into creating new stages and setting them up.
Ideally there would be a new
Simulate
stage separate from the others so animation systems don't conflict with other update systems (i.e. a system that opens a door + a system that moves the door because its anchors' positions changed).I have a feeling the
preview
model should not live ininteraction
anymore and each site module should manage its own preview, but I didn't do the refactor here to avoid making the diff explode with physical camera preview changes.