I have a scene with any number of tiles, (usually around 2500). A tile is a Node2D extended object.
The limiting factor in my map creation speed is whenever I need to search for a specific tile. In my implementation I have tried two methods. One by storing all the tiles in a separate array and searching through it. The other by searching through the node tree for the item. Keeping a reference to the objects in the array and searching that way has reduced my search time by about 30%, but I need some more juice.
Here is my current implementation:
func tile(location) -> Node2D
for item in tiles:
if item.location == location:
return item
return null
Is there a way to use find() by looking for not just the specific object but one of its attributes? And would this be faster? I feel like in the backend it would be doing the same thing I am doing above.
Thank you in advance for any insight.