After a few months of (relatively) smooth sailing developing a shooter in DOTS, I've found myself at a bit of a loss when it comes to implementing inventory and weapon switching.
In my ideal world, a DynamicBuffer accomodating arbitrary weapon entities would be stored on the player, with the player's weapon select up and down actions moving an accessor through the DynamicBuffer to obtain a particular weapon and create it in the player's hands. Ideally it would be created as a reference to the version in the DynamicBuffer so I don't have to copy information between them when putting the weapon away, can avoid unnecessary structural changes.
I initially tried to do this without ghosts, replicating only the index for the weapon a player has selected, but I realized that wasn't going to work as I had no good way of informing clients about what weapons any given connection had in their DynamicBuffer, since Entities cannot be GhostFields. Is solving this problem as simple as Ghosting the weapons themselves, and then performing the logic more or less as I've described? I make this post having not yet tried that strategy, but I'm not convinced it's a good approach and it represents a pretty big refactor that I might not have the time to attack for awhile, so I wanted to float the idea before I commit the time. Does it make sense, or is there a smarter way to do it? If this strategy does make sense, how would I go about creating and destroying hand-held versions of the weapons in the DynamicBuffer in the game world? I have discovered that I can create Entities that reference other entities rather than instantiate them using CreateEntity, but how might I destroy such an entity in the game world without destroying its reference source in the buffer?