From d10d3e0368bd1178085ab8abd2ea24afe912b26f Mon Sep 17 00:00:00 2001 From: troido Date: Sat, 3 Oct 2020 15:47:42 +0200 Subject: removed dispatcher: call systems directly --- src/room.rs | 78 ++++++++++++++++++++++++++++++++----------------------------- 1 file changed, 41 insertions(+), 37 deletions(-) (limited to 'src/room.rs') diff --git a/src/room.rs b/src/room.rs index 4f0aa47..e629791 100644 --- a/src/room.rs +++ b/src/room.rs @@ -4,8 +4,6 @@ use std::collections::HashMap; use specs::{ World, WorldExt, - DispatcherBuilder, - Dispatcher, Join, Entity, RunNow @@ -75,36 +73,18 @@ use crate::{ } }; -pub fn default_dispatcher<'a, 'b>() -> Dispatcher<'a, 'b> { - DispatcherBuilder::new() - .with(Replace, "replace", &[]) - .with(Timeout, "timeout", &[]) - .with(UpdateCooldowns, "cool_down", &[]) - .with(Spawn, "spawn", &[]) - .with(SpawnCheck, "spawncheck", &["spawn"]) - .with(ControlInput, "controlinput", &["cool_down"]) - .with(ControlAI, "controlai", &["cool_down"]) - .with(Take, "take", &["controlinput", "controlai"]) - .with(Use, "use", &["controlinput", "controlai"]) - .with(Interact, "interact", &["controlinput", "controlai"]) - .with(SpawnTrigger, "spawntrigger", &["spawncheck", "replace"]) - .with(Move, "move", &["controlinput", "controlai"]) - .with(Trapping, "trapping", &["move"]) - .with(Fight, "fight", &["move"]) - .with(Heal, "heal", &[]) - .with(Attacking, "attacking", &["use", "trapping", "fight", "heal", "interact", "spawntrigger"]) - .with(Die, "die", &["attacking"]) - .with(DropLoot, "droploot", &["attacking"]) - .with(Building, "building", &["attacking"]) - .with(Migrate, "migrate", &["move", "attacking", "die"]) - .build() +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum RoomType { + Normal, + Purgatory } -pub struct Room<'a, 'b> { + +pub struct Room { world: World, - dispatcher: Option>, pub id: RoomId, - places: HashMap + places: HashMap, + room_type: RoomType } macro_rules! register_insert { @@ -119,9 +99,9 @@ macro_rules! register_insert { } -impl <'a, 'b>Room<'a, 'b> { +impl Room { - pub fn new(id: RoomId, encyclopedia: Encyclopedia, dispatcher: Option>) -> Room<'a, 'b> { + pub fn new(id: RoomId, encyclopedia: Encyclopedia, room_type: RoomType) -> Room { let mut world = World::new(); world.insert(NewEntities::new(encyclopedia)); register_insert!( @@ -132,9 +112,9 @@ impl <'a, 'b>Room<'a, 'b> { Room { world, - dispatcher, id, - places: HashMap::new() + places: HashMap::new(), + room_type } } @@ -165,12 +145,36 @@ impl <'a, 'b>Room<'a, 'b> { self.world.fetch::().output.clone() } - pub fn update(&mut self, timestamp: Timestamp, default_dispatcher: &mut Dispatcher) { + pub fn update(&mut self, timestamp: Timestamp) { self.world.fetch_mut::