diff --git a/src/game/player.rs b/src/game/player.rs index 8290317..4b313cf 100644 --- a/src/game/player.rs +++ b/src/game/player.rs @@ -1,7 +1,7 @@ use std::{hash::Hash, time::Duration}; use animation::AnimBundle; -use bevy::{prelude::*, sprite::MaterialMesh2dBundle, utils::HashMap}; +use bevy::{ecs::system::SystemId, prelude::*, sprite::MaterialMesh2dBundle, utils::HashMap}; use bevy_rapier2d::prelude::*; @@ -14,8 +14,18 @@ mod animation; #[derive(Component)] struct Player; -pub(super) fn player_plugin(app: &mut App) { - app.add_systems(OnEnter(AppState::InGame), add_player.in_set(IngameSet)); +#[derive(Resource)] +struct PlayerSpawnOneshot(SystemId); + +impl FromWorld for PlayerSpawnOneshot { + fn from_world(world: &mut World) -> Self { + Self(world.register_system(add_player)) + } +} + +pub(super) fn plyer_plugin(app: &mut App) { + app.add_systems(OnEnter(AppState::InGame), add_player.in_set(IngameSet)) + .init_resource::(); } #[derive(Component, Hash, PartialEq, Eq, Default)]