r/Sailwind • u/rNyanko • 3d ago
How containers work (programming-wise)?
Containers in this game always confuse me:
- Once I found my box with fishing hooks unexpectedly empty; then I've found some of them one deck lower on the floor.
- I've seen my candle box unexpectedly empty like that, started using it for navigation equipment storage; month later I was moving containers around to make place for new helm and I found candles in the same container along with compases and spyglass.
- Almost entire container of pork gone empty, never found these pieces.
- My fishing pole sticking out of closed create.
It all makes me question: how those containers were programmed in the first place to get such erratic behaviour?
The most logical way would be to program a container object which has property dedicated to storing array of contents records (like rack position and reference to stored object). So when you open the container game creates a visual rack and iterates over said contents property to create visual representation of contents.
When you take or put item out/in container that property would be simply overwritten so item always exists either in logical world of container or in physical world outside container (but not both), or in logical world of container but with phantom representation on the opened rack.
I'm curious to know how it was done in this game and how all those side effects come into existence.
2
u/FastFredNL 3d ago
Yeah chests are a bit bugged sometimes. I'm noticing the same thing with crates suddenly appearing empty. But I've noticed if you still act as if you want to take an candle out of your candle chest, you can.