@@ -20,6 +20,11 @@ class TrackPiece
2020 {
2121 return new TrackPiece ( { x, y, z, direction } , this . type , this . subpositions ) ;
2222 }
23+
24+ toLocation ( ) : CarTrackLocation
25+ {
26+ return { ...this . position , trackType : this . type } ;
27+ }
2328}
2429
2530const flatTrackPiece = new TrackPiece ( { x : 0 , y : 0 , z : 0 , direction : 0 } , 1 ,
@@ -326,7 +331,7 @@ const multiTurnTest = test.macro({
326331 exec ( t , startTrackPiece : number , startProgress : number , progress : number , expectedResult : number ) : void
327332 {
328333 const trackPieces = [ rightTurn1TrackPiece , rightTurn2TrackPiece , steepUpTrackPiece , steepTurnTrackPiece ] ;
329- const trackLocation : CoordsXYZD = { ...trackPieces [ startTrackPiece ] . position , direction : 0 } ;
334+ const trackLocation : CarTrackLocation = { ...trackPieces [ startTrackPiece ] . position , direction : 0 , trackType : 0 } ;
330335 setupTrackIterator ( trackPieces , startTrackPiece ) ;
331336 const car = Mock . car ( { trackProgress : startProgress , trackLocation, remainingDistance : ( progress >= 0 ) ? ForwardRemainingDistance : 0 } ) ;
332337
@@ -405,8 +410,8 @@ test("Flat track: get spacing to preceding vehicle 1 step away", t =>
405410{
406411 const mapMock = setupTrackIterator ( [ flatTrackPiece ] ) ;
407412 const train = createTrain ( mapMock , [
408- { trackProgress : 17 , trackLocation : flatTrackPiece . position } , // front car
409- { trackProgress : 16 , trackLocation : flatTrackPiece . position }
413+ { trackProgress : 17 , trackLocation : flatTrackPiece . toLocation ( ) } , // front car
414+ { trackProgress : 16 , trackLocation : flatTrackPiece . toLocation ( ) }
410415 ] ) ;
411416
412417 const spacing = getSpacingToPrecedingVehicle ( train , train . _at ( 1 ) . _car ( ) , 1 ) ;
@@ -419,8 +424,8 @@ test("Flat track: get spacing to preceding vehicle 10 step away", t =>
419424{
420425 const mapMock = setupTrackIterator ( [ flatTrackPiece ] ) ;
421426 const train = createTrain ( mapMock , [
422- { trackProgress : 17 , trackLocation : flatTrackPiece . position } , // front car
423- { trackProgress : 7 , trackLocation : flatTrackPiece . position }
427+ { trackProgress : 17 , trackLocation : flatTrackPiece . toLocation ( ) } , // front car
428+ { trackProgress : 7 , trackLocation : flatTrackPiece . toLocation ( ) }
424429 ] ) ;
425430
426431 const spacing = getSpacingToPrecedingVehicle ( train , train . _at ( 1 ) . _car ( ) , 1 ) ;
@@ -433,8 +438,8 @@ test("Flat track: get spacing to preceding vehicle 31 step away", t =>
433438{
434439 const mapMock = setupTrackIterator ( [ flatTrackPiece ] ) ;
435440 const train = createTrain ( mapMock , [
436- { trackProgress : 31 , trackLocation : flatTrackPiece . position } , // front car
437- { trackProgress : 0 , trackLocation : flatTrackPiece . position } // back car
441+ { trackProgress : 31 , trackLocation : flatTrackPiece . toLocation ( ) } , // front car
442+ { trackProgress : 0 , trackLocation : flatTrackPiece . toLocation ( ) } // back car
438443 ] ) ;
439444
440445 const spacing = getSpacingToPrecedingVehicle ( train , train . _at ( 1 ) . _car ( ) , 1 ) ;
@@ -447,8 +452,8 @@ test("Flat track: get spacing to preceding vehicle is too far away", t =>
447452{
448453 const mapMock = setupTrackIterator ( [ flatTrackPiece ] ) ;
449454 const train = createTrain ( mapMock , [
450- { trackProgress : 15 , trackLocation : { x : 10 , y : 10 , z : 10 , direction : 0 } } , // front car
451- { trackProgress : 10 , trackLocation : flatTrackPiece . position }
455+ { trackProgress : 15 , trackLocation : { x : 10 , y : 10 , z : 10 , direction : 0 , trackType : 0 } } , // front car
456+ { trackProgress : 10 , trackLocation : flatTrackPiece . toLocation ( ) }
452457 ] ) ;
453458
454459 const spacing = getSpacingToPrecedingVehicle ( train , train . _at ( 1 ) . _car ( ) , 1 ) ;
@@ -462,8 +467,8 @@ test("Two flat tracks: get spacing to next track piece by 1", t =>
462467 const pieces = [ flatTrackPiece . copyTo ( 32 , 64 ) , flatTrackPiece . copyTo ( 32 , 32 ) ] ;
463468 const mapMock = setupTrackIterator ( pieces ) ;
464469 const train = createTrain ( mapMock , [
465- { trackProgress : 0 , trackLocation : pieces [ 1 ] . position } , // front car
466- { trackProgress : 31 , trackLocation : pieces [ 0 ] . position } // back car
470+ { trackProgress : 0 , trackLocation : pieces [ 1 ] . toLocation ( ) } , // front car
471+ { trackProgress : 31 , trackLocation : pieces [ 0 ] . toLocation ( ) } // back car
467472 ] ) ;
468473 const car = train . _at ( 1 ) . _car ( ) ;
469474
@@ -478,8 +483,8 @@ test("Two flat tracks: get spacing to next track piece by 10", t =>
478483 const pieces = [ flatTrackPiece . copyTo ( 32 , 64 ) , flatTrackPiece . copyTo ( 32 , 32 ) ] ;
479484 const mapMock = setupTrackIterator ( pieces ) ;
480485 const train = createTrain ( mapMock , [
481- { trackProgress : 3 , trackLocation : pieces [ 1 ] . position } , // front car
482- { trackProgress : 25 , trackLocation : pieces [ 0 ] . position } // back car
486+ { trackProgress : 3 , trackLocation : pieces [ 1 ] . toLocation ( ) } , // front car
487+ { trackProgress : 25 , trackLocation : pieces [ 0 ] . toLocation ( ) } // back car
483488 ] ) ;
484489 const car = train . _at ( 1 ) . _car ( ) ;
485490
@@ -494,8 +499,8 @@ test("Three flat tracks: get spacing to next track piece by 50", t =>
494499 const pieces = [ flatTrackPiece . copyTo ( 32 , 96 ) , flatTrackPiece . copyTo ( 32 , 64 ) , flatTrackPiece . copyTo ( 32 , 32 ) ] ;
495500 const mapMock = setupTrackIterator ( pieces ) ;
496501 const train = createTrain ( mapMock , [
497- { trackProgress : 5 , trackLocation : pieces [ 2 ] . position } , // front car
498- { trackProgress : 19 , trackLocation : pieces [ 0 ] . position } // back car
502+ { trackProgress : 5 , trackLocation : pieces [ 2 ] . toLocation ( ) } , // front car
503+ { trackProgress : 19 , trackLocation : pieces [ 0 ] . toLocation ( ) } // back car
499504 ] ) ;
500505 const car = train . _at ( 1 ) . _car ( ) ;
501506
0 commit comments