@@ -16,17 +16,12 @@ pub struct Map {
1616 pub height : i32 ,
1717 pub revealed_tiles : Vec < bool > ,
1818 pub visible_tiles : Vec < bool > ,
19- pub blocked : Vec < bool > ,
2019 pub depth : i32 ,
2120 pub bloodstains : HashSet < usize > ,
2221 pub view_blocked : HashSet < usize > ,
2322 pub name : String ,
2423 pub outdoors : bool ,
2524 pub light : Vec < rltk:: RGB > ,
26-
27- #[ serde( skip_serializing) ]
28- #[ serde( skip_deserializing) ]
29- pub tile_content : Vec < Vec < Entity > >
3025}
3126
3227impl Map {
@@ -37,32 +32,27 @@ impl Map {
3732 fn is_exit_valid ( & self , x : i32 , y : i32 ) -> bool {
3833 if x < 1 || x > self . width -1 || y < 1 || y > self . height -1 { return false ; }
3934 let idx = self . xy_idx ( x, y) ;
40- !self . blocked [ idx]
35+ !crate :: spatial :: is_blocked ( idx)
4136 }
4237
4338 pub fn populate_blocked ( & mut self ) {
44- for ( i, tile) in self . tiles . iter_mut ( ) . enumerate ( ) {
45- self . blocked [ i] = !tile_walkable ( * tile) ;
46- }
39+ crate :: spatial:: populate_blocked_from_map ( self ) ;
4740 }
4841
4942 pub fn clear_content_index ( & mut self ) {
50- for content in self . tile_content . iter_mut ( ) {
51- content. clear ( ) ;
52- }
43+ crate :: spatial:: clear ( ) ;
5344 }
5445
5546 /// Generates an empty map, consisting entirely of solid walls
5647 pub fn new < S : ToString > ( new_depth : i32 , width : i32 , height : i32 , name : S ) -> Map {
5748 let map_tile_count = ( width* height) as usize ;
49+ crate :: spatial:: set_size ( map_tile_count) ;
5850 Map {
5951 tiles : vec ! [ TileType :: Wall ; map_tile_count] ,
6052 width,
6153 height,
6254 revealed_tiles : vec ! [ false ; map_tile_count] ,
6355 visible_tiles : vec ! [ false ; map_tile_count] ,
64- blocked : vec ! [ false ; map_tile_count] ,
65- tile_content : vec ! [ Vec :: new( ) ; map_tile_count] ,
6656 depth : new_depth,
6757 bloodstains : HashSet :: new ( ) ,
6858 view_blocked : HashSet :: new ( ) ,
0 commit comments