diff --git a/src/Stride.CommunityToolkit/Engine/GameExtensions.cs b/src/Stride.CommunityToolkit/Engine/GameExtensions.cs index 00fbaf70..65aa87bd 100644 --- a/src/Stride.CommunityToolkit/Engine/GameExtensions.cs +++ b/src/Stride.CommunityToolkit/Engine/GameExtensions.cs @@ -781,7 +781,19 @@ 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); + } + + /// + /// Sets the maximum frames per second (FPS) rate for the game when not in focus. + /// Set to 0 for max possible FPS. + /// + /// + /// + public static void SetFocusLostFPS(this IGame game, int targetFPS) + { + var gameBase = (GameBase)game; + gameBase.MinimizedMinimumUpdateRate.MinimumElapsedTime = TimeSpan.FromMilliseconds(1000f / targetFPS); } /// @@ -789,7 +801,7 @@ public static void SetMaxFPS(this IGame game, int targetFPS) /// /// The game instance from which to obtain the FPS rate. /// The current FPS rate of the game. - 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) {