From 170741fe959d30ee43ce689fd5fbae725cc1dae4 Mon Sep 17 00:00:00 2001 From: troido Date: Thu, 5 Mar 2020 12:50:25 +0100 Subject: equipent now kinda works --- src/room.rs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'src/room.rs') diff --git a/src/room.rs b/src/room.rs index f41350a..44882cf 100644 --- a/src/room.rs +++ b/src/room.rs @@ -31,7 +31,8 @@ use crate::{ Inventory, Health, New, - Removed + Removed, + Equipment }, Encyclopedia, roomtemplate::RoomTemplate, @@ -121,7 +122,7 @@ impl <'a, 'b>Room<'a, 'b> { world.insert(NewEntities::new(encyclopedia)); register_insert!( world, - (Position, Visible, Controller, Movable, Blocking, Floor, New, Removed, Moved, Player, Inventory, Health, Serialise, RoomExit, Entered, Dead, Trap, Fighter, Healing, Volatile, ControlCooldown, Autofight, MonsterAI, Home, Mortal, AttackInbox, Item, Spawner, Clan, Faction, Interactable, Loot, Grow), + (Position, Visible, Controller, Movable, Blocking, Floor, New, Removed, Moved, Player, Inventory, Health, Serialise, RoomExit, Entered, Dead, Trap, Fighter, Healing, Volatile, ControlCooldown, Autofight, MonsterAI, Home, Mortal, AttackInbox, Item, Spawner, Clan, Faction, Interactable, Loot, Grow, Equipment), (Ground, Input, Output, Size, Spawn, Players, Emigration, Time) ); @@ -222,20 +223,22 @@ impl <'a, 'b>Room<'a, 'b> { let players = self.world.read_component::(); let inventories = self.world.read_component::(); let healths = self.world.read_component::(); + let equipments = self.world.read_component::(); let mut saved = HashMap::new(); - for (player, inventory, health) in (&players, &inventories, &healths).join() { + for (player, inventory, health, equipment) in (&players, &inventories, &healths, &equipments).join() { saved.insert(player.id.clone(), PlayerState::create( player.id.clone(), self.id.clone(), inventory.items.iter().map(|item| item.ent.clone()).collect(), inventory.capacity, health.health, - health.maxhealth + health.maxhealth, + HashMap::new() )); } saved } - + // todo: merge save_players and save_player_ent fn save_player_ent(&self, ent: Entity) -> Option { let players = self.world.read_component::(); let player = players.get(ent)?; @@ -243,13 +246,16 @@ impl <'a, 'b>Room<'a, 'b> { let inventory = inventories.get(ent)?; let healths = self.world.read_component::(); let health = healths.get(ent)?; + let equipments = self.world.read_component::(); + let equipment = equipments.get(ent)?; Some(PlayerState::create( player.id.clone(), self.id.clone(), inventory.items.iter().map(|item| item.ent.clone()).collect(), inventory.capacity, health.health, - health.maxhealth + health.maxhealth, + HashMap::new() )) } -- cgit