mirror of
https://github.com/Royce551/Water.git
synced 2025-01-22 19:02:48 -05:00
Input fixes
This commit is contained in:
parent
3f966c01ad
commit
e7c3f9251e
3 changed files with 8 additions and 6 deletions
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue