Hello everyone! I am currently making a game which involves 25x25-tiles dance floor with unique patterns which can be summoned at any time on the floor. However I am very concerned with the performance while I’m doing this.
Because this is a multi-layered (multi-pattern) dance floor; on refresh function in AniCore script currently, the floor has to loop 625 tiles (25x25) times everytime a pattern is created/updated; each tiles looped has to track for tile corresponding to the latest pattern summoned on that frame
This is my example with 16x16, because it is a 256-tiles loop only, it shouldn’t matter much
In this example, there are 2 patterns layered on each other, pattern 1 (checkerboard) stays constant while pattern 2 (white line) keeps summoning over and over and has to override the 1st.
The way how my mechanic currently works consists of tileArr with size of 256 (16x16 tiles), each element is another array consisting group of {id, color}; and an AniTemplateCore script to execute sequence of layers (aka summoning layer scripts). If the frame of one pattern is iterating, it will trigger the AniCore script to keep refreshing. Each tile looped in refresh will check for the last group in array inside tileArr[num] and apply that color. For example, tileArr[4] = {{1, 2}, {2, 6}, {3, 5}}; the refresh will check for last element, which is group {3, 5} and apply color 5 to tile 4
So my question here is, is there a suggestion to apply multi-thread for this refresh function to avoid choppy 625 tiles looping in a very short time and avoid server lagging? Either I could try generate multiple coroutines for each tile group (5x5 each), or 1 script per tile, or something else?