|
|
|
|
@ -4,12 +4,17 @@ use games::*;
|
|
|
|
|
fn main() {
|
|
|
|
|
App::new()
|
|
|
|
|
.init_resource::<Thing>()
|
|
|
|
|
.add_plugins(BaseGamePlugin { camera: CameraType::Camera3d })
|
|
|
|
|
.add_plugins(BaseGamePlugin {
|
|
|
|
|
camera: CameraType::Camera3d,
|
|
|
|
|
})
|
|
|
|
|
.add_systems(Startup, init_ui)
|
|
|
|
|
.add_systems(Update, (
|
|
|
|
|
sync_resource_to_ui::<Thing>.run_if(resource_changed::<Thing>),
|
|
|
|
|
update_foo.run_if(on_event::<MouseMotion>)
|
|
|
|
|
))
|
|
|
|
|
.add_systems(
|
|
|
|
|
Update,
|
|
|
|
|
(
|
|
|
|
|
sync_resource_to_ui::<Thing>.run_if(resource_changed::<Thing>),
|
|
|
|
|
update_foo.run_if(on_event::<MouseMotion>),
|
|
|
|
|
),
|
|
|
|
|
)
|
|
|
|
|
.run();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -22,28 +27,27 @@ impl Display for Thing {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn init_ui(
|
|
|
|
|
mut commands: Commands
|
|
|
|
|
) {
|
|
|
|
|
fn init_ui(mut commands: Commands) {
|
|
|
|
|
commands.spawn((
|
|
|
|
|
Node {
|
|
|
|
|
align_self: AlignSelf::Start,
|
|
|
|
|
justify_self: JustifySelf::Center,
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
Text("Displays a sync'd resource tracking the number of mouse events (mod 256)".into()),
|
|
|
|
|
));
|
|
|
|
|
commands.spawn((Node {
|
|
|
|
|
align_self: AlignSelf::Center,
|
|
|
|
|
justify_self: JustifySelf::Center,
|
|
|
|
|
..default()
|
|
|
|
|
}, Text("Placeholder".into()), SyncResource::<Thing>::default()));
|
|
|
|
|
Node {
|
|
|
|
|
align_self: AlignSelf::Start,
|
|
|
|
|
justify_self: JustifySelf::Center,
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
Text("Displays a sync'd resource tracking the number of mouse events (mod 256)".into()),
|
|
|
|
|
));
|
|
|
|
|
commands.spawn((
|
|
|
|
|
Node {
|
|
|
|
|
align_self: AlignSelf::Center,
|
|
|
|
|
justify_self: JustifySelf::Center,
|
|
|
|
|
..default()
|
|
|
|
|
},
|
|
|
|
|
Text("Placeholder".into()),
|
|
|
|
|
SyncResource::<Thing>::default(),
|
|
|
|
|
));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn update_foo(
|
|
|
|
|
mut events: EventReader<MouseMotion>,
|
|
|
|
|
mut thing: ResMut<Thing>,
|
|
|
|
|
) {
|
|
|
|
|
fn update_foo(mut events: EventReader<MouseMotion>, mut thing: ResMut<Thing>) {
|
|
|
|
|
events.read().for_each(|_| {
|
|
|
|
|
thing.0 = thing.0.overflowing_add(1).0;
|
|
|
|
|
});
|
|
|
|
|
|