1 | using System;
|
---|
2 | using System.Xml;
|
---|
3 | using Oni.Metadata;
|
---|
4 |
|
---|
5 | namespace Oni.Objects
|
---|
6 | {
|
---|
7 | internal class Console : GunkObject
|
---|
8 | {
|
---|
9 | public int ScriptId;
|
---|
10 | public ConsoleFlags Flags;
|
---|
11 | public string InactiveTexture;
|
---|
12 | public string ActiveTexture;
|
---|
13 | public string TriggeredTexture;
|
---|
14 | public ObjectEvent[] Events;
|
---|
15 |
|
---|
16 | public Console()
|
---|
17 | {
|
---|
18 | TypeId = ObjectType.Console;
|
---|
19 | }
|
---|
20 |
|
---|
21 | protected override void WriteOsd(BinaryWriter writer)
|
---|
22 | {
|
---|
23 | writer.Write(ClassName, 63);
|
---|
24 | writer.WriteUInt16(ScriptId);
|
---|
25 | writer.WriteUInt16((ushort)Flags);
|
---|
26 | writer.Write(InactiveTexture, 63);
|
---|
27 | writer.Write(ActiveTexture, 63);
|
---|
28 | writer.Write(TriggeredTexture, 63);
|
---|
29 | ObjectEvent.WriteEventList(writer, Events);
|
---|
30 | }
|
---|
31 |
|
---|
32 | protected override void ReadOsd(BinaryReader reader)
|
---|
33 | {
|
---|
34 | ClassName = reader.ReadString(63);
|
---|
35 | ScriptId = reader.ReadUInt16();
|
---|
36 | Flags = (ConsoleFlags)reader.ReadInt16();
|
---|
37 | InactiveTexture = reader.ReadString(63);
|
---|
38 | ActiveTexture = reader.ReadString(63);
|
---|
39 | TriggeredTexture = reader.ReadString(63);
|
---|
40 | Events = ObjectEvent.ReadEventList(reader);
|
---|
41 | }
|
---|
42 |
|
---|
43 | protected override void WriteOsd(XmlWriter xml)
|
---|
44 | {
|
---|
45 | throw new NotImplementedException();
|
---|
46 | }
|
---|
47 |
|
---|
48 | protected override void ReadOsd(XmlReader xml, ObjectLoadContext context)
|
---|
49 | {
|
---|
50 | string className = null;
|
---|
51 |
|
---|
52 | while (xml.IsStartElement())
|
---|
53 | {
|
---|
54 | switch (xml.LocalName)
|
---|
55 | {
|
---|
56 | case "Class":
|
---|
57 | className = xml.ReadElementContentAsString();
|
---|
58 | break;
|
---|
59 | case "ConsoleId":
|
---|
60 | ScriptId = xml.ReadElementContentAsInt();
|
---|
61 | break;
|
---|
62 | case "Flags":
|
---|
63 | Flags = xml.ReadElementContentAsEnum<ConsoleFlags>();
|
---|
64 | break;
|
---|
65 | case "DisabledTexture":
|
---|
66 | case "InactiveTexture":
|
---|
67 | InactiveTexture = xml.ReadElementContentAsString();
|
---|
68 | break;
|
---|
69 | case "EnabledTexture":
|
---|
70 | case "ActiveTexture":
|
---|
71 | ActiveTexture = xml.ReadElementContentAsString();
|
---|
72 | break;
|
---|
73 | case "UsedTexture":
|
---|
74 | case "TrigerredTexture":
|
---|
75 | TriggeredTexture = xml.ReadElementContentAsString();
|
---|
76 | break;
|
---|
77 | case "Events":
|
---|
78 | Events = ObjectEvent.ReadEventList(xml);
|
---|
79 | break;
|
---|
80 | default:
|
---|
81 | xml.Skip();
|
---|
82 | break;
|
---|
83 | }
|
---|
84 | }
|
---|
85 |
|
---|
86 | GunkClass = context.GetClass(TemplateTag.CONS, className, ConsoleClass.Read);
|
---|
87 | }
|
---|
88 | }
|
---|
89 | }
|
---|