defined update order

This commit is contained in:
Corwin 2023-08-28 11:45:21 +01:00
parent dacecef900
commit 4bd175cd7b
No known key found for this signature in database

View file

@ -315,7 +315,13 @@ impl EntityMap {
.map .map
.iter() .iter()
.map(|(key, entity)| (key, entity.desired_action(hero))) .map(|(key, entity)| (key, entity.desired_action(hero)))
.collect::<VecDeque<_>>(); .collect::<Vec<_>>();
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() while let Some((entity_to_update_key, desired_action)) = entities_to_try_update.pop_front()
{ {