ViewVC Help
View File | Revision Log | View Changeset | Root Listing
root/Oni2/OniSplit/Particles/ImpactEffectSound.cs
Revision: 1114
Committed: Wed Jan 22 14:08:57 2020 UTC (5 years, 8 months ago) by iritscen
File size: 2000 byte(s)
Log Message:
Adding OniSplit source code (v0.9.99.0). Many thanks to Neo for all his work over the years.

File Contents

# Content
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 }