use bevy::prelude::*;
use bevy_hotpatching_experiments::prelude::*;
fn main() -> AppExit {
App::new()
.add_plugins(DefaultPlugins)
.add_plugins(SimpleSubsecondPlugin::default())
.add_systems(Startup, setup)
.add_systems(Startup, register_components)
.add_systems(Update, print_components)
.run()
}
fn setup(mut commands: Commands) {
commands.spawn(Player {
name: "Killgore".to_string(),
health: 100.0,
..default()
});
commands.spawn(Camera2d);
commands.spawn(Text::default());
}
#[hot(rerun_on_hot_patch = true)]
fn register_components(registry: Res<AppTypeRegistry>) {
let mut registry = registry.write();
registry.register::<Player>();
}
#[derive(Debug, Reflect, Component, Default, HotPatchMigrate)]
#[reflect(Component, Default, HotPatchMigrate)]
struct Player {
name: String,
health: f32,
mana: f32,
}
#[hot(hot_patch_signature = true)]
fn print_components(player: Single<&Player>, mut text: Single<&mut Text>) {
text.0 = format!("Player: {:#?}", player.into_inner());
}