Open nww02 opened 3 years ago
One interesting side-effect of this is that you can have a door that has a lock on one side but can just be opened on the other. Attempting to "lock" the lockable side, should check to see if the other side is lockable, and if not, just leave it in the closed state.
Similarly, opening a door on the other side should remove the 'locked' status (if set) on the other side and open the door. In this way you can create closets and bathrooms that can be locked from one side, but still openable and closable without a key from the other. Used cunningly, this could prevent the user from accidentally locking themselves out of a key location...
Having a door between two locations is essential, but there's a system message to do with auto-shutting doors. These do not seem to be present, but could be useful.
However, when the "door slams behind you", there's no door on the other side! Doors don't work both ways, so is it possible to mark doors as having an "other side"?, so that both sides "close" when they auto_shut?
Effectively, when you perform an operation like open, close, lock and unlock on one side of the door, then the state of the other side of the door is updated too. When you pass from a room to another room, if it's auto-shutting, then the door in the room you just left is the one whose "on_close()" handler is called.
This does pose a question of the event handlers executing on the paired side. If you have a handler on side A, then close the door on side B, will the handler on side A fire?
Either
So, in the above, if implemented this way, opening the door from the inside, the on_open is executed on the outside too. This will. hopefully, reduce the complexity for you to implement?