I need a little help with structuring my map. I want to make it efficient but I'm not sure if there's a better way to do this:
public class Map
{
Chunk[][] Chunks;
Object[] Objects;
}
public class Chunk
{
public int[][] Tiles;
public List<int> Objects;
}
This is the current structure of my map. I basically load and unload chunks if the player is too far from them. Every chunk has the same size, and has a list of objects. For each integer in the list of integers in a chunk, the corresponding Object will be updated in the parent map.
This way, I can handle collision detection without comparing two objects that are far apart: I only compare objects to other objects that are in the same chunk, or neighboring chunks.
However, I'm wondering if there is a better way to structure my map. Faster runtime. Less processing. More efficient.
This may seem like an opinion based question but for those who perceive it that way, the question is how can I improve my map to make it more efficient?