source: OniSplit/Objects/TriggerVolume.cs@ 1168

Last change on this file since 1168 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: 3.5 KB
Line 
1using System;
2using System.Xml;
3using Oni.Metadata;
4using Oni.Xml;
5
6namespace Oni.Objects
7{
8 internal class TriggerVolume : ObjectBase
9 {
10 public string Name;
11 public string EntryScript;
12 public string InsideScript;
13 public string ExitScript;
14 public TurretTargetTeams Teams;
15 public Vector3 Size;
16 public int ScriptId;
17 public int ParentId;
18 public string Notes;
19 public TriggerVolumeFlags Flags;
20
21 public TriggerVolume()
22 {
23 TypeId = ObjectType.TriggerVolume;
24 }
25
26 protected override void WriteOsd(BinaryWriter writer)
27 {
28 writer.Write(Name, 63);
29 writer.Write(EntryScript, 32);
30 writer.Write(InsideScript, 32);
31 writer.Write(ExitScript, 32);
32 writer.Write((uint)Teams);
33 writer.Write(Size);
34 writer.Write(ScriptId);
35 writer.Write(ParentId);
36 writer.Write(Notes, 128);
37 writer.Write((uint)Flags);
38 }
39
40 protected override void ReadOsd(BinaryReader reader)
41 {
42 Name = reader.ReadString(63);
43 EntryScript = reader.ReadString(32);
44 InsideScript = reader.ReadString(32);
45 ExitScript = reader.ReadString(32);
46 Teams = (TurretTargetTeams)(reader.ReadUInt32() & 0xff);
47 Size = reader.ReadVector3();
48 ScriptId = reader.ReadInt32();
49 ParentId = reader.ReadInt32();
50 Notes = reader.ReadString(128);
51 Flags = (TriggerVolumeFlags)(reader.ReadUInt32() & 0xff);
52 }
53
54 protected override void WriteOsd(XmlWriter xml)
55 {
56 throw new NotImplementedException();
57 }
58
59 protected override void ReadOsd(XmlReader xml, ObjectLoadContext context)
60 {
61 while (xml.IsStartElement())
62 {
63 switch (xml.LocalName)
64 {
65 case "Name":
66 Name = xml.ReadElementContentAsString();
67 break;
68 case "Scripts":
69 xml.ReadStartElement();
70 EntryScript = xml.ReadElementContentAsString("Entry", "");
71 InsideScript = xml.ReadElementContentAsString("Inside", "");
72 ExitScript = xml.ReadElementContentAsString("Exit", "");
73 xml.ReadEndElement();
74 break;
75 case "Teams":
76 Teams = xml.ReadElementContentAsEnum<TurretTargetTeams>();
77 break;
78 case "Size":
79 Size = xml.ReadElementContentAsVector3();
80 break;
81 case "TriggerVolumeId":
82 case "ScriptId":
83 ScriptId = xml.ReadElementContentAsInt();
84 break;
85 case "ParentId":
86 ParentId = xml.ReadElementContentAsInt();
87 break;
88 case "Notes":
89 Notes = xml.ReadElementContentAsString();
90 break;
91 case "Flags":
92 Flags = xml.ReadElementContentAsEnum<TriggerVolumeFlags>();
93 break;
94
95 default:
96 xml.Skip();
97 break;
98 }
99 }
100 }
101 }
102}
Note: See TracBrowser for help on using the repository browser.