diff options
| author | troido <troido@protonmail.com> | 2020-03-05 12:50:25 +0100 |
|---|---|---|
| committer | troido <troido@protonmail.com> | 2020-03-05 12:50:25 +0100 |
| commit | 170741fe959d30ee43ce689fd5fbae725cc1dae4 (patch) | |
| tree | de337876fb9afc3ca20e5a99ef61689813f51ebe /src/room.rs | |
| parent | ea99b86b89659624133a63f03600f0b57592a5f4 (diff) | |
equipent now kinda works
Diffstat (limited to 'src/room.rs')
| -rw-r--r-- | src/room.rs | 18 |
1 files changed, 12 insertions, 6 deletions
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::<Player>(); let inventories = self.world.read_component::<Inventory>(); let healths = self.world.read_component::<Health>(); + let equipments = self.world.read_component::<Equipment>(); 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<PlayerState> { let players = self.world.read_component::<Player>(); 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::<Health>(); let health = healths.get(ent)?; + let equipments = self.world.read_component::<Equipment>(); + 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() )) } |
