How do I make a factory game?

In short,I need something like a Buffered2DArray or something(an array with objects,and each object has access to its neighbors(no diagnals tho) and the changes is saved in the buffer,and released after all the updates are done
Like what I have done here(that one was abandoned due to code complexity)
https://replit.com/@imcute-aaaa/grid-test

I’m intrigued but confused. We need more info.

You can add rows and columns of objects either manually or through events. You can then either link them through link or a linking behavior or use object variables or you could detect neighboring objects with something like casting a ray. I just don’t know the … and then what?