| 
														
															@@ -1,4 +1,4 @@ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-use rltk::{GameState, Rltk, RGB}; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+use rltk::{GameState, Rltk, Point}; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 use specs::prelude::*; 
														 | 
														
														 | 
														
															 use specs::prelude::*; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 mod components; 
														 | 
														
														 | 
														
															 mod components; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -13,19 +13,34 @@ mod visibility_system; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 use visibility_system::VisibilitySystem; 
														 | 
														
														 | 
														
															 use visibility_system::VisibilitySystem; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 mod monster_ai_system; 
														 | 
														
														 | 
														
															 mod monster_ai_system; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 use monster_ai_system::MonsterAI; 
														 | 
														
														 | 
														
															 use monster_ai_system::MonsterAI; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+mod map_indexing_system; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+use map_indexing_system::MapIndexingSystem; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+mod melee_combat_system; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+use melee_combat_system::MeleeCombatSystem; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+mod damage_system; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+use damage_system::DamageSystem; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+mod gui; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+mod gamelog; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+use gamelog::GameLog; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+mod spawner; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+mod inventory_system; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+use inventory_system::*; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 // ***** // 
														 | 
														
														 | 
														
															 // ***** // 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 // STATE // 
														 | 
														
														 | 
														
															 // STATE // 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 #[derive(PartialEq, Copy, Clone)] 
														 | 
														
														 | 
														
															 #[derive(PartialEq, Copy, Clone)] 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 pub enum RunState {  
														 | 
														
														 | 
														
															 pub enum RunState {  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    Paused,  
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    Running  
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    AwaitingInput, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    PreRun, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    PlayerTurn, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    MonsterTurn, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    ShowInventory, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    ShowDropItem, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 pub struct State { 
														 | 
														
														 | 
														
															 pub struct State { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     pub ecs: World, 
														 | 
														
														 | 
														
															     pub ecs: World, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    pub runstate: RunState 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 impl State { 
														 | 
														
														 | 
														
															 impl State { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -34,6 +49,18 @@ impl State { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         vis.run_now(&self.ecs); 
														 | 
														
														 | 
														
															         vis.run_now(&self.ecs); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         let mut mob = MonsterAI{}; 
														 | 
														
														 | 
														
															         let mut mob = MonsterAI{}; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         mob.run_now(&self.ecs); 
														 | 
														
														 | 
														
															         mob.run_now(&self.ecs); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        let mut mapindex = MapIndexingSystem{}; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        mapindex.run_now(&self.ecs); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        let mut mcs = MeleeCombatSystem{}; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        mcs.run_now(&self.ecs); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        let mut dmgs = DamageSystem{}; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        dmgs.run_now(&self.ecs); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        let mut pickup = ItemCollectionSystem{}; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        pickup.run_now(&self.ecs); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        let mut potions = PotionUseSystem{}; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        potions.run_now(&self.ecs); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        let mut drop_items = ItemDropSystem{}; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        drop_items.run_now(&self.ecs); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         self.ecs.maintain(); 
														 | 
														
														 | 
														
															         self.ecs.maintain(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -41,25 +68,79 @@ impl State { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 impl GameState for State { 
														 | 
														
														 | 
														
															 impl GameState for State { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     fn tick(&mut self, ctx : &mut Rltk) { 
														 | 
														
														 | 
														
															     fn tick(&mut self, ctx : &mut Rltk) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         ctx.cls(); 
														 | 
														
														 | 
														
															         ctx.cls(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-         
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        if self.runstate == RunState::Running { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            self.run_systems(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            self.runstate = RunState::Paused; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        } else { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            self.runstate = player_input(self, ctx); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        let mut newrunstate; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            let runstate = self.ecs.fetch::<RunState>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            newrunstate = *runstate; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        match newrunstate { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            RunState::PreRun => { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                self.run_systems(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                self.ecs.maintain(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                newrunstate = RunState::AwaitingInput; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            RunState::AwaitingInput => { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                newrunstate = player_input(self, ctx); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            RunState::PlayerTurn => { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                self.run_systems(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                self.ecs.maintain(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                newrunstate = RunState::MonsterTurn; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            RunState::MonsterTurn => { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                self.run_systems(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                self.ecs.maintain(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                newrunstate = RunState::AwaitingInput; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            RunState::ShowInventory => { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                let result = gui::show_inventory(self, ctx); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                match result.0 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    gui::ItemMenuResult::Cancel => newrunstate = RunState::AwaitingInput, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    gui::ItemMenuResult::NoResponse => {} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    gui::ItemMenuResult::Selected => { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        let item_entity = result.1.unwrap(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        let mut intent = self.ecs.write_storage::<WantsToDrinkPotion>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        intent.insert(*self.ecs.fetch::<Entity>(), WantsToDrinkPotion{ potion: item_entity }).expect("Unable to insert intent"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        newrunstate = RunState::PlayerTurn; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            RunState::ShowDropItem => { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                let result = gui::drop_item_menu(self, ctx); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                match result.0 { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    gui::ItemMenuResult::Cancel => newrunstate = RunState::AwaitingInput, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    gui::ItemMenuResult::NoResponse => {} 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    gui::ItemMenuResult::Selected => { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        let item_entity = result.1.unwrap(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        let mut intent = self.ecs.write_storage::<WantsToDropItem>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        intent.insert(*self.ecs.fetch::<Entity>(), WantsToDropItem{ item: item_entity }).expect("Unable to insert intent"); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                        newrunstate = RunState::PlayerTurn; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                    } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+                } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            let mut runwriter = self.ecs.write_resource::<RunState>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+            *runwriter = newrunstate; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        damage_system::delete_the_dead(&mut self.ecs); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         draw_map(&self.ecs, ctx); 
														 | 
														
														 | 
														
															         draw_map(&self.ecs, ctx); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         let positions = self.ecs.read_storage::<Position>(); 
														 | 
														
														 | 
														
															         let positions = self.ecs.read_storage::<Position>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         let renderables = self.ecs.read_storage::<Renderable>(); 
														 | 
														
														 | 
														
															         let renderables = self.ecs.read_storage::<Renderable>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         let map = self.ecs.fetch::<Map>(); 
														 | 
														
														 | 
														
															         let map = self.ecs.fetch::<Map>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        for (pos, render) in (&positions, &renderables).join() { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        let mut data = (&positions, &renderables).join().collect::<Vec<_>>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        data.sort_by(|&a, &b| b.1.render_order.cmp(&a.1.render_order) ); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        for (pos, render) in data.iter() { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             let idx = map.xy_idx(pos.x, pos.y); 
														 | 
														
														 | 
														
															             let idx = map.xy_idx(pos.x, pos.y); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															             if map.visible_tiles[idx] { ctx.set(pos.x, pos.y, render.fg, render.bg, render.glyph) } 
														 | 
														
														 | 
														
															             if map.visible_tiles[idx] { ctx.set(pos.x, pos.y, render.fg, render.bg, render.glyph) } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         } 
														 | 
														
														 | 
														
															         } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-         
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        gui::draw_ui(&self.ecs, ctx); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -69,11 +150,13 @@ impl GameState for State { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 fn main() -> rltk::BError { 
														 | 
														
														 | 
														
															 fn main() -> rltk::BError { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     use rltk::RltkBuilder; 
														 | 
														
														 | 
														
															     use rltk::RltkBuilder; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     let context = RltkBuilder::simple80x50() 
														 | 
														
														 | 
														
															     let context = RltkBuilder::simple80x50() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        .with_title("Roguelike Tutorial") 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        .with_title("Saint Antony's Fire") 
														 | 
													
												
											
												
													
														| 
														 | 
														
															         .build()?; 
														 | 
														
														 | 
														
															         .build()?; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    // Add scanlines 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    //context.with_post_scanlines(true); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     let mut gs = State{  
														 | 
														
														 | 
														
															     let mut gs = State{  
														 | 
													
												
											
												
													
														| 
														 | 
														
															         ecs: World::new(), 
														 | 
														
														 | 
														
															         ecs: World::new(), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        runstate: RunState::Running 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     }; 
														 | 
														
														 | 
														
															     }; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     gs.ecs.register::<Position>(); 
														 | 
														
														 | 
														
															     gs.ecs.register::<Position>(); 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -81,47 +164,38 @@ fn main() -> rltk::BError { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     gs.ecs.register::<Player>(); 
														 | 
														
														 | 
														
															     gs.ecs.register::<Player>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     gs.ecs.register::<Viewshed>(); 
														 | 
														
														 | 
														
															     gs.ecs.register::<Viewshed>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     gs.ecs.register::<Monster>(); 
														 | 
														
														 | 
														
															     gs.ecs.register::<Monster>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.register::<Name>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.register::<BlocksTile>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.register::<CombatStats>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.register::<WantsToMelee>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.register::<SufferDamage>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.register::<Item>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.register::<Potion>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.register::<InBackpack>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.register::<WantsToPickupItem>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.register::<WantsToDrinkPotion>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.register::<WantsToDropItem>(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     let map = Map::new_map_rooms_and_corridors(); 
														 | 
														
														 | 
														
															     let map = Map::new_map_rooms_and_corridors(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     let (player_x, player_y) = map.rooms[0].center(); 
														 | 
														
														 | 
														
															     let (player_x, player_y) = map.rooms[0].center(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    let mut rng = rltk::RandomNumberGenerator::new(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    for room in map.rooms.iter().skip(1) { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        let (x,y) = room.center(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        let glyph : rltk::FontCharType; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        let roll = rng.roll_dice(1, 2); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        match roll { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            1 => { glyph = rltk::to_cp437('g') } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            _ => { glyph = rltk::to_cp437('o') } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    let player_entity = spawner::player(&mut gs.ecs, player_x, player_y); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															      
														 | 
														
														 | 
														
															      
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        gs.ecs.create_entity() 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            .with(Position{ x, y }) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            .with(Renderable{ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                glyph: glyph, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                fg: RGB::named(rltk::RED), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-                bg: RGB::named(rltk::BLACK), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            }) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            .with(Viewshed{ visible_tiles : Vec::new(), range: 8, dirty: true }) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            .with(Monster{}) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            .build(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.insert(player_entity); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    let rng = rltk::RandomNumberGenerator::new(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.insert(rng); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    for room in map.rooms.iter().skip(1) { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+        spawner::spawn_room(&mut gs.ecs, room); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     gs.ecs.insert(map); 
														 | 
														
														 | 
														
															     gs.ecs.insert(map); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.insert(Point::new(player_x, player_y)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.insert(RunState::PreRun); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    gs.ecs 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        .create_entity() 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        .with(Position { x: player_x, y: player_y }) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-        .with(Renderable { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            glyph: rltk::to_cp437('@'), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            fg: RGB::named(rltk::YELLOW), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-            bg: RGB::named(rltk::BLACK), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    }) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    .with(Player{}) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    .with(Viewshed{ visible_tiles : Vec::new(), range : 8, dirty: true }) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    .build(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-     
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    gs.ecs.insert(gamelog::GameLog{ entries : vec!["Saint Antony casts out...".to_string()] }); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															     rltk::main_loop(context, gs) 
														 | 
														
														 | 
														
															     rltk::main_loop(context, gs) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 } 
														 | 
														
														 | 
														
															 } 
														 |