Good practices for a sandbox tile based game ?

So, recently, a friend of mine showed me a game called terraria, which is like a 2d minecraft (which is nice, as in my opinion, pixel art looks pretty cool in 2d) ,which is why I wanted to try in my free-time to build a small equivalent.

I only worked on it for like 20 minutes so far, but i already figured out where i’m about to get stuck.
Every little tile is interactive, and a lot of them have different behaviours, i can’t really just put those in separated tilemaps as most of them will need to get modified based on the tiles next to them.

Right now, i have a small working prototype that’ll work as long as there is less than 5k blocks on the map.

Basically, i was being lazy and didn’t want to edit the sprite shapes one by one so i created a Tilebase derived class holding an enum describing it’s shape, and as the game loads, i iterate through all the tiles of the tilemap a create a new path in a polygon collider for each tile (basically, thousands of 0.25 unit big squares and triangles). Once the game loads (when it does), it works flawlessly, but a 4 screen wide map is already too big for the game to be able to load (which is somehow, a problem, even if based on the code i wrote it’s already a miracle it runs with a small map).

I guess that i could use some import presets to automatically set the tiles physics shape correctly and use the provided tilemap collider instead,or i could generate only the necessary sides of the polygon and modify it as the player destroys it ?

But i feel like there are tons of possible mistakes i could do and would love to have a fairly safe path to follow so i can handle an almost infinitely big world without being afraid of having to redo everything from scratch using a totally different logic because i went the wrong way from the very beginning.

So i’m asking you, what are the basic precepts i should follow so i can safely try to learn from the project without getting hardstuck too early? (even if premature optimization is the root of all evil, as the game already breaks here with less than a hundred lines of code ) .

TL;DR : I don’t know the logic behind big open world tilemaps where every tile can be interacted with, and need some basic concepts to make sure i start with the right foot. No worries, I made the roll a ball tutorial at least twice, i know what I’m doing. Seriously speaking, i cannot read hardcore mathemathic schematics, but i’ve learned programmation for years, i know what i’m getting into.

Thanks a lot for reading all of this, i hope some of you will be able to show me the right path to follow, and i’ll enjoy any input you can provide (even if it’s “just” encouragements). Don’t be afraid to ask me to give some details if something that I said isn’t clear enough, and have a good day !

So a little update:

It seems I fixed my loading issue. All i had to do was to map all the tiles that were in contact with empty tiles, then set those to null in the tilemap and add them back in another tilemap with a tilemap collider attached to it. It loads, even big maps, and incredibly fast !
Only (very small) downside i have now, is i have to check for both tilemaps for adjacent tiles when i add or remove tiles during gameplay to edit the collider, but it’s not that hard to do and don’t seem to actually have any real effect on performances.

Stunning work you did there Unity 2D team, i’m certainly going to have fun with your features !