@@ -113,7 +113,9 @@ protected bool CheckTriggers()
113
113
foreach ( var trigger in triggers )
114
114
{
115
115
if ( trigger . IsTriggered )
116
+ {
116
117
return true ;
118
+ }
117
119
}
118
120
return false ;
119
121
}
@@ -141,7 +143,9 @@ public override void Initialize()
141
143
{
142
144
var trigger = rocker . GetComponent < TriggerMechanism > ( ) ;
143
145
if ( trigger )
146
+ {
144
147
triggers . Add ( trigger ) ;
148
+ }
145
149
}
146
150
}
147
151
#endregion
@@ -244,14 +248,18 @@ public abstract class CrankLinkMechanism : Mechanism
244
248
protected override void Awake ( )
245
249
{
246
250
if ( IsIntact )
251
+ {
247
252
Initialize ( ) ;
253
+ }
248
254
}
249
255
250
256
#if UNITY_EDITOR
251
257
protected virtual void Update ( )
252
258
{
253
259
if ( Application . isPlaying )
260
+ {
254
261
return ;
262
+ }
255
263
256
264
if ( IsIntact )
257
265
{
@@ -263,7 +271,9 @@ protected virtual void Update()
263
271
DriveLinkJoints ( ) ;
264
272
}
265
273
else
274
+ {
266
275
isInitialized = false ;
276
+ }
267
277
}
268
278
#endif
269
279
/// <summary>
@@ -322,13 +332,17 @@ public override void Drive(float velocity, DriveType type)
322
332
if ( velocity >= 0 )
323
333
{
324
334
if ( IsLock && isPositive )
335
+ {
325
336
return ;
337
+ }
326
338
isPositive = true ;
327
339
}
328
340
else
329
341
{
330
342
if ( IsLock && ! isPositive )
343
+ {
331
344
return ;
345
+ }
332
346
isPositive = false ;
333
347
}
334
348
crank . Drive ( velocity , type ) ;
@@ -354,7 +368,9 @@ public abstract class RockerMechanism : Mechanism
354
368
protected virtual void Update ( )
355
369
{
356
370
if ( ! Application . isPlaying && joint )
371
+ {
357
372
Drive ( 0 , DriveType . Ignore ) ;
373
+ }
358
374
}
359
375
#endif
360
376
#endregion
@@ -392,12 +408,16 @@ public TelescopicState State
392
408
{
393
409
get
394
410
{
411
+ var state = TelescopicState . Between ;
395
412
if ( Displacement <= stroke . min )
396
- return TelescopicState . Minimum ;
413
+ {
414
+ state = TelescopicState . Minimum ;
415
+ }
397
416
else if ( Displacement >= stroke . max )
398
- return TelescopicState . Maximum ;
399
- else
400
- return TelescopicState . Between ;
417
+ {
418
+ state = TelescopicState . Maximum ;
419
+ }
420
+ return state ;
401
421
}
402
422
}
403
423
0 commit comments