pub fn animation(
    &self,
    source: &puzzleverse_core::Point,
    target: &puzzleverse_core::Point,
    is_first: bool,
  ) -> (&puzzleverse_core::CharacterAnimation, chrono::Duration, bool) {
    if source.platform == target.platform {
      (
        self.platforms.get(target.platform as usize).map(|s| &s.animation).unwrap_or(&puzzleverse_core::CharacterAnimation::Walk),
        chrono::Duration::milliseconds(STEP_TIME.into()),
        false,
      )
    } else {
      self
        .platforms
        .get(source.platform as usize)
        .map(|s| {
          s.bridges
            .iter()
            .filter(|ts| ts.target_platform == target.platform as usize)
            .map(|ts| match &ts.condition {
              BridgeCondition::Static(animation, time) => (animation, chrono::Duration::milliseconds(*time as i64), false),
              BridgeCondition::PuzzleGated(gate, animation, time) => {
                if is_first && gate.load(std::sync::atomic::Ordering::Relaxed) {
                  (animation, chrono::Duration::milliseconds(*time as i64), false)
                } else {
                  (&puzzleverse_core::CharacterAnimation::Confused, chrono::Duration::milliseconds(700), true)
                }
              }
            })
            .nth(0)
        })
        .flatten()
        .unwrap_or((&puzzleverse_core::CharacterAnimation::Walk, chrono::Duration::milliseconds(STEP_TIME.into()), false))
    }
  }
/// Determine the animation that should be used as a player navigates between two points
Determine the animation that should be used as a player navigates between two points
Determine the animation that should be used as a player navigates between two points
pub fn animation(
    &self,
    source: &puzzleverse_core::Point,
    target: &puzzleverse_core::Point,
    is_first: bool,
  ) -> (&puzzleverse_core::CharacterAnimation, chrono::Duration, bool) {
    if source.platform == target.platform {
      (
        self.platforms.get(target.platform as usize).map(|s| &s.animation).unwrap_or(&puzzleverse_core::CharacterAnimation::Walk),
        chrono::Duration::milliseconds(STEP_TIME.into()),
        false,
      )
    } else {
      self
        .platforms
        .get(source.platform as usize)
        .map(|s| {
          s.bridges
            .iter()
            .filter(|ts| ts.target_platform == target.platform as usize)
            .map(|ts| match &ts.condition {
              BridgeCondition::Static(animation, time) => (animation, chrono::Duration::milliseconds(*time as i64), false),
              BridgeCondition::PuzzleGated(gate, animation, time) => {
                if is_first && gate.load(std::sync::atomic::Ordering::Relaxed) {
                  (animation, chrono::Duration::milliseconds(*time as i64), false)
                } else {
                  (&puzzleverse_core::CharacterAnimation::Confused, chrono::Duration::milliseconds(700), true)
                }
              }
            })
            .nth(0)
        })
        .flatten()
        .unwrap_or((&puzzleverse_core::CharacterAnimation::Walk, chrono::Duration::milliseconds(STEP_TIME.into()), false))
    }
  }
pub fn animation ( & self , source : & puzzleverse_core :: Point , target : & puzzleverse_core :: Point , is_first : bool , ) -> ( & puzzleverse_core :: CharacterAnimation , chrono :: Duration , bool ) { if source . platform == target . platform { ( self . platforms . get ( target . platform as usize ) . map ( | s | & s . animation ) . unwrap_or ( & puzzleverse_core :: CharacterAnimation :: Walk ) , chrono :: Duration :: milliseconds ( STEP_TIME . into ( ) ) , false , ) } else { self . platforms . get ( source . platform as usize ) . map ( | s | { s . bridges . iter ( ) . filter ( | ts | ts . target_platform == target . platform as usize ) . map ( | ts | match & ts . condition { BridgeCondition :: Static ( animation , time ) => ( animation , chrono :: Duration :: milliseconds ( * time as i64 ) , false ) , BridgeCondition :: PuzzleGated ( gate , animation , time ) => { if is_first && gate . load ( std :: sync :: atomic :: Ordering :: Relaxed ) { ( animation , chrono :: Duration :: milliseconds ( * time as i64 ) , false ) } else { ( & puzzleverse_core :: CharacterAnimation :: Confused , chrono :: Duration :: milliseconds ( 700 ) , true ) } } } ) . nth ( 0 ) } ) . flatten ( ) . unwrap_or ( ( & puzzleverse_core :: CharacterAnimation :: Walk , chrono :: Duration :: milliseconds ( STEP_TIME . into ( ) ) , false ) ) } }
Determine the animation that should be used as a player navigates between two points
Determine the animation that should be used as a player navigates between two points
&self
source
&puzzleverse_core::Point
target
&puzzleverse_core::Point
is_first
bool
&self
source
&puzzleverse_core::Point
target
&puzzleverse_core::Point
is_first
bool