source: OniSplit/Objects/Particle.cs@ 1179

Last change on this file since 1179 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: 2.2 KB
Line 
1using System;
2using System.Xml;
3using Oni.Metadata;
4using Oni.Xml;
5
6namespace Oni.Objects
7{
8 internal class Particle : ObjectBase
9 {
10 public string ClassName;
11 public string Tag;
12 public ParticleFlags Flags;
13 public Vector2 DecalScale = new Vector2(1.0f, 1.0f);
14
15 public Particle()
16 {
17 TypeId = ObjectType.Particle;
18 }
19
20 protected override void WriteOsd(BinaryWriter writer)
21 {
22 writer.Write(ClassName, 64);
23 writer.Write(Tag, 48);
24 writer.Write((ushort)Flags);
25 writer.Write(DecalScale);
26 }
27
28 protected override void ReadOsd(BinaryReader reader)
29 {
30 ClassName = reader.ReadString(64);
31 Tag = reader.ReadString(48);
32 Flags = (ParticleFlags)reader.ReadUInt16();
33 DecalScale = reader.ReadVector2();
34 }
35
36 protected override void WriteOsd(XmlWriter xml)
37 {
38 xml.WriteElementString("Class", ClassName);
39 xml.WriteElementString("Tag", Tag);
40 xml.WriteElementString("Flags", MetaEnum.ToString<ParticleFlags>(Flags));
41 xml.WriteElementString("DecalScale", XmlConvert.ToString(DecalScale.X) + " " + XmlConvert.ToString(DecalScale.Y));
42 }
43
44 protected override void ReadOsd(XmlReader xml, ObjectLoadContext context)
45 {
46 while (xml.IsStartElement())
47 {
48 switch (xml.LocalName)
49 {
50 case "Class":
51 ClassName = xml.ReadElementContentAsString();
52 break;
53 case "Tag":
54 Tag = xml.ReadElementContentAsString();
55 break;
56 case "Flags":
57 Flags = xml.ReadElementContentAsEnum<ParticleFlags>() & ParticleFlags.NotInitiallyCreated;
58 break;
59 case "DecalScale":
60 DecalScale = xml.ReadElementContentAsVector2();
61 break;
62 default:
63 xml.Skip();
64 break;
65 }
66 }
67 }
68 }
69}
Note: See TracBrowser for help on using the repository browser.