diff --git a/all-is-cubes/src/behavior.rs b/all-is-cubes/src/behavior.rs index 07bd8d3da..228db7ff3 100644 --- a/all-is-cubes/src/behavior.rs +++ b/all-is-cubes/src/behavior.rs @@ -7,7 +7,6 @@ use core::any::TypeId; use core::fmt::{self, Debug}; use downcast_rs::{impl_downcast, Downcast}; -use hashbrown::HashMap as HbHashMap; use crate::time::Tick; use crate::transaction::{self, Merge as _, Transaction}; @@ -109,19 +108,26 @@ pub enum Then { /// #[doc = include_str!("save/serde-warning.md")] pub struct BehaviorSet { - members: HbHashMap>, + /// Note that this map is deterministically ordered, so any incidental things + /// depending on ordering, such as [`Self::query()`] will be deterministic. + /// (Transaction merges would prevent nondeterministic gameplay outcomes, but + /// it still wouldn't be ideal.) + members: BTreeMap>, } impl BehaviorSet { /// Constructs an empty [`BehaviorSet`]. pub fn new() -> Self { BehaviorSet { - members: HbHashMap::new(), + members: BTreeMap::new(), } } /// Find behaviors of a specified type. /// + /// The behaviors will be returned in a deterministic order. In the current + /// implementation, that order is the order in which they were added. + /// /// TODO: Allow querying by attachment details (spatial, etc) pub fn query>(&self) -> impl Iterator> + '_ { self.query_any(Some(TypeId::of::())).map( @@ -137,6 +143,9 @@ impl BehaviorSet { /// Find behaviors by filter criteria. All `None`s mean “anything”. /// + /// The behaviors will be returned in a deterministic order. In the current + /// implementation, that order is the order in which they were added. + /// /// TODO: Allow querying by attachment details (spatial, etc) pub fn query_any<'a>( &'a self,