Bred babies keep the classic sound set; allays walk back to within 4 blocks

- Animal.spawnChildFromBreeding creates the baby with getBreedOffspring and
  no finalizeSpawn, so its sound variant stays the default (classic); the
  spawn path here had just drawn a random one.
- StayCloseToTarget sets a walk target with closeEnough 4: once started at
  16 blocks, the allay walks until MoveToTargetSink.reachedTarget (Manhattan
  block distance 4), not only back inside 16.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Ludovic Marie
2026-10-27 22:54:14 +01:00
parent 154aaa2051
commit 58422bcc19
2 changed files with 15 additions and 0 deletions
@@ -1859,6 +1859,9 @@ impl Game<'_> {
&& let Some(child) = self.mobs.iter_mut().find(|m| m.id == id)
{
child.extra.age = -24000;
// getBreedOffspring creates the baby without finalizeSpawn: it keeps
// the default (`classic`) sound variant.
child.extra.sound_variant = None;
// A llama's baby was drawn in the parent's tick, with the
// experience.
if let Some(o) = llama {
+12
View File
@@ -113,6 +113,18 @@ impl Goal for StayClose {
d >= 256.0
})
}
/// `MoveToTargetSink.reachedTarget`: the walk target it set is reached
/// within a Manhattan block distance of 4 (`closeEnough`).
fn can_continue(&mut self, m: &mut Mob, cx: &mut Cx) -> bool {
m.extra.point.is_none()
&& deposit(m, cx).is_some_and(|p| {
let at = [m.position.x, m.position.y, m.position.z];
(0..3)
.map(|i| (p[i].floor() as i32 - at[i].floor() as i32).abs())
.sum::<i32>()
> 4
})
}
fn tick(&mut self, m: &mut Mob, cx: &mut Cx) {
if let Some(p) = deposit(m, cx)
&& (m.ai.nav.is_done() || m.age.is_multiple_of(10))