Guys I have a technical problem!
Let's say we have a 2D world with tiles which have all the same size!
We can simply store the world in a 2D Array and
we can simply draw the tiles which is in the visible area of the camera, without looping trough the whole array.
This is very efficient!
My problem is now, I want to achieve something efficient like this with tiles which have different sizes!
So, I have a Tile class with a Vector2 for the position.
If I store all the Tiles in a List<Tiles> I have to loop trough the whole list until I found the tiles which are in the cameras visible area.
This is really unefficient.
What I tried is to Split this List into multiple smaller lists,
Like this Dictionary<Rectangle, List<Tiles>>
Let's say for example splitting the world into 4x4 = 16 areas and loop only trough the areas which are in the cameras visible area.
This attempt is more efficient then storing them in a single list.
But this isn't that efficient if you use too few or too much areas and the drawing order is messed up!
Does someone has other ideas how to manage this?