pub fn warp(&mut self, name: Option<&str>) -> Option<puzzleverse_core::Point> {
    let point = match name {
      Some(n) => self.spawn_points.get(n)?,
      None => &self.default_spawn,
    };
    match self.platforms.get_mut(point.platform) {
      Some(platform) => {
        use rand::seq::SliceRandom;
        let mut targets: Vec<_> = Vec::new();
        for x in point.x1..point.x2 {
          targets.extend(
            (point.y1..point.y2)
              .filter(|&y| match platform.terrain.get(&(x, y)) {
                Some(Ground::Obstacle) => false,
                Some(Ground::GatedObstacle(gate)) => gate.load(std::sync::atomic::Ordering::Relaxed),
                _ => true,
              })
              .map(move |y| (x, y)),
          );
        }

        targets.shuffle(&mut rand::thread_rng());
        targets.get(0).map(|&(x, y)| puzzleverse_core::Point { platform: point.platform as u32, x, y })
      }
      None => None,
    }
  }
/// Determine a point at which a player will materialise for a given spawn point
Determine a point at which a player will materialise for a given spawn point
Determine a point at which a player will materialise for a given spawn point
pub fn warp(&mut self, name: Option<&str>) -> Option<puzzleverse_core::Point> {
    let point = match name {
      Some(n) => self.spawn_points.get(n)?,
      None => &self.default_spawn,
    };
    match self.platforms.get_mut(point.platform) {
      Some(platform) => {
        use rand::seq::SliceRandom;
        let mut targets: Vec<_> = Vec::new();
        for x in point.x1..point.x2 {
          targets.extend(
            (point.y1..point.y2)
              .filter(|&y| match platform.terrain.get(&(x, y)) {
                Some(Ground::Obstacle) => false,
                Some(Ground::GatedObstacle(gate)) => gate.load(std::sync::atomic::Ordering::Relaxed),
                _ => true,
              })
              .map(move |y| (x, y)),
          );
        }
        targets.shuffle(&mut rand::thread_rng());
        targets.get(0).map(|&(x, y)| puzzleverse_core::Point { platform: point.platform as u32, x, y })
      }
      None => None,
    }
  }
pub fn warp ( & mut self , name : Option < & str > ) -> Option < puzzleverse_core :: Point > { let point = match name { Some ( n ) => self . spawn_points . get ( n ) ? , None => & self . default_spawn , } ; match self . platforms . get_mut ( point . platform ) { Some ( platform ) => { use rand :: seq :: SliceRandom ; let mut targets : Vec < _ > = Vec :: new ( ) ; for x in point . x1 .. point . x2 { targets . extend ( ( point . y1 .. point . y2 ) . filter ( | & y | match platform . terrain . get ( & ( x , y ) ) { Some ( Ground :: Obstacle ) => false , Some ( Ground :: GatedObstacle ( gate ) ) => gate . load ( std :: sync :: atomic :: Ordering :: Relaxed ) , _ => true , } ) . map ( move | y | ( x , y ) ) , ) ; } targets . shuffle ( & mut rand :: thread_rng ( ) ) ; targets . get ( 0 ) . map ( | & ( x , y ) | puzzleverse_core :: Point { platform : point . platform as u32 , x , y } ) } None => None , } }
Determine a point at which a player will materialise for a given spawn point
Determine a point at which a player will materialise for a given spawn point
&mut self
name
Option<&str>
&mut self
name
Option<&str>