M crates/unified/src/client/key_input.rs => crates/unified/src/client/key_input.rs +0 -1
@@ 1,4 1,3 @@
-use crate::ecs::ThrustEvent;
use bevy::dev_tools::picking_debug::DebugPickingMode;
use crate::prelude::*;
use bevy::{
M crates/unified/src/ecs.rs => crates/unified/src/ecs.rs +1 -4
@@ 23,9 23,6 @@ pub struct FuelText;
#[derive(Component)]
pub struct PowerText;
-#[derive(Debug, Deserialize, Message, Serialize)]
-pub struct ThrustEvent(pub ThrustSolution);
-
#[derive(Component, Serialize, Deserialize, Debug)]
#[require(
RigidBody::Dynamic,
@@ 82,4 79,4 @@ pub struct PlayerStorage {
}
#[derive(Component)]
-pub struct Me;>
\ No newline at end of file
+pub struct Me;
M crates/unified/src/server/player/thrust.rs => crates/unified/src/server/player/thrust.rs +8 -6
@@ 1,5 1,4 @@
use crate::prelude::*;
-use crate::ecs::ThrustEvent;
use crate::server::ConnectedNetworkEntity;
pub fn server_thrust_plugin(app: &mut App) {
@@ 8,14 7,15 @@ pub fn server_thrust_plugin(app: &mut App) {
}
pub fn process_thrust_events(
- mut events: MessageReader<FromClient<ThrustEvent>>,
+ mut events: MessageReader<FromClient<ThrustSolution>>,
clients: Query<&ConnectedNetworkEntity>,
q_ls_me: Query<Entity, With<crate::ecs::Me>>,
+ mut commands: Commands
) {
for FromClient {
client_id,
- message: event,
+ message: thrust_solution,
} in events.read()
{
let player_hearty_entity = match client_id {
@@ 27,8 27,10 @@ pub fn process_thrust_events(
},
ClientId::Server => &q_ls_me.iter().next().unwrap()
};
- let thrust_solution = &event.0;
- if !thrust_solution.converged { return };
+/
+ commands.entity(player_hearty_entity).insert(thrust_solution);
+ trace!("installed thrust solution {:?}", thrust_solution);
+
/* TODO: @tm85: have fun!
TODO: The ThrustSolution contains a set of thrusters that should be on.
TODO: All other thrusters should be off.
@@ 65,4 67,4 @@ pub fn process_thrust_events(
TODO: Handle this with Option<&Component> in the query
*/
}
-}>
\ No newline at end of file
+}
M crates/unified/src/shared_plugins.rs => crates/unified/src/shared_plugins.rs +3 -2
@@ 1,6 1,6 @@
use crate::attachment::{Joint, JointOf, PartInShip, Peer, Ship, SnapOf, SnapOfJoint};
use crate::config::planet::{Planet, PlanetConfigCollection};
-use crate::ecs::{DragRequestEvent, Part, Particles, Player, PlayerStorage, ThrustEvent};
+use crate::ecs::{DragRequestEvent, Part, Particles, Player, PlayerStorage};
use bevy::app::{App, PluginGroup, PluginGroupBuilder};
use bevy_common_assets::toml::TomlAssetPlugin;
use crate::prelude::*;
@@ 8,6 8,7 @@ use bevy_replicon::prelude::{AppRuleExt, Channel, ClientMessageAppExt};
use crate::config::part::PartConfig;
use crate::config::world::GlobalWorldConfig;
use crate::physics::register_physics_components_for_replication;
+use crate::thrust::ThrustSolution;
pub struct SharedPluginGroup;
@@ 28,7 29,7 @@ impl PluginGroup for SharedPluginGroup {
}
pub fn register_everything(app: &mut App) {
- app.add_client_message::<ThrustEvent>(Channel::Ordered)
+ app.add_mapped_client_message::<ThrustSolution>(Channel::Ordered)
.add_mapped_client_message::<DragRequestEvent>(Channel::Ordered)
.replicate::<Transform>()
.replicate::<GlobalTransform>()
M crates/unified/src/thrust.rs => crates/unified/src/thrust.rs +4 -3
@@ 1,12 1,13 @@
use std::collections::BTreeSet;
-use bevy::prelude::{Entity, Resource};
+use bevy::prelude::{Entity, Resource, Compenent};
use serde::{Deserialize, Serialize};
/// A thrust solution, found by the thrust solver on the client.
/// `thrusters_on` is the set of thrusters that should be on.
/// Any thrusters not in this set should be off.
-#[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone, Resource)]
+#[derive(Serialize, Deserialize, Eq, PartialEq, Debug, Clone, Resource, Component, MapEntities)]
pub struct ThrustSolution {
+ #[entities]
pub thrusters_on: BTreeSet<Entity>,
pub converged: bool
-}>
\ No newline at end of file
+}