Input fixes

This commit is contained in:
Royce551 2022-08-04 16:50:25 -05:00
parent 3f966c01ad
commit e7c3f9251e
3 changed files with 8 additions and 6 deletions

View file

@ -12,6 +12,7 @@ namespace Water.Graphics
public class GameObjectManager : IDrawableThing
{
public List<GameObject> AllObjects { get; private set; } = new();
public WaterGame MainGame { get; }
public GraphicsDevice GraphicsDevice { get; }
public TextureCache Textures { get; private set; }
public FontCache Fonts { get; private set; }
@ -22,9 +23,10 @@ namespace Water.Graphics
private readonly List<GameObject> objectsToAdd = new();
private readonly List<GameObject> objectsToRemove = new();
public GameObjectManager(GraphicsDevice graphicsDevice)
public GameObjectManager(GraphicsDevice graphicsDevice, WaterGame waterGame)
{
GraphicsDevice = graphicsDevice;
MainGame = waterGame;
Textures = new TextureCache(graphicsDevice);
Fonts = new FontCache();
Input = new InputManager(this);

View file

@ -51,11 +51,11 @@ namespace Water.Input
KeyUp?.Invoke(this, new(key));
}
if (currentMouseState.LeftButton == ButtonState.Pressed) PrimaryMouseButtonDown?.Invoke(this, new());
if (currentMouseState.LeftButton == ButtonState.Released) PrimaryMouseButtonUp?.Invoke(this, new());
if (currentMouseState.LeftButton == ButtonState.Pressed && previousMouseState.LeftButton != ButtonState.Pressed && game.MainGame.IsActive) PrimaryMouseButtonDown?.Invoke(this, new());
if (currentMouseState.LeftButton == ButtonState.Released && previousMouseState.LeftButton != ButtonState.Released && game.MainGame.IsActive) PrimaryMouseButtonUp?.Invoke(this, new());
if (currentMouseState.RightButton == ButtonState.Pressed) SecondaryMouseButtonDown?.Invoke(this, new());
if (currentMouseState.RightButton == ButtonState.Released) SecondaryMouseButtonUp?.Invoke(this, new());
if (currentMouseState.RightButton == ButtonState.Pressed && previousMouseState.RightButton != ButtonState.Pressed && game.MainGame.IsActive) SecondaryMouseButtonDown?.Invoke(this, new());
if (currentMouseState.RightButton == ButtonState.Released && previousMouseState.RightButton != ButtonState.Released && game.MainGame.IsActive) SecondaryMouseButtonUp?.Invoke(this, new());
previousKbState = currentKbState;
previousMouseState = currentMouseState;

View file

@ -31,7 +31,7 @@ namespace Water
TargetElapsedTime = TimeSpan.FromMilliseconds(1);
Graphics.ApplyChanges();
gameObjectManager = new(GraphicsDevice);
gameObjectManager = new(GraphicsDevice, this);
Screen = new(gameObjectManager, Window);
Screen.RelativePosition = GraphicsDevice.Viewport.Bounds;