I've wondered about this for a while as I worked on my project, but couldn't quite come up with the best way to expose my problem. I'll start with some context.
Context
I have a game that is divided into rooms. So from an asset point of view, it makes sense to load and unload them on a room by room basis. In my case this boils down to all the textures and audio files required by that room.
However, player triggered events can change the state of any dynamic object in the world, even those that are not on the current room. Furthermore, since the game is multiplayer, even if I'm not seeing the changes immediatly, other players might. So, even if the assets aren't loaded, I still need some way to register that change in state.
The way I'm currently handling this is to keep the entire game world state in memory since the start of the game, and only bother about dynamically loading and unloading its assets.
Which leads to the following questions related to resource management.
Questions
Loading and storing the entire game state at once seems reasonable for the scope of my games, but I get the feeling it wouldn't scale very well to larger projects. So how is this usually implemented in massive games such as MMOs that need to update a large amount of entities that are far away from the player?
Assets that are guaranteed to be needed for a particular room (such as the room's scenario and static objects) can be loaded when the player enters the room - possibly with a transition or a loading screen in between. But what about assets for unpredictable game entities that might suddenly come into your current room at any time, such as other players?
Would it be reasonable to treat those separately, load them all at once when the game starts, and keep them in memory the entire time, or would it be better to load them and unloaded dynamically in a separate thread? And in that case, does XNA handle loading assets from another thread well?
ContentManager
class is not itself thread-safe. But you can have multiple content managers on multiple threads. And you can load on a background thread while your game is running. You can inherit fromContentManager
and override its methods to implement your own lifetime policies for things that it loads. \$\endgroup\$ContentManager
but load a few assets from a background thread while the game is running, just to avoid stalling the game. In that scenario, can I "just do it" or would I run into problems? I really need to brush up on concurrency. \$\endgroup\$ContentManager
without unloading everything it has loaded. You need multiple managers, or to customise it. \$\endgroup\$