source: OniSplit/Objects/Turret.cs

Last change on this file 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: 1.9 KB
Line 
1using System;
2using System.Xml;
3using Oni.Metadata;
4using Oni.Xml;
5
6namespace 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}
Note: See TracBrowser for help on using the repository browser.