@@ -20,8 +20,6 @@ export class NukeExecution implements Execution {
2020 private active = true ;
2121 private mg : Game ;
2222 private nuke : Unit | null = null ;
23- private tilesInRangeCache : Map < TileRef , number > ;
24- private tilesToDestroyCache : Set < TileRef > | undefined ;
2523 private pathFinder : ParabolaPathFinder ;
2624
2725 constructor (
@@ -46,40 +44,33 @@ export class NukeExecution implements Execution {
4644 }
4745
4846 private tilesInRange ( ) : Map < TileRef , number > {
49- if ( this . tilesInRangeCache !== undefined ) {
50- return this . tilesInRangeCache ;
51- }
5247 if ( this . nuke === null ) {
5348 throw new Error ( "Not initialized" ) ;
5449 }
55- this . tilesInRangeCache = new Map < TileRef , number > ( ) ;
50+ const tilesInRange = new Map < TileRef , number > ( ) ;
5651 const magnitude = this . mg . config ( ) . nukeMagnitudes ( this . nuke . type ( ) ) ;
5752 const inner2 = magnitude . inner * magnitude . inner ;
5853 const outer2 = magnitude . outer * magnitude . outer ;
5954 this . mg . bfs ( this . dst , ( _ , n : TileRef ) => {
6055 const d2 = this . mg ?. euclideanDistSquared ( this . dst , n ) ?? 0 ;
61- this . tilesInRangeCache . set ( n , d2 <= inner2 ? 1 : 0.5 ) ;
56+ tilesInRange . set ( n , d2 <= inner2 ? 1 : 0.5 ) ;
6257 return d2 <= outer2 ;
6358 } ) ;
64- return this . tilesInRangeCache ;
59+ return tilesInRange ;
6560 }
6661
6762 private tilesToDestroy ( ) : Set < TileRef > {
68- if ( this . tilesToDestroyCache !== undefined ) {
69- return this . tilesToDestroyCache ;
70- }
7163 if ( this . nuke === null ) {
7264 throw new Error ( "Not initialized" ) ;
7365 }
7466 const magnitude = this . mg . config ( ) . nukeMagnitudes ( this . nuke . type ( ) ) ;
7567 const rand = new PseudoRandom ( this . mg . ticks ( ) ) ;
7668 const inner2 = magnitude . inner * magnitude . inner ;
7769 const outer2 = magnitude . outer * magnitude . outer ;
78- this . tilesToDestroyCache = this . mg . bfs ( this . dst , ( _ , n : TileRef ) => {
70+ return this . mg . bfs ( this . dst , ( _ , n : TileRef ) => {
7971 const d2 = this . mg ?. euclideanDistSquared ( this . dst , n ) ?? 0 ;
8072 return d2 <= outer2 && ( d2 <= inner2 || rand . chance ( 2 ) ) ;
8173 } ) ;
82- return this . tilesToDestroyCache ;
8374 }
8475
8576 /**
0 commit comments