Skip to content

Commit

Permalink
feat: upgrade bones and use iroh based multiplayer (#996)
Browse files Browse the repository at this point in the history
Co-authored-by: Max Whitehead <max.blackllama.alt3@gmail.com>
  • Loading branch information
dignifiedquire and MaxCWhitehead authored May 18, 2024
1 parent d27a8b7 commit 800a645
Show file tree
Hide file tree
Showing 9 changed files with 2,581 additions and 199 deletions.
2,747 changes: 2,562 additions & 185 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/game.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ network:

default_settings:
main_volume: 1.0
matchmaking_server: matchmaker.bones.fishfolk.org:65534
matchmaking_server: lokmcpce2uzezmh2iq3vf23cbu3grzrct66qcpdfrizmcrrlk5uq
player_controls:
# Gamepad controls
gamepad:
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.74
1.75
8 changes: 4 additions & 4 deletions src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ use crate::{prelude::*, settings::PlayerControlMapping};

pub mod prelude {
pub use super::{
attachment::*, bullet::*, camera::*, damage::*, debug::*, editor::*, editor::*,
elements::prelude::*, flappy_jellyfish::*, globals::*, input::*, item::*, lifetime::*,
map::*, map_constructor::*, map_pool::*, metadata::*, physics::*, player::*, random::*,
scoring::*, utils::*, win_indicator::*, FPS, MAX_PLAYERS,
attachment::*, bullet::*, camera::*, damage::*, debug::*, editor::*, elements::prelude::*,
flappy_jellyfish::*, globals::*, input::*, item::*, lifetime::*, map::*,
map_constructor::*, map_pool::*, metadata::*, physics::*, player::*, random::*, scoring::*,
utils::*, win_indicator::*, FPS, MAX_PLAYERS,
};
}

Expand Down
6 changes: 3 additions & 3 deletions src/core/player.rs
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ fn hydrate_players(
let meta = assets.get(player_handle);

let animation_bank_sprite = AnimationBankSprite {
current: "idle".try_into().unwrap(),
current: "idle".into(),
animations: meta.layers.body.animations.frames.clone(),
last_animation: default(),
};
Expand Down Expand Up @@ -686,7 +686,7 @@ fn hydrate_players(
animation_bank_sprites.insert(
fin_entity,
AnimationBankSprite {
current: "idle".try_into().unwrap(),
current: "idle".into(),
animations: meta.layers.fin.animations.clone(),
last_animation: default(),
},
Expand Down Expand Up @@ -714,7 +714,7 @@ fn hydrate_players(
animation_bank_sprites.insert(
face_entity,
AnimationBankSprite {
current: "idle".try_into().unwrap(),
current: "idle".into(),
animations: meta.layers.face.animations.clone(),
last_animation: default(),
},
Expand Down
2 changes: 1 addition & 1 deletion src/core/player/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn use_drop_or_grab_items_system(id: Ustr) -> StaticSystem<(), ()> {
.collect::<Vec<_>>();

// Grab the first item we are touching
if let Some(item) = colliders.get(0) {
if let Some(item) = colliders.first() {
// Add the item to the player inventory
commands.add(PlayerCommand::set_inventory(player_ent, Some(*item)));

Expand Down
1 change: 1 addition & 0 deletions src/core/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub use math::*;
mod rect;
pub use rect::*;
mod macros;
#[allow(unused)]
pub use macros::*;
mod metadata;
pub use metadata::*;
10 changes: 7 additions & 3 deletions src/ui/network_game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,8 @@ pub fn network_game_menu(
.show(ui)
.clicked()
{
lan::join_server(server);
// TODO: show error message
lan::join_server(server).expect("failed to join lan");
*status = NetworkGameStatus::Joining;
}

Expand Down Expand Up @@ -346,7 +347,9 @@ pub fn network_game_menu(
});
});

let (is_recreated, service_info) = lan::prepare_to_host(host_info, service_name);
let (is_recreated, service_info) = RUNTIME.block_on(async {
lan::prepare_to_host(host_info, service_name).await
});
if is_recreated {
*status = NetworkGameStatus::Idle;
}
Expand Down Expand Up @@ -456,7 +459,8 @@ pub fn network_game_menu(
.clicked()
{
*status = NetworkGameStatus::Searching;
online::start_search_for_game(matchmaking_server.clone(), *player_count);
let server = matchmaking_server.parse().expect("invalid server id");
online::start_search_for_game(server, *player_count);
}
} else if *status == NetworkGameStatus::Searching {
if let Some(online_socket) = online::update_search_for_game(&mut search_state) {
Expand Down
2 changes: 1 addition & 1 deletion src/ui/scoring.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ fn scoring_menu_system(

#[cfg(not(target_arch = "wasm32"))]
if let Some(socket) = network_socket.as_ref() {
handle_scoring_messages((**socket).deref(), &mut state);
handle_scoring_messages(socket, &mut state);
}

// Check if all non-ai players are ready
Expand Down

0 comments on commit 800a645

Please sign in to comment.