use bevy::{log::LogPlugin, prelude::*}; use bevy_ecs_markers::{ params::{Marker, MarkerMut}, EntityMarker, MarkerExt, }; #[derive(EntityMarker)] struct CurrentPlayer; #[derive(Component)] struct Player { name: &'static str, } fn main() { App::new() .add_plugins(LogPlugin::default()) .init_marker::() .add_systems(Startup, (setup, name_current_player).chain()) .run(); } fn setup(mut commands: Commands, mut current: MarkerMut) { let _ = commands.spawn(Player { name: "Gabriel" }).id(); let liam = commands.spawn(Player { name: "Liam" }).id(); current.assign(liam); } fn name_current_player(query: Query<&Player>, current: Marker) { let Ok(player) = query.get(current.id()) else { warn!("Current Player not set yet!"); return; }; info!("The player is called {}", player.name); }