Through the front door

Haulers walk into the factories now, every building got a door and a welcome mat, and people started looking for work on their own.

Before building anything new I wanted to know how much the game can take. The simulation of one busy factory floor turned out to cost far too much: twenty full floors took 22 to 32 milliseconds a tick, while a tick at top speed only has about 17. The factory step looked everything up again on every tick, so its cost grew with the square of the machines on the floor. Now each factory keeps a list of its machines, inserters and belts that only changes when something is built or removed, and the same test takes 1.2 to 1.5 milliseconds. A hundred factories with 2,500 people cost about one millisecond, so I wrote a soft target of around a hundred factory buildings into the design. I also moved the whole project to .NET 10, which gained a little, less than I had hoped.

To keep an eye on this from now on, the console has a perf command and F9 shows a small table in the corner: for every part of a tick, how long it usually takes, how long the slow ones take, and the worst.

The performance table, in milliseconds. The frame is the one to watch.
The performance table, in milliseconds. The frame is the one to watch.

The factory floor got a real texture too, stone slabs in the factory’s own two colors with grout in between, drawn as one picture instead of a block per tile.

Then the thing I had planned for a while: the door. A hauler used to reach a factory and the goods just jumped to or from the pile inside. Now every factory has an entrance, and a hauler walks in through it, around the belts and machines, to the pile, picks up or puts down, and walks back out. This happens in every factory, whether you are looking inside or not. If a pile gets walled in, the hauler stays outside and an orange warning sign shows over the pile and over the factory on the map.

While watching that, I saw planks being carried out of the sawmill and never seen again. They were not lost. The stockpile only counts what it holds and shows how full it is, so a few planks vanish into one number. Showing what a stockpile really holds is on the list. The same look at logistics showed that the logging camp makes wood out of thin air, one log every five seconds, no trees involved. That one stays for now, but not forever.

Two smaller things came out of setting up a bigger town. The console can spawn twenty people at random spots in one go, and people no longer sit around without a job: anyone jobless takes the best open job by themselves, and when a building is placed or removed the jobs sort themselves out on the next tick.

Next, the logs. Nobody was bringing them to the sawmill. Only a hauler working for the sawmill itself would, and no factory had a place for one. So now the stockpile’s haulers do it: four per stockpile, and when nothing is waiting to be picked up, one of them brings the sawmill what it is short of. A factory without an input pile for something gets none of it, the load goes back to the stockpile.

Buildings outside got doors as well. Each building says in its content file where its door is, people only go in and out there, and nothing can be built on a door. You can also remove buildings now; a factory with equipment or goods inside asks first. To show where the door is I added a doormat. My first one was far too big, nearly a tile and a half wide, and it lay in the middle of the tile, well away from the building.

The mat is small now, a coir welcome mat with a red heart, and it lies right against the building, where roads will connect later. Three buildings, the sawmill, the machine shop and the belt workshop, did not reach the front of their plot, so there was a gap between them and the mat. Instead of stretching them, they got a fenced yard with a stone path to the mat: a pile of logs and a chopping block for the sawmill, iron plates, an oil barrel and a scrap bin for the machine shop, crates, a roll of belt and planks for the belt workshop.

Welcome mats against the buildings, and the sawmill with its yard: logs waiting their turn and a stone path to the mat.
Welcome mats against the buildings, and the sawmill with its yard: logs waiting their turn and a stone path to the mat.

Last, people now walk to the mat itself to go in or out. That showed a bug that had been there all along: every citizen was drawn half a tile off, on the corner of their tile instead of in the middle. They stand where they should now.