diff options
author | Alexander Foremny <aforemny@posteo.de> | 2024-03-14 06:43:53 +0100 |
---|---|---|
committer | Alexander Foremny <aforemny@posteo.de> | 2024-03-15 02:50:57 +0100 |
commit | 69584a302d132dc2bcc3837437e7347a3e0a5114 (patch) | |
tree | fae29ea706451e91a0dee99200fa661b78de3517 /src/server/network.rs | |
parent | 9671dd79163e654f61896ec4f61142a71c2f82c0 (diff) |
feat: players can teleport
Diffstat (limited to 'src/server/network.rs')
-rw-r--r-- | src/server/network.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/server/network.rs b/src/server/network.rs new file mode 100644 index 0000000..0beead7 --- /dev/null +++ b/src/server/network.rs @@ -0,0 +1,31 @@ +use crate::protocol::*; +use crate::shared::*; +use bevy::prelude::*; +use lightyear::prelude::server::NetConfig; +use lightyear::prelude::*; +use lightyear::server::config::*; +use lightyear::server::plugin::PluginConfig; +use lightyear::server::plugin::ServerPlugin; + +pub struct NetworkPlugin { + pub transport: TransportConfig, +} + +impl Plugin for NetworkPlugin { + fn build(&self, app: &mut App) { + app.add_plugins(ServerPlugin::new(PluginConfig::new( + ServerConfig { + net: [NetConfig::Netcode { + config: NetcodeConfig::default() + .with_protocol_id(PROTOCOL_ID) + .with_key(KEY), + io: IoConfig::from_transport(self.transport.clone()), + }] + .to_vec(), + ping: PingConfig::default(), + ..Default::default() + }, + protocol(), + ))); + } +} |