Faster way to get array of object references to set object attribute?

Goal:
Tiles have a ‘Temperature’. the goal is to match the tile temperature with the temperature of its surrounding tiles.
The information about surrounding tiles for each tile is beneficial for other functionality, therefore it is making sense to store this information somewhere, to save ressources.

Current solution (working but not good!):


pseudocode:

Take list of all tiles 
for each tile:
  get list of tiles within a radius
  remove the center tile from list   
     
  for each found tile:                
    cast to HexTile 
    append each HexTile to an ‘buffer’-array called ‘Neigbour Tiles’
                                               i see the typo here  :)
                    
    end → store the buffer into the centertile + clear buffer

end → Not relevant (change materials on neighbour-tiles to visualize if it works)

Problem:
Infinite loop error when radius is longer than 3 steps from center tiles (to many tiles).
I guess this has to do with the loop within a loop code with the cast to HexTile. So i am looking for a more efficient way to code this functionality.

Tried Solution:
I tried to write the output of the ‘sphere overlap actors’ to the needed array of the center tile directly, but the datatypes does not match (Array of Actors is != Array of HexTiles). I understand why it happens but i cannot find a feasable solution to this problem.

I hope you can give me some help. I am open for different approaches and lear along the way.

Have a nice day.