Skip to content

Commit

Permalink
Remove an unnecessary resource
Browse files Browse the repository at this point in the history
  • Loading branch information
Indy2222 committed Aug 15, 2023
1 parent d330247 commit 1432af2
Showing 1 changed file with 1 addition and 17 deletions.
18 changes: 1 addition & 17 deletions crates/multiplayer/src/game.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ impl Plugin for GamePlugin {
fn build(&self, app: &mut App) {
app.add_event::<GameOpenedEvent>()
.add_event::<GameJoinedEvent>()
.add_systems(OnEnter(NetState::Connected), (setup, open_or_join))
.add_systems(OnEnter(NetState::None), cleanup)
.add_systems(OnEnter(NetState::Connected), open_or_join)
.add_systems(
PreMovement,
(
Expand Down Expand Up @@ -57,19 +56,6 @@ impl GameJoinedEvent {
}
}

#[derive(Resource)]
pub(crate) struct Players {
local: Option<Player>,
}

fn setup(mut commands: Commands) {
commands.insert_resource(Players { local: None });
}

fn cleanup(mut commands: Commands) {
commands.remove_resource::<Players>();
}

fn open_or_join(
conf: Res<NetGameConfRes>,
mut main_server: EventWriter<ToMainServerEvent>,
Expand Down Expand Up @@ -128,7 +114,6 @@ fn process_from_server(
}

fn process_from_game(
mut players: ResMut<Players>,
mut inputs: EventReader<FromGameServerEvent>,
mut fatals: EventWriter<FatalErrorEvent>,
state: Res<State<NetState>>,
Expand All @@ -148,7 +133,6 @@ fn process_from_game(
FromGame::Joined(id) => match Player::try_from(*id) {
Ok(player) => {
info!("Joined game as Player {player}.");
players.local = Some(player);
next_state.set(NetState::Joined);
joined_events.send(GameJoinedEvent::new(player));
}
Expand Down

0 comments on commit 1432af2

Please sign in to comment.