From 4bd175cd7b0f147ad0cc4035eb018b925e26499d Mon Sep 17 00:00:00 2001 From: Corwin Date: Mon, 28 Aug 2023 11:45:21 +0100 Subject: [PATCH] defined update order --- .../src/game/simulation/entity.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/the-dungeon-puzzlers-lament/src/game/simulation/entity.rs b/examples/the-dungeon-puzzlers-lament/src/game/simulation/entity.rs index 97645e2c..43dbb675 100644 --- a/examples/the-dungeon-puzzlers-lament/src/game/simulation/entity.rs +++ b/examples/the-dungeon-puzzlers-lament/src/game/simulation/entity.rs @@ -315,7 +315,13 @@ impl EntityMap { .map .iter() .map(|(key, entity)| (key, entity.desired_action(hero))) - .collect::>(); + .collect::>(); + + entities_to_try_update.sort_unstable_by_key(|(e, _)| { + let e = self.map.get(*e).unwrap(); + e.location.x + e.location.y * 1000 + }); + let mut entities_to_try_update = VecDeque::from(entities_to_try_update); while let Some((entity_to_update_key, desired_action)) = entities_to_try_update.pop_front() {