1- use crate :: prelude:: * ;
1+ use crate :: { prelude:: * , spawner:: template:: Templates } ;
2+ pub mod template;
23
34pub fn spawn_player ( ecs : & mut Commands , pos : TilePoint ) {
45 ecs. spawn ( PlayerBundle :: new ( pos) ) ;
56}
67
7- pub fn spawn_enemy ( ecs : & mut Commands , rng : & mut Rng , pos : TilePoint ) {
8- let ( hp, name, render_type) = match rng. i8 ( 0 ..=10 ) {
9- 1 ..=7 => bat ( ) ,
10- _ => giant ( ) ,
11- } ;
12- ecs. spawn ( EnemyBundle {
13- enemy : Enemy ,
14- pos,
15- name : EntityName ( name) ,
16- health : Health {
17- current : hp,
18- max : hp,
19- } ,
20- render : Render {
21- texture : render_type,
22- } ,
23- field_of_view : FieldOfView :: new ( 6 ) ,
24- movement_behaviour : ChasePlayer ,
25- } ) ;
26- }
8+ // pub fn spawn_enemy(ecs: &mut Commands, rng: &mut Rng, pos: TilePoint) {
9+ // let (hp, name, render_type) = match rng.i8(0..=10) {
10+ // 1..=7 => bat(),
11+ // _ => giant(),
12+ // };
13+ // ecs.spawn(EnemyBundle {
14+ // enemy: Enemy,
15+ // pos,
16+ // name: EntityName(name),
17+ // health: Health {
18+ // current: hp,
19+ // max: hp,
20+ // },
21+ // render: Render {
22+ // texture: render_type,
23+ // },
24+ // field_of_view: FieldOfView::new(6),
25+ // movement_behaviour: ChasePlayer,
26+ // });
27+ // }
2728
2829pub fn spawn_amulet ( ecs : & mut Commands , pos : TilePoint ) {
2930 ecs. spawn ( AmuletBundle {
@@ -32,47 +33,57 @@ pub fn spawn_amulet(ecs: &mut Commands, pos: TilePoint) {
3233 pos,
3334 name : EntityName ( "Amulet" . to_string ( ) ) ,
3435 render : Render {
35- texture : EntityType :: Amulet ,
36+ texture : RenderKey :: Amulet ,
3637 } ,
3738 } ) ;
3839}
3940
40- pub fn spawn_healing_potion ( ecs : & mut Commands , pos : TilePoint ) {
41- ecs. spawn ( (
42- Item ,
43- pos,
44- EntityName ( "Health Potion" . to_string ( ) ) ,
45- ProvidesHealing { amount : 6 } ,
46- Render {
47- texture : EntityType :: HealthPotion ,
48- } ,
49- ) ) ;
41+ pub fn spawn_level (
42+ ecs : & mut Commands ,
43+ template : & Templates ,
44+ rng : & mut Rng ,
45+ level : usize ,
46+ spawn_points : & [ TilePoint ] ,
47+ ) {
48+ template. spawn_entities ( ecs, rng, level, spawn_points) ;
5049}
5150
52- pub fn spawn_magic_mapper ( ecs : & mut Commands , pos : TilePoint ) {
53- ecs. spawn ( (
54- Item ,
55- pos,
56- EntityName ( "Mapper " . to_string ( ) ) ,
57- ProvidesDungeonMap ,
58- Render {
59- texture : EntityType :: Map ,
60- } ,
61- ) ) ;
62- }
51+ // pub fn spawn_healing_potion (ecs: &mut Commands, pos: TilePoint) {
52+ // ecs.spawn((
53+ // Item,
54+ // pos,
55+ // EntityName("Health Potion ".to_string()),
56+ // ProvidesHealing { amount: 6 } ,
57+ // Render {
58+ // texture: RenderKey::HealthPotion ,
59+ // },
60+ // ));
61+ // }
6362
64- pub fn spawn_entity ( ecs : & mut Commands , pos : TilePoint , rng : & mut Rng ) {
65- match rng. u8 ( 0 ..6 ) {
66- 1 => spawn_healing_potion ( ecs, pos) ,
67- 2 => spawn_magic_mapper ( ecs, pos) ,
68- _ => spawn_enemy ( ecs, rng, pos) ,
69- }
70- }
63+ // pub fn spawn_magic_mapper(ecs: &mut Commands, pos: TilePoint) {
64+ // ecs.spawn((
65+ // Item,
66+ // pos,
67+ // EntityName("Mapper".to_string()),
68+ // ProvidesDungeonMap,
69+ // Render {
70+ // texture: RenderKey::Map,
71+ // },
72+ // ));
73+ // }
7174
72- fn bat ( ) -> ( i32 , String , EntityType ) {
73- ( 1 , "Goblin" . to_string ( ) , EntityType :: Bat )
74- }
75+ // pub fn spawn_entity(ecs: &mut Commands, pos: TilePoint, rng: &mut Rng) {
76+ // match rng.u8(0..6) {
77+ // 1 => spawn_healing_potion(ecs, pos),
78+ // 2 => spawn_magic_mapper(ecs, pos),
79+ // _ => spawn_enemy(ecs, rng, pos),
80+ // }
81+ // }
7582
76- fn giant ( ) -> ( i32 , String , EntityType ) {
77- ( 2 , "Giant" . to_string ( ) , EntityType :: Cyclops )
78- }
83+ // fn bat() -> (i32, String, RenderKey) {
84+ // (1, "Goblin".to_string(), RenderKey::Bat)
85+ // }
86+
87+ // fn giant() -> (i32, String, RenderKey) {
88+ // (2, "Giant".to_string(), RenderKey::Cyclops)
89+ // }
0 commit comments