Skip to content

Commit

Permalink
Update Local Stopwatch.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
Xlinka committed Dec 13, 2024
1 parent a081a15 commit 01e160f
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions ProjectObsidian/ProtoFlux/Flow/Time/Local Stopwatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,11 @@ protected override void ComputeOutputs(FrooxEngineContext context)
// Update elapsed time if running
if (_isRunning)
{
if (_startTime > 0)
if (_startTime >= 0) // Only update if startTime is initialized
{
_elapsedTime += currentTime - _startTime;
}
_startTime = currentTime;
}
else
{
_startTime = -1.0;
_startTime = currentTime;
}

// Write outputs
Expand All @@ -66,7 +62,7 @@ protected override void ComputeOutputs(FrooxEngineContext context)
private IOperation DoStart(FrooxEngineContext context)
{
_isRunning = true;
if (_startTime < 0)
if (_startTime < 0)
{
_startTime = context.World.Time.WorldTime;
}
Expand All @@ -81,9 +77,8 @@ private IOperation DoStop(FrooxEngineContext context)

private IOperation DoReset(FrooxEngineContext context)
{
_isRunning = false;
_elapsedTime = 0.0;
_startTime = -1.0;
_startTime = -1.0;
return OnReset.Target;
}
}
Expand Down

0 comments on commit 01e160f

Please sign in to comment.