xnaparticle-system

Real-time alterations to XML to change the particle effect


I am currently writing a Particle System using XNA. What I'd like to do is use an external file (XML for example) and be able to modify this file, whilst the application is running, and once saved, the changes will be reflected in the Particle System.

My original proposal: Use a FileWatcher (can't remember the exact class name) to monitor the particle effect file and when the date changes, reload the file thus causing the changes to be made.

Any help would be appreciated.


Solution

  • You are on the right track.

    Create a System.IO.FileSystemWatcher.
    Subscribe to the Changed event.
    
    When the Changed event occurs
       If the path/file extension corresponds to a buildable resource type
          Either
             Directly create and invoke a content importer and processor. (Xna 4.0)
          Or
             Use MSBuild to build a dummy content project.
          
          Replace references to the existing resource with the newly built resource
          Dispose of the old resource if necessary
    

    Notes: