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:
@@ -1859,6 +1859,9 @@ impl Game<'_> {
|
|||||||
&& let Some(child) = self.mobs.iter_mut().find(|m| m.id == id)
|
&& let Some(child) = self.mobs.iter_mut().find(|m| m.id == id)
|
||||||
{
|
{
|
||||||
child.extra.age = -24000;
|
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
|
// A llama's baby was drawn in the parent's tick, with the
|
||||||
// experience.
|
// experience.
|
||||||
if let Some(o) = llama {
|
if let Some(o) = llama {
|
||||||
|
|||||||
@@ -113,6 +113,18 @@ impl Goal for StayClose {
|
|||||||
d >= 256.0
|
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) {
|
fn tick(&mut self, m: &mut Mob, cx: &mut Cx) {
|
||||||
if let Some(p) = deposit(m, cx)
|
if let Some(p) = deposit(m, cx)
|
||||||
&& (m.ai.nav.is_done() || m.age.is_multiple_of(10))
|
&& (m.ai.nav.is_done() || m.age.is_multiple_of(10))
|
||||||
|
|||||||
Reference in New Issue
Block a user