I got unit construction in. Wasn't a lot of difficult work. It basically was adding an additional check to the techtree retrieval function, and if a tech item was a unit, place the icon in the Unit strip, and otherwise the building strip.
The rest of the system is the same: The building asks the ConstructionManager if there's a job waiting for him, and if so, it takes the order and executes it. When done, it will now check what kind of object is done. If it's a unit, it will check if there's a free spot around the building, and if yes, it will deploy the vehicle there. When there are no more tiles free around the building, it will show a nice message in the debuglog telling me to implement carry-all's to pickup tanks from buildings(Which is actually really friendly).
I still have to implement showing a deployment animation when a unit is deployed, but that's not that difficult. It's a matter of minutes to implement the additional class(ConstructionBuilding) and the code to trigger the animation.
The next step is to give each unit / building a unique ID which is also linked to it's owner. I'm running into some nasty bugs, which makes debugging difficult if you got 20 units on the screen and 1 flips out...
Bugs I have at the moment: When a unit runs into an obstacle along it's path, it will try to find a new route. If it can't find one(Because the blocking object is the end-tile), it suddenly changes it's position to 1 tile back and starts vibrating... Very odd.
The other bug is related to units popping their states off the stack for no apparant reason. That only happens when moving in groups tho, so I need IDs to track them.
To do for next time:
- Add IDs for units and buildings
- Fix movement bug
- Fix state popping bug
- Add deployment animation
- Add icon sorting to the construction bars. It's annoying to have the order change depending on how you build the buildings(Or if you lose your barracks half way) and the icons end up in the bottom.