@@ 22,6 22,7 @@ static GLOBAL: tikv_jemallocator::Jemalloc = tikv_jemallocator::Jemalloc;
use std::net::IpAddr;
use crate::mathutil::rot2d;
+use crate::ws::{StkTungsteniteServerConfig, StkTungsteniteServerPlugin, WsEvent};
use bevy::math::{vec2, vec3};
use bevy::{
app::{PluginGroupBuilder, ScheduleRunnerPlugin},
@@ 30,7 31,6 @@ use bevy::{
time::TimePlugin,
};
use bevy_rapier2d::prelude::*;
-use bevy_tungstenite_stk::{StkTungsteniteServerConfig, StkTungsteniteServerPlugin, WsEvent};
use component::Input;
use component::*;
use hmac::{Hmac, Mac};
@@ 49,6 49,7 @@ pub mod component;
pub mod macros;
pub mod mathutil;
pub mod packet;
+pub mod ws;
const CLIENT_SCALE: f32 = 50.0;
@@ 297,7 298,14 @@ fn on_message(
(Without<PlanetType>, Without<Player>),
>,
mut player_query: Query<
- (Entity, &mut Player, &Transform, &Velocity, &mut Attach, &mut PartFlags),
+ (
+ Entity,
+ &mut Player,
+ &Transform,
+ &Velocity,
+ &mut Attach,
+ &mut PartFlags,
+ ),
Without<PlanetType>,
>,
mut packet_recv: Local<ManualEventReader<WsEvent>>,
@@ 648,7 656,8 @@ fn on_message(
module.2.translation = vec3(x, y, 0.);
if *module.1 == PartType::LandingThruster {
let sub_entity = attach.children[2].unwrap();
- let mut suspension = attached_query.get_mut(sub_entity).unwrap();
+ let mut suspension =
+ attached_query.get_mut(sub_entity).unwrap();
suspension.2.translation = vec3(x, y, 0.);
}
break;
@@ 1017,7 1026,14 @@ fn detach_recursive(
(Without<PlanetType>, Without<Player>),
>,
player_query: &mut Query<
- (Entity, &mut Player, &Transform, &Velocity, &mut Attach, &mut PartFlags),
+ (
+ Entity,
+ &mut Player,
+ &Transform,
+ &Velocity,
+ &mut Attach,
+ &mut PartFlags,
+ ),
Without<PlanetType>,
>,
) {
@@ 1030,8 1046,7 @@ fn detach_recursive(
detach_recursive(commands, *child, attached_query, player_query);
}
let (entity, part_type, attach, mut flags) = if attached_query.contains(this) {
- let (entity, part_type, _, attach, _, _, _, flags) =
- attached_query.get_mut(this).unwrap();
+ let (entity, part_type, _, attach, _, _, _, flags) = attached_query.get_mut(this).unwrap();
(entity, part_type, attach, flags)
} else {
let (entity, _, _, _, attach, part_flags) = player_query.get_mut(this).unwrap();
@@ 1102,7 1117,14 @@ fn attach_on_module_tree(
(Without<PlanetType>, Without<Player>, Without<Attach>),
>,
player_query: &mut Query<
- (Entity, &mut Player, &Transform, &Velocity, &mut Attach, &mut PartFlags),
+ (
+ Entity,
+ &mut Player,
+ &Transform,
+ &Velocity,
+ &mut Attach,
+ &mut PartFlags,
+ ),
Without<PlanetType>,
>,
) -> bool {
@@ 1508,7 1530,17 @@ fn break_modules(
),
(Without<PlanetType>, Without<Player>),
>,
- mut player_query: Query<(Entity, &mut Player, &Transform, &Velocity, &mut Attach, &mut PartFlags), Without<PlanetType>>,
+ mut player_query: Query<
+ (
+ Entity,
+ &mut Player,
+ &Transform,
+ &Velocity,
+ &mut Attach,
+ &mut PartFlags,
+ ),
+ Without<PlanetType>,
+ >,
) {
let joints = rapier_context.entity2impulse_joint();
let mut detach_list = Vec::new();
@@ 1524,7 1556,12 @@ fn break_modules(
}
}
for (entity, _part_type, _attach) in detach_list {
- detach_recursive(&mut commands, entity, &mut attached_query, &mut player_query);
+ detach_recursive(
+ &mut commands,
+ entity,
+ &mut attached_query,
+ &mut player_query,
+ );
}
}