@@ -23,7 +23,7 @@ public class ParticlesDrawable : Sprite
23
23
private const float depth_speed_multiplier = 0.05f ;
24
24
private const float side_speed_multiplier = 0.0005f ;
25
25
26
- public readonly Bindable < MoveDirection > Direction = new Bindable < MoveDirection > ( ) ;
26
+ public readonly Bindable < ParticlesDirection > Direction = new Bindable < ParticlesDirection > ( ) ;
27
27
28
28
[ Resolved ( canBeNull : true ) ]
29
29
private SandboxRulesetConfigManager config { get ; set ; }
@@ -61,8 +61,8 @@ public void Restart(int particleCount)
61
61
62
62
public void SetRandomDirection ( )
63
63
{
64
- var count = Enum . GetValues ( typeof ( MoveDirection ) ) . Length ;
65
- var newDirection = ( MoveDirection ) RNG . Next ( count ) ;
64
+ var count = Enum . GetValues ( typeof ( ParticlesDirection ) ) . Length ;
65
+ var newDirection = ( ParticlesDirection ) RNG . Next ( 1 , count ) ;
66
66
67
67
if ( Direction . Value == newDirection )
68
68
{
@@ -169,21 +169,21 @@ private class Particle
169
169
170
170
public Particle ( )
171
171
{
172
- reset ( MoveDirection . Forward , false ) ;
172
+ reset ( ParticlesDirection . Forward , false ) ;
173
173
}
174
174
175
- private void reset ( MoveDirection direction , bool maxDepth = true )
175
+ private void reset ( ParticlesDirection direction , bool maxDepth = true )
176
176
{
177
177
switch ( direction )
178
178
{
179
179
default :
180
- case MoveDirection . Backwards :
180
+ case ParticlesDirection . Backwards :
181
181
initialPosition = new Vector2 ( RNG . NextSingle ( - 0.5f , 0.5f ) , RNG . NextSingle ( - 0.5f , 0.5f ) ) * max_depth ;
182
182
CurrentPosition = getPositionOnTheEdge ( Vector2 . Divide ( initialPosition . Value , max_depth ) ) ;
183
183
currentDepth = initialPosition . Value . X / CurrentPosition . X ;
184
184
break ;
185
185
186
- case MoveDirection . Forward :
186
+ case ParticlesDirection . Forward :
187
187
currentDepth = maxDepth ? max_depth : RNG . NextSingle ( min_depth , max_depth ) ;
188
188
initialPosition = new Vector2 ( RNG . NextSingle ( - 0.5f , 0.5f ) , RNG . NextSingle ( - 0.5f , 0.5f ) ) * max_depth ;
189
189
CurrentPosition = getCurrentPosition ( direction ) ;
@@ -194,32 +194,32 @@ private void reset(MoveDirection direction, bool maxDepth = true)
194
194
}
195
195
break ;
196
196
197
- case MoveDirection . Left :
197
+ case ParticlesDirection . Left :
198
198
CurrentPosition = getRandomPositionAtTheLeft ( ) ;
199
199
break ;
200
200
201
- case MoveDirection . Right :
201
+ case ParticlesDirection . Right :
202
202
CurrentPosition = getRandomPositionAtTheRight ( ) ;
203
203
break ;
204
204
205
- case MoveDirection . Up :
205
+ case ParticlesDirection . Up :
206
206
CurrentPosition = getRandomPositionAtTheTop ( ) ;
207
207
break ;
208
208
209
- case MoveDirection . Down :
209
+ case ParticlesDirection . Down :
210
210
CurrentPosition = getRandomPositionAtTheBottom ( ) ;
211
211
break ;
212
212
}
213
213
214
214
updateProperties ( ) ;
215
215
}
216
216
217
- public void UpdateCurrentPosition ( float timeDifference , MoveDirection direction , float multiplier , bool horizontalIsFaster )
217
+ public void UpdateCurrentPosition ( float timeDifference , ParticlesDirection direction , float multiplier , bool horizontalIsFaster )
218
218
{
219
219
switch ( direction )
220
220
{
221
221
default :
222
- case MoveDirection . Forward :
222
+ case ParticlesDirection . Forward :
223
223
currentDepth -= timeDifference ;
224
224
225
225
if ( currentDepth < min_depth )
@@ -238,7 +238,7 @@ public void UpdateCurrentPosition(float timeDifference, MoveDirection direction,
238
238
239
239
break ;
240
240
241
- case MoveDirection . Backwards :
241
+ case ParticlesDirection . Backwards :
242
242
currentDepth += timeDifference ;
243
243
244
244
if ( currentDepth > max_depth )
@@ -250,7 +250,7 @@ public void UpdateCurrentPosition(float timeDifference, MoveDirection direction,
250
250
CurrentPosition = getCurrentPosition ( direction ) ;
251
251
break ;
252
252
253
- case MoveDirection . Left :
253
+ case ParticlesDirection . Left :
254
254
initialPosition = null ;
255
255
CurrentPosition += new Vector2 ( max_depth / currentDepth * timeDifference * ( horizontalIsFaster ? multiplier : 1 ) * side_speed_multiplier , 0 ) ;
256
256
@@ -260,7 +260,7 @@ public void UpdateCurrentPosition(float timeDifference, MoveDirection direction,
260
260
}
261
261
break ;
262
262
263
- case MoveDirection . Right :
263
+ case ParticlesDirection . Right :
264
264
initialPosition = null ;
265
265
CurrentPosition -= new Vector2 ( max_depth / currentDepth * timeDifference * ( horizontalIsFaster ? multiplier : 1 ) * side_speed_multiplier , 0 ) ;
266
266
@@ -270,7 +270,7 @@ public void UpdateCurrentPosition(float timeDifference, MoveDirection direction,
270
270
}
271
271
break ;
272
272
273
- case MoveDirection . Up :
273
+ case ParticlesDirection . Up :
274
274
initialPosition = null ;
275
275
CurrentPosition += new Vector2 ( 0 , max_depth / currentDepth * timeDifference * ( horizontalIsFaster ? 1 : multiplier ) * side_speed_multiplier ) ;
276
276
@@ -280,7 +280,7 @@ public void UpdateCurrentPosition(float timeDifference, MoveDirection direction,
280
280
}
281
281
break ;
282
282
283
- case MoveDirection . Down :
283
+ case ParticlesDirection . Down :
284
284
initialPosition = null ;
285
285
CurrentPosition -= new Vector2 ( 0 , max_depth / currentDepth * timeDifference * ( horizontalIsFaster ? 1 : multiplier ) * side_speed_multiplier ) ;
286
286
@@ -300,13 +300,13 @@ private void updateProperties()
300
300
CurrentAlpha = CurrentSize < 1 ? MathExtensions . Map ( CurrentSize , particle_min_size , 1 , 0 , 1 ) : 1 ;
301
301
}
302
302
303
- private Vector2 getCurrentPosition ( MoveDirection direction )
303
+ private Vector2 getCurrentPosition ( ParticlesDirection direction )
304
304
{
305
305
switch ( direction )
306
306
{
307
307
default :
308
- case MoveDirection . Forward :
309
- case MoveDirection . Backwards :
308
+ case ParticlesDirection . Forward :
309
+ case ParticlesDirection . Backwards :
310
310
if ( initialPosition . HasValue )
311
311
{
312
312
return Vector2 . Divide ( initialPosition . Value , currentDepth ) ;
@@ -350,8 +350,9 @@ private static Vector2 getPositionOnTheEdge(Vector2 inBoundsPosition)
350
350
}
351
351
}
352
352
353
- public enum MoveDirection
353
+ public enum ParticlesDirection
354
354
{
355
+ Random ,
355
356
Forward ,
356
357
Backwards ,
357
358
Left ,
0 commit comments