aboutsummaryrefslogtreecommitdiff
path: root/src/client/map/mod.rs
diff options
context:
space:
mode:
authorArne Dußin2021-02-03 10:51:08 +0100
committerArne Dußin2021-02-03 10:51:08 +0100
commitd4c1c7ecb5688ef64f45425d9ac8e7ddeb8e8602 (patch)
tree6788d2efc22373d735947ba46d3a3ea3b3b3733c /src/client/map/mod.rs
parentf92e9f6f07b1e3834c2ca58ce3510734819d08e4 (diff)
downloadgraf_karto-d4c1c7ecb5688ef64f45425d9ac8e7ddeb8e8602.tar.gz
graf_karto-d4c1c7ecb5688ef64f45425d9ac8e7ddeb8e8602.zip
Fix commands
Commands now operate on the local file system, but on the remote world
Diffstat (limited to 'src/client/map/mod.rs')
-rw-r--r--src/client/map/mod.rs30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/client/map/mod.rs b/src/client/map/mod.rs
index eaab72f..27cafc4 100644
--- a/src/client/map/mod.rs
+++ b/src/client/map/mod.rs
@@ -20,6 +20,7 @@ use crate::world::{Room, Wall, World};
use icon_texture_manager::IconTextureManager;
use raylib::drawing::RaylibDrawHandle;
use raylib::{RaylibHandle, RaylibThread};
+use std::ops::Deref;
use std::rc::Rc;
/// The map containing all map elements that are seen on the screen.
@@ -194,7 +195,10 @@ impl Map {
/// items with the same id will therefore be ignored and not added.
pub fn add_data(&mut self, world: World) {
for (id, i) in world.icons().iter() {
- self.add_icon(*id, IconMark::from_icon(*i, self.icon_renderer.clone()));
+ self.add_icon(
+ *id,
+ IconMark::from_icon(i.clone(), self.icon_renderer.clone()),
+ );
}
for (id, r) in world.rooms().iter() {
self.add_room(*id, r.clone());
@@ -203,4 +207,28 @@ impl Map {
self.add_wall(*id, w.clone());
}
}
+
+ /// Creates a world from
+ pub fn clone_as_world(&self) -> World {
+ let rooms = self
+ .rooms
+ .iter()
+ .map(|(id, mark)| (*id, mark.deref().clone()))
+ .collect();
+ let rooms = StableVec::from_raw_unchecked(rooms);
+ let icons = self
+ .icons
+ .iter()
+ .map(|(id, mark)| (*id, mark.deref().clone()))
+ .collect();
+ let icons = StableVec::from_raw_unchecked(icons);
+ let walls = self
+ .walls
+ .iter()
+ .map(|(id, mark)| (*id, mark.deref().clone()))
+ .collect();
+ let walls = StableVec::from_raw_unchecked(walls);
+
+ World::from_raw_unchecked(rooms, walls, icons, self.used_ids.clone())
+ }
}