disable mouse polling when window is inactive
parent
96b0990418
commit
2e3a331d13
|
@ -13,6 +13,13 @@ namespace KavTest.Engines
|
||||||
)]
|
)]
|
||||||
public class InputEngine : Engine
|
public class InputEngine : Engine
|
||||||
{
|
{
|
||||||
|
private Game Game { get; }
|
||||||
|
|
||||||
|
public InputEngine(Game game)
|
||||||
|
{
|
||||||
|
Game = game;
|
||||||
|
}
|
||||||
|
|
||||||
public override void Update(double dt)
|
public override void Update(double dt)
|
||||||
{
|
{
|
||||||
var keyboardState = Keyboard.GetState();
|
var keyboardState = Keyboard.GetState();
|
||||||
|
@ -38,6 +45,8 @@ namespace KavTest.Engines
|
||||||
SendMessage(new MoveCameraMessage(new Vector3(5, 0, 0)));
|
SendMessage(new MoveCameraMessage(new Vector3(5, 0, 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Game.IsActive)
|
||||||
|
{
|
||||||
if (SomeComponent<CameraComponent>())
|
if (SomeComponent<CameraComponent>())
|
||||||
{
|
{
|
||||||
var cameraEntity = ReadEntity<CameraComponent>();
|
var cameraEntity = ReadEntity<CameraComponent>();
|
||||||
|
@ -45,4 +54,5 @@ namespace KavTest.Engines
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ namespace KavTest
|
||||||
Smuggler.Importer.ImportGLB(GraphicsDevice, File.OpenRead("Content/rustysphere.glb"))
|
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 AngularVelocityEngine());
|
||||||
WorldBuilder.AddEngine(new MotionEngine());
|
WorldBuilder.AddEngine(new MotionEngine());
|
||||||
WorldBuilder.AddEngine(new CameraEngine());
|
WorldBuilder.AddEngine(new CameraEngine());
|
||||||
|
|
Loading…
Reference in New Issue