M crates/unified/src/client/key_input.rs => crates/unified/src/client/key_input.rs +3 -64
@@ 1,9 1,5 @@
-use crate::attachment::{JointOf, Peer, SnapOf};
-use crate::ecs::{Part, ThrustEvent};
-use bevy::color::palettes::css::{FUCHSIA, GREEN, ORANGE, WHITE};
+use crate::ecs::ThrustEvent;
use bevy::dev_tools::picking_debug::DebugPickingMode;
-use bevy::gizmos::gizmos::Gizmos;
-use bevy::math::{Vec3, Vec3Swizzles};
use crate::prelude::*;
use bevy::{
app::{App, Update},
@@ 11,25 7,15 @@ use bevy::{
input::{ButtonInput, keyboard::KeyCode},
};
use std::ops::Deref;
-use avian2d::prelude::*;
+use crate::client::ship::attachment::AttachmentDebugRes;
pub fn key_input_plugin(app: &mut App) {
app.add_systems(Update, directional_keys)
.add_systems(Update, debug_render_keybind)
- .init_resource::<AttachmentDebugRes>()
- .init_resource::<PhysicsDebugRes>()
- .add_systems(Update, draw_attachment_debug);
+ .init_resource::<PhysicsDebugRes>();
}
-#[derive(Resource, Default)]
-pub struct AttachmentDebugRes(pub bool);
-impl Deref for AttachmentDebugRes {
- type Target = bool;
- fn deref(&self) -> &Self::Target {
- &self.0
- }
-}
#[derive(Resource, Default)]
pub struct PhysicsDebugRes(pub bool);
impl Deref for PhysicsDebugRes {
@@ 79,50 65,3 @@ fn directional_keys(keys: Res<ButtonInput<KeyCode>>, mut thrust_event: MessageWr
}
}
-fn draw_attachment_debug(
- joints: Query<(&Transform, &JointOf, Option<&Peer>)>,
- snaps: Query<(&Transform, &SnapOf)>,
- parts: Query<&GlobalTransform, With<Part>>,
- mut gizmos: Gizmos,
- state: ResMut<AttachmentDebugRes>,
-) {
- if !state.0 {
- return;
- }
- for (offset, parent, peer) in joints.iter() {
- let Ok(parent_pos) = parts.get(parent.0) else {
- continue;
- };
- let joint_target = parent_pos.transform_point(offset.translation);
- gizmos.cross_2d(joint_target.xy(), 4.0, FUCHSIA);
-
- if let Some(peer_id) = peer
- && let Ok(peer) = joints.get(peer_id.peer_joint_entity_id)
- {
- let Ok(peer_parent_pos) = parts.get(peer.1.0) else {
- continue;
- };
- gizmos.arrow_2d(
- peer_parent_pos.translation().xy(),
- peer_parent_pos.translation().xy()
- + ((peer.0.rotation * peer_parent_pos.rotation())
- .mul_vec3(Vec3::Y)
- .xy()
- * 20.0),
- ORANGE,
- );
- gizmos.arrow_2d(
- parent_pos.translation().xy(),
- peer_parent_pos.translation().xy(),
- WHITE,
- );
- }
- }
- for (offset, parent) in snaps.iter() {
- let Ok(parent_pos) = parts.get(parent.0) else {
- continue;
- };
- let joint_snap = parent_pos.transform_point(offset.translation);
- gizmos.cross_2d(joint_snap.xy(), 4.0, GREEN);
- }
-}
M crates/unified/src/client/mod.rs => crates/unified/src/client/mod.rs +13 -10
@@ 1,13 1,3 @@
-mod colors;
-mod key_input;
-mod net;
-mod particles;
-mod parts;
-mod planet;
-mod starfield;
-mod ui;
-mod zoom;
-
use crate::client::key_input::key_input_plugin;
use crate::client::net::set_config;
use crate::client::parts::parts_plugin;
@@ 24,6 14,18 @@ use bevy::post_process::bloom::Bloom;
use crate::prelude::*;
use bevy::window::PrimaryWindow;
use planet::incoming_planets::incoming_planets_plugin;
+use crate::client::ship::attachment::client_attachment_plugin;
+
+pub mod colors;
+pub mod key_input;
+pub mod net;
+pub mod particles;
+pub mod parts;
+pub mod planet;
+pub mod starfield;
+pub mod ui;
+pub mod zoom;
+pub mod ship;
pub struct ClientPlugin {
pub server: Option<String>,
@@ 52,6 54,7 @@ impl Plugin for ClientPlugin {
.add_plugins(starfield_plugin)
.add_plugins(ui_plugin)
.add_plugins(zoom_plugin)
+ .add_plugins(client_attachment_plugin)
.insert_resource(DebugPickingMode::Disabled);
if self.server.is_some() {
app.add_observer(net::on_connecting)
M crates/unified/src/client/net.rs => crates/unified/src/client/net.rs +1 -1
@@ 6,7 6,7 @@ use crate::prelude::*;
pub fn set_config(mut q: Query<&mut TransportConfig, Added<TransportConfig>>) {
for mut q in &mut q {
- q.max_memory_usage = 8_388_608; // 8 MiB
+ q.max_memory_usage = 536_870_912; // 512 MiB
}
}
M crates/unified/src/client/parts.rs => crates/unified/src/client/parts.rs +1 -13
@@ 42,11 42,6 @@ fn handle_incoming_parts(
commands
.entity(new_entity)
.insert(sprite)
- /*.insert(AdditionalMassProperties::MassProperties(MassProperties {
- local_center_of_mass: Vec2::ZERO,
- mass: new_part.strong_config.physics.mass,
- principal_inertia: 7.5,
- }))*/
.insert(Pickable::default())
.observe(on_part_click);
}
@@ 70,14 65,7 @@ fn handle_updated_parts(
commands
.entity(updated_entity)
.remove::<Sprite>()
- //.remove::<AdditionalMassProperties>()
- .insert(sprite)
- /*
- .insert(AdditionalMassProperties::MassProperties(MassProperties {
- local_center_of_mass: Vec2::ZERO,
- mass: updated_part.strong_config.physics.mass,
- principal_inertia: 7.5,
- }))*/;
+ .insert(sprite);
}
}
A crates/unified/src/client/ship/attachment.rs => crates/unified/src/client/ship/attachment.rs +72 -0
@@ 0,0 1,72 @@
+use std::ops::Deref;
+use bevy::color::palettes::basic::{FUCHSIA, GREEN, WHITE};
+use bevy::color::palettes::css::ORANGE;
+use crate::attachment::{JointOf, Peer, SnapOf};
+use crate::ecs::Part;
+use crate::prelude::*;
+
+pub fn client_attachment_plugin(app: &mut App) {
+ app
+ .init_resource::<AttachmentDebugRes>()
+ .add_systems(Update, draw_attachment_debug);
+}
+
+
+#[derive(Resource, Default)]
+pub struct AttachmentDebugRes(pub bool);
+impl Deref for AttachmentDebugRes {
+ type Target = bool;
+
+ fn deref(&self) -> &Self::Target {
+ &self.0
+ }
+}
+
+
+pub fn draw_attachment_debug(
+ joints: Query<(&Transform, &JointOf, Option<&Peer>)>,
+ snaps: Query<(&Transform, &SnapOf)>,
+ parts: Query<&GlobalTransform, With<Part>>,
+ mut gizmos: Gizmos,
+ state: ResMut<AttachmentDebugRes>,
+) {
+ if !state.0 {
+ return;
+ }
+ for (offset, parent, peer) in joints.iter() {
+ let Ok(parent_pos) = parts.get(parent.0) else {
+ continue;
+ };
+ let joint_target = parent_pos.transform_point(offset.translation);
+ gizmos.cross_2d(joint_target.xy(), 4.0, FUCHSIA);
+
+ if let Some(peer_id) = peer
+ && let Ok(peer) = joints.get(peer_id.peer_joint_entity_id)
+ {
+ let Ok(peer_parent_pos) = parts.get(peer.1.0) else {
+ continue;
+ };
+ gizmos.arrow_2d(
+ peer_parent_pos.translation().xy(),
+ peer_parent_pos.translation().xy()
+ + ((peer.0.rotation * peer_parent_pos.rotation())
+ .mul_vec3(Vec3::Y)
+ .xy()
+ * 20.0),
+ ORANGE,
+ );
+ gizmos.arrow_2d(
+ parent_pos.translation().xy(),
+ peer_parent_pos.translation().xy(),
+ WHITE,
+ );
+ }
+ }
+ for (offset, parent) in snaps.iter() {
+ let Ok(parent_pos) = parts.get(parent.0) else {
+ continue;
+ };
+ let joint_snap = parent_pos.transform_point(offset.translation);
+ gizmos.cross_2d(joint_snap.xy(), 4.0, GREEN);
+ }
+}
A crates/unified/src/client/ship/mod.rs => crates/unified/src/client/ship/mod.rs +1 -0
@@ 0,0 1,1 @@
+pub mod attachment;<
\ No newline at end of file