I need to be able to place structures in my game that span multiple tiles and can also be rotated. My idea on how to solve this would be to use 2D arrays that hold data about the structure.
Crafting table layout:
X - data
O - data, but also used as a pivot point
If we were to rotate it clockwise, it'd look like this:
X O X
My problem lies in that these positions have to be real-world coordinates, so here's the above example again but in a way that makes sense for my actual grid in-game. (replacing the X and O with coords):
And now, rotated clockwise (around the pivot point, which is
(1,2) (1,1) (1,0)
Another example purely for more information, but more complex (2x3 array):
Complex workstation ((6,4) IS THE PIVOT!):
Rotate it counterclockwise and we should get this:
(5,5)(6,5) (5,4)(6,4) (5,3)(6,3)
I have tried and succeeded in doing it only on a conceptual level with the "X" and "O"s, but I don't know how to implement actual coordinates.
I've never dealt with rotation matrices before so any advice, suggestion or solution on how to implement this is appreciated.