Skip to content

Commit

Permalink
Restore "legacy" time mode for older versions for backward compatibil…
Browse files Browse the repository at this point in the history
…ity (please update the time mode in early access 6.1 releases!)
  • Loading branch information
acidbubbles committed Nov 27, 2022
1 parent 91e4f1c commit cb1cfdc
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 23 deletions.
1 change: 0 additions & 1 deletion VamTimeline.AtomAnimation.cslist
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ src\AtomAnimations\Animations\AtomPose.cs
src\AtomAnimations\Animations\IAtomAnimationClip.cs
src\AtomAnimations\Animations\IAtomAnimationTargetsList.cs
src\AtomAnimations\Animations\TimeModes.cs
src\AtomAnimations\Animations\TimeTypeValues.cs
src\AtomAnimations\Animations\UnitySpecific.cs
src\AtomAnimations\Animations\VamOverlaysFadeManager.cs
src\AtomAnimations\BezierCurves\Smoothing\BezierAnimationCurveSmoothingBase.cs
Expand Down
1 change: 0 additions & 1 deletion VamTimeline.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@
<Compile Include="src\AtomAnimations\Animations\IAtomAnimationClip.cs" />
<Compile Include="src\AtomAnimations\Animations\IAtomAnimationTargetsList.cs" />
<Compile Include="src\AtomAnimations\Animations\TimeModes.cs" />
<Compile Include="src\AtomAnimations\Animations\TimeTypeValues.cs" />
<Compile Include="src\AtomAnimations\Animations\UnitySpecific.cs" />
<Compile Include="src\AtomAnimations\Animations\VamOverlaysFadeManager.cs" />
<Compile Include="src\AtomAnimations\BezierCurves\Smoothing\BezierAnimationCurveSmoothingBase.cs" />
Expand Down
1 change: 0 additions & 1 deletion meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
"Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\Animations\\IAtomAnimationClip.cs",
"Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\Animations\\IAtomAnimationTargetsList.cs",
"Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\Animations\\TimeModes.cs",
"Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\Animations\\TimeTypeValues.cs",
"Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\Animations\\UnitySpecific.cs",
"Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\Animations\\VamOverlaysFadeManager.cs",
"Custom\\Scripts\\AcidBubbles\\Timeline\\src\\AtomAnimations\\BezierCurves\\Smoothing\\BezierAnimationCurveSmoothingBase.cs",
Expand Down
28 changes: 26 additions & 2 deletions src/AtomAnimations/Animations/AtomAnimation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,19 @@ private void OnTargetsListChanged()

public void Update()
{
var deltaTime = timeMode == TimeModes.RealTime ? (Time.time - _lastUpdateTime) : Time.deltaTime;
float deltaTime;
switch (timeMode)
{
case TimeModes.RealTime:
deltaTime = Time.time - _lastUpdateTime;
break;
case TimeModes.RealTimeLegacy:
deltaTime = Time.unscaledDeltaTime * Time.timeScale;
break;
default:
deltaTime = Time.deltaTime;
break;
}
_lastUpdateTime = Time.time;

SyncTriggers(true);
Expand All @@ -60,7 +72,19 @@ public void Update()

public void FixedUpdate()
{
var deltaTime = timeMode == TimeModes.RealTime ? (Time.time - _lastFixedUpdateTime) : Time.deltaTime;
float deltaTime;
switch (timeMode)
{
case TimeModes.RealTime:
deltaTime = Time.time - _lastFixedUpdateTime;
break;
case TimeModes.RealTimeLegacy:
deltaTime = Time.unscaledDeltaTime * Time.timeScale;
break;
default:
deltaTime = Time.deltaTime;
break;
}
_lastFixedUpdateTime = Time.time;


Expand Down
3 changes: 2 additions & 1 deletion src/AtomAnimations/Animations/TimeModes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
public static class TimeModes
{
public const int UnityTime = 0;
public const int RealTime = 1;
public const int RealTimeLegacy = 1;
public const int RealTime = 2;
}
}
12 changes: 0 additions & 12 deletions src/AtomAnimations/Animations/TimeTypeValues.cs

This file was deleted.

17 changes: 13 additions & 4 deletions src/UI/Screens/OptionsScreen.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,23 @@ private void InitLockedUI()

private void InitUseRealTimeUI()
{
var timeTypeJSON = new JSONStorableStringChooser("Time mode", new List<string> {TimeTypeValues.GameTime.ToString(), TimeTypeValues.RealTime.ToString()}, TimeTypeValues.GameTime.ToString(), "Time mode");
timeTypeJSON.displayChoices = new List<string>
var timeModes = new List<string> {TimeModes.UnityTime.ToString(), TimeModes.RealTime.ToString()};
var timeModeDisplay = new List<string>
{
"Game time (slows with low fps)",
"Real time (better for audio sync)"
};
timeTypeJSON.valNoCallback = animation.timeMode.ToString();
timeTypeJSON.setCallbackFunction = val => animation.timeMode = int.Parse(val);
if (animation.timeMode == TimeModes.RealTimeLegacy)
{
timeModes.Add(TimeModes.RealTimeLegacy.ToString());
timeModeDisplay.Add("Real time (legacy, only use for old scenes)");
}
var timeTypeJSON = new JSONStorableStringChooser("Time mode", timeModes, TimeModes.UnityTime.ToString(), "Time mode")
{
displayChoices = timeModeDisplay,
valNoCallback = animation.timeMode.ToString(),
setCallbackFunction = val => animation.timeMode = int.Parse(val)
};
prefabFactory.CreatePopup(timeTypeJSON, true, true);
}

Expand Down
1 change: 0 additions & 1 deletion tests/VamTimeline.Tests.cslist
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
..\src\AtomAnimations\Animations\IAtomAnimationClip.cs
..\src\AtomAnimations\Animations\IAtomAnimationTargetsList.cs
..\src\AtomAnimations\Animations\TimeModes.cs
..\src\AtomAnimations\Animations\TimeTypeValues.cs
..\src\AtomAnimations\Animations\UnitySpecific.cs
..\src\AtomAnimations\Animations\VamOverlaysFadeManager.cs
..\src\AtomAnimations\BezierCurves\Smoothing\BezierAnimationCurveSmoothingBase.cs
Expand Down

0 comments on commit cb1cfdc

Please sign in to comment.