Give the level random back to the level after the mobs' ticks

Brain behaviours draw from the level random (DoNothing, POI scans): the
game lends it to the mobs and keeps what they drew.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-12 17:13:57 +02:00
parent 000e676b57
commit 839ea6d04c
@@ -460,8 +460,11 @@ impl Game<'_> {
let mut mobs = std::mem::take(&mut self.mobs);
let mut dead = Vec::new();
let mut died = std::mem::take(&mut self.died);
let level_random;
{
let w = self.mob_world_base(&snapshot);
// The level random, lent to the mobs (brain behaviours draw from
// it) and taken back after their ticks.
let mut scratch = self.world.random.clone();
mobs.retain_mut(|m| {
if !w
@@ -481,7 +484,9 @@ impl Game<'_> {
keep
});
push_apart(&mut mobs);
level_random = scratch;
}
self.world.random = level_random;
self.mobs.append(&mut mobs);
self.died = died;
self.sync_riders();