From 068f98cec100772defce8ba966e5b917558b191c Mon Sep 17 00:00:00 2001 From: troido Date: Sat, 4 Apr 2020 23:48:07 +0200 Subject: draw the room after new entities have been added --- src/room.rs | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'src/room.rs') diff --git a/src/room.rs b/src/room.rs index fa46d47..2b4fb7e 100644 --- a/src/room.rs +++ b/src/room.rs @@ -6,7 +6,6 @@ use specs::{ WorldExt, DispatcherBuilder, Dispatcher, - Builder, Join, Entity }; @@ -30,7 +29,6 @@ use crate::{ Player, Inventory, Health, - New, Removed }, Encyclopedia, @@ -66,17 +64,17 @@ use crate::{ Spawn, Interact, DropLoot, - Growth + Growth, + Clear } }; pub fn default_dispatcher<'a, 'b>() -> Dispatcher<'a, 'b> { DispatcherBuilder::new() .with(Volate, "volate", &[]) - .with(RegisterNew::default(), "registernew", &[]) - .with(Growth, "growth", &["registernew"]) - .with(UpdateCooldowns, "cool_down", &["registernew"]) - .with(Spawn, "spawn", &["registernew"]) + .with(Growth, "growth", &[]) + .with(UpdateCooldowns, "cool_down", &[]) + .with(Spawn, "spawn", &[]) .with(ControlInput, "controlinput", &["cool_down"]) .with(ControlAI, "controlai", &["cool_down"]) .with(Take, "take", &["controlinput", "controlai"]) @@ -85,20 +83,20 @@ pub fn default_dispatcher<'a, 'b>() -> Dispatcher<'a, 'b> { .with(Move, "move", &["controlinput", "controlai"]) .with(Trapping, "trapping", &["move"]) .with(Fight, "fight", &["move"]) - .with(Heal, "heal", &["registernew"]) + .with(Heal, "heal", &[]) .with(Attacking, "attacking", &["use", "trapping", "fight", "heal", "interact"]) .with(Die, "die", &["attacking"]) .with(DropLoot, "droploot", &["attacking"]) - .with(View::default(), "view", &["move", "attacking", "volate", "die"]) - .with(Migrate, "migrate", &["view"]) - .with(Create, "create", &["view", "spawn", "droploot", "growth"]) - .with(Remove, "remove", &["view", "move", "droploot"]) + .with(Migrate, "migrate", &["move", "attacking", "volate", "die"]) + .with(Create, "create", &["migrate", "spawn", "droploot", "growth"]) + .with(Remove, "remove", &["migrate", "move", "droploot"]) .build() } pub struct Room<'a, 'b> { world: World, dispatcher: Dispatcher<'a, 'b>, + view_dispatcher: Dispatcher<'a, 'b>, pub id: RoomId, places: HashMap } @@ -129,6 +127,11 @@ impl <'a, 'b>Room<'a, 'b> { Room { world, dispatcher, + view_dispatcher: DispatcherBuilder::new() + .with(RegisterNew, "registernew", &[]) + .with(View, "view", &["registernew"]) + .with(Clear, "clear", &["view"]) + .build(), id, places: HashMap::new() } @@ -170,6 +173,7 @@ impl <'a, 'b>Room<'a, 'b> { self.world.fetch_mut::