File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed
Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ export class NukeExecution implements Execution {
2020 private active = true ;
2121 private mg : Game ;
2222 private nuke : Unit | null = null ;
23+ private tilesToDestroyCache : Set < TileRef > | undefined ;
2324 private pathFinder : ParabolaPathFinder ;
2425
2526 constructor (
@@ -62,17 +63,21 @@ export class NukeExecution implements Execution {
6263 }
6364
6465 private tilesToDestroy ( ) : Set < TileRef > {
66+ if ( this . tilesToDestroyCache !== undefined ) {
67+ return this . tilesToDestroyCache ;
68+ }
6569 if ( this . nuke === null ) {
6670 throw new Error ( "Not initialized" ) ;
6771 }
6872 const magnitude = this . mg . config ( ) . nukeMagnitudes ( this . nuke . type ( ) ) ;
6973 const rand = new PseudoRandom ( this . mg . ticks ( ) ) ;
7074 const inner2 = magnitude . inner * magnitude . inner ;
7175 const outer2 = magnitude . outer * magnitude . outer ;
72- return this . mg . bfs ( this . dst , ( _ , n : TileRef ) => {
76+ this . tilesToDestroyCache = this . mg . bfs ( this . dst , ( _ , n : TileRef ) => {
7377 const d2 = this . mg ?. euclideanDistSquared ( this . dst , n ) ?? 0 ;
7478 return d2 <= outer2 && ( d2 <= inner2 || rand . chance ( 2 ) ) ;
7579 } ) ;
80+ return this . tilesToDestroyCache ;
7681 }
7782
7883 /**
You can’t perform that action at this time.
0 commit comments