@@ -162,7 +162,7 @@ class GameMap {
162162 this . portalTexture = await loadTexture ( `${ INTERFACE_DIR } /gateAnm.sad` ) ;
163163 }
164164
165- async loadMap ( rmdFileName = "[000]T01.rmd" ) {
165+ async loadMap ( rmdFileName = "[000]T01.rmd" , gate = - 1 ) {
166166 // async loadMap(rmdFileName = "[373]T02.rmd") {
167167 // async loadMap(rmdFileName = "[130]G09.rmd") {
168168 // async loadMap(rmdFileName = "[010]G13.rmd") {
@@ -176,7 +176,7 @@ class GameMap {
176176 console . log ( "[Game]" , "Map:" , this . rsMap . name ) ;
177177
178178 Camera . setMapSize ( this . rsMap . pixelWidth , this . rsMap . pixelHeight ) ;
179- this . initPosition ( ) ;
179+ this . initPosition ( gate ) ;
180180
181181 const mapsetName = getMapsetName ( this . rsMap . tileSet ) ;
182182 this . tileTexture = await loadTexture ( `${ MAPSET_DIR } /${ mapsetName } /tile.mpr` ) ;
@@ -373,7 +373,7 @@ class GameMap {
373373 } ;
374374 if ( getDistance ( RedStone . player , portalPoint ) < 70 ) {
375375 console . log ( "portal gate" , this . selectedPortal . area . string ) ;
376- this . moveField ( this . selectedPortal . area . string ) ;
376+ this . moveField ( this . selectedPortal . area ) ;
377377 this . selectedPortal = null ;
378378 return ;
379379 }
@@ -430,13 +430,8 @@ class GameMap {
430430 bounds = mergedBounds ;
431431 }
432432
433- if ( ! Camera . isRectInView ( bounds ) ) {
434- return ;
435- }
436-
433+ // Update actor sprites regardless of whether it is visible or not
437434 if ( sprite . isActorSprite ) {
438- actorSpritesInView . push ( sprite , sprite . shadowSprite ) ;
439-
440435 const actor = sprite . actor ;
441436
442437 actor . getBody ( ) . updatePixiSprite ( sprite , "body" , actor . pos . x , actor . pos . y , actor . anm , actor . direct , actor . frame , actor . horizonScale , actor . verticalScale ) ;
@@ -445,7 +440,14 @@ class GameMap {
445440 } else {
446441 sprite . shadowSprite = actor . getBody ( ) . createPixiSprite ( "shadow" , actor . pos . x , actor . pos . y , actor . anm , actor . direct , actor . frame , actor . horizonScale , actor . verticalScale ) ;
447442 }
443+ }
448444
445+ if ( ! Camera . isRectInView ( bounds ) ) {
446+ return ;
447+ }
448+
449+ if ( sprite . isActorSprite ) {
450+ actorSpritesInView . push ( sprite , sprite . shadowSprite ) ;
449451 sprite . actor . put ( ) ;
450452 }
451453
@@ -744,9 +746,14 @@ class GameMap {
744746 } ) ;
745747 }
746748
747- initPosition ( ) {
749+ initPosition ( gate ) {
748750 if ( this . prevRmdName ) {
749- const portalToPrevMap = this . rsMap . area . areas . find ( area => area ?. string === this . prevRmdName ) ;
751+ const portalToPrevMap = this . rsMap . area . areas . find ( area => {
752+ if ( typeof gate === 'number' && gate !== - 1 ) {
753+ return area ?. serial === gate ;
754+ }
755+ return area ?. string === this . prevRmdName ;
756+ } ) ;
750757
751758 if ( portalToPrevMap ) {
752759 const centerPos = portalToPrevMap . getCenterPos ( ) ;
@@ -765,6 +772,20 @@ class GameMap {
765772 }
766773 }
767774
775+ movePosition ( gate ) {
776+ const targetPortal = this . rsMap . area . areas . find ( area => {
777+ if ( typeof gate === 'number' && gate !== - 1 ) {
778+ return area ?. serial === gate ;
779+ }
780+ return area ?. string === this . prevRmdName ;
781+ } ) ;
782+
783+ const centerPos = targetPortal . getCenterPos ( ) ;
784+
785+ Camera . setPosition ( centerPos . x , centerPos . y ) ;
786+ RedStone . player . setPosition ( centerPos . x , centerPos . y ) ;
787+ }
788+
768789 getRealSize ( ) {
769790 if ( ! this . rsMap ) return null ;
770791 return {
@@ -773,13 +794,25 @@ class GameMap {
773794 }
774795 }
775796
776- async moveField ( rmdFileName ) {
777- if ( rmdFileName === this . currentRmdFileName ) return ;
797+ async moveField ( destInfo ) {
798+ if ( typeof destInfo === 'string' && rmdFileName === this . currentRmdFileName ) return ;
799+
800+ const isInnerPortal = destInfo ?. gateShape === GAS_INNER_PORTAL ;
801+ const gateSerial = destInfo ?. moveGate ;
802+
803+ if ( isInnerPortal ) {
804+ this . movePosition ( gateSerial ) ;
805+ return ;
806+ }
807+
778808 this . prevRmdName = this . currentRmdFileName ;
779809 LoadingScreen . render ( ) ;
780810 RedStone . miniMap . reset ( ) ;
781811 this . reset ( ) ;
782- await this . loadMap ( rmdFileName ) ;
812+
813+ const rmdFileName = typeof destInfo === 'string' ? destInfo : destInfo . string ;
814+
815+ await this . loadMap ( rmdFileName , gateSerial ) ;
783816 await this . init ( ) ;
784817 RedStone . mainCanvas . mainContainer . removeChild ( RedStone . player . container ) ;
785818 RedStone . player . reset ( ) ;
0 commit comments