1 | using System;
|
---|
2 | using System.Xml;
|
---|
3 | using Oni.Metadata;
|
---|
4 |
|
---|
5 | namespace Oni.Particles
|
---|
6 | {
|
---|
7 | internal class ImpactEffectSound
|
---|
8 | {
|
---|
9 | private string soundName;
|
---|
10 | private bool aiCanHear;
|
---|
11 | private InstanceMetadata.DOORSoundType aiSoundType;
|
---|
12 | private float aiSoundRadius;
|
---|
13 |
|
---|
14 | public ImpactEffectSound(BinaryReader reader)
|
---|
15 | {
|
---|
16 | soundName = reader.ReadString(32);
|
---|
17 | reader.Skip(8);
|
---|
18 | aiCanHear = (reader.ReadInt16() != 0);
|
---|
19 | aiSoundType = (InstanceMetadata.DOORSoundType)reader.ReadInt16();
|
---|
20 | aiSoundRadius = reader.ReadSingle();
|
---|
21 | }
|
---|
22 |
|
---|
23 | public void Write(BinaryWriter writer)
|
---|
24 | {
|
---|
25 | writer.Write(soundName, 32);
|
---|
26 | writer.Skip(8);
|
---|
27 | writer.WriteInt16(aiCanHear ? 1 : 0);
|
---|
28 | writer.WriteInt16((short)aiSoundType);
|
---|
29 | writer.Write(aiSoundRadius);
|
---|
30 | }
|
---|
31 |
|
---|
32 | public ImpactEffectSound(XmlReader xml)
|
---|
33 | {
|
---|
34 | soundName = xml.ReadElementContentAsString("Name", "");
|
---|
35 | aiCanHear = bool.Parse(xml.ReadElementContentAsString("AICanHear", ""));
|
---|
36 | aiSoundType = MetaEnum.Parse<InstanceMetadata.DOORSoundType>(xml.ReadElementContentAsString("AISoundType", ""));
|
---|
37 | aiSoundRadius = XmlConvert.ToSingle(xml.ReadElementContentAsString("AISoundRadius", ""));
|
---|
38 | }
|
---|
39 |
|
---|
40 | public void Write(XmlWriter writer)
|
---|
41 | {
|
---|
42 | writer.WriteElementString("Name", soundName);
|
---|
43 | writer.WriteElementString("AICanHear", XmlConvert.ToString(aiCanHear));
|
---|
44 | writer.WriteElementString("AISoundType", aiSoundType.ToString());
|
---|
45 | writer.WriteElementString("AISoundRadius", XmlConvert.ToString(aiSoundRadius));
|
---|
46 | }
|
---|
47 |
|
---|
48 | public string SoundName => soundName;
|
---|
49 | public bool AICanHear => aiCanHear;
|
---|
50 | public InstanceMetadata.DOORSoundType AISoundType => aiSoundType;
|
---|
51 | public float AISoundRadius => aiSoundRadius;
|
---|
52 | }
|
---|
53 | }
|
---|