Completely confounded by ExternalReference

I’m working on a map class consisting of tiles of particular terrains. I’m going to have a lot of said maps (loaded individually), and since the terrains will be shared between all of them, I’d like for the terrains to be references to external definitions, rather than shared resources or any other approach that includes the definition within the map.

I’ve inferred that the ExternalReference class in Content.Pipeline is (probably) intended for this very purpose, but I can’t figure out the first thing about how to use it. Googling I can only find the class definitions and issues with using it (at a much more specific level than anything that helps me). The closest thing I’ve found to a tutorial is the demonstration of how IntermediateSerializer handles it on Shawn Hargreaves’s blog.

So what I would like is some very basic questions about ExternalReference answered, like:

  • Is it actually intended for this purpose? (and if not, is there another faculty that is?)
  • Should I use it as a serialization helper property, as part of a ContentTypeSerializer/Writer/Reader, or store it directly in the class?
  • How do I obtain the Terrain object from the ExternalReference< Terrain> object?

of course, i’m considering loading each level in its own contentmanager, but it’ll still help with hard drive size

Well, after some time (and lucking across something relevant while looking for something else) I have found some information relevant.

  • It does, in fact, appear that this is exactly what the ExternalReference class is for.
  • None of the options listed above is the correct one; instead, ExternalReference should be used in a proxy content class.
  • When it is used in a proxy content class, the ContentManager will automatically convert it into the correct object on loading the game-time class. I think. I haven’t actually gotten that working yet.

(Edit: removed bug as fairly irrelevant to the topic, which might be helpful to Googlers)

This definitely looks like a bug. Can you open an issue on GitHub?

1 Like