Im trying to make a simple 2d automation/factory game, and was wondering on how to design my conveyor belt system. I want it to be simple as possible.
My current idea is to organize every connected belt tile into a segment class. Each segment object has a container field where it is an array of unique postive integer IDs which map to an Item object. The absence of an item in the segment container array is represented as -1.
Every tick, i just simply iterate starting from the end to start of the container and if it has space then move to that index.
Is my current idea robust enough or no? I would assume there are lot of edge cases: deleting a belt in 1 segment means i have to divide that into 2 segment with their own arrays with the right index transformations. What about the case where a user places a belt perpendicularly to an existing segment, what about splitters, mergers. etc…
I just need some guidance on a good simple foundation for my conveyor belt system.