mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Make use of states in char-selection
Former-commit-id: f74d4811bebb0e60093a96d70feeedaae8bc6c04
This commit is contained in:
parent
7d683affe9
commit
ad5dcb4158
@ -102,6 +102,7 @@ impl Client {
|
||||
|
||||
pub fn register(&mut self, player: comp::Player) {
|
||||
self.postbox.send_message(ClientMsg::Register { player });
|
||||
self.pending_state_request = true;
|
||||
}
|
||||
|
||||
pub fn request_character(&mut self, name: String, body: comp::Body) {
|
||||
|
@ -1,5 +1,5 @@
|
||||
use specs::{Component, FlaggedStorage, NullStorage, VecStorage};
|
||||
use crate::state::Time;
|
||||
use specs::{Component, FlaggedStorage, NullStorage, VecStorage};
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
pub struct Health {
|
||||
|
@ -5,7 +5,7 @@ use vek::*;
|
||||
// Crate
|
||||
use crate::{
|
||||
comp::{phys::Pos, Action, Actions, Control, Stats},
|
||||
state::{Time, DeltaTime},
|
||||
state::{DeltaTime, Time},
|
||||
};
|
||||
|
||||
// Basic ECS AI agent system
|
||||
|
@ -8,7 +8,7 @@ use crate::{
|
||||
Direction, GlobalState, PlayState, PlayStateResult,
|
||||
};
|
||||
use client::{self, Client};
|
||||
use common::{clock::Clock, comp, msg::ClientMsg};
|
||||
use common::{clock::Clock, comp, msg::ClientMsg, msg::ClientState};
|
||||
use scene::Scene;
|
||||
use std::{cell::RefCell, rc::Rc, time::Duration};
|
||||
use ui::CharSelectionUi;
|
||||
@ -46,7 +46,9 @@ impl PlayState for CharSelectionState {
|
||||
// Set up an fps clock.
|
||||
let mut clock = Clock::new();
|
||||
|
||||
loop {
|
||||
while self.client.borrow().is_request_pending()
|
||||
|| self.client.borrow().get_client_state() == Some(ClientState::Registered)
|
||||
{
|
||||
// Handle window events.
|
||||
for event in global_state.window.fetch_events() {
|
||||
match event {
|
||||
@ -122,6 +124,8 @@ impl PlayState for CharSelectionState {
|
||||
// Wait for the next tick.
|
||||
clock.tick(Duration::from_millis(1000 / FPS));
|
||||
}
|
||||
|
||||
PlayStateResult::Pop
|
||||
}
|
||||
|
||||
fn name(&self) -> &'static str {
|
||||
|
Loading…
Reference in New Issue
Block a user