Click to Interact and Launch UI
Hey Folks! Finally got back to some gamedev today. I returned to work on the ship equipment UI system, and I think I have a working prototype now, albeit with minor issues to sort out.
Basically, I've setup a way for the game to launch different UIs based on what the AI is doing at the time. This is the precursor to controlling important ship actions using the crew.
The way it works is that the player left-clicks the crew they want to use, then right-clicks the target item. The game will first check for any valid interactions between the AI and the item. If it finds one, it'll check to see if the AI can pathfind to that interaction's specified point on the ship (usually next to the item). If that passes, the AI is ordered to walk to the item and the interaction is queued for when it gets there.
If that interaction has a GUI specified, the interaction will raise that GUI with any parameters that were specified in the interaction's data. These params will define things like label names, min and max values, and probably, which items and stats to connect to which UI elements.
And so far, it works! I have a simple charge meter UI setup for the battery, and choosing an AI and then right-clicking on the battery causes the AI to walk across the ship, opening doors as needed. When it gets to the battery, a charge meter opens on the screen, showing real-time battery charge. Pretty cool!
Of course, it has some kinks to work out. For one thing, the UI appears as the AI is finishing the interaction, instead of when it starts interacting. Also, the UI never goes away. Also, the UI is just the first valid interaction, and should probably have some list of options present for the player to choose from (in cases where more than one UI is possible).
Also, as evidenced in this discussion from an earlier post, I have a lot of thinking to do about how the player controls the crew.
There are pros and cons to each approach, and likely, I'll have to try them out to see which feels the best. For now, the easiest will be to have the AIs autonomously self-care (i.e. eat, sleep) but have the player direct them to do more complex stuff (e.g. steer ship, change life support settings). But there may be compelling reasons to make the AI handle those more UI-centric tasks, in which case I'll need to work on a way for AIs to do these widget tasks.
Anyway, progress! This is a subtle upgrade with serious power potential. Lots of cool shipboard items to interact with through widgets now!