From 075ccc5a552078c92ae3d7d8d469150438ce5913 Mon Sep 17 00:00:00 2001 From: Mitchell M Date: Thu, 14 Nov 2024 21:58:39 -0600 Subject: [PATCH] refactor --- Cargo.lock | 1 + Cargo.toml | 6 + assets/registry.json | 1255 ++++------------------------------------ src/char_controller.rs | 1 - src/main.rs | 83 ++- src/server.rs | 2 +- 6 files changed, 167 insertions(+), 1181 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 831418f..bcdc710 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2049,6 +2049,7 @@ dependencies = [ "bevy_dolly", "bevy_editor_pls", "blenvy", + "cfg-if", "clap", "lazy_static", "lightyear", diff --git a/Cargo.toml b/Cargo.toml index 3490742..2242074 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,6 +9,7 @@ bevy = { version = "0.14.2", features = ["jpeg"] } bevy_dolly = "0.0.4" bevy_editor_pls = "0.10.0" blenvy = "0.1.0-alpha.1" +cfg-if = "1.0.0" clap = { version = "4.5.20", features = ["derive"] } lazy_static = "1.5.0" lightyear = { version = "0.17.1", features = ["avian3d"] } @@ -16,3 +17,8 @@ serde = { version = "1.0.213", features = ["derive"] } [profile.dev.package."*"] opt-level = 3 + +[features] +default = ["client"] +client = [] +server = [] diff --git a/assets/registry.json b/assets/registry.json index 92ea769..1c391dd 100644 --- a/assets/registry.json +++ b/assets/registry.json @@ -3972,44 +3972,6 @@ "type": "object", "typeInfo": "Enum" }, - "bevy_asset::handle::Handle": { - "isComponent": true, - "isResource": false, - "long_name": "bevy_asset::handle::Handle", - "oneOf": [ - { - "items": false, - "long_name": "Strong", - "prefixItems": [ - { - "type": { - "$ref": "#/$defs/std::sync::Arc" - } - } - ], - "short_name": "Strong", - "type": "array", - "typeInfo": "Tuple" - }, - { - "items": false, - "long_name": "Weak", - "prefixItems": [ - { - "type": { - "$ref": "#/$defs/bevy_asset::id::AssetId" - } - } - ], - "short_name": "Weak", - "type": "array", - "typeInfo": "Tuple" - } - ], - "short_name": "Handle", - "type": "object", - "typeInfo": "Enum" - }, "bevy_asset::handle::Handle": { "isComponent": true, "isResource": false, @@ -4390,44 +4352,6 @@ "type": "object", "typeInfo": "Enum" }, - "bevy_asset::handle::Handle": { - "isComponent": true, - "isResource": false, - "long_name": "bevy_asset::handle::Handle", - "oneOf": [ - { - "items": false, - "long_name": "Strong", - "prefixItems": [ - { - "type": { - "$ref": "#/$defs/std::sync::Arc" - } - } - ], - "short_name": "Strong", - "type": "array", - "typeInfo": "Tuple" - }, - { - "items": false, - "long_name": "Weak", - "prefixItems": [ - { - "type": { - "$ref": "#/$defs/bevy_asset::id::AssetId" - } - } - ], - "short_name": "Weak", - "type": "array", - "typeInfo": "Tuple" - } - ], - "short_name": "Handle", - "type": "object", - "typeInfo": "Enum" - }, "bevy_asset::id::AssetId<()>": { "isComponent": false, "isResource": false, @@ -5026,52 +4950,6 @@ "type": "object", "typeInfo": "Enum" }, - "bevy_asset::id::AssetId": { - "isComponent": false, - "isResource": false, - "long_name": "bevy_asset::id::AssetId", - "oneOf": [ - { - "additionalProperties": false, - "long_name": "Index", - "properties": { - "index": { - "long_name": "index", - "type": { - "$ref": "#/$defs/bevy_asset::assets::AssetIndex" - } - } - }, - "required": [ - "index" - ], - "short_name": "Index", - "type": "object", - "typeInfo": "Struct" - }, - { - "additionalProperties": false, - "long_name": "Uuid", - "properties": { - "uuid": { - "long_name": "uuid", - "type": { - "$ref": "#/$defs/uuid::Uuid" - } - } - }, - "required": [ - "uuid" - ], - "short_name": "Uuid", - "type": "object", - "typeInfo": "Struct" - } - ], - "short_name": "AssetId", - "type": "object", - "typeInfo": "Enum" - }, "bevy_asset::id::AssetId": { "isComponent": false, "isResource": false, @@ -5532,52 +5410,6 @@ "type": "object", "typeInfo": "Enum" }, - "bevy_asset::id::AssetId": { - "isComponent": false, - "isResource": false, - "long_name": "bevy_asset::id::AssetId", - "oneOf": [ - { - "additionalProperties": false, - "long_name": "Index", - "properties": { - "index": { - "long_name": "index", - "type": { - "$ref": "#/$defs/bevy_asset::assets::AssetIndex" - } - } - }, - "required": [ - "index" - ], - "short_name": "Index", - "type": "object", - "typeInfo": "Struct" - }, - { - "additionalProperties": false, - "long_name": "Uuid", - "properties": { - "uuid": { - "long_name": "uuid", - "type": { - "$ref": "#/$defs/uuid::Uuid" - } - } - }, - "required": [ - "uuid" - ], - "short_name": "Uuid", - "type": "object", - "typeInfo": "Struct" - } - ], - "short_name": "AssetId", - "type": "object", - "typeInfo": "Enum" - }, "bevy_asset::path::AssetPath": { "isComponent": false, "isResource": false, @@ -6668,30 +6500,6 @@ "type": "object", "typeInfo": "Value" }, - "bevy_egui::EguiSettings": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "bevy_egui::EguiSettings", - "properties": { - "default_open_url_target": { - "type": { - "$ref": "#/$defs/core::option::Option" - } - }, - "scale_factor": { - "type": { - "$ref": "#/$defs/f32" - } - } - }, - "required": [ - "scale_factor" - ], - "short_name": "EguiSettings", - "type": "object", - "typeInfo": "Struct" - }, "bevy_gizmos::aabb::AabbGizmoConfigGroup": { "additionalProperties": false, "isComponent": false, @@ -10879,72 +10687,6 @@ "type": "object", "typeInfo": "Struct" }, - "bevy_pbr::wireframe::NoWireframe": { - "additionalProperties": false, - "isComponent": true, - "isResource": false, - "long_name": "bevy_pbr::wireframe::NoWireframe", - "properties": {}, - "required": [], - "short_name": "NoWireframe", - "type": "object", - "typeInfo": "Struct" - }, - "bevy_pbr::wireframe::Wireframe": { - "additionalProperties": false, - "isComponent": true, - "isResource": false, - "long_name": "bevy_pbr::wireframe::Wireframe", - "properties": {}, - "required": [], - "short_name": "Wireframe", - "type": "object", - "typeInfo": "Struct" - }, - "bevy_pbr::wireframe::WireframeColor": { - "additionalProperties": false, - "isComponent": true, - "isResource": false, - "long_name": "bevy_pbr::wireframe::WireframeColor", - "properties": { - "color": { - "type": { - "$ref": "#/$defs/bevy_color::color::Color" - } - } - }, - "required": [ - "color" - ], - "short_name": "WireframeColor", - "type": "object", - "typeInfo": "Struct" - }, - "bevy_pbr::wireframe::WireframeConfig": { - "additionalProperties": false, - "isComponent": false, - "isResource": true, - "long_name": "bevy_pbr::wireframe::WireframeConfig", - "properties": { - "default_color": { - "type": { - "$ref": "#/$defs/bevy_color::color::Color" - } - }, - "global": { - "type": { - "$ref": "#/$defs/bool" - } - } - }, - "required": [ - "global", - "default_color" - ], - "short_name": "WireframeConfig", - "type": "object", - "typeInfo": "Struct" - }, "bevy_render::alpha::AlphaMode": { "isComponent": false, "isResource": false, @@ -16145,30 +15887,6 @@ "type": "object", "typeInfo": "Value" }, - "core::ops::Range": { - "isComponent": false, - "isResource": false, - "long_name": "core::ops::Range", - "short_name": "Range", - "type": "object", - "typeInfo": "Value" - }, - "core::ops::RangeInclusive": { - "isComponent": false, - "isResource": false, - "long_name": "core::ops::RangeInclusive", - "short_name": "RangeInclusive", - "type": "object", - "typeInfo": "Value" - }, - "core::ops::RangeInclusive": { - "isComponent": false, - "isResource": false, - "long_name": "core::ops::RangeInclusive", - "short_name": "RangeInclusive", - "type": "object", - "typeInfo": "Value" - }, "core::option::Option<(u8, u8)>": { "isComponent": false, "isResource": false, @@ -17168,33 +16886,6 @@ "type": "object", "typeInfo": "Enum" }, - "core::option::Option": { - "isComponent": false, - "isResource": false, - "long_name": "core::option::Option", - "oneOf": [ - { - "long_name": "None" - }, - { - "items": false, - "long_name": "Some", - "prefixItems": [ - { - "type": { - "$ref": "#/$defs/u64" - } - } - ], - "short_name": "Some", - "type": "array", - "typeInfo": "Tuple" - } - ], - "short_name": "Option", - "type": "object", - "typeInfo": "Enum" - }, "crooks::setup::Player": { "additionalProperties": false, "isComponent": true, @@ -17283,295 +16974,6 @@ "type": "object", "typeInfo": "Struct" }, - "glam::BVec2": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::BVec2", - "properties": { - "x": { - "type": { - "$ref": "#/$defs/bool" - } - }, - "y": { - "type": { - "$ref": "#/$defs/bool" - } - } - }, - "required": [ - "x", - "y" - ], - "short_name": "BVec2", - "type": "object", - "typeInfo": "Struct" - }, - "glam::BVec3": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::BVec3", - "properties": { - "x": { - "type": { - "$ref": "#/$defs/bool" - } - }, - "y": { - "type": { - "$ref": "#/$defs/bool" - } - }, - "z": { - "type": { - "$ref": "#/$defs/bool" - } - } - }, - "required": [ - "x", - "y", - "z" - ], - "short_name": "BVec3", - "type": "object", - "typeInfo": "Struct" - }, - "glam::BVec3A": { - "isComponent": false, - "isResource": false, - "long_name": "glam::BVec3A", - "short_name": "BVec3A", - "type": "object", - "typeInfo": "Value" - }, - "glam::BVec4": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::BVec4", - "properties": { - "w": { - "type": { - "$ref": "#/$defs/bool" - } - }, - "x": { - "type": { - "$ref": "#/$defs/bool" - } - }, - "y": { - "type": { - "$ref": "#/$defs/bool" - } - }, - "z": { - "type": { - "$ref": "#/$defs/bool" - } - } - }, - "required": [ - "x", - "y", - "z", - "w" - ], - "short_name": "BVec4", - "type": "object", - "typeInfo": "Struct" - }, - "glam::BVec4A": { - "isComponent": false, - "isResource": false, - "long_name": "glam::BVec4A", - "short_name": "BVec4A", - "type": "object", - "typeInfo": "Value" - }, - "glam::DAffine2": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::DAffine2", - "properties": { - "matrix2": { - "type": { - "$ref": "#/$defs/glam::DMat2" - } - }, - "translation": { - "type": { - "$ref": "#/$defs/glam::DVec2" - } - } - }, - "required": [ - "matrix2", - "translation" - ], - "short_name": "DAffine2", - "type": "object", - "typeInfo": "Struct" - }, - "glam::DAffine3": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::DAffine3", - "properties": { - "matrix3": { - "type": { - "$ref": "#/$defs/glam::DMat3" - } - }, - "translation": { - "type": { - "$ref": "#/$defs/glam::DVec3" - } - } - }, - "required": [ - "matrix3", - "translation" - ], - "short_name": "DAffine3", - "type": "object", - "typeInfo": "Struct" - }, - "glam::DMat2": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::DMat2", - "properties": { - "x_axis": { - "type": { - "$ref": "#/$defs/glam::DVec2" - } - }, - "y_axis": { - "type": { - "$ref": "#/$defs/glam::DVec2" - } - } - }, - "required": [ - "x_axis", - "y_axis" - ], - "short_name": "DMat2", - "type": "object", - "typeInfo": "Struct" - }, - "glam::DMat3": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::DMat3", - "properties": { - "x_axis": { - "type": { - "$ref": "#/$defs/glam::DVec3" - } - }, - "y_axis": { - "type": { - "$ref": "#/$defs/glam::DVec3" - } - }, - "z_axis": { - "type": { - "$ref": "#/$defs/glam::DVec3" - } - } - }, - "required": [ - "x_axis", - "y_axis", - "z_axis" - ], - "short_name": "DMat3", - "type": "object", - "typeInfo": "Struct" - }, - "glam::DMat4": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::DMat4", - "properties": { - "w_axis": { - "type": { - "$ref": "#/$defs/glam::DVec4" - } - }, - "x_axis": { - "type": { - "$ref": "#/$defs/glam::DVec4" - } - }, - "y_axis": { - "type": { - "$ref": "#/$defs/glam::DVec4" - } - }, - "z_axis": { - "type": { - "$ref": "#/$defs/glam::DVec4" - } - } - }, - "required": [ - "x_axis", - "y_axis", - "z_axis", - "w_axis" - ], - "short_name": "DMat4", - "type": "object", - "typeInfo": "Struct" - }, - "glam::DQuat": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::DQuat", - "properties": { - "w": { - "type": { - "$ref": "#/$defs/f64" - } - }, - "x": { - "type": { - "$ref": "#/$defs/f64" - } - }, - "y": { - "type": { - "$ref": "#/$defs/f64" - } - }, - "z": { - "type": { - "$ref": "#/$defs/f64" - } - } - }, - "required": [ - "x", - "y", - "z", - "w" - ], - "short_name": "DQuat", - "type": "object", - "typeInfo": "Struct" - }, "glam::DVec2": { "additionalProperties": false, "isComponent": false, @@ -17597,74 +16999,6 @@ "type": "object", "typeInfo": "Struct" }, - "glam::DVec3": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::DVec3", - "properties": { - "x": { - "type": { - "$ref": "#/$defs/f64" - } - }, - "y": { - "type": { - "$ref": "#/$defs/f64" - } - }, - "z": { - "type": { - "$ref": "#/$defs/f64" - } - } - }, - "required": [ - "x", - "y", - "z" - ], - "short_name": "DVec3", - "type": "object", - "typeInfo": "Struct" - }, - "glam::DVec4": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::DVec4", - "properties": { - "w": { - "type": { - "$ref": "#/$defs/f64" - } - }, - "x": { - "type": { - "$ref": "#/$defs/f64" - } - }, - "y": { - "type": { - "$ref": "#/$defs/f64" - } - }, - "z": { - "type": { - "$ref": "#/$defs/f64" - } - } - }, - "required": [ - "x", - "y", - "z", - "w" - ], - "short_name": "DVec4", - "type": "object", - "typeInfo": "Struct" - }, "glam::IVec2": { "additionalProperties": false, "isComponent": false, @@ -17690,74 +17024,6 @@ "type": "object", "typeInfo": "Struct" }, - "glam::IVec3": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::IVec3", - "properties": { - "x": { - "type": { - "$ref": "#/$defs/i32" - } - }, - "y": { - "type": { - "$ref": "#/$defs/i32" - } - }, - "z": { - "type": { - "$ref": "#/$defs/i32" - } - } - }, - "required": [ - "x", - "y", - "z" - ], - "short_name": "IVec3", - "type": "object", - "typeInfo": "Struct" - }, - "glam::IVec4": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::IVec4", - "properties": { - "w": { - "type": { - "$ref": "#/$defs/i32" - } - }, - "x": { - "type": { - "$ref": "#/$defs/i32" - } - }, - "y": { - "type": { - "$ref": "#/$defs/i32" - } - }, - "z": { - "type": { - "$ref": "#/$defs/i32" - } - } - }, - "required": [ - "x", - "y", - "z", - "w" - ], - "short_name": "IVec4", - "type": "object", - "typeInfo": "Struct" - }, "glam::Mat2": { "additionalProperties": false, "isComponent": false, @@ -17975,43 +17241,6 @@ "type": "object", "typeInfo": "Struct" }, - "glam::UVec4": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "glam::UVec4", - "properties": { - "w": { - "type": { - "$ref": "#/$defs/u32" - } - }, - "x": { - "type": { - "$ref": "#/$defs/u32" - } - }, - "y": { - "type": { - "$ref": "#/$defs/u32" - } - }, - "z": { - "type": { - "$ref": "#/$defs/u32" - } - } - }, - "required": [ - "x", - "y", - "z", - "w" - ], - "short_name": "UVec4", - "type": "object", - "typeInfo": "Struct" - }, "glam::Vec2": { "additionalProperties": false, "isComponent": false, @@ -18184,351 +17413,6 @@ "type": "int", "typeInfo": "Value" }, - "lightyear::client::components::Confirmed": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "lightyear::client::components::Confirmed", - "properties": { - "interpolated": { - "type": { - "$ref": "#/$defs/core::option::Option" - } - }, - "predicted": { - "type": { - "$ref": "#/$defs/core::option::Option" - } - }, - "tick": { - "type": { - "$ref": "#/$defs/lightyear::shared::tick_manager::tick_module::Tick" - } - } - }, - "required": [ - "tick" - ], - "short_name": "Confirmed", - "type": "object", - "typeInfo": "Struct" - }, - "lightyear::client::input::native::InputConfig": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "lightyear::client::input::native::InputConfig", - "properties": { - "packet_redundancy": { - "type": { - "$ref": "#/$defs/u16" - } - }, - "send_interval": { - "type": { - "$ref": "#/$defs/bevy_utils::Duration" - } - } - }, - "required": [ - "packet_redundancy", - "send_interval" - ], - "short_name": "InputConfig", - "type": "object", - "typeInfo": "Struct" - }, - "lightyear::client::interpolation::Interpolated": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "lightyear::client::interpolation::Interpolated", - "properties": { - "confirmed_entity": { - "type": { - "$ref": "#/$defs/bevy_ecs::entity::Entity" - } - } - }, - "required": [ - "confirmed_entity" - ], - "short_name": "Interpolated", - "type": "object", - "typeInfo": "Struct" - }, - "lightyear::client::interpolation::plugin::InterpolationConfig": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "lightyear::client::interpolation::plugin::InterpolationConfig", - "properties": { - "delay": { - "type": { - "$ref": "#/$defs/lightyear::client::interpolation::plugin::InterpolationDelay" - } - } - }, - "required": [ - "delay" - ], - "short_name": "InterpolationConfig", - "type": "object", - "typeInfo": "Struct" - }, - "lightyear::client::interpolation::plugin::InterpolationDelay": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "lightyear::client::interpolation::plugin::InterpolationDelay", - "properties": { - "min_delay": { - "type": { - "$ref": "#/$defs/bevy_utils::Duration" - } - }, - "send_interval_ratio": { - "type": { - "$ref": "#/$defs/f32" - } - } - }, - "required": [ - "min_delay", - "send_interval_ratio" - ], - "short_name": "InterpolationDelay", - "type": "object", - "typeInfo": "Struct" - }, - "lightyear::client::networking::HostServerMetadata": { - "additionalProperties": false, - "isComponent": false, - "isResource": true, - "long_name": "lightyear::client::networking::HostServerMetadata", - "properties": { - "client_entity": { - "type": { - "$ref": "#/$defs/core::option::Option" - } - } - }, - "required": [], - "short_name": "HostServerMetadata", - "type": "object", - "typeInfo": "Struct" - }, - "lightyear::client::prediction::Predicted": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "lightyear::client::prediction::Predicted", - "properties": { - "confirmed_entity": { - "type": { - "$ref": "#/$defs/core::option::Option" - } - } - }, - "required": [], - "short_name": "Predicted", - "type": "object", - "typeInfo": "Struct" - }, - "lightyear::client::prediction::despawn::PredictionDespawnMarker": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "lightyear::client::prediction::despawn::PredictionDespawnMarker", - "properties": { - "death_tick": { - "type": { - "$ref": "#/$defs/lightyear::shared::tick_manager::tick_module::Tick" - } - } - }, - "required": [ - "death_tick" - ], - "short_name": "PredictionDespawnMarker", - "type": "object", - "typeInfo": "Struct" - }, - "lightyear::client::prediction::diagnostics::PredictionMetrics": { - "additionalProperties": false, - "isComponent": false, - "isResource": true, - "long_name": "lightyear::client::prediction::diagnostics::PredictionMetrics", - "properties": { - "rollback_ticks": { - "type": { - "$ref": "#/$defs/u32" - } - }, - "rollbacks": { - "type": { - "$ref": "#/$defs/u32" - } - } - }, - "required": [ - "rollbacks", - "rollback_ticks" - ], - "short_name": "PredictionMetrics", - "type": "object", - "typeInfo": "Struct" - }, - "lightyear::client::prediction::plugin::PredictionConfig": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "lightyear::client::prediction::plugin::PredictionConfig", - "properties": { - "always_rollback": { - "type": { - "$ref": "#/$defs/bool" - } - }, - "correction_ticks_factor": { - "type": { - "$ref": "#/$defs/f32" - } - }, - "maximum_input_delay_before_prediction": { - "type": { - "$ref": "#/$defs/u16" - } - }, - "maximum_predicted_ticks": { - "type": { - "$ref": "#/$defs/u16" - } - }, - "minimum_input_delay_ticks": { - "type": { - "$ref": "#/$defs/u16" - } - } - }, - "required": [ - "always_rollback", - "minimum_input_delay_ticks", - "maximum_input_delay_before_prediction", - "maximum_predicted_ticks", - "correction_ticks_factor" - ], - "short_name": "PredictionConfig", - "type": "object", - "typeInfo": "Struct" - }, - "lightyear::client::prediction::prespawn::PreSpawnedPlayerObject": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "lightyear::client::prediction::prespawn::PreSpawnedPlayerObject", - "properties": { - "hash": { - "type": { - "$ref": "#/$defs/core::option::Option" - } - }, - "user_salt": { - "type": { - "$ref": "#/$defs/core::option::Option" - } - } - }, - "required": [], - "short_name": "PreSpawnedPlayerObject", - "type": "object", - "typeInfo": "Struct" - }, - "lightyear::client::prediction::rollback::Rollback": { - "additionalProperties": false, - "isComponent": false, - "isResource": true, - "long_name": "lightyear::client::prediction::rollback::Rollback", - "properties": {}, - "required": [], - "short_name": "Rollback", - "type": "object", - "typeInfo": "Struct" - }, - "lightyear::client::prediction::rollback::RollbackState": { - "isComponent": false, - "isResource": false, - "long_name": "lightyear::client::prediction::rollback::RollbackState", - "oneOf": [ - { - "long_name": "Default" - }, - { - "additionalProperties": false, - "long_name": "ShouldRollback", - "properties": { - "current_tick": { - "long_name": "current_tick", - "type": { - "$ref": "#/$defs/lightyear::shared::tick_manager::tick_module::Tick" - } - } - }, - "required": [ - "current_tick" - ], - "short_name": "ShouldRollback", - "type": "object", - "typeInfo": "Struct" - } - ], - "short_name": "RollbackState", - "type": "object", - "typeInfo": "Enum" - }, - "lightyear::client::replication::send::Replicate": { - "additionalProperties": false, - "isComponent": false, - "isResource": false, - "long_name": "lightyear::client::replication::send::Replicate", - "properties": { - "authority": { - "type": { - "$ref": "#/$defs/lightyear::shared::replication::authority::HasAuthority" - } - }, - "group": { - "type": { - "$ref": "#/$defs/lightyear::shared::replication::components::ReplicationGroup" - } - }, - "hierarchy": { - "type": { - "$ref": "#/$defs/lightyear::shared::replication::components::ReplicateHierarchy" - } - }, - "replicating": { - "type": { - "$ref": "#/$defs/lightyear::shared::replication::components::Replicating" - } - }, - "target": { - "type": { - "$ref": "#/$defs/lightyear::client::replication::send::ReplicateToServer" - } - } - }, - "required": [ - "target", - "authority", - "group", - "hierarchy", - "replicating" - ], - "short_name": "Replicate", - "type": "object", - "typeInfo": "Struct" - }, "lightyear::client::replication::send::ReplicateToServer": { "additionalProperties": false, "isComponent": false, @@ -18592,6 +17476,129 @@ "type": "object", "typeInfo": "Enum" }, + "lightyear::server::replication::send::ControlledBy": { + "additionalProperties": false, + "isComponent": true, + "isResource": false, + "long_name": "lightyear::server::replication::send::ControlledBy", + "properties": { + "lifetime": { + "type": { + "$ref": "#/$defs/lightyear::server::replication::send::Lifetime" + } + }, + "target": { + "type": { + "$ref": "#/$defs/lightyear::shared::replication::network_target::NetworkTarget" + } + } + }, + "required": [ + "target", + "lifetime" + ], + "short_name": "ControlledBy", + "type": "object", + "typeInfo": "Struct" + }, + "lightyear::server::replication::send::Lifetime": { + "isComponent": false, + "isResource": false, + "long_name": "lightyear::server::replication::send::Lifetime", + "oneOf": [ + "SessionBased", + "Persistent" + ], + "short_name": "Lifetime", + "type": "string", + "typeInfo": "Enum" + }, + "lightyear::server::replication::send::Replicate": { + "additionalProperties": false, + "isComponent": false, + "isResource": false, + "long_name": "lightyear::server::replication::send::Replicate", + "properties": { + "authority": { + "type": { + "$ref": "#/$defs/lightyear::shared::replication::authority::AuthorityPeer" + } + }, + "controlled_by": { + "type": { + "$ref": "#/$defs/lightyear::server::replication::send::ControlledBy" + } + }, + "group": { + "type": { + "$ref": "#/$defs/lightyear::shared::replication::components::ReplicationGroup" + } + }, + "hierarchy": { + "type": { + "$ref": "#/$defs/lightyear::shared::replication::components::ReplicateHierarchy" + } + }, + "marker": { + "type": { + "$ref": "#/$defs/lightyear::shared::replication::components::Replicating" + } + }, + "relevance_mode": { + "type": { + "$ref": "#/$defs/lightyear::shared::replication::components::NetworkRelevanceMode" + } + }, + "sync": { + "type": { + "$ref": "#/$defs/lightyear::server::replication::send::SyncTarget" + } + }, + "target": { + "type": { + "$ref": "#/$defs/lightyear::shared::replication::components::ReplicationTarget" + } + } + }, + "required": [ + "target", + "authority", + "sync", + "relevance_mode", + "controlled_by", + "group", + "hierarchy", + "marker" + ], + "short_name": "Replicate", + "type": "object", + "typeInfo": "Struct" + }, + "lightyear::server::replication::send::SyncTarget": { + "additionalProperties": false, + "isComponent": false, + "isResource": false, + "long_name": "lightyear::server::replication::send::SyncTarget", + "properties": { + "interpolation": { + "type": { + "$ref": "#/$defs/lightyear::shared::replication::network_target::NetworkTarget" + } + }, + "prediction": { + "type": { + "$ref": "#/$defs/lightyear::shared::replication::network_target::NetworkTarget" + } + } + }, + "required": [ + "prediction", + "interpolation" + ], + "short_name": "SyncTarget", + "type": "object", + "typeInfo": "Struct" + }, "lightyear::shared::config::Mode": { "isComponent": false, "isResource": false, @@ -19190,22 +18197,6 @@ "type": "object", "typeInfo": "Struct" }, - "lightyear::shared::tick_manager::tick_module::Tick": { - "isComponent": false, - "isResource": false, - "items": false, - "long_name": "lightyear::shared::tick_manager::tick_module::Tick", - "prefixItems": [ - { - "type": { - "$ref": "#/$defs/u16" - } - } - ], - "short_name": "Tick", - "type": "array", - "typeInfo": "TupleStruct" - }, "lightyear::transport::config::SharedIoConfig": { "additionalProperties": false, "isComponent": false, diff --git a/src/char_controller.rs b/src/char_controller.rs index c640fdb..6cdb4d7 100644 --- a/src/char_controller.rs +++ b/src/char_controller.rs @@ -241,7 +241,6 @@ fn movement( let local_direction = transform.rotation * Vec3::new(direction.y, 0., direction.x); let local_direction = Vec2::new(local_direction.z, local_direction.x); - println!("{local_direction:?}"); linear_velocity.x += local_direction.x * movement_acceleration.0 * delta_time * 10.; linear_velocity.z -= diff --git a/src/main.rs b/src/main.rs index f15134a..4534027 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,24 +1,11 @@ use avian3d::prelude::PhysicsDebugPlugin; 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::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 blenvy::BlenvyPlugin; use char_controller::CharacterControllerPlugin; use clap::Parser; -use client::MyClientPlugin; -use lightyear::prelude::client::ClientPlugins; -use lightyear::prelude::server::ServerPlugins; -use server::MyServerPlugin; -use setup::{Player, PlayerHead, SetupPlugin}; +use setup::SetupPlugin; pub mod char_controller; 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::() - // .disable::() - // .disable::() - // .disable::() - // .disable::() - // .disable::() - // .disable::() - // .disable::() - // .disable::(), - ) - .add_plugins(ServerPlugins::new(shared_net::server_config())) - .add_plugins(MyServerPlugin); - } - } -} - #[derive(Parser)] #[command(version, about, long_about = None)] pub struct Cli { @@ -71,13 +31,41 @@ pub struct Cli { server: bool, } fn main() { - App::new() - .insert_resource(Msaa::Sample4) + let mut app = App::new(); + app.insert_resource(Msaa::Sample4) .insert_resource(AmbientLight { brightness: 200.0, ..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::() + // .disable::() + // .disable::() + // .disable::() + // .disable::() + // .disable::() + // .disable::() + // .disable::() + // .disable::() + ) + .add_plugins(lightyear::server::plugin::ServerPlugins::new( + shared_net::server_config(), + )) + .add_plugins(server::MyServerPlugin); + + let app = app .add_plugins(SetupPlugin) .add_plugins(( PhysicsPlugins::default(), @@ -85,6 +73,7 @@ fn main() { CharacterControllerPlugin, )) .add_plugins(protocol::ProtocolPlugin) - .add_plugins(BlenvyPlugin::default()) - .run(); + .add_plugins(BlenvyPlugin::default()); + + app.run(); } diff --git a/src/server.rs b/src/server.rs index afd1d27..a25fa43 100644 --- a/src/server.rs +++ b/src/server.rs @@ -1,5 +1,5 @@ use bevy::prelude::*; -use lightyear::prelude::{ClientConnectEvent, ServerConnectEvent}; +use lightyear::prelude::ServerConnectEvent; pub struct MyServerPlugin;