add player spawn oneshot

This commit is contained in:
Schrottkatze 2024-11-23 18:28:37 +01:00
parent a24e6e39a6
commit f7f50a1b54
Signed by: schrottkatze
SSH key fingerprint: SHA256:hXb3t1vINBFCiDCmhRABHX5ocdbLiKyCdKI4HK2Rbbc

View file

@ -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::<PlayerSpawnOneshot>();
}
#[derive(Component, Hash, PartialEq, Eq, Default)]