Here is how I approximated a 2D array in order to implement a system to store groups of tiles for landmasses and bodies of water:
So the above starts with 1 tile index from map in the Open List. Then I neighbor check his 6 neighbors and each neighbor sharing a tile type gets added to the open list. This continues until each like tile in the landmass or body of water is put into the closed list. When that is complete I dump the closed list into an array and add 100,000 multiplied by the multiplier. The multiplier starts at 1 and increments by 1 every time the closed list gets dumped. So the first lake would have tiles that look like 1XX,XXX, the second 2XX,XXX, etc. The reason I use 100,000 is because the upper range for map indexes is over 10,000, and the highest number is what I use to track which lake I am looking at.
With each lake serialized into an array I need a way to retrieve that information:
I have Current Index which is whatever tile I want to look at. I go through my entire Water Body Array, divide it by the 100,000, and match the remainder to my Current Index. Then I know I have the right lake, so I set that to the Current Landmass/Body of Water for use in:
Since I now know what lake I am looking for, I use that info to pull all the tiles of that lake from the Water Body Array and dump them into my Lake Array.
[= ;128865]
Hi ,
Well, in my case I’ve expanded on the idea a bit. I am currently attempting to build an NPC dialogue system using nothing but blueprints. So here is the section where it chooses which array to select your answers from to prompts based on what you have previously selected. Currently I’m up to 12 arrays and haven’t had a chance to set up the prompt array yet for it to choose what the npc says.
[/]
Would love to see how you are handling it now, or if you have any ideas to improve my method.
I can probably get by without 2D arrays, but I think they would be at least somewhat more performant than doing 6 digit math potentially tens of thousands of times.