@@ -33,6 +33,7 @@ public static void Unload() {
33
33
private CancellationTokenSource computeSpinnerNeighborsToken ;
34
34
35
35
private Dictionary < SpinnerType , HashSet < SpinnerType > > spinnerNeighbors ;
36
+ private List < SpinnerType > listOfSpinners ;
36
37
private HashSet < SpinnerType > shatteredSpinners = new HashSet < SpinnerType > ( ) ;
37
38
38
39
public SpinnerBreakingBallGeneric ( EntityData data , Vector2 offset , EntityID entityID , ColorType color ) : base ( data . Position + offset ) {
@@ -62,6 +63,7 @@ public SpinnerBreakingBallGeneric(EntityData data, Vector2 offset, EntityID enti
62
63
private void onTransitionOut ( ) {
63
64
// wipe the spinner connections so that they are computed again after the transition (in the new room).
64
65
spinnerNeighbors = null ;
66
+ listOfSpinners = null ;
65
67
}
66
68
67
69
public override void Awake ( Scene scene ) {
@@ -84,15 +86,15 @@ public override void Update() {
84
86
85
87
base . Update ( ) ;
86
88
87
- IEnumerable < SpinnerType > listOfSpinners ;
88
- if ( spinnerNeighbors == null ) {
89
- if ( computeSpinnerNeighbors == null ) {
90
- computeSpinnerNeighborsToken = new CancellationTokenSource ( ) ;
91
- computeSpinnerNeighbors = computeSpinnerConnections ( computeSpinnerNeighborsToken . Token ) ;
92
- }
93
- listOfSpinners = Scene . Tracker . GetEntities < SpinnerType > ( ) . OfType < SpinnerType > ( ) . Where ( spinner => getColor ( spinner ) . Equals ( color ) ) ;
94
- } else {
95
- listOfSpinners = spinnerNeighbors . Keys ;
89
+ if ( spinnerNeighbors == null && computeSpinnerNeighbors == null ) {
90
+ computeSpinnerNeighborsToken = new CancellationTokenSource ( ) ;
91
+ computeSpinnerNeighbors = computeSpinnerConnections ( computeSpinnerNeighborsToken . Token ) ;
92
+ }
93
+ if ( listOfSpinners == null ) {
94
+ listOfSpinners = Scene . Tracker . GetEntities < SpinnerType > ( )
95
+ . OfType < SpinnerType > ( )
96
+ . Where ( spinner => getColor ( spinner ) . Equals ( color ) )
97
+ . ToList ( ) ;
96
98
}
97
99
98
100
// we want to check all spinners explicitly instead of just going CollideCheck<SpinnerType>(),
0 commit comments