@@ -15,6 +15,7 @@ export class NukeTrajectoryPreviewLayer implements Layer {
1515 // Trajectory preview state
1616 private mousePos = { x : 0 , y : 0 } ;
1717 private trajectoryPoints : TileRef [ ] = [ ] ;
18+ private targetableSwitchPointIndex : [ number , number ] = [ - 1 , - 1 ] ;
1819 private lastTrajectoryUpdate : number = 0 ;
1920 private lastTargetTile : TileRef | null = null ;
2021 private currentGhostStructure : UnitType | null = null ;
@@ -210,6 +211,35 @@ export class NukeTrajectoryPreviewLayer implements Layer {
210211 ) ;
211212
212213 this . trajectoryPoints = pathFinder . allTiles ( ) ;
214+
215+ // Calculate points when bomb targetability switches
216+ const targetRangeSquared =
217+ this . game . config ( ) . defaultNukeTargetableRange ( ) ** 2 ;
218+
219+ this . targetableSwitchPointIndex = [ - 1 , - 1 ] ;
220+ for ( let i = 0 ; i < this . trajectoryPoints . length ; i ++ ) {
221+ const tile = this . trajectoryPoints [ i ] ;
222+ if ( this . targetableSwitchPointIndex [ 0 ] === - 1 ) {
223+ if (
224+ this . game . euclideanDistSquared ( tile , this . cachedSpawnTile ) >
225+ targetRangeSquared
226+ ) {
227+ if (
228+ this . game . euclideanDistSquared ( tile , targetTile ) <
229+ targetRangeSquared
230+ ) {
231+ break ;
232+ } else {
233+ this . targetableSwitchPointIndex [ 0 ] = i ;
234+ }
235+ }
236+ } else if (
237+ this . game . euclideanDistSquared ( tile , targetTile ) < targetRangeSquared
238+ ) {
239+ this . targetableSwitchPointIndex [ 1 ] = i ;
240+ break ;
241+ }
242+ }
213243 }
214244
215245 /**
@@ -231,14 +261,21 @@ export class NukeTrajectoryPreviewLayer implements Layer {
231261 }
232262
233263 const territoryColor = player . territoryColor ( ) ;
234- const lineColor = territoryColor . alpha ( 0.7 ) . toRgbString ( ) ;
264+ const untargetableLineColor = territoryColor
265+ . alpha ( 0.8 )
266+ . saturate ( 0.8 )
267+ . toRgbString ( ) ;
268+ const targetableLineColor = territoryColor
269+ . alpha ( 0.8 )
270+ . saturate ( 0.5 )
271+ . toRgbString ( ) ;
235272
236273 // Calculate offset to center coordinates (same as canvas drawing)
237274 const offsetX = - this . game . width ( ) / 2 ;
238275 const offsetY = - this . game . height ( ) / 2 ;
239276
240277 context . save ( ) ;
241- context . strokeStyle = lineColor ;
278+ context . strokeStyle = targetableLineColor ;
242279 context . lineWidth = 1.5 ;
243280 context . setLineDash ( [ 8 , 4 ] ) ;
244281 context . beginPath ( ) ;
@@ -254,6 +291,29 @@ export class NukeTrajectoryPreviewLayer implements Layer {
254291 } else {
255292 context . lineTo ( x , y ) ;
256293 }
294+ if ( i === this . targetableSwitchPointIndex [ 0 ] ) {
295+ context . stroke ( ) ;
296+
297+ context . beginPath ( ) ;
298+ context . setLineDash ( [ ] ) ;
299+ context . arc ( x , y , 4 , 0 , 2 * Math . PI , false ) ;
300+ context . stroke ( ) ;
301+
302+ context . beginPath ( ) ;
303+ context . strokeStyle = untargetableLineColor ;
304+ context . setLineDash ( [ 2 , 6 ] ) ;
305+ } else if ( i === this . targetableSwitchPointIndex [ 1 ] ) {
306+ context . stroke ( ) ;
307+
308+ context . beginPath ( ) ;
309+ context . strokeStyle = targetableLineColor ;
310+ context . setLineDash ( [ ] ) ;
311+ context . arc ( x , y , 4 , 0 , 2 * Math . PI , false ) ;
312+ context . stroke ( ) ;
313+
314+ context . beginPath ( ) ;
315+ context . setLineDash ( [ 8 , 4 ] ) ;
316+ }
257317 }
258318
259319 context . stroke ( ) ;
0 commit comments