Beispiel #1
0
 private void UpdateInterpolatedValues()
 {
     interpolatedOffsetX.Update();
     interpolatedOffsetY.Update();
     if (gasProps.AnimationAmplitude > 0)
     {
         interpolatedScale.Update();
         interpolatedRotation.Update();
         if (interpolatedOffsetX.finished)
         {
             // start offset interpolation
             var newX     = Rand.Range(-gasProps.AnimationAmplitude, gasProps.AnimationAmplitude);
             var newY     = Rand.Range(-gasProps.AnimationAmplitude, gasProps.AnimationAmplitude);
             var duration = gasProps.AnimationPeriod.RandomInRange;
             interpolatedOffsetX.StartInterpolation(newX, duration, CurveType.CubicInOut);
             interpolatedOffsetY.StartInterpolation(newY, duration, CurveType.CubicInOut);
         }
         if (interpolatedScale.finished)
         {
             // start scale interpolation
             interpolatedScale.StartInterpolation(GetRandomGasScale(), gasProps.AnimationPeriod.RandomInRange, CurveType.CubicInOut);
         }
         if (interpolatedRotation.finished)
         {
             // start rotation interpolation
             const float MaxRotationDelta = 90f;
             var         newRotation      = interpolatedRotation.value + Rand.Range(-MaxRotationDelta, MaxRotationDelta) * gasProps.AnimationAmplitude;
             interpolatedRotation.StartInterpolation(newRotation, gasProps.AnimationPeriod.RandomInRange, CurveType.CubicInOut);
         }
     }
 }
 private void RefreshCurrentTargetPosition(bool forceRefresh)
 {
     if (offsetXAnim.finished || forceRefresh)
     {
         Vector3 lightOffset;
         if (currentTarget != null)
         {
             lightOffset = (currentTarget.TrueCenter() - parent.TrueCenter()).normalized * OffsetDistance;
         }
         else
         {
             lightOffset = Vector3.zero;
         }
         var animDuration = currentTarget is Pawn ? OffsetAnimDuration / 2f : OffsetAnimDuration;
         offsetXAnim.StartInterpolation(lightOffset.x, animDuration, CurveType.CubicInOut);
         offsetZAnim.StartInterpolation(lightOffset.z, animDuration, CurveType.CubicInOut);
     }
 }
 public override void PostDraw()
 {
     base.PostDraw();
     if (blinker != null && Enabled)
     {
         var currentTick = GenTicks.TicksGame;
         RefreshCurrentTargetPosition(false);
         if (nextBlinkTick <= currentTick)
         {
             nextBlinkTick = currentTick + Mathf.Round(Rand.Range(BlinkMaxInterval / 2f, BlinkMaxInterval)).SecondsToTicks();
             blinkAnim.StartInterpolation(0f, BlinkAnimDuration / 2f, CurveType.CubicInOut);
             blinkAnim.SetFinishedCallback((interpolator, value, duration, curve) =>
                                           interpolator.StartInterpolation(1f, duration, curve).SetFinishedCallback(null)
                                           );
         }
         if (blinkSquintAnim.finished)
         {
             // squint if target is a dirty humanlike
             var isHumanlike  = currentTarget is Pawn p && p.RaceProps != null && p.RaceProps.Humanlike;
             var targetSquint = isHumanlike ? .5f : 1f;
             if (!blinkSquintAnim.value.ApproximatelyEquals(targetSquint))
             {
                 blinkSquintAnim.StartInterpolation(targetSquint, SquintAnimDuration, CurveType.CubicInOut);
             }
         }
         if (currentTarget != null && targetExpirationTick <= GenTicks.TicksGame)
         {
             SetLookTarget(null, false);
         }
         blinkAnim.UpdateIfUnpaused();
         blinkSquintAnim.UpdateIfUnpaused();
         offsetXAnim.UpdateIfUnpaused();
         offsetZAnim.UpdateIfUnpaused();
         RemoteTechUtility.DrawFlareOverlay(Resources.Graphics.FlareOverlayNormal,
                                            parent.DrawPos + new Vector3(offsetXAnim.value, 0, offsetZAnim.value) + Altitudes.AltIncVect, blinker, 1f, blinkAnim.value * blinkSquintAnim.value);
     }
 }
Beispiel #4
0
 private void PrimeSpawnAnimation()
 {
     animationProgress.value = 0;
     animationProgress.StartInterpolation(1f, animationDuration, CurveType.QuinticOut);
 }