use bevy::prelude::*; use std::{net::UdpSocket, time::SystemTime}; use bevy_renet::{ renet::{transport::ClientAuthentication, ConnectionConfig, RenetClient}, transport::NetcodeClientPlugin, RenetClientPlugin, }; use renet::transport::{NetcodeClientTransport, NetcodeTransportError, NETCODE_USER_DATA_BYTES}; // This id needs to be the same as the server is using const PROTOCOL_ID: u64 = 2878; fn main() { // Get username from stdin args let args = std::env::args().collect::>(); let username = &args[1]; let (client, transport) = new_renet_client(&username).unwrap(); App::new() // Lets add a nice dark grey background color .insert_resource(ClearColor(Color::hex("282828").unwrap())) .add_plugins(DefaultPlugins.set(WindowPlugin { primary_window: Some(Window { // Adding the username to the window title makes debugging a whole lot easier. title: format!("TricTrac <{}>", username), resolution: (1080.0, 1080.0).into(), ..default() }), ..default() })) // Renet setup .add_plugins(RenetClientPlugin) .add_plugins(NetcodeClientPlugin) .insert_resource(client) .insert_resource(transport) .add_systems(Startup, setup) .add_systems(Update, update_waiting_text) .add_systems(Update, panic_on_error_system) .run(); } ////////// COMPONENTS ////////// #[derive(Component)] struct UIRoot; #[derive(Component)] struct WaitingText; ////////// UPDATE SYSTEMS ////////// fn update_waiting_text(mut text_query: Query<&mut Text, With>, time: Res