I am recreating a edge-link system from the game "Rimworld".
The purple squares are individual squares that need to form "links", in the direction the arrows are drawn in, with that exact length.
Currently, I don't know how to do this better than by placing all of those squares in a dictionary where I mark a square's position and its direction (which can be UP or RIGHT), like this:
Dictionary<Vector3Int, bool> linkSquares;
I want to sort this dictionary so that the KV pairs that come first are the ones where the Vector3Int.x
is lowest and then where the Vector3Int.y
is lowest.
That way, I could always start at those squares (marked with numbers 1-4 on the picture) and go in the appropriate arrow direction, removing those squares as I go, which would only leave other starting squares.
I've read that dictionaries can't be sorted, but I don't know how I would use a SortedDictionary for this case. This whole system seems overly dirty but I don't know how else I would achieve my goal here, so any design change suggestions are highly appreciated.