refactor
This commit is contained in:
parent
2ba4f03ba0
commit
075ccc5a55
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -2049,6 +2049,7 @@ dependencies = [
|
|||||||
"bevy_dolly",
|
"bevy_dolly",
|
||||||
"bevy_editor_pls",
|
"bevy_editor_pls",
|
||||||
"blenvy",
|
"blenvy",
|
||||||
|
"cfg-if",
|
||||||
"clap",
|
"clap",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"lightyear",
|
"lightyear",
|
||||||
|
|||||||
@ -9,6 +9,7 @@ bevy = { version = "0.14.2", features = ["jpeg"] }
|
|||||||
bevy_dolly = "0.0.4"
|
bevy_dolly = "0.0.4"
|
||||||
bevy_editor_pls = "0.10.0"
|
bevy_editor_pls = "0.10.0"
|
||||||
blenvy = "0.1.0-alpha.1"
|
blenvy = "0.1.0-alpha.1"
|
||||||
|
cfg-if = "1.0.0"
|
||||||
clap = { version = "4.5.20", features = ["derive"] }
|
clap = { version = "4.5.20", features = ["derive"] }
|
||||||
lazy_static = "1.5.0"
|
lazy_static = "1.5.0"
|
||||||
lightyear = { version = "0.17.1", features = ["avian3d"] }
|
lightyear = { version = "0.17.1", features = ["avian3d"] }
|
||||||
@ -16,3 +17,8 @@ serde = { version = "1.0.213", features = ["derive"] }
|
|||||||
|
|
||||||
[profile.dev.package."*"]
|
[profile.dev.package."*"]
|
||||||
opt-level = 3
|
opt-level = 3
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["client"]
|
||||||
|
client = []
|
||||||
|
server = []
|
||||||
|
|||||||
1255
assets/registry.json
1255
assets/registry.json
File diff suppressed because it is too large
Load Diff
@ -241,7 +241,6 @@ fn movement(
|
|||||||
let local_direction =
|
let local_direction =
|
||||||
transform.rotation * Vec3::new(direction.y, 0., direction.x);
|
transform.rotation * Vec3::new(direction.y, 0., direction.x);
|
||||||
let local_direction = Vec2::new(local_direction.z, local_direction.x);
|
let local_direction = Vec2::new(local_direction.z, local_direction.x);
|
||||||
println!("{local_direction:?}");
|
|
||||||
linear_velocity.x +=
|
linear_velocity.x +=
|
||||||
local_direction.x * movement_acceleration.0 * delta_time * 10.;
|
local_direction.x * movement_acceleration.0 * delta_time * 10.;
|
||||||
linear_velocity.z -=
|
linear_velocity.z -=
|
||||||
|
|||||||
83
src/main.rs
83
src/main.rs
@ -1,24 +1,11 @@
|
|||||||
use avian3d::prelude::PhysicsDebugPlugin;
|
use avian3d::prelude::PhysicsDebugPlugin;
|
||||||
use avian3d::PhysicsPlugins;
|
use avian3d::PhysicsPlugins;
|
||||||
use bevy::core_pipeline::CorePipelinePlugin;
|
|
||||||
use bevy::gizmos::GizmoPlugin;
|
|
||||||
use bevy::log::LogPlugin;
|
|
||||||
use bevy::pbr::PbrPlugin;
|
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use bevy::render::RenderPlugin;
|
|
||||||
use bevy::sprite::SpritePlugin;
|
|
||||||
use bevy::state::app::StatesPlugin;
|
|
||||||
use bevy::text::TextPlugin;
|
|
||||||
use bevy::winit::WinitPlugin;
|
|
||||||
use bevy_editor_pls::prelude::*;
|
use bevy_editor_pls::prelude::*;
|
||||||
use blenvy::BlenvyPlugin;
|
use blenvy::BlenvyPlugin;
|
||||||
use char_controller::CharacterControllerPlugin;
|
use char_controller::CharacterControllerPlugin;
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use client::MyClientPlugin;
|
use setup::SetupPlugin;
|
||||||
use lightyear::prelude::client::ClientPlugins;
|
|
||||||
use lightyear::prelude::server::ServerPlugins;
|
|
||||||
use server::MyServerPlugin;
|
|
||||||
use setup::{Player, PlayerHead, SetupPlugin};
|
|
||||||
|
|
||||||
pub mod char_controller;
|
pub mod char_controller;
|
||||||
pub mod client;
|
pub mod client;
|
||||||
@ -33,33 +20,6 @@ lazy_static::lazy_static! {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ClientOrServerPlugin;
|
|
||||||
impl Plugin for ClientOrServerPlugin {
|
|
||||||
fn build(&self, app: &mut App) {
|
|
||||||
if CONFIG.client {
|
|
||||||
app.add_plugins(DefaultPlugins)
|
|
||||||
.add_plugins(ClientPlugins::new(shared_net::client_config()))
|
|
||||||
.add_plugins(EditorPlugin::default())
|
|
||||||
.add_plugins(MyClientPlugin);
|
|
||||||
}
|
|
||||||
if CONFIG.server {
|
|
||||||
app.add_plugins(
|
|
||||||
DefaultPlugins.build(), // .disable::<RenderPlugin>()
|
|
||||||
// .disable::<PbrPlugin>()
|
|
||||||
// .disable::<CorePipelinePlugin>()
|
|
||||||
// .disable::<ImagePlugin>()
|
|
||||||
// .disable::<TextPlugin>()
|
|
||||||
// .disable::<SpritePlugin>()
|
|
||||||
// .disable::<WindowPlugin>()
|
|
||||||
// .disable::<WinitPlugin>()
|
|
||||||
// .disable::<GizmoPlugin>(),
|
|
||||||
)
|
|
||||||
.add_plugins(ServerPlugins::new(shared_net::server_config()))
|
|
||||||
.add_plugins(MyServerPlugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[command(version, about, long_about = None)]
|
#[command(version, about, long_about = None)]
|
||||||
pub struct Cli {
|
pub struct Cli {
|
||||||
@ -71,13 +31,41 @@ pub struct Cli {
|
|||||||
server: bool,
|
server: bool,
|
||||||
}
|
}
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
let mut app = App::new();
|
||||||
.insert_resource(Msaa::Sample4)
|
app.insert_resource(Msaa::Sample4)
|
||||||
.insert_resource(AmbientLight {
|
.insert_resource(AmbientLight {
|
||||||
brightness: 200.0,
|
brightness: 200.0,
|
||||||
..default()
|
..default()
|
||||||
})
|
});
|
||||||
.add_plugins(ClientOrServerPlugin)
|
|
||||||
|
#[cfg(feature = "client")]
|
||||||
|
let app = app
|
||||||
|
.add_plugins(DefaultPlugins)
|
||||||
|
.add_plugins(lightyear::client::plugin::ClientPlugins::new(
|
||||||
|
shared_net::client_config(),
|
||||||
|
))
|
||||||
|
.add_plugins(EditorPlugin::default())
|
||||||
|
.add_plugins(client::MyClientPlugin);
|
||||||
|
|
||||||
|
#[cfg(feature = "server")]
|
||||||
|
app.add_plugins(
|
||||||
|
DefaultPlugins.build(), // disable some plugins on the server
|
||||||
|
// .disable::<RenderPlugin>()
|
||||||
|
// .disable::<PbrPlugin>()
|
||||||
|
// .disable::<CorePipelinePlugin>()
|
||||||
|
// .disable::<ImagePlugin>()
|
||||||
|
// .disable::<TextPlugin>()
|
||||||
|
// .disable::<SpritePlugin>()
|
||||||
|
// .disable::<WindowPlugin>()
|
||||||
|
// .disable::<WinitPlugin>()
|
||||||
|
// .disable::<GizmoPlugin>()
|
||||||
|
)
|
||||||
|
.add_plugins(lightyear::server::plugin::ServerPlugins::new(
|
||||||
|
shared_net::server_config(),
|
||||||
|
))
|
||||||
|
.add_plugins(server::MyServerPlugin);
|
||||||
|
|
||||||
|
let app = app
|
||||||
.add_plugins(SetupPlugin)
|
.add_plugins(SetupPlugin)
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
PhysicsPlugins::default(),
|
PhysicsPlugins::default(),
|
||||||
@ -85,6 +73,7 @@ fn main() {
|
|||||||
CharacterControllerPlugin,
|
CharacterControllerPlugin,
|
||||||
))
|
))
|
||||||
.add_plugins(protocol::ProtocolPlugin)
|
.add_plugins(protocol::ProtocolPlugin)
|
||||||
.add_plugins(BlenvyPlugin::default())
|
.add_plugins(BlenvyPlugin::default());
|
||||||
.run();
|
|
||||||
|
app.run();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use lightyear::prelude::{ClientConnectEvent, ServerConnectEvent};
|
use lightyear::prelude::ServerConnectEvent;
|
||||||
|
|
||||||
pub struct MyServerPlugin;
|
pub struct MyServerPlugin;
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user