Group Selection, and OOO Monday
Hey Folks! I managed to solve the duplicate object bug, and worked on group selection today.
The duplicate object bug turned out to be a fairly simple fix. Before my shallow ship loading code, the ship would just load everything it needed right away, using the provided data file. But the shallow loading code deferred that until later. Unfortunately, it was using the wrong name for the data file. It used the generic ship template name, instead of the one from save data. And so, when it loaded, it was generating new objects as if it was based on a template, and the ones the game already loaded were left hanging there.
The fix was just saving the correct name, and making sure that data file was accessible later when needed.
Moving on, I started refactoring the selection system. I want to be able to select an area or group of items so I can designate it as a resource gathering zone, or a zone that trading uses to list items, or security no-go zones, etc. It also lays the groundwork for group commands.
The current system only allows selecting one item, and there's a single bracket object that floats around following whatever is selected. The new system gives each object its own selection bracket, and keeps them hidden/inactive until they're needed. It also uses Unity's 9-slice sprite type so they can expand/contract without smearing the edges.
I have most of this in place now, except I'm running into some coordinate system issues. I'm not entirely sure the viewport coords I'm getting for both camera bounds and item position make sense. I may end up switching it to world space, but we'll see.
Once this is working, I think I'll need some sort of UI I can use to tag the current selection with flags like "tradeable" or "gather" or "blank." These tags might just be conditions on the objects themselves, or on the tiles. Plus some sort of way to make an AI pick up or drop an item in these zones, at a bare minimum. (They can already pickup and use items, so this could just be a command added to their list.)
And then, some UI I can load when one AI is bartering with another, that ties into these zones when searching for items to list on each side. Add and remove funds accordingly.
And then, I think we'll have a crude way for players to earn money. Assuming they can find things by docking, walk to an object, pick it up, drop in the barter zone, then find an NPC to barter with.
As I said, it's crude. But it's the beginnings of a game loop. And something from which I can start spiraling out into more connected systems.
Also, just as a heads-up, I'm OOO Monday due to the holiday. I'll be back on Tuesday, though. Have a good weekend, all!