Slightly better implementation of peers, still need to create a more generic system for deciding which components to distribute where and then use that for Peers.
This commit is contained in:
parent
e013fb427a
commit
53fe3333f0
14 changed files with 438 additions and 265 deletions
|
|
@ -13,7 +13,10 @@ use super::{
|
|||
check_for_seed, setup_balls, setup_camera, setup_from_seed, setup_player, setup_walls,
|
||||
},
|
||||
state::AppState,
|
||||
ui::{setup_peer_ui, setup_seed_ui, update_peer_ui, update_peer_ui_timings, update_seed_ui},
|
||||
ui::{
|
||||
setup_peer_ui, setup_potential_peer_ui, setup_seed_ui, update_peer_ui,
|
||||
update_peer_ui_timings, update_potential_peer_ui, update_seed_ui,
|
||||
},
|
||||
};
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
|
|
@ -55,11 +58,20 @@ impl GamePlugin {
|
|||
impl Plugin for GamePlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.add_plugins((
|
||||
NetIOPlugin::new(self.port, self.source.try_to_address()),
|
||||
NetIOPlugin::maybe_peer(self.port, self.source.try_to_address()),
|
||||
distribution_plugin::<Seed>,
|
||||
PhysicsPlugins::default().with_length_unit(50.0),
|
||||
))
|
||||
.init_state::<AppState>()
|
||||
.add_systems(Startup, (setup_camera, setup_seed_ui, setup_peer_ui))
|
||||
.add_systems(
|
||||
Startup,
|
||||
(
|
||||
setup_camera,
|
||||
setup_seed_ui,
|
||||
setup_peer_ui,
|
||||
setup_potential_peer_ui,
|
||||
),
|
||||
)
|
||||
.add_systems(
|
||||
OnEnter(AppState::InGame),
|
||||
(
|
||||
|
|
@ -75,8 +87,7 @@ impl Plugin for GamePlugin {
|
|||
handle_new_peer,
|
||||
handle_deleted_peer,
|
||||
handle_incoming_packets,
|
||||
)
|
||||
.run_if(in_state(NetworkState::MultiPlayer)),
|
||||
),
|
||||
),
|
||||
)
|
||||
.add_systems(
|
||||
|
|
@ -85,14 +96,15 @@ impl Plugin for GamePlugin {
|
|||
((move_player, move_camera).chain(), zoom_camera)
|
||||
.run_if(in_state(AppState::InGame)),
|
||||
update_seed_ui,
|
||||
(update_peer_ui, update_peer_ui_timings)
|
||||
.run_if(in_state(NetworkState::MultiPlayer)),
|
||||
(
|
||||
update_peer_ui,
|
||||
update_peer_ui_timings,
|
||||
update_potential_peer_ui,
|
||||
),
|
||||
quit.run_if(input_pressed(KeyCode::KeyQ)),
|
||||
),
|
||||
);
|
||||
|
||||
Seed::register(app);
|
||||
|
||||
match self.source {
|
||||
DataSource::Address(peer) => {
|
||||
info!("Will retrieve seed from peer => {peer}");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue