Skip to content

Commit

Permalink
Merge branch 'stride3d:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
VaclavElias authored Mar 10, 2024
2 parents 06a451a + 0ff5354 commit 5b3aaef
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/Stride.CommunityToolkit/Engine/GameExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -781,15 +781,27 @@ public static Entity Create3DPrimitiveWithBepu(this IGame game, PrimitiveModelTy
public static void SetMaxFPS(this IGame game, int targetFPS)
{
var gameBase = (GameBase)game;
gameBase.WindowMinimumUpdateRate.MinimumElapsedTime = TimeSpan.FromMilliseconds(1000 / targetFPS);
gameBase.WindowMinimumUpdateRate.MinimumElapsedTime = TimeSpan.FromMilliseconds(1000f / targetFPS);
}

/// <summary>
/// Sets the maximum frames per second (FPS) rate for the game when not in focus.
/// Set <param name="targetFPS"/> to 0 for max possible FPS.
/// </summary>
/// <param name="game"></param>
/// <param name="targetFPS"></param>
public static void SetFocusLostFPS(this IGame game, int targetFPS)
{
var gameBase = (GameBase)game;
gameBase.MinimizedMinimumUpdateRate.MinimumElapsedTime = TimeSpan.FromMilliseconds(1000f / targetFPS);
}

/// <summary>
/// Retrieves the current frames per second (FPS) rate of the running game.
/// </summary>
/// <param name="game">The game instance from which to obtain the FPS rate.</param>
/// <returns>The current FPS rate of the game.</returns>
public static float FPS(this Game game) => game.UpdateTime.FramePerSecond;
public static float FPS(this IGame game) => game.UpdateTime.FramePerSecond;

private static ColliderBase? Get2DColliderShapeWithBepu(Primitive2DModelType type, Vector2? size = null, float depth = 0)
{
Expand Down

0 comments on commit 5b3aaef

Please sign in to comment.