source: OniSplit/Particles/ImpactEffectSound.cs@ 1191

Last change on this file since 1191 was 1114, checked in by iritscen, 5 years ago

Adding OniSplit source code (v0.9.99.0). Many thanks to Neo for all his work over the years.

File size: 2.0 KB
RevLine 
[1114]1using System;
2using System.Xml;
3using Oni.Metadata;
4
5namespace 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}
Note: See TracBrowser for help on using the repository browser.