11use super :: {
2- gamelog:: GameLog , mana_at_level, player_hp_at_level, Attributes , Equipped , InBackpack ,
3- LootTable , Map , Name , Player , Pools , Position , RunState , SufferDamage ,
2+ gamelog:: GameLog , mana_at_level, particle_system:: ParticleBuilder , player_hp_at_level,
3+ Attributes , Equipped , InBackpack , LootTable , Map , Name , Player , Point , Pools , Position ,
4+ RunState , SufferDamage ,
45} ;
56use crate :: prefabs:: { get_item_drop, spawn_named_item, SpawnType , PREFABS } ;
67use legion:: prelude:: * ;
@@ -12,9 +13,15 @@ pub fn build() -> Box<(dyn Schedulable + 'static)> {
1213 . read_component :: < Position > ( )
1314 . write_resource :: < Map > ( )
1415 . read_resource :: < Entity > ( )
16+ . write_resource :: < GameLog > ( )
1517 . read_component :: < Attributes > ( )
18+ . write_resource :: < ParticleBuilder > ( )
19+ . read_resource :: < Point > ( )
1620 . build (
17- |command_buffer, world, ( map, player_entity) , query| unsafe {
21+ |command_buffer,
22+ world,
23+ ( map, player_entity, log, particles, player_pos) ,
24+ query| unsafe {
1825 let mut xp_gain = 0 ;
1926 for ( entity, mut damage) in query. iter_entities_unchecked ( world) {
2027 if let Some ( mut stats) = world. get_component_mut_unchecked :: < Pools > ( entity) {
@@ -45,6 +52,10 @@ pub fn build() -> Box<(dyn Schedulable + 'static)> {
4552 if player_stats. experience >= player_stats. level * 1000 {
4653 // We've gone up a level!
4754 player_stats. level = player_stats. experience / 1000 + 1 ;
55+ log. entries . push ( format ! (
56+ "Congratulations, you are now level {}" ,
57+ player_stats. level
58+ ) ) ;
4859 player_stats. hit_points . max = player_hp_at_level (
4960 player_attributes. fitness . base + player_attributes. fitness . modifiers ,
5061 player_stats. level ,
@@ -56,6 +67,19 @@ pub fn build() -> Box<(dyn Schedulable + 'static)> {
5667 player_stats. level ,
5768 ) ;
5869 player_stats. mana . current = player_stats. mana . max ;
70+
71+ for i in 0 ..10 {
72+ if player_pos. y - i > 1 {
73+ particles. request (
74+ player_pos. x ,
75+ player_pos. y - i,
76+ rltk:: RGB :: named ( rltk:: GOLD ) ,
77+ rltk:: RGB :: named ( rltk:: BLACK ) ,
78+ rltk:: to_cp437 ( '░' ) ,
79+ 400.0 ,
80+ ) ;
81+ }
82+ }
5983 }
6084 }
6185 } ,
0 commit comments