How would I make a tiled road system?

Hello,

I am working on a RTS game and the player will be able to place roads and other things.

So whenever a player places a road tile it should be texture 1 aka just a straight piece of road texture.

But whenever the player places another road tile besides a existing on it should change the texture of the existing one to texture2 so it connects seamlessly.

Example:

How would I do this seamlessly and so it doesn’t affect performance etc?

Without any complicated scripting, I would recommend just making multiple separate road types that you can rotate.

Like “Straight Road” “Left Turn” “Right Turn” “T-Road” and “Cross Road”

This will eliminate the idea of having to change textures of everything in the vicinity of a single road placement and will make for an “easier” connection system

I’m not really much of a scripter but this is the best I can think of aside from casting multiple rays in the 4 directions on creations, checking if it’s a road, checking if it’s connected, and then changing the road to fit where it’s connected between all of the 4 cardinal directions with or without the roads

Would you think going through all the tiles and checking if neighboring tiles is too performance heavy?

If you’re able to make a “Neighbor checker” with that, then it would be find with doing it, the problem would be if you made it check every tile in a folder.
something like a table with column and rows that checks for
1,1 | 1,2 | 1,3
2,1 | 2,2 | 2,3
3,1 | 3,2 | 3,3

If you put a tile in 2,2
it will check {0, + - 1} and {+ - 1, 0}

I recommended making different roads to avoid having problems like making 2 straight roads next to each other but the roads connect when you don’t want to.
┗────┓
┏────┛
This would look like
┣┳┳┳┓
┣┻┻┻┛

Problem is that the user is the one who builds the roads and I want it to be easily made.

Then having multiple road options will be easier for the player because they have the freedom to choose which roads would connect instead of the game deciding which roads connects to which. I’ll stop here, it’s just a suggestion, but there may be other people who would have a better solution.