diff --git a/MLEM/Content/RawContentManager.cs b/MLEM/Content/RawContentManager.cs index 2255d8d..820779c 100644 --- a/MLEM/Content/RawContentManager.cs +++ b/MLEM/Content/RawContentManager.cs @@ -50,7 +50,7 @@ namespace MLEM.Content { if (!file.Exists) continue; using (var stream = file.OpenRead()) { - var read = reader.Read(this, assetName, stream, existing); + var read = reader.Read(this, assetName, stream, typeof(T), existing); if (!(read is T t)) throw new ContentLoadException($"{reader} returned non-{typeof(T)} for asset {assetName}"); this.LoadedAssets[assetName] = t; diff --git a/MLEM/Content/RawContentReader.cs b/MLEM/Content/RawContentReader.cs index 82e31aa..1aa1d33 100644 --- a/MLEM/Content/RawContentReader.cs +++ b/MLEM/Content/RawContentReader.cs @@ -6,7 +6,7 @@ namespace MLEM.Content { public abstract bool CanRead(Type t); - public abstract object Read(RawContentManager manager, string assetPath, Stream stream, object existing); + public abstract object Read(RawContentManager manager, string assetPath, Stream stream, Type t, object existing); public abstract string[] GetFileExtensions(); @@ -18,7 +18,7 @@ namespace MLEM.Content { return typeof(T).IsAssignableFrom(t); } - public override object Read(RawContentManager manager, string assetPath, Stream stream, object existing) { + public override object Read(RawContentManager manager, string assetPath, Stream stream, Type t, object existing) { return this.Read(manager, assetPath, stream, (T) existing); } diff --git a/MLEM/Content/SoundEffectReader.cs b/MLEM/Content/SoundEffectReader.cs index a5ca9d2..26411f6 100644 --- a/MLEM/Content/SoundEffectReader.cs +++ b/MLEM/Content/SoundEffectReader.cs @@ -1,3 +1,4 @@ +using System; using System.IO; using Microsoft.Xna.Framework.Audio; diff --git a/MLEM/Content/XmlReader.cs b/MLEM/Content/XmlReader.cs new file mode 100644 index 0000000..28b6833 --- /dev/null +++ b/MLEM/Content/XmlReader.cs @@ -0,0 +1,21 @@ +using System; +using System.IO; +using System.Xml.Serialization; + +namespace MLEM.Content { + public class XmlReader : RawContentReader { + + public override bool CanRead(Type t) { + return true; + } + + public override object Read(RawContentManager manager, string assetPath, Stream stream, Type t, object existing) { + return new XmlSerializer(t).Deserialize(stream); + } + + public override string[] GetFileExtensions() { + return new[] {"xml"}; + } + + } +} \ No newline at end of file