@@ -26,7 +26,6 @@ export class Tile {
26
26
}
27
27
28
28
export interface MapRegion {
29
- tiles : Tile [ ] ;
30
29
objects : LandscapeObject [ ] ;
31
30
mapFile : MapFile ;
32
31
}
@@ -101,25 +100,30 @@ export class ChunkManager {
101
100
logger . error ( `Error decoding landscape file ${ mapRegionX } ,${ mapRegionY } ` ) ;
102
101
}
103
102
104
- const region : MapRegion = { mapFile, tiles : [ ] ,
105
- objects : landscapeFile ?. landscapeObjects || [ ] } ;
103
+ const region : MapRegion = { mapFile, objects : landscapeFile ?. landscapeObjects || [ ] } ;
106
104
107
105
this . regionMap . set ( key , region ) ;
108
- this . registerObjects ( region . objects , region . tiles || [ ] ) ;
106
+ this . registerObjects ( region . objects , mapFile ) ;
109
107
}
110
108
111
- public registerObjects ( objects : LandscapeObject [ ] , tiles : Tile [ ] ) : void {
109
+ public registerObjects ( objects : LandscapeObject [ ] , mapFile : MapFile ) : void {
112
110
if ( ! objects || objects . length === 0 ) {
113
111
return ;
114
112
}
115
113
114
+ const mapWorldPositionX = ( mapFile . regionX & 0xff ) * 64 ;
115
+ const mapWorldPositionY = mapFile . regionY * 64 ;
116
+
116
117
for ( const object of objects ) {
117
118
const position = new Position ( object . x , object . y , object . level ) ;
118
-
119
- if ( tiles . some ( tile => ( tile ?. settings & 0x2 ) === 2 &&
120
- tile ?. x === object . x && tile ?. y === object . y && tile ?. level >= object . level ) ) {
121
- // Object is on or underneath a bridge tile and needs to move down one level
122
- position . move ( object . x , object . y , object . level - 1 ) ;
119
+ const localX = object . x - mapWorldPositionX ;
120
+ const localY = object . y - mapWorldPositionY ;
121
+
122
+ for ( let level = 3 ; level >= 0 ; level -- ) {
123
+ if ( ( mapFile . tileSettings [ level ] [ localX ] [ localY ] & 0x2 ) === 2 ) {
124
+ // Object is on or underneath a bridge tile and needs to move down one level
125
+ position . move ( object . x , object . y , object . level - 1 ) ;
126
+ }
123
127
}
124
128
125
129
this . getChunkForWorldPosition ( position ) . setFilestoreLandscapeObject ( object ) ;
0 commit comments