1 | using System.Xml;
|
---|
2 | using Oni.Particles;
|
---|
3 |
|
---|
4 | namespace Oni.Xml
|
---|
5 | {
|
---|
6 | internal class OnieXmlExporter : RawXmlExporter
|
---|
7 | {
|
---|
8 | private OnieXmlExporter(BinaryReader reader, XmlWriter xml)
|
---|
9 | : base(reader, xml)
|
---|
10 | {
|
---|
11 | }
|
---|
12 |
|
---|
13 | public static void Export(BinaryReader reader, XmlWriter xml)
|
---|
14 | {
|
---|
15 | var exporter = new OnieXmlExporter(reader, xml);
|
---|
16 | exporter.Export();
|
---|
17 | }
|
---|
18 |
|
---|
19 | private void Export()
|
---|
20 | {
|
---|
21 | Reader.Skip(8);
|
---|
22 | var impacts = new string[Reader.ReadInt32()];
|
---|
23 | var materials = new string[Reader.ReadInt32()];
|
---|
24 | var particles = new ImpactEffectParticle[Reader.ReadInt32()];
|
---|
25 | var sounds = new ImpactEffectSound[Reader.ReadInt32()];
|
---|
26 | var effects = new ImpactEffect[Reader.ReadInt32()];
|
---|
27 | Reader.Skip(4);
|
---|
28 |
|
---|
29 | for (int i = 0; i < impacts.Length; i++)
|
---|
30 | {
|
---|
31 | impacts[i] = Reader.ReadString(128);
|
---|
32 | Reader.Skip(4);
|
---|
33 | }
|
---|
34 |
|
---|
35 | for (int i = 0; i < materials.Length; i++)
|
---|
36 | {
|
---|
37 | materials[i] = Reader.ReadString(128);
|
---|
38 | Reader.Skip(4);
|
---|
39 | }
|
---|
40 |
|
---|
41 | for (int i = 0; i < impacts.Length; i++)
|
---|
42 | {
|
---|
43 | Reader.Skip(8);
|
---|
44 | }
|
---|
45 |
|
---|
46 | for (int i = 0; i < particles.Length; i++)
|
---|
47 | {
|
---|
48 | particles[i] = new ImpactEffectParticle(Reader);
|
---|
49 | }
|
---|
50 |
|
---|
51 | for (int i = 0; i < sounds.Length; i++)
|
---|
52 | {
|
---|
53 | sounds[i] = new ImpactEffectSound(Reader);
|
---|
54 | }
|
---|
55 |
|
---|
56 | for (int i = 0; i < effects.Length; i++)
|
---|
57 | {
|
---|
58 | effects[i] = new ImpactEffect(Reader, impacts, materials, particles, sounds);
|
---|
59 | }
|
---|
60 |
|
---|
61 | Xml.WriteStartElement("ImpactEffects");
|
---|
62 |
|
---|
63 | foreach (string impact in impacts)
|
---|
64 | {
|
---|
65 | Xml.WriteStartElement("Impact");
|
---|
66 | Xml.WriteAttributeString("Name", impact);
|
---|
67 |
|
---|
68 | foreach (string material in materials)
|
---|
69 | {
|
---|
70 | bool found = false;
|
---|
71 |
|
---|
72 | foreach (ImpactEffect effect in effects)
|
---|
73 | {
|
---|
74 | if (effect.ImpactName == impact && effect.MaterialName == material)
|
---|
75 | {
|
---|
76 | found = true;
|
---|
77 | break;
|
---|
78 | }
|
---|
79 | }
|
---|
80 |
|
---|
81 | if (!found)
|
---|
82 | continue;
|
---|
83 |
|
---|
84 | Xml.WriteStartElement("Material");
|
---|
85 | Xml.WriteAttributeString("Name", material);
|
---|
86 |
|
---|
87 | foreach (ImpactEffect effect in effects)
|
---|
88 | {
|
---|
89 | if (effect.ImpactName == impact && effect.MaterialName == material)
|
---|
90 | {
|
---|
91 | Xml.WriteStartElement("ImpactEffect");
|
---|
92 | effect.Write(Xml);
|
---|
93 | Xml.WriteEndElement();
|
---|
94 | }
|
---|
95 | }
|
---|
96 |
|
---|
97 | Xml.WriteEndElement();
|
---|
98 | }
|
---|
99 |
|
---|
100 | Xml.WriteEndElement();
|
---|
101 | }
|
---|
102 |
|
---|
103 | Xml.WriteEndElement();
|
---|
104 | }
|
---|
105 | }
|
---|
106 | }
|
---|