Boss events: custom bars first, as a joining player gets them

CustomBossEvents.onPlayerConnect adds a joining player to its bars before any
entity, dragon fight or raid tells it about theirs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-25 02:21:03 +02:00
parent 75c009e3fc
commit e55b5b7c00
+18 -17
View File
@@ -474,9 +474,26 @@ impl Game<'_> {
}
out
}
/// Dragon, withers, the raid and custom bars, in that order.
/// Custom bars (`CustomBossEvents.onPlayerConnect` sends them as a player
/// joins), then the dragon, withers and the raid.
fn boss_events_for(&self, viewer: &Viewer) -> Vec<Offer> {
let mut out = Vec::new();
for b in &self.bosses.bars.bars {
if !b.visible || !b.players.contains(&viewer.ints) {
continue;
}
out.push(Offer {
id: b.uuid,
name: json_to_tag(&b.name),
progress: b.progress(),
color: color_index(&b.color),
overlay: style_index(&b.style),
darken: b.darken,
music: b.music,
fog: b.fog,
scope: Scope::Global,
});
}
if viewer.here
&& let Some(progress) = self.dragon_boss_progress(viewer.at, viewer.alive)
{
@@ -543,22 +560,6 @@ impl Game<'_> {
scope: Scope::Level(self.dim),
});
}
for b in &self.bosses.bars.bars {
if !b.visible || !b.players.contains(&viewer.ints) {
continue;
}
out.push(Offer {
id: b.uuid,
name: json_to_tag(&b.name),
progress: b.progress(),
color: color_index(&b.color),
overlay: style_index(&b.style),
darken: b.darken,
music: b.music,
fog: b.fog,
scope: Scope::Global,
});
}
out
}
/// The packets that take `viewer` from what it was last sent to `desired`