There are two parts to the direction of an entity:
1) the collision box rotates, the direction of the belt changes, the location of pipe connection changes.
2) You get a different graphic.
I agree that rotating a tree makes little sense. Well, the first 90° rotation makes the tree a fallen tree. That could still work. 180° rotation producing an upside down tree? Not sensible.
But nobody said every entity must be rotatable in 90° steps. A tree simple has just one direction to rotate through. There is nothing stopping the tree from having a direction that must always be 0 other than it being unnecessary to store that. Now if someone makes a sunflower that can point it's flower in different directions then maybe they want it to be a tree with multiple directions. For example the entity could be rotated via LUA script so the flower follows the sun over the course of a day.
Similar with resources. They have variations. Since resources are square rotating them (point 1) has no effect and you are only left with different graphics (point 2). So resource placement would simply set random rotations instead of random variations. You would have gotten resource variations for free with rotatable resources.
You say: "Support rotation" is entirely dependent on a given entity for what that means.
I take rotation as rotation of the entity around the Z axis (reaching out of the ground). As everything is 2D in the game that means the selection and collision boxes rotate and the graphics should match that effect. Any connections like pipes or wires should rotate so the entity visually looks like it rotates. That is the meaning of rotation in the game at the moment. For buildings this works because they are generally retangular and scewed so they don't exceed the footprint they would have as 3D model.
As you said for some things that makes rotation nonsense. Like trees. Unlike buildings they are not designed to have a selection/collision box matching their base plate but the box encompasses the whole tree as projected. Rotating them would make them wider than high instead of rotating them around their roots. One could say the error here is that trees should have a square collision box with the crown growing out of the box. Then they could be rotated to give the same tree as seen from different sides.
Would it maybe just straight up rotate the drawn sprites all looney-tunes like with the tree-trunk facing to the weast?
Not sure how you come to that idea. I believe none of the rotatable entities has just one sprite sheet that the game then just draws rotated. That doesn't work with the viewpoint shown in the game. To make an entity rotatable the user has to provide the rotated graphics and all the information for how wire connections change and such just like for already rotatable entities.
So if the user defines a tree that is rotatable then the most natural would be to simply render a single 3D tree model from different sides. But since the user can't rotate trees it could also be just a collection of different trees. Variants of trees and the map generator makes a more natural looking forest by picking different rotations of one oak tree entity instead of having 20 slightly different oak entities. Same idea for resource entities. It's just variations.
My current use case would be a rotatable chest. I'm working on a simpler crafting combinator that can change the recipe of an assembler placed next to it with circuit logic. Internally it is a chest because I want the user to be able to store module items in it. Currently the assembler can be placed on any side of the crafting combinator making it a problem if the crafting combinator is placed between 2 assemblers. Since internally it is a chest the crafting combinator can't be rotated so I can't make it only connect to an assembler on one side and have the user rotate it to face the assembler it should connect to.
Creating graphics and defining wire connections for a rotatable chest would be my job. The game just rotates the bounding boxes and selects the sprites defined for the selected rotation. It's my job to make the rotation make sense.
curiosity wrote: Thu Apr 18, 2024 1:26 am
Rseding91 wrote: Wed Apr 17, 2024 8:57 pm
Letting a mod change this through some Lua API would be trivial.. but nobody has asked for it because it's not technically a direction on the entity. It's just an 8-bit unsigned number that determines which sprite variation is used.
I wonder, if people knew that having a script-controlled sprite variation was possible, maybe they would ask for that instead of rotatable entities.
Kind of but not totally. For my example above for the crafting combinator the user has to be able to rotate the entity before placing it. It should be rotatable as ghost or after being build as well, ideally. So access only through LUA wouldn't be enough. If you only need that then you can define 4 entities and swap them in LUA whenever you want to "rotate". Slightly complex but totally doable now.
For the crafting combinator I now need to use one entity that is rotatable, like a constant combinator, and then have a second chest entity that gets created on-entity-built and do some ugly tricks to make blueprints, copy&paste and wire connections work correctly. User interface wise it's suboptimal too. In the middle you get the selection box of the chest and can open the chest to place modules. Going off center you get the selection box of the constant combinator and can rotate it.
Side Note: I just remembered a mod called "Landfill Painting" that has rotatable landfill. Rotating gives different variations of landfill. I should look how they did that since normally landfill (tiles) isn't rotatable in the UI. Maybe they same would work for a chest? For me the the GUI interaction (rotating when placing the entity) is more important than it being a rotatable entity internally.