public override float GetSpeedBasedDuration(Vector3ArrayOptions options, float unitsXSecond, Vector3[] changeValue) => default; // 0x004D4A00-0x004D4B20 public override void EvaluateAndApply(Vector3ArrayOptions options, Tween t, bool isRelative, DOGetter <Vector3> getter, DOSetter <Vector3> setter, float elapsed, Vector3[] startValue, Vector3[] changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { } // 0x004D4B20-0x004D5560
// Token: 0x0600015B RID: 347 internal abstract bool ApplyTween(float prevPosition, int prevCompletedLoops, int newCompletedSteps, bool useInversePosition, UpdateMode updateMode, UpdateNotice updateNotice);
public abstract void EvaluateAndApply(TPlugOptions options, Tween t, bool isRelative, DOGetter <T1> getter, DOSetter <T1> setter, float elapsed, T2 startValue, T2 changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice);
public override void EvaluateAndApply(UintOptions options, Tween t, bool isRelative, DOGetter <uint> getter, DOSetter <uint> setter, float elapsed, uint startValue, uint changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { uint num; if (t.loopType == LoopType.Incremental) { num = (uint)(changeValue * (t.isComplete ? (t.completedLoops - 1) : t.completedLoops)); startValue = ((!options.isNegativeChangeValue) ? (startValue + num) : (startValue - num)); } if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) { num = (uint)(changeValue * ((t.loopType != LoopType.Incremental) ? 1 : t.loops) * (t.sequenceParent.isComplete ? (t.sequenceParent.completedLoops - 1) : t.sequenceParent.completedLoops)); startValue = ((!options.isNegativeChangeValue) ? (startValue + num) : (startValue - num)); } num = (uint)Math.Round((double)((float)(double)changeValue * EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod))); if (options.isNegativeChangeValue) { setter(startValue - num); } else { setter(startValue + num); } }
// Instead of advancing the tween from the previous position each time, // uses the given position to calculate running time since startup, and places the tween there like a Goto. // Executes regardless of whether the tween is playing. // Returns TRUE if the tween needs to be killed internal static bool DoGoto(Tween t, float toPosition, int toCompletedLoops, UpdateMode updateMode) { // Startup if (!t.startupDone) { if (!t.Startup()) { return(true); } } // OnStart and first OnPlay callbacks if (!t.playedOnce && updateMode == UpdateMode.Update) { t.playedOnce = true; if (t.onStart != null) { OnTweenCallback(t.onStart); if (!t.active) { return(true); // Tween might have been killed by onStart callback } } if (t.onPlay != null) { OnTweenCallback(t.onPlay); if (!t.active) { return(true); // Tween might have been killed by onPlay callback } } } float prevPosition = t.position; int prevCompletedLoops = t.completedLoops; t.completedLoops = toCompletedLoops; bool wasRewinded = t.position <= 0 && prevCompletedLoops <= 0; bool wasComplete = t.isComplete; // Determine if it will be complete after update if (t.loops != -1) { t.isComplete = t.completedLoops == t.loops; } // Calculate newCompletedSteps (always useful with Sequences) int newCompletedSteps = 0; if (updateMode == UpdateMode.Update) { if (t.isBackwards) { newCompletedSteps = t.completedLoops < prevCompletedLoops ? prevCompletedLoops - t.completedLoops : (toPosition <= 0 && !wasRewinded ? 1 : 0); if (wasComplete) { newCompletedSteps--; } } else { newCompletedSteps = t.completedLoops > prevCompletedLoops ? t.completedLoops - prevCompletedLoops : 0; } } else if (t.tweenType == TweenType.Sequence) { newCompletedSteps = prevCompletedLoops - toCompletedLoops; if (newCompletedSteps < 0) { newCompletedSteps = -newCompletedSteps; } } // Set position (makes position 0 equal to position "end" when looping) t.position = toPosition; if (t.position > t.duration) { t.position = t.duration; } else if (t.position <= 0) { if (t.completedLoops > 0 || t.isComplete) { t.position = t.duration; } else { t.position = 0; } } // Set playing state after update bool wasPlaying = t.isPlaying; if (t.isPlaying) { if (!t.isBackwards) { t.isPlaying = !t.isComplete; // Reached the end } else { t.isPlaying = !(t.completedLoops == 0 && t.position <= 0); // Rewinded } } // updatePosition is different in case of Yoyo loop under certain circumstances bool useInversePosition = t.loopType == LoopType.Yoyo && (t.position < t.duration ? t.completedLoops % 2 != 0 : t.completedLoops % 2 == 0); // Get values from plugin and set them bool isRewindStep = !wasRewinded && ( t.loopType == LoopType.Restart && t.completedLoops != prevCompletedLoops && (t.loops == -1 || t.completedLoops < t.loops) || t.position <= 0 && t.completedLoops <= 0 ); UpdateNotice updateNotice = isRewindStep ? UpdateNotice.RewindStep : UpdateNotice.None; if (t.ApplyTween(prevPosition, prevCompletedLoops, newCompletedSteps, useInversePosition, updateMode, updateNotice)) { return(true); } // Additional callbacks if (t.onUpdate != null && updateMode != UpdateMode.IgnoreOnUpdate) { OnTweenCallback(t.onUpdate); } if (t.position <= 0 && t.completedLoops <= 0 && !wasRewinded && t.onRewind != null) { OnTweenCallback(t.onRewind); } if (newCompletedSteps > 0 && updateMode == UpdateMode.Update && t.onStepComplete != null) { for (int i = 0; i < newCompletedSteps; ++i) { OnTweenCallback(t.onStepComplete); } } if (t.isComplete && !wasComplete && updateMode != UpdateMode.IgnoreOnComplete && t.onComplete != null) { OnTweenCallback(t.onComplete); } if (!t.isPlaying && wasPlaying && (!t.isComplete || !t.autoKill) && t.onPause != null) { OnTweenCallback(t.onPause); } // Return return(t.autoKill && t.isComplete); }
public override void EvaluateAndApply(RectOptions options, Tween t, bool isRelative, DOGetter <Rect> getter, DOSetter <Rect> setter, float elapsed, Rect startValue, Rect changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { if (t.loopType == LoopType.Incremental) { int num = t.isComplete ? (t.completedLoops - 1) : t.completedLoops; startValue.x += changeValue.x * (float)num; startValue.y += changeValue.y * (float)num; startValue.width += changeValue.width * (float)num; startValue.height += changeValue.height * (float)num; } if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) { int num2 = ((t.loopType != LoopType.Incremental) ? 1 : t.loops) * (t.sequenceParent.isComplete ? (t.sequenceParent.completedLoops - 1) : t.sequenceParent.completedLoops); startValue.x += changeValue.x * (float)num2; startValue.y += changeValue.y * (float)num2; startValue.width += changeValue.width * (float)num2; startValue.height += changeValue.height * (float)num2; } float num3 = EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod); startValue.x += changeValue.x * num3; startValue.y += changeValue.y * num3; startValue.width += changeValue.width * num3; startValue.height += changeValue.height * num3; if (options.snapping) { startValue.x = (float)Math.Round((double)startValue.x); startValue.y = (float)Math.Round((double)startValue.y); startValue.width = (float)Math.Round((double)startValue.width); startValue.height = (float)Math.Round((double)startValue.height); } setter(startValue); }
internal override bool ApplyTween(float prevPosition, int prevCompletedLoops, int newCompletedSteps, bool useInversePosition, UpdateMode updateMode, UpdateNotice updateNotice) { float elapsed = useInversePosition ? (base.duration - base.position) : base.position; if (DOTween.useSafeMode) { try { this.tweenPlugin.EvaluateAndApply(this.plugOptions, this, base.isRelative, this.getter, this.setter, elapsed, this.startValue, this.changeValue, base.duration, useInversePosition, updateNotice); } catch { return(true); } } else { this.tweenPlugin.EvaluateAndApply(this.plugOptions, this, base.isRelative, this.getter, this.setter, elapsed, this.startValue, this.changeValue, base.duration, useInversePosition, updateNotice); } return(false); }
public override void EvaluateAndApply(NoOptions options, Tween t, bool isRelative, DOGetter <Quaternion> getter, DOSetter <Quaternion> setter, float elapsed, Quaternion startValue, Quaternion changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { float num = EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod); startValue.x += changeValue.x * num; startValue.y += changeValue.y * num; startValue.z += changeValue.z * num; startValue.w += changeValue.w * num; setter(startValue); }
public override void EvaluateAndApply(UintOptions options, Tween t, bool isRelative, DOGetter <uint> getter, DOSetter <uint> setter, float elapsed, uint startValue, uint changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { uint v; if (t.loopType == LoopType.Incremental) { v = (uint)(changeValue * (t.isComplete ? t.completedLoops - 1 : t.completedLoops)); if (options.isNegativeChangeValue) { startValue -= v; } else { startValue += v; } } if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) { v = (uint)(changeValue * (t.loopType == LoopType.Incremental ? t.loops : 1) * (t.sequenceParent.isComplete ? t.sequenceParent.completedLoops - 1 : t.sequenceParent.completedLoops)); if (options.isNegativeChangeValue) { startValue -= v; } else { startValue += v; } } v = (uint)Math.Round(changeValue * EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod)); if (options.isNegativeChangeValue) { setter(startValue - v); } else { setter(startValue + v); } }
internal static bool DoGoto(Tween t, float toPosition, int toCompletedLoops, UpdateMode updateMode) { if (!t.startupDone && !t.Startup()) { return(true); } if (!t.playedOnce && (updateMode == UpdateMode.Update)) { t.playedOnce = true; if (t.onStart != null) { OnTweenCallback(t.onStart); if (!t.active) { return(true); } } if (t.onPlay != null) { OnTweenCallback(t.onPlay); if (!t.active) { return(true); } } } float position = t.position; int completedLoops = t.completedLoops; t.completedLoops = toCompletedLoops; bool flag = (t.position <= 0f) && (completedLoops <= 0); bool isComplete = t.isComplete; if (t.loops != -1) { t.isComplete = t.completedLoops == t.loops; } int newCompletedSteps = 0; if (updateMode == UpdateMode.Update) { if (t.isBackwards) { newCompletedSteps = (t.completedLoops < completedLoops) ? (completedLoops - t.completedLoops) : (((toPosition <= 0f) && !flag) ? 1 : 0); if (isComplete) { newCompletedSteps--; } } else { newCompletedSteps = (t.completedLoops > completedLoops) ? (t.completedLoops - completedLoops) : 0; } } else if (t.tweenType == TweenType.Sequence) { newCompletedSteps = completedLoops - toCompletedLoops; if (newCompletedSteps < 0) { newCompletedSteps = -newCompletedSteps; } } t.position = toPosition; if (t.position > t.duration) { t.position = t.duration; } else if (t.position <= 0f) { if ((t.completedLoops > 0) || t.isComplete) { t.position = t.duration; } else { t.position = 0f; } } bool isPlaying = t.isPlaying; if (t.isPlaying) { if (!t.isBackwards) { t.isPlaying = !t.isComplete; } else { t.isPlaying = (t.completedLoops != 0) || (t.position > 0f); } } bool useInversePosition = (t.loopType == LoopType.Yoyo) && ((t.position < t.duration) ? ((t.completedLoops % 2) > 0) : ((t.completedLoops % 2) == 0)); UpdateNotice updateNotice = (!flag && (((t.loopType == LoopType.Restart) && (t.completedLoops != completedLoops)) || ((t.position <= 0f) && (t.completedLoops <= 0)))) ? UpdateNotice.RewindStep : UpdateNotice.None; if (t.ApplyTween(position, completedLoops, newCompletedSteps, useInversePosition, updateMode, updateNotice)) { return(true); } if ((t.onUpdate != null) && (updateMode != UpdateMode.IgnoreOnUpdate)) { OnTweenCallback(t.onUpdate); } if (((t.position <= 0f) && (t.completedLoops <= 0)) && (!flag && (t.onRewind != null))) { OnTweenCallback(t.onRewind); } if (((newCompletedSteps > 0) && (updateMode == UpdateMode.Update)) && (t.onStepComplete != null)) { for (int i = 0; i < newCompletedSteps; i++) { OnTweenCallback(t.onStepComplete); } } if ((t.isComplete && !isComplete) && (t.onComplete != null)) { OnTweenCallback(t.onComplete); } if (((!t.isPlaying & isPlaying) && (!t.isComplete || !t.autoKill)) && (t.onPause != null)) { OnTweenCallback(t.onPause); } return(t.autoKill && t.isComplete); }
public override void EvaluateAndApply(VectorOptions options, Tween t, bool isRelative, DOGetter <Vector4Wrapper> getter, DOSetter <Vector4Wrapper> setter, float elapsed, Vector4Wrapper startValue, Vector4Wrapper changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { if (t.loopType == LoopType.Incremental) { startValue.value += changeValue.value * (t.isComplete ? t.completedLoops - 1 : t.completedLoops); } if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) { startValue.value += changeValue.value * (t.loopType == LoopType.Incremental ? t.loops : 1) * (t.sequenceParent.isComplete ? t.sequenceParent.completedLoops - 1 : t.sequenceParent.completedLoops); } float easeVal = EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod); switch (options.axisConstraint) { case AxisConstraint.X: Vector4 resX = getter().value; resX.x = startValue.value.x + changeValue.value.x * easeVal; if (options.snapping) { resX.x = (float)Math.Round(resX.x); } setter(resX); break; case AxisConstraint.Y: Vector4 resY = getter().value; resY.y = startValue.value.y + changeValue.value.y * easeVal; if (options.snapping) { resY.y = (float)Math.Round(resY.y); } setter(resY); break; case AxisConstraint.Z: Vector4 resZ = getter().value; resZ.z = startValue.value.z + changeValue.value.z * easeVal; if (options.snapping) { resZ.z = (float)Math.Round(resZ.z); } setter(resZ); break; case AxisConstraint.W: Vector4 resW = getter().value; resW.w = startValue.value.w + changeValue.value.w * easeVal; if (options.snapping) { resW.w = (float)Math.Round(resW.w); } setter(resW); break; default: startValue.value.x += changeValue.value.x * easeVal; startValue.value.y += changeValue.value.y * easeVal; startValue.value.z += changeValue.value.z * easeVal; startValue.value.w += changeValue.value.w * easeVal; if (options.snapping) { startValue.value.x = (float)Math.Round(startValue.value.x); startValue.value.y = (float)Math.Round(startValue.value.y); startValue.value.z = (float)Math.Round(startValue.value.z); startValue.value.w = (float)Math.Round(startValue.value.w); } setter(startValue.value); break; } }
public override void EvaluateAndApply(VectorOptions options, Tween t, bool isRelative, DOGetter <Vector3> getter, DOSetter <Vector3> setter, float elapsed, Vector3 startValue, Vector3 changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { if (t.loopType == LoopType.Incremental) { startValue += changeValue * (float)(t.isComplete ? (t.completedLoops - 1) : t.completedLoops); } if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) { startValue += changeValue * (float)((t.loopType != LoopType.Incremental) ? 1 : t.loops) * (float)(t.sequenceParent.isComplete ? (t.sequenceParent.completedLoops - 1) : t.sequenceParent.completedLoops); } float num = EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod); switch (options.axisConstraint) { case AxisConstraint.X: { Vector3 vector2 = getter(); vector2.x = startValue.x + changeValue.x * num; if (options.snapping) { vector2.x = (float)Math.Round((double)vector2.x); } setter(vector2); break; } case AxisConstraint.Y: { Vector3 vector = getter(); vector.y = startValue.y + changeValue.y * num; if (options.snapping) { vector.y = (float)Math.Round((double)vector.y); } setter(vector); break; } case AxisConstraint.Z: { Vector3 vector3 = getter(); vector3.z = startValue.z + changeValue.z * num; if (options.snapping) { vector3.z = (float)Math.Round((double)vector3.z); } setter(vector3); break; } default: startValue.x += changeValue.x * num; startValue.y += changeValue.y * num; startValue.z += changeValue.z * num; if (options.snapping) { startValue.x = (float)Math.Round((double)startValue.x); startValue.y = (float)Math.Round((double)startValue.y); startValue.z = (float)Math.Round((double)startValue.z); } setter(startValue); break; } }
public override void EvaluateAndApply(NoOptions options, Tween t, bool isRelative, DOGetter <LineComponent> getter, DOSetter <LineComponent> setter, float elapsed, LineComponent startValue, LineComponent changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { float easeVal = EaseManager.Evaluate(t, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod); LineComponent com = getter(); if (com.Line_Render.positionCount <= com.m_ls_v3.Count) { int nowvalue = (int)(com.m_ls_v3.Count * easeVal); if (nowvalue != com.Line_Render.positionCount) { com.SetV3ToLine(nowvalue); } } //throw new NotImplementedException(); }
public override void EvaluateAndApply(QuaternionOptions options, Tween t, bool isRelative, DOGetter <Quaternion> getter, DOSetter <Quaternion> setter, float elapsed, Vector3 startValue, Vector3 changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { Vector3 vector = startValue; if (t.loopType == LoopType.Incremental) { vector += changeValue * (float)(t.isComplete ? (t.completedLoops - 1) : t.completedLoops); } if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) { vector += changeValue * (float)((t.loopType == LoopType.Incremental) ? t.loops : 1) * (float)(t.sequenceParent.isComplete ? (t.sequenceParent.completedLoops - 1) : t.sequenceParent.completedLoops); } float num = EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod); switch (options.rotateMode) { case RotateMode.WorldAxisAdd: case RotateMode.LocalAxisAdd: { Quaternion quaternion = Quaternion.Euler(startValue); vector.x = changeValue.x * num; vector.y = changeValue.y * num; vector.z = changeValue.z * num; if (options.rotateMode == RotateMode.WorldAxisAdd) { setter(quaternion * Quaternion.Inverse(quaternion) * Quaternion.Euler(vector) * quaternion); return; } setter(quaternion * Quaternion.Euler(vector)); return; } default: vector.x += changeValue.x * num; vector.y += changeValue.y * num; vector.z += changeValue.z * num; setter(Quaternion.Euler(vector)); return; } }
public override float GetSpeedBasedDuration(NoOptions options, float unitsXSecond, ulong changeValue) => default; // 0x004D3BE0-0x004D3C00 public override void EvaluateAndApply(NoOptions options, Tween t, bool isRelative, DOGetter <ulong> getter, DOSetter <ulong> setter, float elapsed, ulong startValue, ulong changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { } // 0x004D3C00-0x004D3DA0
// Token: 0x06000174 RID: 372 RVA: 0x00008114 File Offset: 0x00006314 public override void EvaluateAndApply(ColorOptions options, Tween t, bool isRelative, DOGetter <Color2> getter, DOSetter <Color2> setter, float elapsed, Color2 startValue, Color2 changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { if (t.loopType == LoopType.Incremental) { startValue += changeValue * (float)(t.isComplete ? (t.completedLoops - 1) : t.completedLoops); } if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) { startValue += changeValue * (float)((t.loopType == LoopType.Incremental) ? t.loops : 1) * (float)(t.sequenceParent.isComplete ? (t.sequenceParent.completedLoops - 1) : t.sequenceParent.completedLoops); } float num = EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod); if (!options.alphaOnly) { startValue.ca.r = startValue.ca.r + changeValue.ca.r * num; startValue.ca.g = startValue.ca.g + changeValue.ca.g * num; startValue.ca.b = startValue.ca.b + changeValue.ca.b * num; startValue.ca.a = startValue.ca.a + changeValue.ca.a * num; startValue.cb.r = startValue.cb.r + changeValue.cb.r * num; startValue.cb.g = startValue.cb.g + changeValue.cb.g * num; startValue.cb.b = startValue.cb.b + changeValue.cb.b * num; startValue.cb.a = startValue.cb.a + changeValue.cb.a * num; setter(startValue); return; } Color2 pNewValue = getter(); pNewValue.ca.a = startValue.ca.a + changeValue.ca.a * num; pNewValue.cb.a = startValue.cb.a + changeValue.cb.a * num; setter(pNewValue); }
// Token: 0x060001D7 RID: 471 RVA: 0x0000A764 File Offset: 0x00008964 public override void EvaluateAndApply(VectorOptions options, Tween t, bool isRelative, DOGetter <Vector2> getter, DOSetter <Vector2> setter, float elapsed, Vector2 startValue, Vector2 changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { if (t.loopType == LoopType.Incremental) { startValue += changeValue * (float)(t.isComplete ? (t.completedLoops - 1) : t.completedLoops); } if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) { startValue += changeValue * (float)((t.loopType == LoopType.Incremental) ? t.loops : 1) * (float)(t.sequenceParent.isComplete ? (t.sequenceParent.completedLoops - 1) : t.sequenceParent.completedLoops); } float num = EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod); AxisConstraint axisConstraint = options.axisConstraint; if (axisConstraint == AxisConstraint.X) { Vector2 vector = getter(); vector.x = startValue.x + changeValue.x * num; if (options.snapping) { vector.x = (float)Math.Round((double)vector.x); } setter(vector); return; } if (axisConstraint != AxisConstraint.Y) { startValue.x += changeValue.x * num; startValue.y += changeValue.y * num; if (options.snapping) { startValue.x = (float)Math.Round((double)startValue.x); startValue.y = (float)Math.Round((double)startValue.y); } setter(startValue); return; } Vector2 vector2 = getter(); vector2.y = startValue.y + changeValue.y * num; if (options.snapping) { vector2.y = (float)Math.Round((double)vector2.y); } setter(vector2); }
public override void EvaluateAndApply(PathOptions options, Tween t, bool isRelative, DOGetter <Vector3> getter, DOSetter <Vector3> setter, float elapsed, Path startValue, Path changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { base.EvaluateAndApply(options, t, isRelative, () => getter(), (x) => setter(new Vector3(Mathf.Round(x.x * unitConv) / unitConv, Mathf.Round(x.y * unitConv) / unitConv, Mathf.Round(x.z * unitConv) / unitConv)), elapsed, startValue, changeValue, duration, usingInversePosition, updateNotice); }
public override void EvaluateAndApply(AMPlugValueSetOptions options, Tween t, bool isRelative, DOGetter <T> getter, DOSetter <T> setter, float elapsed, T startValue, T changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { if (updateNotice == UpdateNotice.RewindStep) { mCounter = -1; } else if (options.Refresh(ref mCounter)) { setter(getter()); } }
public override void EvaluateAndApply(ColorOptions options, Tween t, bool isRelative, DOGetter <Color> getter, DOSetter <Color> setter, float elapsed, Color startValue, Color changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { if (t.loopType == LoopType.Incremental) { startValue += changeValue * (t.isComplete ? t.completedLoops - 1 : t.completedLoops); } if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) { startValue += changeValue * (t.loopType == LoopType.Incremental ? t.loops : 1) * (t.sequenceParent.isComplete ? t.sequenceParent.completedLoops - 1 : t.sequenceParent.completedLoops); } float easeVal = EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod); if (!options.alphaOnly) { startValue.r += changeValue.r * easeVal; startValue.g += changeValue.g * easeVal; startValue.b += changeValue.b * easeVal; startValue.a += changeValue.a * easeVal; setter(startValue); return; } // Alpha only Color res = getter(); res.a = startValue.a + changeValue.a * easeVal; setter(res); }
public override void EvaluateAndApply(TweenPlugElapsedOptions options, Tween t, bool isRelative, DOGetter <float> getter, DOSetter <float> setter, float elapsed, float startValue, float changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { if (updateNotice == UpdateNotice.RewindStep) { options.Reset(); } else if (options.Refresh()) { setter(elapsed); } }
// ChangeValue is the same as endValue in this plugin public override void EvaluateAndApply(StringOptions options, Tween t, bool isRelative, DOGetter <string> getter, DOSetter <string> setter, float elapsed, string startValue, string changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { _Buffer.Remove(0, _Buffer.Length); // Incremental works only with relative tweens (otherwise the tween makes no sense) // Sequence with Incremental loops have no effect here (why should they?) if (isRelative && t.loopType == LoopType.Incremental) { int iterations = t.isComplete ? t.completedLoops - 1 : t.completedLoops; if (iterations > 0) { _Buffer.Append(startValue); for (int i = 0; i < iterations; ++i) { _Buffer.Append(changeValue); } startValue = _Buffer.ToString(); _Buffer.Remove(0, _Buffer.Length); } } int startValueLen = options.richTextEnabled ? options.startValueStrippedLength : startValue.Length; int changeValueLen = options.richTextEnabled ? options.changeValueStrippedLength : changeValue.Length; int len = (int)Math.Round(changeValueLen * EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod)); if (len > changeValueLen) { len = changeValueLen; } else if (len < 0) { len = 0; } if (isRelative) { _Buffer.Append(startValue); if (options.scrambleMode != ScrambleMode.None) { setter(Append(changeValue, 0, len, options.richTextEnabled).AppendScrambledChars(changeValueLen - len, ScrambledCharsToUse(options)).ToString()); return; } setter(Append(changeValue, 0, len, options.richTextEnabled).ToString()); return; } if (options.scrambleMode != ScrambleMode.None) { setter(Append(changeValue, 0, len, options.richTextEnabled).AppendScrambledChars(changeValueLen - len, ScrambledCharsToUse(options)).ToString()); return; } int diff = startValueLen - changeValueLen; int startValueMaxLen = startValueLen; if (diff > 0) { // String to be replaced is longer than endValue: remove parts of it while tweening float perc = (float)len / changeValueLen; startValueMaxLen -= (int)(startValueMaxLen * perc); } else { startValueMaxLen -= len; } Append(changeValue, 0, len, options.richTextEnabled); if (len < changeValueLen && len < startValueLen) { Append(startValue, len, options.richTextEnabled ? len + startValueMaxLen : startValueMaxLen, options.richTextEnabled); } setter(_Buffer.ToString()); }
// Token: 0x0600018C RID: 396 RVA: 0x0000869C File Offset: 0x0000689C public override void EvaluateAndApply(NoOptions options, Tween t, bool isRelative, DOGetter <ulong> getter, DOSetter <ulong> setter, float elapsed, ulong startValue, ulong changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { if (t.loopType == LoopType.Incremental) { startValue += changeValue * (ulong)(t.isComplete ? (t.completedLoops - 1) : t.completedLoops); } if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) { startValue += changeValue * (ulong)((t.loopType == LoopType.Incremental) ? t.loops : 1) * (ulong)(t.sequenceParent.isComplete ? (t.sequenceParent.completedLoops - 1) : t.sequenceParent.completedLoops); } setter((ulong)(startValue + changeValue * (decimal)EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod))); }
public override void EvaluateAndApply(FloatOptions options, Tween t, bool isRelative, DOGetter <float> getter, DOSetter <float> setter, float elapsed, float startValue, float changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { if (t.loopType == LoopType.Incremental) { startValue += changeValue * (float)(t.isComplete ? (t.completedLoops - 1) : t.completedLoops); } if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) { startValue += changeValue * (float)((t.loopType != LoopType.Incremental) ? 1 : t.loops) * (float)(t.sequenceParent.isComplete ? (t.sequenceParent.completedLoops - 1) : t.sequenceParent.completedLoops); } setter((!options.snapping) ? (startValue + changeValue * EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod)) : ((float)Math.Round((double)(startValue + changeValue * EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod))))); }
// Calculates the value based on the given time and ease public override void EvaluateAndApply(NoOptions options, Tween t, bool isRelative, DOGetter <CustomRange> getter, DOSetter <CustomRange> setter, float elapsed, CustomRange startValue, CustomRange changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { float easeVal = EaseManager.Evaluate(t, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod); // Here I use startValue directly because CustomRange a struct, so it won't reference the original. // If CustomRange was a class, I should create a new one to pass to the setter startValue.min += changeValue.min * easeVal; startValue.max += changeValue.max * easeVal; setter(startValue); }
/// <summary>INTERNAL: do not use</summary> public override void EvaluateAndApply(NoOptions options, Tween t, bool isRelative, DOGetter <Quaternion> getter, DOSetter <Quaternion> setter, float elapsed, Quaternion startValue, Quaternion changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { // if (t.loopType == LoopType.Incremental) startValue *= changeValue * (t.isComplete ? t.completedLoops - 1 : t.completedLoops); // if (t.isSequenced && t.sequenceParent.loopType == LoopType.Incremental) { // startValue += changeValue * (t.loopType == LoopType.Incremental ? t.loops : 1) // * (t.sequenceParent.isComplete ? t.sequenceParent.completedLoops - 1 : t.sequenceParent.completedLoops); // } float easeVal = EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod); startValue.x += changeValue.x * easeVal; startValue.y += changeValue.y * easeVal; startValue.z += changeValue.z * easeVal; startValue.w += changeValue.w * easeVal; setter(startValue); }
public override void EvaluateAndApply(PathOptions options, Tween t, bool isRelative, DOGetter <Vector3> getter, DOSetter <Vector3> setter, float elapsed, Path startValue, Path changeValue, float duration, bool usingInversePosition, UpdateNotice updateNotice) { if (t.loopType == LoopType.Incremental && !options.isClosedPath) { int increment = (t.isComplete ? t.completedLoops - 1 : t.completedLoops); if (increment > 0) { changeValue = changeValue.CloneIncremental(increment); } } float pathPerc = EaseManager.Evaluate(t.easeType, t.customEase, elapsed, duration, t.easeOvershootOrAmplitude, t.easePeriod); float constantPathPerc = changeValue.ConvertToConstantPathPerc(pathPerc); Vector3 newPos = changeValue.GetPoint(constantPathPerc); changeValue.targetPosition = newPos; // Used to draw editor gizmos setter(newPos); if (options.mode != PathMode.Ignore && options.orientType != OrientType.None) { SetOrientation(options, t, changeValue, constantPathPerc, newPos, updateNotice); } // Determine if current waypoint changed and eventually dispatch callback bool isForward = !usingInversePosition; if (t.isBackwards) { isForward = !isForward; } int newWaypointIndex = changeValue.GetWaypointIndexFromPerc(pathPerc, isForward); if (newWaypointIndex != t.miscInt) { int prevWPIndex = t.miscInt; t.miscInt = newWaypointIndex; if (t.onWaypointChange != null) { // If more than one waypoint changed, dispatch multiple callbacks bool isBackwards = newWaypointIndex < prevWPIndex; if (isBackwards) { for (int i = prevWPIndex - 1; i > newWaypointIndex - 1; --i) { Tween.OnTweenCallback(t.onWaypointChange, i); } } else { for (int i = prevWPIndex + 1; i < newWaypointIndex + 1; ++i) { Tween.OnTweenCallback(t.onWaypointChange, i); } } } } }
internal override bool ApplyTween(float prevPosition, int prevCompletedLoops, int newCompletedSteps, bool useInversePosition, UpdateMode updateMode, UpdateNotice updateNotice) { return(DoApplyTween(this, prevPosition, prevCompletedLoops, newCompletedSteps, useInversePosition, updateMode)); }
// Public so it can be called by GotoWaypoint public void SetOrientation(PathOptions options, Tween t, Path path, float pathPerc, Vector3 tPos, UpdateNotice updateNotice) { Transform trans = (Transform)t.target; Quaternion newRot = Quaternion.identity; if (updateNotice == UpdateNotice.RewindStep) { // Reset orientation before continuing trans.rotation = options.startupRot; } switch (options.orientType) { case OrientType.LookAtPosition: path.lookAtPosition = options.lookAtPosition; // Used to draw editor gizmos newRot = Quaternion.LookRotation(options.lookAtPosition - trans.position, trans.up); break; case OrientType.LookAtTransform: if (options.lookAtTransform != null) { path.lookAtPosition = options.lookAtTransform.position; // Used to draw editor gizmos newRot = Quaternion.LookRotation(options.lookAtTransform.position - trans.position, trans.up); } break; case OrientType.ToPath: Vector3 lookAtP; if (path.type == PathType.Linear && options.lookAhead <= MinLookAhead) { // Calculate lookAhead so that it doesn't turn until it starts moving on next waypoint lookAtP = tPos + path.wps[path.linearWPIndex] - path.wps[path.linearWPIndex - 1]; } else { float lookAheadPerc = pathPerc + options.lookAhead; if (lookAheadPerc > 1) { lookAheadPerc = (options.isClosedPath ? lookAheadPerc - 1 : path.type == PathType.Linear ? 1 : 1.00001f); } lookAtP = path.GetPoint(lookAheadPerc); } if (path.type == PathType.Linear) { // Check if it's the last waypoint, and keep correct direction Vector3 lastWp = path.wps[path.wps.Length - 1]; if (lookAtP == lastWp) { lookAtP = tPos == lastWp ? lastWp + (lastWp - path.wps[path.wps.Length - 2]) : lastWp; } } Vector3 transUp = trans.up; // Apply basic modification for local position movement if (options.useLocalPosition && options.parent != null) { lookAtP = options.parent.TransformPoint(lookAtP); } // LookAt axis constraint if (options.lockRotationAxis != AxisConstraint.None) { if ((options.lockRotationAxis & AxisConstraint.X) == AxisConstraint.X) { Vector3 v0 = trans.InverseTransformPoint(lookAtP); v0.y = 0; lookAtP = trans.TransformPoint(v0); transUp = options.useLocalPosition && options.parent != null ? options.parent.up : Vector3.up; } if ((options.lockRotationAxis & AxisConstraint.Y) == AxisConstraint.Y) { Vector3 v0 = trans.InverseTransformPoint(lookAtP); if (v0.z < 0) { v0.z = -v0.z; } v0.x = 0; lookAtP = trans.TransformPoint(v0); } if ((options.lockRotationAxis & AxisConstraint.Z) == AxisConstraint.Z) { // Fix to allow racing loops to keep cars straight and not flip it if (options.useLocalPosition && options.parent != null) { transUp = options.parent.TransformDirection(Vector3.up); } else { transUp = trans.TransformDirection(Vector3.up); } transUp.z = options.startupZRot; } } if (options.mode == PathMode.Full3D) { // 3D path Vector3 diff = lookAtP - trans.position; if (diff == Vector3.zero) { diff = trans.forward; } newRot = Quaternion.LookRotation(diff, transUp); } else { // 2D path float rotY = 0; float rotZ = Utils.Angle2D(trans.position, lookAtP); if (rotZ < 0) { rotZ = 360 + rotZ; } if (options.mode == PathMode.Sidescroller2D) { // Manage Y and modified Z rotation rotY = lookAtP.x < trans.position.x ? 180 : 0; if (rotZ > 90 && rotZ < 270) { rotZ = 180 - rotZ; } } newRot = Quaternion.Euler(0, rotY, rotZ); } break; } if (options.hasCustomForwardDirection) { newRot *= options.forward; } trans.rotation = newRot; }
// Token: 0x0600015C RID: 348 RVA: 0x00007778 File Offset: 0x00005978 internal static bool DoGoto(Tween t, float toPosition, int toCompletedLoops, UpdateMode updateMode) { if (!t.startupDone && !t.Startup()) { return(true); } if (!t.playedOnce && updateMode == UpdateMode.Update) { t.playedOnce = true; if (t.onStart != null) { Tween.OnTweenCallback(t.onStart); if (!t.active) { return(true); } } if (t.onPlay != null) { Tween.OnTweenCallback(t.onPlay); if (!t.active) { return(true); } } } float prevPosition = t.position; int num = t.completedLoops; t.completedLoops = toCompletedLoops; bool flag = t.position <= 0f && num <= 0; bool flag2 = t.isComplete; if (t.loops != -1) { t.isComplete = (t.completedLoops == t.loops); } int num2 = 0; if (updateMode == UpdateMode.Update) { if (t.isBackwards) { num2 = ((t.completedLoops < num) ? (num - t.completedLoops) : ((toPosition <= 0f && !flag) ? 1 : 0)); if (flag2) { num2--; } } else { num2 = ((t.completedLoops > num) ? (t.completedLoops - num) : 0); } } else if (t.tweenType == TweenType.Sequence) { num2 = num - toCompletedLoops; if (num2 < 0) { num2 = -num2; } } t.position = toPosition; if (t.position > t.duration) { t.position = t.duration; } else if (t.position <= 0f) { if (t.completedLoops > 0 || t.isComplete) { t.position = t.duration; } else { t.position = 0f; } } bool flag3 = t.isPlaying; if (t.isPlaying) { if (!t.isBackwards) { t.isPlaying = !t.isComplete; } else { t.isPlaying = (t.completedLoops != 0 || t.position > 0f); } } bool useInversePosition = t.loopType == LoopType.Yoyo && ((t.position < t.duration) ? (t.completedLoops % 2 != 0) : (t.completedLoops % 2 == 0)); UpdateNotice updateNotice = (!flag && ((t.loopType == LoopType.Restart && t.completedLoops != num) || (t.position <= 0f && t.completedLoops <= 0))) ? UpdateNotice.RewindStep : UpdateNotice.None; if (t.ApplyTween(prevPosition, num, num2, useInversePosition, updateMode, updateNotice)) { return(true); } if (t.onUpdate != null && updateMode != UpdateMode.IgnoreOnUpdate) { Tween.OnTweenCallback(t.onUpdate); } if (t.position <= 0f && t.completedLoops <= 0 && !flag && t.onRewind != null) { Tween.OnTweenCallback(t.onRewind); } if (num2 > 0 && updateMode == UpdateMode.Update && t.onStepComplete != null) { for (int i = 0; i < num2; i++) { Tween.OnTweenCallback(t.onStepComplete); } } if (t.isComplete && !flag2 && t.onComplete != null) { Tween.OnTweenCallback(t.onComplete); } if (!t.isPlaying && flag3 && (!t.isComplete || !t.autoKill) && t.onPause != null) { Tween.OnTweenCallback(t.onPause); } return(t.autoKill && t.isComplete); }
internal override bool ApplyTween(float prevPosition, int prevCompletedLoops, int newCompletedSteps, bool useInversePosition, UpdateMode updateMode, UpdateNotice updateNotice) { return DoApplyTween(this, prevPosition, prevCompletedLoops, newCompletedSteps, useInversePosition, updateMode); }