Trade UI Hooked-Up (Mostly)
Hey Folks! I managed to get most of the trade UI hooked-up and running today. Still a few bits missing, but what you see in the image today is actual inventory data from two crew members.
There were a few bumps on the road getting it all working. Some missed data here and there, null pointers, selection glitches. I still can't figure out why AIs sometimes walk away while the other AI waits for their reply.
But I now see rows for each item type, complete with a "price" (currently same as mass), name, image, and amounts for each party involved. I can adjust the amount being traded, and each line item updates subtotal, which changes the overall total. Cancel bails out. Accept does too, for now. And Reset does nothing.
I also haven't hooked-up the barter zone, as that's a bit trickier. The player's barter zone would be easy, since I could just assume it's any barter zone on the game's "ship" property. There's only one, after all.
NPCs, on the other hand, are trickier. In theory, there are going to be stations where multiple NPCs live, and they won't share barter zones. A food supplier might have one of their own, while the clothing store next door has a different one.
I'm going to need some way to tie a given AI to one or more barter zones.
And as I think about that, this might tie into how NPCs are spawned. A storekeeper will need to spawn in a fairly specific place on a station, and be linked to a given barter zone and loot list. So stations are going to need spawn zones set, and some rules as to who spawns where.
The plot system overlaps this a bit, too. When we speak with a bartender and they offer a mission to find a bartender off-station, that bartender should probably use these spawn rules so they appear in a reasonable place.
Zone info is already part of a ship save file, so that much is covered. There isn't any more to it besides which tile has which flags, so we'll probably need some data that says "spawn NPC template X at spawn zone Y on station Z, and link X to Y after doing so." Where does that link info live?
ConditionOwners (CO) and/or PersonSpec (PS)classes seem like one approach. When an NPC exists in the game, it has at least a PS, and potentially a CO if it gets fleshed-out and walks around. So the PS could list which zones it owns.
However, there might be a case for making each zone (and each item, for that matter) list its owner(s). If the player steals from a shop, we'll need to know who owned that item to initiate a consequence/response.
Could be this needs to be two-way. But this is something I'll need to think about. And unfortunately, that means starting Monday at the bottom of a big, unknown task. It's always tough to start from that.
Alas, I don't have a better idea right now, so weekend break it is! Have a good one, all!