Lightyear setup (#55)
This commit is contained in:
@@ -5,6 +5,7 @@ edition = "2024"
|
||||
build = "build.rs"
|
||||
|
||||
[features]
|
||||
default = ["lightyear/client"]
|
||||
dbg = ["avian3d/debug-plugin", "dep:bevy-inspector-egui", "shared/dbg"]
|
||||
|
||||
[dependencies]
|
||||
@@ -20,6 +21,7 @@ bevy_debug_log = { workspace = true }
|
||||
bevy_sprite3d = { workspace = true }
|
||||
bevy_trenchbroom = { workspace = true }
|
||||
happy_feet = { workspace = true }
|
||||
lightyear = { workspace = true }
|
||||
nil = { workspace = true }
|
||||
rand = { workspace = true }
|
||||
ron = { workspace = true }
|
||||
|
||||
35
crates/client/src/client.rs
Normal file
35
crates/client/src/client.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use bevy::prelude::*;
|
||||
use lightyear::{
|
||||
netcode::Key,
|
||||
prelude::{client::NetcodeConfig, *},
|
||||
};
|
||||
use std::net::{IpAddr, Ipv4Addr, SocketAddr};
|
||||
|
||||
pub fn plugin(app: &mut App) {
|
||||
app.add_systems(Startup, temp_connect_on_startup);
|
||||
}
|
||||
|
||||
fn temp_connect_on_startup(mut commands: Commands) -> Result {
|
||||
let client_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 25564);
|
||||
let server_addr = SocketAddr::new(IpAddr::V4(Ipv4Addr::new(127, 0, 0, 1)), 25565);
|
||||
let auth = Authentication::Manual {
|
||||
server_addr,
|
||||
client_id: 0,
|
||||
private_key: Key::default(),
|
||||
protocol_id: 0,
|
||||
};
|
||||
commands
|
||||
.spawn((
|
||||
Name::from("Client"),
|
||||
Client::default(),
|
||||
LocalAddr(client_addr),
|
||||
PeerAddr(server_addr),
|
||||
Link::new(None),
|
||||
ReplicationReceiver::default(),
|
||||
client::NetcodeClient::new(auth, NetcodeConfig::default())?,
|
||||
UdpIo::default(),
|
||||
))
|
||||
.trigger(Connect);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
mod client;
|
||||
mod debug;
|
||||
mod steam;
|
||||
mod ui;
|
||||
@@ -16,8 +17,10 @@ use bevy_trenchbroom::prelude::*;
|
||||
use bevy_ui_gradients::UiGradientsPlugin;
|
||||
use camera::MainCamera;
|
||||
use heads_database::HeadDatabaseAsset;
|
||||
use lightyear::prelude::client::ClientPlugins;
|
||||
use loading_assets::AudioAssets;
|
||||
use shared::*;
|
||||
use std::time::Duration;
|
||||
use utils::{billboards, sprite_3d_animation, squish_animation, trail};
|
||||
|
||||
fn main() {
|
||||
@@ -58,6 +61,9 @@ fn main() {
|
||||
.auto_open_threshold(bevy::log::tracing::level_filters::LevelFilter::OFF),
|
||||
);
|
||||
app.add_plugins(PhysicsPlugins::default());
|
||||
app.add_plugins(ClientPlugins {
|
||||
tick_duration: Duration::from_secs_f64(1.0 / 60.0),
|
||||
});
|
||||
app.add_plugins(Sprite3dPlugin);
|
||||
app.add_plugins(TrenchBroomPlugins(
|
||||
TrenchBroomConfig::new("hedz").icon(None),
|
||||
@@ -87,9 +93,11 @@ fn main() {
|
||||
app.add_plugins(player::plugin);
|
||||
app.add_plugins(gates::plugin);
|
||||
app.add_plugins(platforms::plugin);
|
||||
app.add_plugins(protocol::plugin);
|
||||
app.add_plugins(movables::plugin);
|
||||
app.add_plugins(billboards::plugin);
|
||||
app.add_plugins(aim::plugin);
|
||||
app.add_plugins(client::plugin);
|
||||
app.add_plugins(npc::plugin);
|
||||
app.add_plugins(keys::plugin);
|
||||
app.add_plugins(squish_animation::plugin);
|
||||
@@ -106,7 +114,7 @@ fn main() {
|
||||
app.add_plugins(hitpoints::plugin);
|
||||
app.add_plugins(cash_heal::plugin);
|
||||
app.add_plugins(debug::plugin);
|
||||
app.add_plugins(utils::observers::plugin);
|
||||
app.add_plugins(utils::plugin);
|
||||
app.add_plugins(water::plugin);
|
||||
app.add_plugins(head_drop::plugin);
|
||||
app.add_plugins(trail::plugin);
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use crate::GameState;
|
||||
use bevy::{color::palettes::css::BLACK, prelude::*};
|
||||
use shared::{HEDZ_GREEN, HEDZ_PURPLE, control::CharacterInputEnabled, loading_assets::UIAssets};
|
||||
|
||||
use crate::GameState;
|
||||
|
||||
#[derive(States, Default, Clone, Eq, PartialEq, Debug, Hash)]
|
||||
#[states(scoped_entities)]
|
||||
enum PauseMenuState {
|
||||
|
||||
Reference in New Issue
Block a user