mirror of
https://github.com/horizon-rust/horizon.git
synced 2026-11-07 17:21:49 -10:00
A player who dies with a container open closes it at death, not at respawn
AbstractContainerScreen.tick closes the container as soon as the player is no longer alive, so the server's doCloseContainer runs at death. Horizon closed a dead guest's container only in guest_respawn, so the lid stayed up and PlayerContainerEvent.Close reached mods only after the Respawn button. tick_player_menus now closes the menu (and drops the lid) for a dead guest and counts a dead guest's other menus as closed. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
This commit is contained in:
1 parent
f4833621f9
commit
c7d2b1199c
1 file changed
+9
-1
@@ -287,8 +287,16 @@ impl Game<'_> {
|
||||
.map(|g| g.conn)
|
||||
.collect();
|
||||
for conn in conns {
|
||||
// `AbstractContainerScreen.tick` closes the container once the player is no longer
|
||||
// alive, so a death closes the menu now (the lid falls, the mods hear Close), not at
|
||||
// the respawn.
|
||||
let dead = host.hub.guest(conn).is_some_and(|g| g.dead);
|
||||
if dead && host.hub.guest(conn).is_some_and(|g| g.menu.is_some()) {
|
||||
self.guest_container_closed(host, conn);
|
||||
host.hub.close_container(conn);
|
||||
}
|
||||
// Compared as borrowed: nothing is built each tick while it stays open.
|
||||
let now = open_menu_of(host, conn);
|
||||
let now = if dead { None } else { open_menu_of(host, conn) };
|
||||
let heard = host.play.get(&conn).and_then(|p| p.menu_heard.as_ref());
|
||||
if now == heard.map(|h| (h.window, h.menu.as_str(), h.pos)) {
|
||||
continue;
|
||||
|
||||
Reference in new issue
Block a user