Dune 2 – The Maker – 4J – Devlog – Harvester
Since the concept of money is introduced, it would be fun to have a harvester gathering resources.
While doing so, I’m introducing a state machine for the harvesting logic. (so far, I could get away with using simple if statements, but the complexity is growing)
Although I would like to move all logic into the state machine, I tried tonight and failed. Some more thought is required in order to make movement work better.
So, what *does* work? Well, for a harvester, there is a nice little loop going on like so:
given a harvester which is ordered to harvest at a spice field:
– moves to spice field
– harvest (state)
– done harvesting? (ie, cell is ’empty’?) -> seekspice (state)
– look ‘around’ the cell for other spice cells, if found, pick one randomly (state is still ‘seekspice’)
– move to the spice field (no state change here, this is still old stuff)
– once arrived, change into harvest state again
Which looks like: