39 int num = shape == FireworksBlock.Shape.SmallBurst ? 100 : 200;
40 while (m_nextParticle < num) {
41 Particle particle = Particles[m_nextParticle++];
42 particle.IsActive = true;
43 particle.Position = position;
44 particle.Size = new Vector2(0.2f * particleSize);
45 particle.TimeToLive = shape == FireworksBlock.Shape.SmallBurst ? m_random.Float(0.5f, 2f) : m_random.Float(1f, 3f);
46 particle.Velocity = m_random.Vector3(0.5f, 1f);
47 particle.Velocity *= (shape == FireworksBlock.Shape.SmallBurst ? 16 : 26) * particle.Velocity.LengthSquared();
48 particle.TextureSlot = m_random.Int(0, 3);
49 particle.FadeRate = m_random.Float(1f, 3f);
50 particle.BaseColor = m_color * m_random.Float(0.5f, 1f);
51 particle.RotationSpeed = 0f;
58 for (
int j = 0; j < num5; j++) {
59 float x2 = (float)Math.PI * 2f * j / num5 + num4;
63 obj2.Position = position;
64 obj2.Size =
new Vector2(0.2f * particleSize);
66 obj2.Velocity = 20f * v2;
70 obj2.RotationSpeed = 0f;
74 case FireworksBlock.Shape.Disc: {
75 float num10 =
m_random.Float(0f, (
float)Math.PI * 2f);
77 for (
int m = 0; m <= num11; m++) {
78 float num12 = m / (float)num11;
79 int num13 = (int)MathF.Round(num12 * 2f * num11);
80 for (
int n = 0; n < num13; n++) {
81 float x5 = (float)Math.PI * 2f * n / num13 + num10;
83 num12 * MathF.Sin(x5) + 0.1f *
m_random.Float(-1f, 1f),
85 num12 * MathF.Cos(x5) + 0.1f *
m_random.Float(-1f, 1f)
89 obj4.Position = position;
90 obj4.Size =
new Vector2(0.2f * particleSize);
91 obj4.TimeToLive =
m_random.Float(1f, 3f);
92 obj4.Velocity = 22f * v4;
93 obj4.TextureSlot =
m_random.Int(0, 3);
94 obj4.FadeRate =
m_random.Float(1f, 3f);
96 obj4.RotationSpeed = 0f;
101 case FireworksBlock.Shape.Ball: {
102 float num14 =
m_random.Float(0f, (
float)Math.PI * 2f);
105 for (
int num16 = 0; num16 <= num15; num16++) {
106 float x6 = (float)Math.PI * num16 / num15;
107 v5.Y = MathF.Cos(x6);
108 float num17 = MathF.Sin(x6);
109 int num18 = (int)MathF.Round(num17 * 2f * num15);
110 for (
int num19 = 0; num19 < num18; num19++) {
111 float x7 = (float)Math.PI * 2f * num19 / num18 + num14;
112 v5.X = num17 * MathF.Sin(x7);
113 v5.Z = num17 * MathF.Cos(x7);
115 obj5.IsActive =
true;
116 obj5.Position = position;
117 obj5.Size =
new Vector2(0.2f * particleSize);
118 obj5.TimeToLive =
m_random.Float(1f, 3f);
119 obj5.Velocity = 20f * v5;
120 obj5.TextureSlot =
m_random.Int(0, 3);
121 obj5.FadeRate =
m_random.Float(1f, 3f);
123 obj5.RotationSpeed = 0f;
128 case FireworksBlock.Shape.ShortTrails:
129 case FireworksBlock.Shape.LongTrails: {
130 float num6 =
m_random.Float(0f, (
float)Math.PI * 2f);
133 for (
int k = 0; k <= num7; k++) {
134 float x3 = (float)Math.PI * k / num7;
135 float num8 = MathF.Sin(x3);
136 int num9 = (int)MathF.Round(num8 * (shape == FireworksBlock.Shape.ShortTrails ? 3 : 2) * num7);
137 for (
int l = 0; l < num9; l++) {
138 float x4 = (float)Math.PI * 2f * l / num9 + num6;
139 v3.X = num8 * MathF.Sin(x4) + 0.3f *
m_random.Float(-1f, 1f);
140 v3.Y = MathF.Cos(x3) + 0.3f *
m_random.Float(-1f, 1f);
141 v3.Z = num8 * MathF.Cos(x4) + 0.3f *
m_random.Float(-1f, 1f);
143 obj3.IsActive =
true;
144 obj3.Position = position;
145 obj3.Size =
new Vector2(0.25f);
146 obj3.TimeToLive =
m_random.Float(0.5f, 2.5f);
147 obj3.Velocity = shape == FireworksBlock.Shape.ShortTrails ? 25f * v3 : 35f * v3;
148 obj3.TextureSlot =
m_random.Int(0, 3);
149 obj3.FadeRate =
m_random.Float(1f, 3f);
151 obj3.GenerationFrequency = shape == FireworksBlock.Shape.ShortTrails ? 1.9f : 2.1f;
152 obj3.RotationSpeed =
m_random.Float(-40f, 40f);
157 case FireworksBlock.Shape.FlatTrails: {
158 float num2 =
m_random.Float(0f, (
float)Math.PI * 2f);
160 for (
int i = 0; i < num3; i++) {
161 float x = (float)Math.PI * 2f * i / num3 + num2;
162 Vector3 v =
new(MathF.Sin(x) + 0.1f *
m_random.Float(-1f, 1f), 0f, MathF.Cos(x) + 0.1f *
m_random.Float(-1f, 1f));
165 obj.Position = position;
167 obj.TimeToLive =
m_random.Float(0.5f, 2.5f);
168 obj.Velocity = 25f * v;
169 obj.TextureSlot =
m_random.Int(0, 3);
170 obj.FadeRate =
m_random.Float(1f, 3f);
172 obj.GenerationFrequency = 2.5f;
173 obj.RotationSpeed =
m_random.Float(-40f, 40f);
181 dt = Math.Clamp(dt, 0f, 0.1f);
182 float num = MathF.Pow(0.01f, dt);
183 float num2 = MathF.Pow(0.1f, dt);
185 for (
int i = 0; i <
Particles.Length; i++) {
191 particle.TimeToLive -= dt;
193 Vector3 position = particle.Position += particle.Velocity * dt;
194 particle.Velocity.Y += -9.81f * dt;
195 particle.Velocity *= particle.HighDamping ? num : num2;
197 particle.Rotation += particle.RotationSpeed * dt;
202 if (
m_random.Float(0f, 1f) < 20f * dt) {
203 particle.TextureSlot =
m_random.Int(0, 3);
207 particle.GenerationAccumulator += particle.GenerationFrequency * num3 * dt;
210 particle.GenerationAccumulator -= 1f;
213 obj.Position = position;
216 obj.TextureSlot =
m_random.Int(0, 3);
219 obj.HighDamping =
true;
220 obj.RotationSpeed = 0f;
225 particle.IsActive =
false;