1
1
use std:: collections:: HashMap ;
2
2
3
- use bevy:: { ecs :: system :: CommandQueue , prelude:: * } ;
3
+ use bevy:: prelude:: * ;
4
4
5
5
struct Enemy {
6
6
hit_points : u32 ,
@@ -32,19 +32,16 @@ fn spawn_enemy(mut commands: Commands, character_template: Res<CharacterTemplate
32
32
33
33
#[ test]
34
34
fn did_hurt_enemy ( ) {
35
- // Setup world and commands
35
+ // Setup world
36
36
let mut world = World :: default ( ) ;
37
- let mut queue = CommandQueue :: default ( ) ;
38
- let mut commands = Commands :: new ( & mut queue, & world) ;
39
37
40
38
// Setup stage with our two systems
41
39
let mut update_stage = SystemStage :: parallel ( ) ;
42
40
update_stage. add_system ( hurt_enemies. system ( ) . before ( "death" ) ) ;
43
41
update_stage. add_system ( despawn_dead_enemies. system ( ) . label ( "death" ) ) ;
44
42
45
43
// Setup test entities
46
- let enemy_id = commands. spawn ( ) . insert ( Enemy { hit_points : 5 } ) . id ( ) ;
47
- queue. apply ( & mut world) ;
44
+ let enemy_id = world. spawn ( ) . insert ( Enemy { hit_points : 5 } ) . id ( ) ;
48
45
49
46
// Run systems
50
47
update_stage. run ( & mut world) ;
@@ -56,19 +53,16 @@ fn did_hurt_enemy() {
56
53
57
54
#[ test]
58
55
fn did_despawn_enemy ( ) {
59
- // Setup world and commands
56
+ // Setup world
60
57
let mut world = World :: default ( ) ;
61
- let mut queue = CommandQueue :: default ( ) ;
62
- let mut commands = Commands :: new ( & mut queue, & world) ;
63
58
64
59
// Setup stage with our two systems
65
60
let mut update_stage = SystemStage :: parallel ( ) ;
66
61
update_stage. add_system ( hurt_enemies. system ( ) . before ( "death" ) ) ;
67
62
update_stage. add_system ( despawn_dead_enemies. system ( ) . label ( "death" ) ) ;
68
63
69
64
// Setup test entities
70
- let enemy_id = commands. spawn ( ) . insert ( Enemy { hit_points : 1 } ) . id ( ) ;
71
- queue. apply ( & mut world) ;
65
+ let enemy_id = world. spawn ( ) . insert ( Enemy { hit_points : 1 } ) . id ( ) ;
72
66
73
67
// Run systems
74
68
update_stage. run ( & mut world) ;
@@ -79,10 +73,8 @@ fn did_despawn_enemy() {
79
73
80
74
#[ test]
81
75
fn spawned_from_resource ( ) {
82
- // Setup world and commands
76
+ // Setup world
83
77
let mut world = World :: default ( ) ;
84
- let mut queue = CommandQueue :: default ( ) ;
85
- let mut commands = Commands :: new ( & mut queue, & world) ;
86
78
87
79
// Setup stage with a system
88
80
let mut update_stage = SystemStage :: parallel ( ) ;
@@ -91,8 +83,7 @@ fn spawned_from_resource() {
91
83
// Setup test resource
92
84
let mut hit_points = HashMap :: new ( ) ;
93
85
hit_points. insert ( "enemy" , 25 ) ;
94
- commands. insert_resource ( CharacterTemplate { hit_points } ) ;
95
- queue. apply ( & mut world) ;
86
+ world. insert_resource ( CharacterTemplate { hit_points } ) ;
96
87
97
88
// Run systems
98
89
update_stage. run ( & mut world) ;
0 commit comments