source: OniSplit/Particles/Emitter.cs@ 1114

Last change on this file since 1114 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: 4.2 KB
Line 
1using System;
2
3namespace Oni.Particles
4{
5 internal class Emitter
6 {
7 #region Private data
8 private string particleClass;
9 private EmitterFlags flags;
10 private int turnOffTreshold;
11 private int probability;
12 private float copies;
13 private int linkTo;
14 private EmitterRate rate;
15 private EmitterPosition position;
16 private EmitterDirection direction;
17 private EmitterSpeed speed;
18 private EmitterOrientation orientationDir;
19 private EmitterOrientation orientationUp;
20 private Value[] parameters;
21 #endregion
22
23 public Emitter()
24 {
25 parameters = new Value[12];
26 }
27
28 public Emitter(BinaryReader reader)
29 {
30 particleClass = reader.ReadString(64);
31 reader.Skip(4);
32 flags = (EmitterFlags)reader.ReadInt32();
33 turnOffTreshold = reader.ReadInt16();
34 probability = reader.ReadUInt16();
35 copies = reader.ReadSingle();
36 linkTo = reader.ReadInt32();
37 rate = (EmitterRate)reader.ReadInt32();
38 position = (EmitterPosition)reader.ReadInt32();
39 direction = (EmitterDirection)reader.ReadInt32();
40 speed = (EmitterSpeed)reader.ReadInt32();
41 orientationDir = (EmitterOrientation)reader.ReadInt32();
42 orientationUp = (EmitterOrientation)reader.ReadInt32();
43
44 parameters = new Value[12];
45
46 for (int i = 0; i < parameters.Length; i++)
47 parameters[i] = Value.Read(reader);
48 }
49
50 public void Write(BinaryWriter writer)
51 {
52 writer.Write(particleClass, 64);
53 writer.Skip(4);
54 writer.Write((int)flags);
55 writer.WriteInt16(turnOffTreshold);
56 writer.WriteUInt16(probability);
57 writer.Write(copies);
58 writer.Write(linkTo);
59 writer.Write((int)rate);
60 writer.Write((int)position);
61 writer.Write((int)direction);
62 writer.Write((int)speed);
63 writer.Write((int)orientationDir);
64 writer.Write((int)orientationUp);
65
66 for (int i = 0; i < parameters.Length; i++)
67 {
68 if (parameters[i] != null)
69 parameters[i].Write(writer);
70 else
71 Value.Empty.Write(writer);
72 }
73 }
74
75 public EmitterFlags Flags
76 {
77 get { return flags; }
78 set { flags = value; }
79 }
80
81 public int Probability
82 {
83 get { return probability; }
84 set { probability = value; }
85 }
86
87 public int TurnOffTreshold
88 {
89 get { return turnOffTreshold; }
90 set { turnOffTreshold = value; }
91 }
92
93 public int LinkTo
94 {
95 get { return linkTo; }
96 set { linkTo = value; }
97 }
98
99 public string ParticleClass
100 {
101 get { return particleClass; }
102 set { particleClass = value; }
103 }
104
105 public float Copies
106 {
107 get { return copies; }
108 set { copies = value; }
109 }
110
111 public EmitterRate Rate
112 {
113 get { return rate; }
114 set { rate = value; }
115 }
116
117 public EmitterPosition Position
118 {
119 get { return position; }
120 set { position = value; }
121 }
122
123 public EmitterDirection Direction
124 {
125 get { return direction; }
126 set { direction = value; }
127 }
128
129 public EmitterSpeed Speed
130 {
131 get { return speed; }
132 set { speed = value; }
133 }
134
135 public EmitterOrientation OrientationDir
136 {
137 get { return orientationDir; }
138 set { orientationDir = value; }
139 }
140
141 public EmitterOrientation OrientationUp
142 {
143 get { return orientationUp; }
144 set { orientationUp = value; }
145 }
146
147 public Value[] Parameters => parameters;
148 }
149}
Note: See TracBrowser for help on using the repository browser.