M crates/unified/src/client/key_input.rs => crates/unified/src/client/key_input.rs +14 -12
@@ 1,12 1,9 @@
-use crate::attachment::{Joint, SnapOfJoint};
-use crate::ecs::ThrustEvent;
+use crate::attachment::{Joint, JointOf, SnapOf, SnapOfJoint};
+use crate::ecs::{Part, ThrustEvent};
use bevy::color::palettes::css::{FUCHSIA, GREEN};
use bevy::dev_tools::picking_debug::DebugPickingMode;
use bevy::math::Vec3Swizzles;
-use bevy::prelude::{
- Gizmos, GlobalTransform, Query,
- ResMut, Resource, With,
-};
+use bevy::prelude::{Gizmos, GlobalTransform, Query, ResMut, Resource, Transform, With};
use bevy::{
app::{App, Update},
ecs::{event::EventWriter, system::Res},
@@ 69,18 66,23 @@ fn directional_keys(keys: Res<ButtonInput<KeyCode>>, mut thrust_event: EventWrit
}
fn draw_attachment_debug(
- joints: Query<&GlobalTransform, With<Joint>>,
- snaps: Query<&GlobalTransform, With<SnapOfJoint>>,
+ joints: Query<(&Transform, &JointOf)>,
+ snaps: Query<(&Transform, &SnapOf)>,
+ parts: Query<&GlobalTransform, With<Part>>,
mut gizmos: Gizmos,
state: ResMut<AttachmentDebugRes>,
) {
if !state.0 {
return;
}
- for joint_target in joints.iter() {
- gizmos.cross_2d(joint_target.translation().xy(), 4.0, FUCHSIA);
+ for (offset, parent) 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);
}
- for joint_snap in snaps.iter() {
- gizmos.cross_2d(joint_snap.translation().xy(), 4.0, GREEN);
+ 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/server/part.rs => crates/unified/src/server/part.rs +0 -4
@@ 72,13 72,11 @@ fn spawn_joint_bundle(joint: &JointConfig, part: &PartConfig, parent: &Entity) -
};
let joint_transform: Transform = j_comp.transform;
let joint_of = JointOf(*parent);
- let child_of = ChildOf(*parent);
(
j_comp,
joint_transform,
joint_of,
- child_of,
Replicated
)
}
@@ 86,13 84,11 @@ fn spawn_snap_bundle(joint: &JointConfig, parent: &Entity, p_joint: &Entity) ->
let snap_transform: Transform = joint.snap.into();
let snap_for = SnapOf(*parent);
let snap_of = SnapOfJoint(*p_joint);
- let child_of = ChildOf(*parent);
(
snap_transform,
snap_for,
snap_of,
- child_of,
Replicated
)
}
M crates/unified/src/shared_plugins.rs => crates/unified/src/shared_plugins.rs +3 -2
@@ 1,4 1,4 @@
-use crate::attachment::{Joint, JointOf, SnapOfJoint, PartInShip, Peer, Ship};
+use crate::attachment::{Joint, JointOf, SnapOfJoint, PartInShip, Peer, Ship, SnapOf};
use crate::config::planet::Planet;
use crate::ecs::{DragRequestEvent, Part, Particles, Player, ThrustEvent};
use bevy::app::{App, PluginGroup, PluginGroupBuilder};
@@ 34,7 34,8 @@ pub fn register_everything(app: &mut App) {
.replicate::<Joint>()
.replicate::<Peer>()
.replicate::<JointOf>()
- .replicate::<SnapOfJoint>();
+ .replicate::<SnapOfJoint>()
+ .replicate::<SnapOf>();
}
fn physics_setup_plugin(app: &mut App) {