diff --git a/samples/Games/JumpyJet/JumpyJet.Game/CharacterScript.cs b/samples/Games/JumpyJet/JumpyJet.Game/CharacterScript.cs index 9a93043225..b34951135e 100644 --- a/samples/Games/JumpyJet/JumpyJet.Game/CharacterScript.cs +++ b/samples/Games/JumpyJet/JumpyJet.Game/CharacterScript.cs @@ -124,7 +124,7 @@ public override async Task Execute() if (!isRunning) continue; - var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; // apply impulse on the touch/space if (Input.IsKeyPressed(Keys.Space) || UserTappedScreen()) diff --git a/samples/Games/JumpyJet/JumpyJet.Game/PipesScript.cs b/samples/Games/JumpyJet/JumpyJet.Game/PipesScript.cs index 2371ba1734..22467489a5 100644 --- a/samples/Games/JumpyJet/JumpyJet.Game/PipesScript.cs +++ b/samples/Games/JumpyJet/JumpyJet.Game/PipesScript.cs @@ -66,7 +66,7 @@ public override void Update() if (!isScrolling) return; - var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; for (int i = 0; i < pipeSets.Count; i++) { diff --git a/samples/Games/SpaceEscape/SpaceEscape.Game/Background/BackgroundScript.cs b/samples/Games/SpaceEscape/SpaceEscape.Game/Background/BackgroundScript.cs index 9f1c6e9b60..96842d8043 100644 --- a/samples/Games/SpaceEscape/SpaceEscape.Game/Background/BackgroundScript.cs +++ b/samples/Games/SpaceEscape/SpaceEscape.Game/Background/BackgroundScript.cs @@ -78,7 +78,7 @@ public override void Update() if (!isScrolling) return; - var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; // Check if needed to remove the first block var firstBlock = levelBlocks[0]; diff --git a/samples/Graphics/AnimatedModel/AnimatedModel.Game/RotateEntity.cs b/samples/Graphics/AnimatedModel/AnimatedModel.Game/RotateEntity.cs index 58f5143a5d..2562d1ebec 100644 --- a/samples/Graphics/AnimatedModel/AnimatedModel.Game/RotateEntity.cs +++ b/samples/Graphics/AnimatedModel/AnimatedModel.Game/RotateEntity.cs @@ -24,7 +24,7 @@ public override async Task Execute() rotationSpeed = 200f * Input.PointerEvents.Sum(x => x.DeltaPosition.X); rotationSpeed *= 0.93f; - var elapsedTime = (float) Game.UpdateTime.Elapsed.TotalSeconds; + var elapsedTime = (float) Game.UpdateTime.WarpElapsed.TotalSeconds; Entity.Transform.Rotation *= Quaternion.RotationY(rotationSpeed * elapsedTime); } } diff --git a/samples/Graphics/SpriteStudioDemo/SpriteStudioDemo.Game/PlayerScript.cs b/samples/Graphics/SpriteStudioDemo/SpriteStudioDemo.Game/PlayerScript.cs index 0322c1b091..792ba69a92 100644 --- a/samples/Graphics/SpriteStudioDemo/SpriteStudioDemo.Game/PlayerScript.cs +++ b/samples/Graphics/SpriteStudioDemo/SpriteStudioDemo.Game/PlayerScript.cs @@ -103,7 +103,7 @@ public override async Task Execute() if (inputState == InputState.RunLeft || inputState == InputState.RunRight) { // Update Agent's position - var dt = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var dt = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; Entity.Transform.Position.X += ((inputState == InputState.RunRight) ? AgentMoveDistance : -AgentMoveDistance) * dt; diff --git a/samples/Input/TouchInputs/TouchInputs.Game/TouchInputsScript.cs b/samples/Input/TouchInputs/TouchInputs.Game/TouchInputsScript.cs index 318aa1ead9..54e4379bf4 100644 --- a/samples/Input/TouchInputs/TouchInputs.Game/TouchInputsScript.cs +++ b/samples/Input/TouchInputs/TouchInputs.Game/TouchInputsScript.cs @@ -81,7 +81,7 @@ public override void Start() public override void Update() { - var currentTime = Game.DrawTime.Total; + var currentTime = Game.UpdateTime.Total; keyDown = ""; keyEvents = ""; diff --git a/samples/Particles/ParticlesSample/ParticlesSample.Game/CameraOrbitScript.cs b/samples/Particles/ParticlesSample/ParticlesSample.Game/CameraOrbitScript.cs index 8bec53afe8..9dce4e4530 100644 --- a/samples/Particles/ParticlesSample/ParticlesSample.Game/CameraOrbitScript.cs +++ b/samples/Particles/ParticlesSample/ParticlesSample.Game/CameraOrbitScript.cs @@ -33,7 +33,7 @@ public override async Task Execute() { while (Game.IsRunning) { - var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; timeToProcess = Math.Max(timeToProcess + elapsedTime, 1.0f); // determine if the user is currently touching the screen. diff --git a/samples/Particles/ParticlesSample/ParticlesSample.Game/PrefabInstance.cs b/samples/Particles/ParticlesSample/ParticlesSample.Game/PrefabInstance.cs index fae389fbae..8737391a1a 100644 --- a/samples/Particles/ParticlesSample/ParticlesSample.Game/PrefabInstance.cs +++ b/samples/Particles/ParticlesSample/ParticlesSample.Game/PrefabInstance.cs @@ -115,7 +115,7 @@ protected void SpawnInstance() while (secondsCountdown > 0f) { await Script.NextFrame(); - secondsCountdown -= (float)Game.UpdateTime.Elapsed.TotalSeconds; + secondsCountdown -= (float)Game.UpdateTime.WarpElapsed.TotalSeconds; } // Remove diff --git a/samples/Particles/ParticlesSample/ParticlesSample.Game/RotateEntity.cs b/samples/Particles/ParticlesSample/ParticlesSample.Game/RotateEntity.cs index fe460ef026..39d875b8f3 100644 --- a/samples/Particles/ParticlesSample/ParticlesSample.Game/RotateEntity.cs +++ b/samples/Particles/ParticlesSample/ParticlesSample.Game/RotateEntity.cs @@ -24,7 +24,7 @@ public override async Task Execute() rotationSpeed = 200f * Input.PointerEvents.Sum(x => x.DeltaPosition.X); rotationSpeed *= 0.93f; - var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; Entity.Transform.Rotation *= Quaternion.RotationY(rotationSpeed * elapsedTime); } } diff --git a/samples/Physics/BepuSample/BepuSample.Game/Components/Camera/BasicCameraControllerComponent.cs b/samples/Physics/BepuSample/BepuSample.Game/Components/Camera/BasicCameraControllerComponent.cs index b5e3c06eca..e184508d88 100644 --- a/samples/Physics/BepuSample/BepuSample.Game/Components/Camera/BasicCameraControllerComponent.cs +++ b/samples/Physics/BepuSample/BepuSample.Game/Components/Camera/BasicCameraControllerComponent.cs @@ -72,7 +72,7 @@ private void UpdateDebugShapes() private void ProcessInput() { - float deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + float deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; translation = Vector3.Zero; yaw = 0f; pitch = 0f; diff --git a/samples/Physics/BepuSample/BepuSample.Game/Components/Camera/FindAndAttachCameraComponent.cs b/samples/Physics/BepuSample/BepuSample.Game/Components/Camera/FindAndAttachCameraComponent.cs index a4a09d75ef..ae5a0df119 100644 --- a/samples/Physics/BepuSample/BepuSample.Game/Components/Camera/FindAndAttachCameraComponent.cs +++ b/samples/Physics/BepuSample/BepuSample.Game/Components/Camera/FindAndAttachCameraComponent.cs @@ -16,7 +16,7 @@ public override void Start() public override void Update() { - var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; var currentPosition = CameraComponent.Entity.Transform.Position; var currentRotation = CameraComponent.Entity.Transform.Rotation; diff --git a/samples/Templates/FirstPersonShooter/FirstPersonShooter/FirstPersonShooter.Game/Player/AnimationController.cs b/samples/Templates/FirstPersonShooter/FirstPersonShooter/FirstPersonShooter.Game/Player/AnimationController.cs index b610bf0640..66d320e05c 100644 --- a/samples/Templates/FirstPersonShooter/FirstPersonShooter/FirstPersonShooter.Game/Player/AnimationController.cs +++ b/samples/Templates/FirstPersonShooter/FirstPersonShooter/FirstPersonShooter.Game/Player/AnimationController.cs @@ -123,7 +123,7 @@ public override void Update() // Update current animation var currentTicks = TimeSpan.FromTicks((long)(currentTime * currentClip.Duration.Ticks)); - var updatedTicks = currentTicks.Ticks + (long)(Game.DrawTime.Elapsed.Ticks * TimeFactor); + var updatedTicks = currentTicks.Ticks + (long)(Game.UpdateTime.WarpElapsed.Ticks * TimeFactor); var currentClipFinished = (updatedTicks >= currentClip.Duration.Ticks); diff --git a/samples/Templates/FirstPersonShooter/FirstPersonShooter/FirstPersonShooter.Game/Player/WeaponScript.cs b/samples/Templates/FirstPersonShooter/FirstPersonShooter/FirstPersonShooter.Game/Player/WeaponScript.cs index 7b3b8e10ee..f60dec6f91 100644 --- a/samples/Templates/FirstPersonShooter/FirstPersonShooter/FirstPersonShooter.Game/Player/WeaponScript.cs +++ b/samples/Templates/FirstPersonShooter/FirstPersonShooter/FirstPersonShooter.Game/Player/WeaponScript.cs @@ -56,7 +56,7 @@ private void ReloadWeapon() while (secondsCountdown > 0f) { await Script.NextFrame(); - secondsCountdown -= (float) Game.UpdateTime.Elapsed.TotalSeconds; + secondsCountdown -= (float) Game.UpdateTime.WarpElapsed.TotalSeconds; } remainingBullets = 9; @@ -77,7 +77,7 @@ public override void Update() bool didReload; reloadEvent.TryReceive(out didReload); - cooldownRemaining = (cooldownRemaining > 0) ? (cooldownRemaining - (float)this.Game.UpdateTime.Elapsed.TotalSeconds) : 0f; + cooldownRemaining = (cooldownRemaining > 0) ? (cooldownRemaining - (float)this.Game.UpdateTime.WarpElapsed.TotalSeconds) : 0f; if (cooldownRemaining > 0) return; // Can't shoot yet diff --git a/samples/Templates/FirstPersonShooter/FirstPersonShooter/FirstPersonShooter.Game/Trigger/TriggerScript.cs b/samples/Templates/FirstPersonShooter/FirstPersonShooter/FirstPersonShooter.Game/Trigger/TriggerScript.cs index ee6bd968ab..bbb66f8e35 100644 --- a/samples/Templates/FirstPersonShooter/FirstPersonShooter/FirstPersonShooter.Game/Trigger/TriggerScript.cs +++ b/samples/Templates/FirstPersonShooter/FirstPersonShooter/FirstPersonShooter.Game/Trigger/TriggerScript.cs @@ -59,7 +59,7 @@ protected void SpawnInstance(Prefab source, Entity attachEntity, float timeout, while (secondsCountdown > 0f) { await Script.NextFrame(); - secondsCountdown -= (float)Game.UpdateTime.Elapsed.TotalSeconds; + secondsCountdown -= (float)Game.UpdateTime.WarpElapsed.TotalSeconds; } // Remove diff --git a/samples/Templates/Platformer2D/Platformer2D/Platformer2D.Game/Gameplay/CoinRotation.cs b/samples/Templates/Platformer2D/Platformer2D/Platformer2D.Game/Gameplay/CoinRotation.cs index 4c61dd90ed..e8c11a7af5 100644 --- a/samples/Templates/Platformer2D/Platformer2D/Platformer2D.Game/Gameplay/CoinRotation.cs +++ b/samples/Templates/Platformer2D/Platformer2D/Platformer2D.Game/Gameplay/CoinRotation.cs @@ -19,7 +19,7 @@ public class CoinRotation : SyncScript public override void Update() { - animationTimer += (float) Game.UpdateTime.Elapsed.TotalSeconds; + animationTimer += (float) Game.UpdateTime.WarpElapsed.TotalSeconds; if (animationTimer >= animationInterval) { diff --git a/samples/Templates/Platformer2D/Platformer2D/Platformer2D.Game/PlayerController.cs b/samples/Templates/Platformer2D/Platformer2D/Platformer2D.Game/PlayerController.cs index 273f1684e1..d136ea48ed 100644 --- a/samples/Templates/Platformer2D/Platformer2D/Platformer2D.Game/PlayerController.cs +++ b/samples/Templates/Platformer2D/Platformer2D/Platformer2D.Game/PlayerController.cs @@ -93,7 +93,7 @@ private bool HandleInput() private void HandleAnimation(bool isMoving) { - animationTimer += (float) Game.UpdateTime.Elapsed.TotalSeconds; + animationTimer += (float) Game.UpdateTime.WarpElapsed.TotalSeconds; if (CharacterComponent.IsGrounded && !isMoving) { diff --git a/samples/Templates/ThirdPersonPlatformer/ThirdPersonPlatformer/ThirdPersonPlatformer.Game/BasicCameraController.cs b/samples/Templates/ThirdPersonPlatformer/ThirdPersonPlatformer/ThirdPersonPlatformer.Game/BasicCameraController.cs index d27a23eb48..13698ef943 100644 --- a/samples/Templates/ThirdPersonPlatformer/ThirdPersonPlatformer/ThirdPersonPlatformer.Game/BasicCameraController.cs +++ b/samples/Templates/ThirdPersonPlatformer/ThirdPersonPlatformer/ThirdPersonPlatformer.Game/BasicCameraController.cs @@ -157,7 +157,7 @@ private void ProcessInput() private void UpdateTransform() { - var elapsedTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var elapsedTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; translation *= elapsedTime; yaw *= elapsedTime; diff --git a/samples/Templates/ThirdPersonPlatformer/ThirdPersonPlatformer/ThirdPersonPlatformer.Game/Player/AnimationController.cs b/samples/Templates/ThirdPersonPlatformer/ThirdPersonPlatformer/ThirdPersonPlatformer.Game/Player/AnimationController.cs index 174e2d15c7..a3ab4816ab 100644 --- a/samples/Templates/ThirdPersonPlatformer/ThirdPersonPlatformer/ThirdPersonPlatformer.Game/Player/AnimationController.cs +++ b/samples/Templates/ThirdPersonPlatformer/ThirdPersonPlatformer/ThirdPersonPlatformer.Game/Player/AnimationController.cs @@ -139,8 +139,7 @@ private void UpdateWalking() animationClipWalkLerp2 = AnimationRun; } - // Use DrawTime rather than UpdateTime - var time = Game.DrawTime; + var time = Game.UpdateTime; // This update function will account for animation with different durations, keeping a current time relative to the blended maximum duration long blendedMaxDuration = 0; blendedMaxDuration = @@ -150,7 +149,7 @@ private void UpdateWalking() currentTicks = blendedMaxDuration == 0 ? TimeSpan.Zero - : TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.Elapsed.Ticks * TimeFactor)) % + : TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.WarpElapsed.Ticks * TimeFactor)) % blendedMaxDuration); currentTime = ((double)currentTicks.Ticks / (double)blendedMaxDuration); @@ -160,7 +159,7 @@ private void UpdateJumping() { var speedFactor = 1; var currentTicks = TimeSpan.FromTicks((long)(currentTime * AnimationJumpStart.Duration.Ticks)); - var updatedTicks = currentTicks.Ticks + (long)(Game.DrawTime.Elapsed.Ticks * TimeFactor * speedFactor); + var updatedTicks = currentTicks.Ticks + (long)(Game.UpdateTime.WarpElapsed.Ticks * TimeFactor * speedFactor); if (updatedTicks < AnimationJumpStart.Duration.Ticks) { @@ -177,10 +176,9 @@ private void UpdateJumping() private void UpdateAirborne() { - // Use DrawTime rather than UpdateTime - var time = Game.DrawTime; + var time = Game.UpdateTime; var currentTicks = TimeSpan.FromTicks((long)(currentTime * AnimationJumpMid.Duration.Ticks)); - currentTicks = TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.Elapsed.Ticks * TimeFactor)) % + currentTicks = TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.WarpElapsed.Ticks * TimeFactor)) % AnimationJumpMid.Duration.Ticks); currentTime = ((double)currentTicks.Ticks / (double)AnimationJumpMid.Duration.Ticks); } @@ -189,7 +187,7 @@ private void UpdateLanding() { var speedFactor = 1; var currentTicks = TimeSpan.FromTicks((long)(currentTime * AnimationJumpEnd.Duration.Ticks)); - var updatedTicks = currentTicks.Ticks + (long) (Game.DrawTime.Elapsed.Ticks * TimeFactor * speedFactor); + var updatedTicks = currentTicks.Ticks + (long) (Game.UpdateTime.WarpElapsed.Ticks * TimeFactor * speedFactor); if (updatedTicks < AnimationJumpEnd.Duration.Ticks) { diff --git a/samples/Templates/ThirdPersonPlatformer/ThirdPersonPlatformer/ThirdPersonPlatformer.Game/Player/PlayerController.cs b/samples/Templates/ThirdPersonPlatformer/ThirdPersonPlatformer/ThirdPersonPlatformer.Game/Player/PlayerController.cs index 498bfeeae2..2df7f0dbe2 100644 --- a/samples/Templates/ThirdPersonPlatformer/ThirdPersonPlatformer/ThirdPersonPlatformer.Game/Player/PlayerController.cs +++ b/samples/Templates/ThirdPersonPlatformer/ThirdPersonPlatformer/ThirdPersonPlatformer.Game/Player/PlayerController.cs @@ -61,7 +61,6 @@ public override void Start() /// public override void Update() { - // var dt = Game.UpdateTime.Elapsed.Milliseconds * 0.001; Move(MaxRunSpeed); Jump(); diff --git a/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Core/Utils.cs b/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Core/Utils.cs index e6527c0907..58e6d56941 100644 --- a/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Core/Utils.cs +++ b/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Core/Utils.cs @@ -77,7 +77,7 @@ public static void SpawnPrefabInstance(this ScriptComponent script, Prefab sourc while (secondsCountdown > 0f) { await script.Script.NextFrame(); - secondsCountdown -= (float)script.Game.UpdateTime.Elapsed.TotalSeconds; + secondsCountdown -= (float)script.Game.UpdateTime.WarpElapsed.TotalSeconds; } // Remove diff --git a/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Gameplay/CoinScript.cs b/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Gameplay/CoinScript.cs index 366162b3b6..206b4371f9 100644 --- a/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Gameplay/CoinScript.cs +++ b/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Gameplay/CoinScript.cs @@ -43,7 +43,7 @@ public override void Update() public void UpdateAnimation() { - var dt = (float) Game.UpdateTime.Elapsed.TotalSeconds; + var dt = (float) Game.UpdateTime.WarpElapsed.TotalSeconds; Entity.Transform.Rotation *= Quaternion.RotationMatrix(Matrix.RotationY(spinSpeed * (float)(dt * Math.PI))); if (!activated) diff --git a/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Gameplay/CrateScript.cs b/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Gameplay/CrateScript.cs index 84b1ed9e6b..53f28347f6 100644 --- a/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Gameplay/CrateScript.cs +++ b/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Gameplay/CrateScript.cs @@ -46,7 +46,7 @@ public void UpdateAnimation() if (!activated) return; - var dt = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var dt = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; animationTime += dt * 8; var coinHeight = Math.Max(0, Math.Sin(animationTime)); diff --git a/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Gameplay/LootCoinScript.cs b/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Gameplay/LootCoinScript.cs index 9d3d164fdd..07932bb25d 100644 --- a/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Gameplay/LootCoinScript.cs +++ b/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Gameplay/LootCoinScript.cs @@ -44,7 +44,7 @@ public override void Update() public void UpdateAnimation() { - var dt = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var dt = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; if (!activated) return; diff --git a/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Player/AnimationController.cs b/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Player/AnimationController.cs index 9dfe874a34..535e5c2cb1 100644 --- a/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Player/AnimationController.cs +++ b/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Player/AnimationController.cs @@ -121,8 +121,7 @@ private void UpdateWalking() animationClipWalkLerp2 = AnimationRun; } - // Use DrawTime rather than UpdateTime - var time = Game.DrawTime; + var time = Game.UpdateTime; // This update function will account for animation with different durations, keeping a current time relative to the blended maximum duration long blendedMaxDuration = 0; blendedMaxDuration = @@ -132,7 +131,7 @@ private void UpdateWalking() currentTicks = blendedMaxDuration == 0 ? TimeSpan.Zero - : TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.Elapsed.Ticks * TimeFactor)) % + : TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.WarpElapsed.Ticks * TimeFactor)) % blendedMaxDuration); currentTime = ((double)currentTicks.Ticks / (double)blendedMaxDuration); @@ -142,7 +141,7 @@ private void UpdatePunching() { var speedFactor = 1; var currentTicks = TimeSpan.FromTicks((long)(currentTime * AnimationPunch.Duration.Ticks)); - var updatedTicks = currentTicks.Ticks + (long)(Game.DrawTime.Elapsed.Ticks * TimeFactor * speedFactor); + var updatedTicks = currentTicks.Ticks + (long)(Game.UpdateTime.WarpElapsed.Ticks * TimeFactor * speedFactor); if (updatedTicks < AnimationPunch.Duration.Ticks) { diff --git a/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Player/PlayerController.cs b/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Player/PlayerController.cs index 9d1543a582..6372b16da3 100644 --- a/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Player/PlayerController.cs +++ b/samples/Templates/TopDownRPG/TopDownRPG/TopDownRPG.Game/Player/PlayerController.cs @@ -123,7 +123,7 @@ public override void Update() private void Attack() { - var dt = (float) Game.UpdateTime.Elapsed.TotalSeconds; + var dt = (float) Game.UpdateTime.WarpElapsed.TotalSeconds; attackCooldown = (attackCooldown > 0) ? attackCooldown - dt : 0f; PunchCollision.Enabled = (attackCooldown > 0); diff --git a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/DeltaTimeDemo.cs b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/DeltaTimeDemo.cs index abfe9c5724..4c31223cf1 100644 --- a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/DeltaTimeDemo.cs +++ b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/DeltaTimeDemo.cs @@ -30,7 +30,7 @@ public override void Start() public override void Update() { /// We can access Delta time through the static 'Game' object. - var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; // We update the total time totalTime += deltaTime; diff --git a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/KeyboardInputDemo.cs b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/KeyboardInputDemo.cs index 2b0ef41933..f48dc6f695 100644 --- a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/KeyboardInputDemo.cs +++ b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/KeyboardInputDemo.cs @@ -27,7 +27,7 @@ public override void Update() DebugText.Print("Hold the 1 key down to rotate the blue teapot", new Int2(340, 500)); if (Input.IsKeyDown(Keys.D1)) { - var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; BlueTeapot.Transform.Rotation *= Quaternion.RotationY(0.3f * deltaTime); } diff --git a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/LerpDemo.cs b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/LerpDemo.cs index 211508ced3..6c457833dd 100644 --- a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/LerpDemo.cs +++ b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/LerpDemo.cs @@ -30,7 +30,7 @@ public override void Start() public override void Update() { // Keep track of elapsed time - var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; elapsedTime += deltaTime; // In order to make use of the lerp method, we need to calculate the 'interpolation value': a value going from 0 to 1. diff --git a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/MouseInputDemo.cs b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/MouseInputDemo.cs index 53010f74a5..bf3d553f87 100644 --- a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/MouseInputDemo.cs +++ b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/MouseInputDemo.cs @@ -30,7 +30,7 @@ public override void Update() DebugText.Print("Hold the left mouse button down to rotate the blue teapot", new Int2(400, 600)); if (Input.IsMouseButtonDown(MouseButton.Left)) { - var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; BlueTeapot.Transform.Rotation *= Quaternion.RotationY(0.4f * deltaTime); } diff --git a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/RemoveEntitiesDemo.cs b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/RemoveEntitiesDemo.cs index d177b4d693..7b4f4c8def 100644 --- a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/RemoveEntitiesDemo.cs +++ b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/RemoveEntitiesDemo.cs @@ -49,7 +49,7 @@ private void CloneEntityAndAddToScene() public override void Update() { // We use a simple timer - timer += (float)Game.UpdateTime.Elapsed.TotalSeconds; + timer += (float)Game.UpdateTime.WarpElapsed.TotalSeconds; if (timer > currentTimer) { // If the entities exist, we remove them from the scene diff --git a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/TutorialUI.cs b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/TutorialUI.cs index 8e5fbb5106..5a37f82be8 100644 --- a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/TutorialUI.cs +++ b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/TutorialUI.cs @@ -124,7 +124,7 @@ public override void Update() { if (startTransform != null && cameraLerpTimer < cameraLerpTime) { - var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; cameraLerpTimer += deltaTime; var lerpTime = cameraLerpTimer / cameraLerpTime; Camera.Transform.Position = Vector3.Lerp(startTransform.Position, targetTransform.Position, lerpTime); diff --git a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/VirtualButtonsDemo.cs b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/VirtualButtonsDemo.cs index 8d101f26b6..42b02eb278 100644 --- a/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/VirtualButtonsDemo.cs +++ b/samples/Tutorials/CSharpBeginner/CSharpBeginner/CSharpBeginner.Game/Code/VirtualButtonsDemo.cs @@ -49,7 +49,7 @@ public override void Update() // Note: Gamepad sticks can be a negative value. For this example we only check if the value is higher than 0 if (forward > 0) { - var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; BlueTeapot.Transform.Rotation *= Quaternion.RotationY(0.6f * forward * deltaTime); } diff --git a/samples/Tutorials/CSharpIntermediate/CSharpIntermediate/CSharpIntermediate.Game/11_Navigation/NavigateCharacter.cs b/samples/Tutorials/CSharpIntermediate/CSharpIntermediate/CSharpIntermediate.Game/11_Navigation/NavigateCharacter.cs index 60f463d3e4..c2e607a7fa 100644 --- a/samples/Tutorials/CSharpIntermediate/CSharpIntermediate/CSharpIntermediate.Game/11_Navigation/NavigateCharacter.cs +++ b/samples/Tutorials/CSharpIntermediate/CSharpIntermediate/CSharpIntermediate.Game/11_Navigation/NavigateCharacter.cs @@ -48,7 +48,7 @@ private void UpdateMovement() return; } - var deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; var curPosition = RegularCharacter.Transform.WorldMatrix.TranslationVector; var nextWaypointPosition = waypoints[waypointIndex]; var distanceToWaypoint = Vector3.Distance(curPosition, nextWaypointPosition); diff --git a/samples/Tutorials/CSharpIntermediate/CSharpIntermediate/CSharpIntermediate.Game/Utils/OmniDirectionMovement.cs b/samples/Tutorials/CSharpIntermediate/CSharpIntermediate/CSharpIntermediate.Game/Utils/OmniDirectionMovement.cs index 014855849f..2ff26401ac 100644 --- a/samples/Tutorials/CSharpIntermediate/CSharpIntermediate/CSharpIntermediate.Game/Utils/OmniDirectionMovement.cs +++ b/samples/Tutorials/CSharpIntermediate/CSharpIntermediate/CSharpIntermediate.Game/Utils/OmniDirectionMovement.cs @@ -55,7 +55,7 @@ public override void Update() movement.X -= 1; } - var delta = (float)Game.UpdateTime.Elapsed.TotalSeconds; + var delta = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; Entity.Transform.Position += movement * delta * MoveSpeed; } } diff --git a/samples/UI/GameMenu/GameMenu.Game/MainScript.cs b/samples/UI/GameMenu/GameMenu.Game/MainScript.cs index a3471058ed..9d5689fd98 100644 --- a/samples/UI/GameMenu/GameMenu.Game/MainScript.cs +++ b/samples/UI/GameMenu/GameMenu.Game/MainScript.cs @@ -198,7 +198,7 @@ private async Task FillLifeBar() { await Script.NextFrame(); - gaugePercentage = Math.Min(1f, gaugePercentage + (float)Game.UpdateTime.Elapsed.TotalSeconds * 0.02f); + gaugePercentage = Math.Min(1f, gaugePercentage + (float)Game.UpdateTime.WarpElapsed.TotalSeconds * 0.02f); var gaugeCurrentRegion = lifebarGaugeImage.Region; gaugeCurrentRegion.Width = gaugePercentage * gaugeBarRegion.Width; diff --git a/samples/UI/UIParticles/UIParticles.Game/SplashScript.cs b/samples/UI/UIParticles/UIParticles.Game/SplashScript.cs index f7da3a9891..9734128ac2 100644 --- a/samples/UI/UIParticles/UIParticles.Game/SplashScript.cs +++ b/samples/UI/UIParticles/UIParticles.Game/SplashScript.cs @@ -211,7 +211,7 @@ protected void SpawnParticles(Vector3 uiPosition, Prefab hitEffectPrefab, float while (secondsCountdown > 0f) { await Script.NextFrame(); - secondsCountdown -= (float)Game.UpdateTime.Elapsed.TotalSeconds; + secondsCountdown -= (float)Game.UpdateTime.WarpElapsed.TotalSeconds; } // Remove @@ -283,7 +283,7 @@ private void EnterNewGame() private void DrawFuse() { - fusePercentage = Math.Min(1f, fusePercentage - (float)Game.UpdateTime.Elapsed.TotalSeconds * 0.04f); + fusePercentage = Math.Min(1f, fusePercentage - (float)Game.UpdateTime.WarpElapsed.TotalSeconds * 0.04f); var gaugeCurrentRegion = lifeBarGaugeImage.Region; gaugeCurrentRegion.Width = Math.Max(1, fusePercentage * gaugeBarRegion.Width); @@ -323,7 +323,7 @@ private void EnterEndGame() private void NewGameState() { - fusePercentage = Math.Min(1f, fusePercentage - (float)Game.UpdateTime.Elapsed.TotalSeconds * 0.03f); + fusePercentage = Math.Min(1f, fusePercentage - (float)Game.UpdateTime.WarpElapsed.TotalSeconds * 0.03f); DrawFuse(); if (desiredState == GameState.EndGame || fusePercentage <= 0f) diff --git a/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Animation/AnimationBlend.cs b/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Animation/AnimationBlend.cs index ad13736e43..ce02fc4e9e 100644 --- a/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Animation/AnimationBlend.cs +++ b/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Animation/AnimationBlend.cs @@ -58,8 +58,7 @@ public override void Cancel() public override void Update() { - // Use DrawTime rather than UpdateTime - var time = Game.DrawTime; + var time = Game.UpdateTime; // This update function will account for animation with different durations, keeping a current time relative to the blended maximum duration long blendedMaxDuration = 0; @@ -67,7 +66,7 @@ public override void Update() var currentTicks = TimeSpan.FromTicks((long)(currentTime * blendedMaxDuration)); - currentTicks = blendedMaxDuration == 0 ? TimeSpan.Zero : TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.Elapsed.Ticks * TimeFactor)) % blendedMaxDuration); + currentTicks = blendedMaxDuration == 0 ? TimeSpan.Zero : TimeSpan.FromTicks((currentTicks.Ticks + (long)(time.WarpElapsed.Ticks * TimeFactor)) % blendedMaxDuration); currentTime = (currentTicks.Ticks/(double) blendedMaxDuration); } diff --git a/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Camera/BasicCameraController.cs b/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Camera/BasicCameraController.cs index be6891da22..41ee3171da 100644 --- a/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Camera/BasicCameraController.cs +++ b/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Camera/BasicCameraController.cs @@ -59,7 +59,7 @@ public override void Update() private void ProcessInput() { - float deltaTime = (float)Game.UpdateTime.Elapsed.TotalSeconds; + float deltaTime = (float)Game.UpdateTime.WarpElapsed.TotalSeconds; translation = Vector3.Zero; yaw = 0f; pitch = 0f; diff --git a/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Camera/FpsCamera.cs b/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Camera/FpsCamera.cs index 071bd83f8b..cdb59fb897 100644 --- a/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Camera/FpsCamera.cs +++ b/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Camera/FpsCamera.cs @@ -156,7 +156,7 @@ protected virtual void UpdateCamera() } // Compute translation speed according to framerate and modifiers - var translationSpeed = MoveSpeed * (float)Game.UpdateTime.Elapsed.TotalSeconds; + var translationSpeed = MoveSpeed * (float)Game.UpdateTime.WarpElapsed.TotalSeconds; var oldPitch = Pitch; @@ -170,7 +170,7 @@ protected virtual void UpdateCamera() desiredYaw = Yaw + deltaYaw; // Perform orientation transition - var rotationAdaptation = (float)Game.UpdateTime.Elapsed.TotalSeconds * RotationAdaptationSpeed; + var rotationAdaptation = (float)Game.UpdateTime.WarpElapsed.TotalSeconds * RotationAdaptationSpeed; Yaw = Math.Abs(deltaYaw) < rotationAdaptation ? desiredYaw : Yaw + rotationAdaptation * Math.Sign(deltaYaw); Pitch = Math.Abs(deltaPitch) < rotationAdaptation ? desiredPitch : Pitch + rotationAdaptation * Math.Sign(deltaPitch); diff --git a/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Camera/FreeCamera.cs b/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Camera/FreeCamera.cs index 647bc67fb6..e6bca82f0b 100644 --- a/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Camera/FreeCamera.cs +++ b/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Camera/FreeCamera.cs @@ -173,7 +173,7 @@ protected virtual void UpdateCamera() } // Compute translation speed according to framerate and modifiers - float translationSpeed = MoveSpeed * (float)Game.UpdateTime.Elapsed.TotalSeconds; + float translationSpeed = MoveSpeed * (float)Game.UpdateTime.WarpElapsed.TotalSeconds; if (Input.IsKeyDown(Keys.LeftShift) || Input.IsKeyDown(Keys.RightShift)) translationSpeed *= 10; @@ -193,7 +193,7 @@ protected virtual void UpdateCamera() var isAdaptingOrientation = !MathUtil.NearEqual(deltaPitch, 0) || !MathUtil.NearEqual(deltaYaw, 0); // Perform orientation transition - var rotationAdaptation = (float)Game.UpdateTime.Elapsed.TotalSeconds * RotationAdaptationSpeed; + var rotationAdaptation = (float)Game.UpdateTime.WarpElapsed.TotalSeconds * RotationAdaptationSpeed; Yaw = Math.Abs(deltaYaw) < rotationAdaptation ? desiredYaw : Yaw + rotationAdaptation * Math.Sign(deltaYaw); Pitch = Math.Abs(deltaPitch) < rotationAdaptation ? desiredPitch : Pitch + rotationAdaptation * Math.Sign(deltaPitch); diff --git a/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Physics/PlayerController.cs b/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Physics/PlayerController.cs index 248262dcae..fbe502296b 100644 --- a/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Physics/PlayerController.cs +++ b/sources/editor/Stride.Assets.Presentation/Templates/Assets/Scripts/Physics/PlayerController.cs @@ -97,7 +97,7 @@ public override void Update() var rotationDelta = Input.MouseDelta; // Compute translation speed according to framerate and modifiers - var translationSpeed = Speed * (float)Game.UpdateTime.Elapsed.TotalSeconds; + var translationSpeed = Speed * (float)Game.UpdateTime.WarpElapsed.TotalSeconds; // Take shortest path var deltaPitch = desiredPitch - pitch; @@ -109,7 +109,7 @@ public override void Update() desiredYaw = yaw + deltaYaw; // Perform orientation transition - var rotationAdaptation = (float)Game.UpdateTime.Elapsed.TotalSeconds * RotationAdaptationSpeed; + var rotationAdaptation = (float)Game.UpdateTime.WarpElapsed.TotalSeconds * RotationAdaptationSpeed; yaw = Math.Abs(deltaYaw) < rotationAdaptation ? desiredYaw : yaw + rotationAdaptation * Math.Sign(deltaYaw); pitch = Math.Abs(deltaPitch) < rotationAdaptation ? desiredPitch : pitch + rotationAdaptation * Math.Sign(deltaPitch);