1 | using System;
|
---|
2 | using System.Xml;
|
---|
3 | using Oni.Metadata;
|
---|
4 | using Oni.Xml;
|
---|
5 |
|
---|
6 | namespace Oni.Objects
|
---|
7 | {
|
---|
8 | internal class Turret : GunkObject
|
---|
9 | {
|
---|
10 | public int ScriptId;
|
---|
11 | public TurretFlags Flags;
|
---|
12 | public TurretTargetTeams TargetTeams;
|
---|
13 |
|
---|
14 | public Turret()
|
---|
15 | {
|
---|
16 | TypeId = ObjectType.Turret;
|
---|
17 | }
|
---|
18 |
|
---|
19 | protected override void WriteOsd(BinaryWriter writer)
|
---|
20 | {
|
---|
21 | writer.Write(ClassName, 63);
|
---|
22 | writer.WriteUInt16(ScriptId);
|
---|
23 | writer.WriteUInt16((ushort)Flags);
|
---|
24 | writer.Skip(36);
|
---|
25 | writer.Write((uint)TargetTeams);
|
---|
26 | }
|
---|
27 |
|
---|
28 | protected override void ReadOsd(BinaryReader reader)
|
---|
29 | {
|
---|
30 | ClassName = reader.ReadString(63);
|
---|
31 | ScriptId = reader.ReadUInt16();
|
---|
32 | Flags = (TurretFlags)reader.ReadUInt16();
|
---|
33 | reader.Skip(36);
|
---|
34 | TargetTeams = (TurretTargetTeams)reader.ReadInt32();
|
---|
35 | }
|
---|
36 |
|
---|
37 | protected override void WriteOsd(XmlWriter xml)
|
---|
38 | {
|
---|
39 | xml.WriteElementString("Class", ClassName);
|
---|
40 | xml.WriteElementString("TurretId", XmlConvert.ToString(ScriptId));
|
---|
41 | xml.WriteElementString("Flags", MetaEnum.ToString<TurretFlags>(Flags));
|
---|
42 | xml.WriteElementString("TargetedTeams", MetaEnum.ToString<TurretTargetTeams>(TargetTeams));
|
---|
43 | }
|
---|
44 |
|
---|
45 | protected override void ReadOsd(XmlReader xml, ObjectLoadContext context)
|
---|
46 | {
|
---|
47 | string className = xml.ReadElementContentAsString("Class", "");
|
---|
48 |
|
---|
49 | ScriptId = xml.ReadElementContentAsInt("TurretId", "");
|
---|
50 | Flags = xml.ReadElementContentAsEnum<TurretFlags>("Flags");
|
---|
51 | TargetTeams = xml.ReadElementContentAsEnum<TurretTargetTeams>("TargetedTeams");
|
---|
52 |
|
---|
53 | GunkClass = context.GetClass(TemplateTag.TURR, className, TurretClass.Read);
|
---|
54 | }
|
---|
55 | }
|
---|
56 | }
|
---|