source: OniSplit/Objects/ConsoleClass.cs@ 1119

Last change on this file since 1119 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.1 KB
Line 
1using System.Xml;
2using Oni.Akira;
3using Oni.Metadata;
4using Oni.Motoko;
5using Oni.Physics;
6using Oni.Xml;
7
8namespace Oni.Objects
9{
10 internal class ConsoleClass : GunkObjectClass
11 {
12 public ConsoleClassFlags Flags;
13 public Vector3 ActionPoint;
14 public Vector3 ActionOrientation;
15 public ObjectNode Geometry;
16 public Geometry ScreenGeometry;
17 public GunkFlags ScreenGunkFlags;
18 public string InactiveTexture;
19 public string ActiveTexture;
20 public string TriggeredTexture;
21
22 public static ConsoleClass Read(InstanceDescriptor cons)
23 {
24 var klass = new ConsoleClass();
25
26 InstanceDescriptor geometryDescriptor;
27 InstanceDescriptor screenGeometryDescriptor;
28
29 using (var reader = cons.OpenRead())
30 {
31 klass.Flags = (ConsoleClassFlags)reader.ReadUInt32();
32 klass.ActionPoint = reader.ReadVector3();
33 klass.ActionOrientation = reader.ReadVector3();
34 geometryDescriptor = reader.ReadInstance();
35 screenGeometryDescriptor = reader.ReadInstance();
36 klass.ScreenGunkFlags = (GunkFlags)reader.ReadUInt32();
37 klass.InactiveTexture = reader.ReadString(32);
38 klass.ActiveTexture = reader.ReadString(32);
39 klass.TriggeredTexture = reader.ReadString(32);
40 }
41
42 if (geometryDescriptor != null)
43 klass.Geometry = ObjectDatReader.ReadObjectGeometry(geometryDescriptor);
44
45 if (screenGeometryDescriptor != null)
46 klass.ScreenGeometry = GeometryDatReader.Read(screenGeometryDescriptor);
47
48 return klass;
49 }
50
51 public static ConsoleClass Read(XmlReader xml)
52 {
53 var klass = new ConsoleClass();
54
55 while (xml.IsStartElement())
56 {
57 switch (xml.LocalName)
58 {
59 case "Flags":
60 klass.Flags = xml.ReadElementContentAsEnum<ConsoleClassFlags>();
61 break;
62 case "ActionPoint":
63 klass.ActionPoint = xml.ReadElementContentAsVector3();
64 break;
65 case "ActionOrientation":
66 klass.ActionOrientation = xml.ReadElementContentAsVector3();
67 break;
68 case "ConsoleGeometry":
69 break;
70 case "InactiveTexture":
71 klass.InactiveTexture = xml.ReadElementContentAsString();
72 break;
73 case "ActiveTexture":
74 klass.ActiveTexture = xml.ReadElementContentAsString();
75 break;
76 case "TriggeredTexture":
77 klass.TriggeredTexture = xml.ReadElementContentAsString();
78 break;
79 }
80 }
81
82 return klass;
83 }
84
85 public override ObjectGeometry[] GunkNodes => Geometry.Geometries;
86 }
87}
Note: See TracBrowser for help on using the repository browser.