disable mouse polling when window is inactive

pull/1/head
cosmonaut 2020-08-06 16:28:47 -07:00
parent 96b0990418
commit 2e3a331d13
2 changed files with 14 additions and 4 deletions

View File

@ -13,6 +13,13 @@ namespace KavTest.Engines
)]
public class InputEngine : Engine
{
private Game Game { get; }
public InputEngine(Game game)
{
Game = game;
}
public override void Update(double dt)
{
var keyboardState = Keyboard.GetState();
@ -38,6 +45,8 @@ namespace KavTest.Engines
SendMessage(new MoveCameraMessage(new Vector3(5, 0, 0)));
}
if (Game.IsActive)
{
if (SomeComponent<CameraComponent>())
{
var cameraEntity = ReadEntity<CameraComponent>();
@ -46,3 +55,4 @@ namespace KavTest.Engines
}
}
}
}

View File

@ -50,7 +50,7 @@ namespace KavTest
Smuggler.Importer.ImportGLB(GraphicsDevice, File.OpenRead("Content/rustysphere.glb"))
);
WorldBuilder.AddEngine(new InputEngine());
WorldBuilder.AddEngine(new InputEngine(this));
WorldBuilder.AddEngine(new AngularVelocityEngine());
WorldBuilder.AddEngine(new MotionEngine());
WorldBuilder.AddEngine(new CameraEngine());