@@ -73,7 +73,7 @@ pub struct Fatigue {
7373/// Increases an entity's fatigue over time
7474pub fn fatigue_system ( time : Res < Time > , mut fatigues : Query < & mut Fatigue > ) {
7575 for mut fatigue in & mut fatigues {
76- fatigue. level += fatigue. per_second * time. delta_seconds ( ) ;
76+ fatigue. level += fatigue. per_second * time. delta_secs ( ) ;
7777 if fatigue. level >= 100.0 {
7878 fatigue. level = 100.0 ;
7979 }
@@ -111,7 +111,7 @@ pub struct Sleep {
111111// the Sleep component's parameters.
112112fn sleep_action_system (
113113 time : Res < Time > ,
114- mut fatigues : Query < ( & mut Fatigue , & Handle < StandardMaterial > ) > ,
114+ mut fatigues : Query < ( & mut Fatigue , & MeshMaterial3d < StandardMaterial > ) > ,
115115 // Resource used to modify the appearance of the farmer.
116116 mut materials : ResMut < Assets < StandardMaterial > > ,
117117 // We execute actions by querying for their associated Action Component
@@ -133,7 +133,7 @@ fn sleep_action_system(
133133 }
134134 ActionState :: Executing => {
135135 trace ! ( "Sleeping..." ) ;
136- fatigue. level -= sleep. per_second * time. delta_seconds ( ) ;
136+ fatigue. level -= sleep. per_second * time. delta_secs ( ) ;
137137 materials. get_mut ( material) . unwrap ( ) . base_color = SLEEP_COLOR ;
138138
139139 if fatigue. level <= sleep. until {
@@ -208,7 +208,7 @@ pub struct Farm {
208208// Farm component's parameters and changes the entity's appearance to indicate the farming action.
209209fn farm_action_system (
210210 time : Res < Time > ,
211- mut actors : Query < ( & mut Inventory , & Handle < StandardMaterial > ) > ,
211+ mut actors : Query < ( & mut Inventory , & MeshMaterial3d < StandardMaterial > ) > ,
212212 // Resource used to modify the appearance of the farmer.
213213 mut materials : ResMut < Assets < StandardMaterial > > ,
214214 // Query to manage the state of the farming action.
@@ -225,7 +225,7 @@ fn farm_action_system(
225225 }
226226 ActionState :: Executing => {
227227 trace ! ( "Farming..." ) ;
228- inventory. items += farm. per_second * time. delta_seconds ( ) ;
228+ inventory. items += farm. per_second * time. delta_secs ( ) ;
229229 materials. get_mut ( material) . unwrap ( ) . base_color = FARM_COLOR ;
230230
231231 if inventory. items >= MAX_INVENTORY_ITEMS {
@@ -398,7 +398,7 @@ pub fn move_to_nearest_system<T: Component + std::fmt::Debug + Clone>(
398398 if distance > MAX_DISTANCE {
399399 trace ! ( "Stepping closer." ) ;
400400
401- let step_size = time. delta_seconds ( ) * move_to. speed ;
401+ let step_size = time. delta_secs ( ) * move_to. speed ;
402402 let step = delta. normalize ( ) * step_size. min ( distance) ;
403403
404404 // We only care about moving in the XZ plane.
@@ -455,15 +455,15 @@ fn update_ui(
455455) {
456456 for ( inventory, fatigue) in & mut actor_query. iter ( ) {
457457 for mut text in & mut money_query {
458- text. sections [ 0 ] . value = format ! ( "Money: {}" , inventory. money) ;
458+ text. 0 = format ! ( "Money: {}" , inventory. money) ;
459459 }
460460
461461 for mut text in & mut fatigue_query {
462- text. sections [ 0 ] . value = format ! ( "Fatigue: {}" , fatigue. level as u32 ) ;
462+ text. 0 = format ! ( "Fatigue: {}" , fatigue. level as u32 ) ;
463463 }
464464
465465 for mut text in & mut inventory_query {
466- text. sections [ 0 ] . value = format ! ( "Inventory: {}" , inventory. items as u32 ) ;
466+ text. 0 = format ! ( "Inventory: {}" , inventory. items as u32 ) ;
467467 }
468468 }
469469}
@@ -475,11 +475,10 @@ fn init_entities(
475475 mut meshes : ResMut < Assets < Mesh > > ,
476476 mut materials : ResMut < Assets < StandardMaterial > > ,
477477) {
478- commands. spawn ( Camera3dBundle {
479- transform : Transform :: from_xyz ( 6.0 , 6.0 , 4.0 )
480- . looking_at ( Vec3 :: new ( 0.0 , -1.0 , 0.0 ) , Vec3 :: Y ) ,
481- ..default ( )
482- } ) ;
478+ commands. spawn ( (
479+ Camera3d :: default ( ) ,
480+ Transform :: from_xyz ( 6.0 , 6.0 , 4.0 ) . looking_at ( Vec3 :: new ( 0.0 , -1.0 , 0.0 ) , Vec3 :: Y ) ,
481+ ) ) ;
483482
484483 commands. insert_resource ( AmbientLight {
485484 color : Color :: WHITE ,
@@ -488,26 +487,20 @@ fn init_entities(
488487
489488 commands. spawn ( (
490489 Name :: new ( "Light" ) ,
491- SpotLightBundle {
492- spot_light : SpotLight {
493- shadows_enabled : true ,
494- intensity : 500_000.0 ,
495- range : 100.0 ,
496- ..default ( )
497- } ,
498- transform : Transform :: from_xyz ( 2.0 , 10.0 , 0.0 ) . looking_at ( Vec3 :: ZERO , Vec3 :: Y ) ,
490+ SpotLight {
491+ shadows_enabled : true ,
492+ intensity : 500_000.0 ,
493+ range : 100.0 ,
499494 ..default ( )
500495 } ,
496+ Transform :: from_xyz ( 2.0 , 10.0 , 0.0 ) . looking_at ( Vec3 :: ZERO , Vec3 :: Y ) ,
501497 ) ) ;
502498
503499 // Loading our scene here. Note we'll still need to add components to different parts
504500 // of the gltf in order to query their positions. We do this through an observer further below.
505501 commands. spawn ( (
506502 Name :: new ( "Town" ) ,
507- SceneBundle {
508- scene : asset_server. load ( "models/town.glb#Scene0" ) ,
509- ..default ( )
510- } ,
503+ SceneRoot ( asset_server. load ( "models/town.glb#Scene0" ) ) ,
511504 ) ) ;
512505
513506 // We'll use `Steps` to execute a sequence of actions.
@@ -538,16 +531,13 @@ fn init_entities(
538531
539532 commands. spawn ( (
540533 Name :: new ( "Farmer" ) ,
541- PbrBundle {
542- mesh : meshes. add ( Mesh :: from ( Capsule3d {
543- half_length : 0.15 ,
544- radius : 0.1 ,
545- ..default ( )
546- } ) ) ,
547- material : materials. add ( DEFAULT_COLOR ) ,
548- transform : Transform :: from_xyz ( 0.0 , 0.5 , 0.0 ) ,
534+ Mesh3d ( meshes. add ( Mesh :: from ( Capsule3d {
535+ half_length : 0.15 ,
536+ radius : 0.1 ,
549537 ..default ( )
550- } ,
538+ } ) ) ) ,
539+ MeshMaterial3d ( materials. add ( DEFAULT_COLOR ) ) ,
540+ Transform :: from_xyz ( 0.0 , 0.5 , 0.0 ) ,
551541 Fatigue {
552542 is_sleeping : false ,
553543 per_second : 4.0 ,
@@ -566,29 +556,26 @@ fn init_entities(
566556 . when ( SellNeedScorer , move_and_sell) ,
567557 ) ) ;
568558
569- let style = TextStyle {
559+ let font = TextFont {
570560 font_size : 40.0 ,
571561 ..default ( )
572562 } ;
573563
574564 // Our scoreboard.
575565 commands
576- . spawn ( NodeBundle {
577- style : Style {
578- width : Val :: Percent ( 100.0 ) ,
579- height : Val :: Percent ( 100.0 ) ,
580- flex_direction : FlexDirection :: Column ,
581- justify_content : JustifyContent :: End ,
582- align_items : AlignItems :: FlexStart ,
583- padding : UiRect :: all ( Val :: Px ( 20.0 ) ) ,
584- ..default ( )
585- } ,
566+ . spawn ( Node {
567+ width : Val :: Percent ( 100.0 ) ,
568+ height : Val :: Percent ( 100.0 ) ,
569+ flex_direction : FlexDirection :: Column ,
570+ justify_content : JustifyContent :: End ,
571+ align_items : AlignItems :: FlexStart ,
572+ padding : UiRect :: all ( Val :: Px ( 20.0 ) ) ,
586573 ..default ( )
587574 } )
588575 . with_children ( |builder| {
589- builder. spawn ( ( TextBundle :: from_section ( "" , style . clone ( ) ) , MoneyText ) ) ;
590- builder. spawn ( ( TextBundle :: from_section ( "" , style . clone ( ) ) , FatigueText ) ) ;
591- builder. spawn ( ( TextBundle :: from_section ( "" , style . clone ( ) ) , InventoryText ) ) ;
576+ builder. spawn ( ( Text :: new ( "" ) , font . clone ( ) , MoneyText ) ) ;
577+ builder. spawn ( ( Text :: new ( "" ) , font . clone ( ) , FatigueText ) ) ;
578+ builder. spawn ( ( Text :: new ( "" ) , font . clone ( ) , InventoryText ) ) ;
592579 } ) ;
593580}
594581
@@ -640,7 +627,7 @@ fn main() {
640627 . add_event :: < SceneLoaded > ( )
641628 . add_systems ( Update , check_scene_loaded)
642629 // This observer will attach components to entities in the scene based on their names.
643- . observe (
630+ . add_observer (
644631 |trigger : Trigger < SceneLoaded > ,
645632 query : Query < ( Entity , & Name ) > ,
646633 mut commands : Commands | {
0 commit comments