Zone Data Revision
Hey Folks! Hope everyone had a good weekend. Some more heavy labor here, as we finished up a path in the front yard. Digging and hauling dirt and rock, grading sand, and laying patio bricks. Nothing like some good old dusty, back-breaking work to give one time to think. And it fortunately gave me an idea for solving my zoning issue.
I decided to slightly change the way zone info is stored on a ship, to better tie together NPCs with the zones that apply to them. Plus some other per-zone info, like zone name, etc.
Basically, zones are their own data type now, and ships have zero or more zones defined as part of their data. A given zone has a name, list of tile IDs it applies to, list of conditions all of those tiles will get, and a trigger. The trigger was the big idea that occurred to me while digging holes. If I can say a zone applies to anyone with the "player crew" tag, that makes searching for applicable zones easy. Ditto for a trigger like "bartender" + "Hangzhou resident." It's better than assigning a simple NPC name/ID for zone ownership, because this lets me set a filter of sorts. I can have an entire crew share a zone, or the staff at a store, just by using the existing trigger system.
It's also a bit more intuitive than ships having an arbitrary array of strings to apply to tiles later on.
Anyway, this new approach required some data changes under the hood, and some UI changes, too. I spent most of the day swapping out the old format for the new one, and got it just about back to where it was last week. I can set zones by drag-selecting a box, and choosing the toggle in the UI for the zone type I want.
I also improved selection code a bit to be more consistent, update the toggles in real-time, and single-clicking tiles. I'd also want to be able to select a whole zone by clicking a tile in that zone, and have most of the code for that in place.
Once I can do those things, I need to hook-up the drop-down so the user can choose a trigger that applies to that zone. In the final game, this will probably need some special handling so players and game editors have different lists to choose from. And maybe even limit the zone access to just the player ship except in game edit mode.
I'll also likely need to add a text box for changing the zone name, and maybe some other fields in the future. For now, though, this should help me get a step closer to bartering with not only items on one's person, but also from their cargo hold or store room or whatever. (Particularly important if you're buying/selling something that can't be carried, like a salvaged reactor!)