I have a class TileChunk which at it's most basic contains a rectangle that surrounds the chunk, and four bools isLeftLoaded, isTopLoaded, etc. Using the rectangle I can determine which chunk the player is in.
What I want to do is create some kind of method which checks the current chunk the player is in, and if nothing is loaded then create new chunks that surround the sides that haven't been loaded. The problem I'm coming across is that using the four bool variables doesn't seem to work correctly. At initialization, I create 9 chunks to make a 3x3 starting area but some of the bool variables aren't being set correctly.
My question is how should I write a method which determines what chunks have loaded chunks adjacent to them? Every chunk is stored in a List, but other than using the bool variables I'm not sure what is the best way to do this.