@@ -214,12 +214,18 @@ function addControllables(){
214214 trashCanLayer . objects . forEach ( ( obj , idx ) => {
215215 const x = ( obj . x ?? 0 ) + 30 ;
216216 const y = ( obj . y ?? 0 ) + 30 - ( obj . height ?? 0 ) ;
217- const trashCan = new TrashCan ( this , idx , x , y ) ;
218- ( trashCan . body as Phaser . Physics . Arcade . Body ) . setSize ( trashCan . width / 2 , 20 ) ;
219- this . trashCans . add ( trashCan ) ;
220- trashCan . setDepth ( 2 ) ;
221- // console.log(`Created trash can at (${x}, ${y})`);
222-
217+ if ( obj . properties && obj . properties [ 0 ] ) {
218+ const heldItems = obj . properties [ 0 ] . value . split ( "," ) . map ( ( item : string ) => item . trim ( ) as itemKeys ) ;
219+ const trashCan = new TrashCan ( this , idx , x , y , heldItems ) ;
220+ ( trashCan . body as Phaser . Physics . Arcade . Body ) . setSize ( trashCan . width / 2 , 20 ) ;
221+ this . trashCans . add ( trashCan ) ;
222+ trashCan . setDepth ( 2 ) ;
223+ } else {
224+ const trashCan = new TrashCan ( this , idx , x , y ) ;
225+ ( trashCan . body as Phaser . Physics . Arcade . Body ) . setSize ( trashCan . width / 2 , 20 ) ;
226+ this . trashCans . add ( trashCan ) ;
227+ trashCan . setDepth ( 2 ) ;
228+ }
223229 } ) ;
224230 }
225231 this . physics . add . collider ( this . trashCans , this . player ) ;
@@ -231,8 +237,7 @@ function addControllables(){
231237 doorLayer . objects . forEach ( ( obj , idx ) => {
232238 const x = ( obj . x ?? 0 ) + ( obj . width ?? 0 ) / 2 ;
233239 const y = ( obj . y ?? 0 ) - ( obj . height ?? 0 ) / 2 ;
234- const door = new Door ( this , idx , x , y , obj . id , obj . name . slice ( 0 , 4 ) , obj . properties . open ) ;
235- // const door = new Door(this, idx, x, y, obj.id, obj.properties.open);
240+ const door = new Door ( this , idx , x , y , obj . id , obj . name . slice ( 0 , 4 ) , obj . properties [ 0 ] . value ) ;
236241 this . doors . add ( door ) ;
237242 door . setDepth ( 2 ) ;
238243 // console.log(`Created door at (${x}, ${y})`);
@@ -276,7 +281,6 @@ function addControllables(){
276281 decorLayer . objects . forEach ( ( obj ) => {
277282 const x = ( obj . x ?? 0 ) + ( obj . width ?? 0 ) / 2 ;
278283 const y = ( obj . y ?? 0 ) - ( obj . height ?? 0 ) / 2 ;
279- console . log ( obj . name ) ;
280284 const decor = this . add . image ( x , y , obj . name ?? 'glass_shards' ) ;
281285 decor . setDisplaySize ( ( obj . width ?? decor . width ) , ( obj . height ?? decor . height ) )
282286 decor . setFlipX ( obj . flippedHorizontal ?? false ) ;
0 commit comments