pub(crate) fn prepare_consequences(state: &mut crate::realm::RealmPuzzleState) -> bool {
  let mut changed = false;
  for (i, p) in state.pieces.iter().enumerate() {
    for cr in state.consequence_rules.iter().filter(|cr| cr.sender == i) {
      for c in p.update_check(&cr.consequence) {
        match c {
          puzzleverse_core::asset::rules::PuzzleConsequence::ClientStateUpdate(name, value) => {
            changed |= state.current_states.insert(name.into(), value.clone()).map(|old| old == value).unwrap_or(true);
          }
          puzzleverse_core::asset::rules::PuzzleConsequence::UpdateMap(storage, state) => storage.store(state, std::sync::atomic::Ordering::Relaxed),
        }
      }
    }
  }
  changed
}
/// Update a realm's state from puzzle pieces
Update a realm's state from puzzle pieces
Update a realm ' s state from puzzle pieces
pub(crate) fn prepare_consequences(state: &mut crate::realm::RealmPuzzleState) -> bool {
  let mut changed = false;
  for (i, p) in state.pieces.iter().enumerate() {
    for cr in state.consequence_rules.iter().filter(|cr| cr.sender == i) {
      for c in p.update_check(&cr.consequence) {
        match c {
          puzzleverse_core::asset::rules::PuzzleConsequence::ClientStateUpdate(name, value) => {
            changed |= state.current_states.insert(name.into(), value.clone()).map(|old| old == value).unwrap_or(true);
          }
          puzzleverse_core::asset::rules::PuzzleConsequence::UpdateMap(storage, state) => storage.store(state, std::sync::atomic::Ordering::Relaxed),
        }
      }
    }
  }
  changed
}
pub ( crate ) fn prepare_consequences ( state : & mut crate :: realm :: RealmPuzzleState ) -> bool { let mut changed = false ; for ( i , p ) in state . pieces . iter ( ) . enumerate ( ) { for cr in state . consequence_rules . iter ( ) . filter ( | cr | cr . sender == i ) { for c in p . update_check ( & cr . consequence ) { match c { puzzleverse_core :: asset :: rules :: PuzzleConsequence :: ClientStateUpdate ( name , value ) => { changed |= state . current_states . insert ( name . into ( ) , value . clone ( ) ) . map ( | old | old == value ) . unwrap_or ( true ) ; } puzzleverse_core :: asset :: rules :: PuzzleConsequence :: UpdateMap ( storage , state ) => storage . store ( state , std :: sync :: atomic :: Ordering :: Relaxed ) , } } } } changed }
Update a realm's state from puzzle pieces
Update a realm ' s state from puzzle pieces
state
&mut crate::realm::RealmPuzzleState
state
&mut crate::realm::RealmPuzzleState