pub(crate) async fn spawn_player(
    &mut self,
    server: &crate::Server,
    realm_name: &str,
    in_directory: bool,
    realm_key: &crate::RealmKey,
    player_key: &crate::PlayerKey,
    player_state: &mut crate::player_state::MutablePlayerState,
  ) {
    match self.manifold.warp(None) {
      Some(point) => {
        player_state.goal = crate::player_state::Goal::InRealm(realm_key.clone(), crate::player_state::RealmGoal::Idle);
        self.active_players.insert(player_key.clone(), (point.clone(), vec![]));
        self.committed_movements.push(crate::realm::PlayerMovement {
          player: player_key.clone(),
          leave_pieces: vec![],
          enter_pieces: self.manifold.active_proximity(&point).collect(),
          movement: puzzleverse_core::CharacterMotion::Enter { to: point, end: chrono::Utc::now() },
        });
        let players = server.player_states.read("spawn_player").await;
        player_state.connection.send(server, player_key, puzzleverse_core::RealmResponse::NameChanged(realm_name.to_string(), in_directory)).await;
        player_state.connection.send(server, player_key, self.make_update_state(&players)).await;
      }
      None => {
        player_state.goal = crate::player_state::Goal::Undecided;
        self.active_players.remove(player_key);
        player_state.connection.release_player(server).await;
      }
    }
  }
/// Insert a new player into this realm
Insert a new player into this realm
Insert a new player into this realm
pub(crate) async fn spawn_player(
    &mut self,
    server: &crate::Server,
    realm_name: &str,
    in_directory: bool,
    realm_key: &crate::RealmKey,
    player_key: &crate::PlayerKey,
    player_state: &mut crate::player_state::MutablePlayerState,
  ) {
    match self.manifold.warp(None) {
      Some(point) => {
        player_state.goal = crate::player_state::Goal::InRealm(realm_key.clone(), crate::player_state::RealmGoal::Idle);
        self.active_players.insert(player_key.clone(), (point.clone(), vec![]));
        self.committed_movements.push(crate::realm::PlayerMovement {
          player: player_key.clone(),
          leave_pieces: vec![],
          enter_pieces: self.manifold.active_proximity(&point).collect(),
          movement: puzzleverse_core::CharacterMotion::Enter { to: point, end: chrono::Utc::now() },
        });
        let players = server.player_states.read("spawn_player").await;
        player_state.connection.send(server, player_key, puzzleverse_core::RealmResponse::NameChanged(realm_name.to_string(), in_directory)).await;
        player_state.connection.send(server, player_key, self.make_update_state(&players)).await;
      }
      None => {
        player_state.goal = crate::player_state::Goal::Undecided;
        self.active_players.remove(player_key);
        player_state.connection.release_player(server).await;
      }
    }
  }
pub ( crate ) async fn spawn_player ( & mut self , server : & crate :: Server , realm_name : & str , in_directory : bool , realm_key : & crate :: RealmKey , player_key : & crate :: PlayerKey , player_state : & mut crate :: player_state :: MutablePlayerState , ) { match self . manifold . warp ( None ) { Some ( point ) => { player_state . goal = crate :: player_state :: Goal :: InRealm ( realm_key . clone ( ) , crate :: player_state :: RealmGoal :: Idle ) ; self . active_players . insert ( player_key . clone ( ) , ( point . clone ( ) , vec ! [ ] ) ) ; self . committed_movements . push ( crate :: realm :: PlayerMovement { player : player_key . clone ( ) , leave_pieces : vec ! [ ] , enter_pieces : self . manifold . active_proximity ( & point ) . collect ( ) , movement : puzzleverse_core :: CharacterMotion :: Enter { to : point , end : chrono :: Utc :: now ( ) } , } ) ; let players = server . player_states . read ( " " ) . await ; player_state . connection . send ( server , player_key , puzzleverse_core :: RealmResponse :: NameChanged ( realm_name . to_string ( ) , in_directory ) ) . await ; player_state . connection . send ( server , player_key , self . make_update_state ( & players ) ) . await ; } None => { player_state . goal = crate :: player_state :: Goal :: Undecided ; self . active_players . remove ( player_key ) ; player_state . connection . release_player ( server ) . await ; } } }
Insert a new player into this realm
Insert a new player into this realm
&mut self
server
&crate::Server
realm_name
&str
in_directory
bool
realm_key
&crate::RealmKey
player_key
&crate::PlayerKey
player_state
&mut crate::player_state::MutablePlayerState
&mut self
server
&crate::Server
realm_name
&str
in_directory
bool
realm_key
&crate::RealmKey
player_key
&crate::PlayerKey
player_state
&mut crate::player_state::MutablePlayerState