Skip to content

Commit

Permalink
fix online bug
Browse files Browse the repository at this point in the history
  • Loading branch information
aratama committed Dec 17, 2024
1 parent 8eea913 commit e42a71e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/controller/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::controller::player::Player;
use crate::entity::bullet::SpawnBullet;
use crate::entity::life::Life;
use crate::inventory::Inventory;
use crate::level::{CurrentLevel, GameLevel, NextLevel};
use crate::level::{setup_level, CurrentLevel, GameLevel, NextLevel};
use crate::se::SE;
use crate::{
asset::GameAssets,
Expand Down Expand Up @@ -351,7 +351,11 @@ pub struct RemotePlayerPlugin;

impl Plugin for RemotePlayerPlugin {
fn build(&self, app: &mut App) {
app.add_systems(OnEnter(GameState::InGame), on_enter);
// setup_level も OnEnter(GameState::InGame) に登録されていますが、
// setup_level が完了すると current.level が更新されるため、
// on_enter の条件分岐が正しく動かず、オンラインになりません
// on_enter を先にやります
app.add_systems(OnEnter(GameState::InGame), on_enter.before(setup_level));

app.add_systems(OnExit(GameState::InGame), on_exit);

Expand Down
7 changes: 7 additions & 0 deletions src/debug.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ fn process_debug_command(
state: PlayerState::from_config(&config),
};
writer.send(OverlayEvent::Close(GameState::Warp));
} else if local.ends_with("arena") {
local.clear();
*level = NextLevel {
level: GameLevel::MultiPlayArena,
state: PlayerState::from_config(&config),
};
writer.send(OverlayEvent::Close(GameState::Warp));
} else if local.ends_with("boss") {
local.clear();
*level = NextLevel {
Expand Down
2 changes: 1 addition & 1 deletion src/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl Default for NextLevel {
}

/// レベルとプレイヤーキャラクターを生成します
fn setup_level(
pub fn setup_level(
mut commands: Commands,
level_aseprites: Res<Assets<Aseprite>>,
images: Res<Assets<Image>>,
Expand Down

0 comments on commit e42a71e

Please sign in to comment.