update lightyear + fix aiming crash (#67)
This commit is contained in:
@@ -1,11 +1,17 @@
|
||||
use crate::config::ServerConfig;
|
||||
use bevy::prelude::*;
|
||||
use lightyear::prelude::{
|
||||
server::{NetcodeConfig, NetcodeServer, ServerUdpIo, Started},
|
||||
*,
|
||||
use lightyear::{
|
||||
link::LinkConditioner,
|
||||
prelude::{
|
||||
server::{NetcodeConfig, NetcodeServer, ServerUdpIo, Started},
|
||||
*,
|
||||
},
|
||||
};
|
||||
use shared::{GameState, global_observer, heads_database::HeadsDatabase, tb_entities::SpawnPoint};
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
use std::{
|
||||
net::{IpAddr, Ipv4Addr, SocketAddr},
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
pub fn plugin(app: &mut App) {
|
||||
app.add_systems(Startup, (start_server, setup_timeout_timer));
|
||||
@@ -34,9 +40,15 @@ fn handle_new_client(
|
||||
|
||||
info!("Client connected on IP: {}", id.ip());
|
||||
|
||||
let conditioner = LinkConditioner::new(LinkConditionerConfig {
|
||||
incoming_latency: Duration::from_millis(10),
|
||||
incoming_jitter: Duration::from_millis(0),
|
||||
incoming_loss: 0.0,
|
||||
});
|
||||
|
||||
commands
|
||||
.entity(trigger.target())
|
||||
.insert(ReplicationSender::default());
|
||||
.insert((ReplicationSender::default(), Link::new(Some(conditioner))));
|
||||
|
||||
crate::player::spawn(commands, trigger.target(), query, asset_server, heads_db);
|
||||
|
||||
@@ -56,11 +68,17 @@ fn close_on_disconnect(
|
||||
fn start_server(mut commands: Commands) -> Result {
|
||||
let server_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 25565);
|
||||
|
||||
let conditioner = LinkConditioner::new(LinkConditionerConfig {
|
||||
incoming_latency: Duration::from_millis(10),
|
||||
incoming_jitter: Duration::from_millis(0),
|
||||
incoming_loss: 0.0,
|
||||
});
|
||||
let mut commands = commands.spawn((
|
||||
Name::from("Server"),
|
||||
LocalAddr(server_addr),
|
||||
ServerUdpIo::default(),
|
||||
NetcodeServer::new(NetcodeConfig::default()),
|
||||
Link::new(Some(conditioner)),
|
||||
));
|
||||
commands.trigger(server::Start);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user