From 1da37d24aed234a6af2ff6e62f4a88c1d9c36cd5 Mon Sep 17 00:00:00 2001 From: Acruid Date: Tue, 17 Sep 2019 16:24:10 -0700 Subject: [PATCH] Removes the old obsolete input system where the state system directly handles input. Everything is using the InputManager/InputSystem now. --- .../GameController/GameController.Input.cs | 2 - .../Components/Input/ClickableComponent.cs | 7 --- .../Components/IClientClickableComponent.cs | 7 --- .../Interfaces/State/IStateManager.cs | 7 +-- Robust.Client/State/State.cs | 48 +------------------ Robust.Client/State/StateManager.cs | 40 +--------------- Robust.Client/State/States/GameScreen.cs | 26 ---------- .../GameObjects/ComponentMessages/Messages.cs | 14 ------ 8 files changed, 3 insertions(+), 148 deletions(-) diff --git a/Robust.Client/GameController/GameController.Input.cs b/Robust.Client/GameController/GameController.Input.cs index 55fab3a710..1c179f9888 100644 --- a/Robust.Client/GameController/GameController.Input.cs +++ b/Robust.Client/GameController/GameController.Input.cs @@ -31,7 +31,6 @@ namespace Robust.Client public void MouseMove(MouseMoveEventArgs mouseMoveEventArgs) { _userInterfaceManager.MouseMove(mouseMoveEventArgs); - _stateManager.MouseMove(mouseMoveEventArgs); } /// @@ -44,7 +43,6 @@ namespace Robust.Client { return; } - _stateManager.MouseWheelMove(mouseWheelEventArgs); } } } diff --git a/Robust.Client/GameObjects/Components/Input/ClickableComponent.cs b/Robust.Client/GameObjects/Components/Input/ClickableComponent.cs index fd6bfccbca..5212730da4 100644 --- a/Robust.Client/GameObjects/Components/Input/ClickableComponent.cs +++ b/Robust.Client/GameObjects/Components/Input/ClickableComponent.cs @@ -88,13 +88,6 @@ namespace Robust.Client.GameObjects return true; } - /// - public void DispatchClick(IEntity user, ClickType clickType) - { - var message = new ClientEntityClickMsg(user.Uid, clickType); - SendMessage(message); - } - /// public void OnMouseEnter() { diff --git a/Robust.Client/Interfaces/GameObjects/Components/IClientClickableComponent.cs b/Robust.Client/Interfaces/GameObjects/Components/IClientClickableComponent.cs index ac0867b998..d00dfced43 100644 --- a/Robust.Client/Interfaces/GameObjects/Components/IClientClickableComponent.cs +++ b/Robust.Client/Interfaces/GameObjects/Components/IClientClickableComponent.cs @@ -22,13 +22,6 @@ namespace Robust.Client.Interfaces.GameObjects.Components /// True if the click worked, false otherwise. bool CheckClick(Vector2 worldPos, out int drawdepth); - /// - /// Sends the click to the sister component on the server and things subscribed to - /// - /// The entity owned by the player that clicked. - /// See . - void DispatchClick(IEntity user, ClickType clickType); - /// /// Invoked whenever the mouse hovers over this entity. /// diff --git a/Robust.Client/Interfaces/State/IStateManager.cs b/Robust.Client/Interfaces/State/IStateManager.cs index e748e49745..5b2e0c8c7c 100644 --- a/Robust.Client/Interfaces/State/IStateManager.cs +++ b/Robust.Client/Interfaces/State/IStateManager.cs @@ -1,5 +1,4 @@ -using Robust.Client.Input; -using System; +using System; using Robust.Shared.Timing; namespace Robust.Client.Interfaces.State @@ -12,10 +11,6 @@ namespace Robust.Client.Interfaces.State void RequestStateChange() where T : Client.State.State, new(); void Update(FrameEventArgs e); void FrameUpdate(FrameEventArgs e); - void MouseUp(MouseButtonEventArgs e); - void MouseDown(MouseButtonEventArgs e); - void MouseMove(MouseMoveEventArgs e); - void MouseWheelMove(MouseWheelEventArgs e); void FormResize(); } diff --git a/Robust.Client/State/State.cs b/Robust.Client/State/State.cs index 678419604a..8ed3e67ba4 100644 --- a/Robust.Client/State/State.cs +++ b/Robust.Client/State/State.cs @@ -1,6 +1,4 @@ -using System; -using Robust.Client.Input; -using Robust.Shared.Timing; +using Robust.Shared.Timing; namespace Robust.Client.State { @@ -23,53 +21,9 @@ namespace Robust.Client.State public virtual void FrameUpdate(FrameEventArgs e) { } - #region Events - - /// - /// Mouse button was pressed. - /// - public virtual void MousePressed(MouseButtonEventArgs e) { } - - /// - /// Mouse button was released. - /// - public virtual void MouseUp(MouseButtonEventArgs e) { } - - /// - /// Mouse button will be pressed. - /// - public virtual void MouseDown(MouseButtonEventArgs e) { } - - /// - /// Mouse cursor has moved. - /// - public virtual void MouseMoved(MouseMoveEventArgs e) { } - - /// - /// Mouse cursor will move. - /// - public virtual void MouseMove(MouseMoveEventArgs e) { } - - /// - /// Mouse wheel has been moved. - /// - public virtual void MouseWheelMove(MouseWheelEventArgs e) { } - - /// - /// Mouse has entered this screen. - /// - public virtual void MouseEntered(EventArgs e) { } - - /// - /// Left mouse button has been pressed. - /// - public virtual void MouseLeft(EventArgs e) { } - /// /// The screen has changed size, usually from resizing window. This is called automatically right after Startup. /// public virtual void FormResize() { } - - #endregion Events } } diff --git a/Robust.Client/State/StateManager.cs b/Robust.Client/State/StateManager.cs index f69d10278f..84a81f26ab 100644 --- a/Robust.Client/State/StateManager.cs +++ b/Robust.Client/State/StateManager.cs @@ -1,5 +1,4 @@ -using Robust.Client.Input; -using Robust.Client.Interfaces.State; +using Robust.Client.Interfaces.State; using Robust.Shared.Log; using System; using Robust.Shared.IoC; @@ -16,8 +15,6 @@ namespace Robust.Client.State public event Action OnStateChanged; public State CurrentState { get; private set; } - #region Updates & Statechanges - public void Update(FrameEventArgs e) { CurrentState?.Update(e); @@ -60,40 +57,5 @@ namespace Robust.Client.State OnStateChanged?.Invoke(new StateChangedEventArgs(old, CurrentState)); } - - #endregion Updates & Statechanges - #region Input - - public void MouseUp(MouseButtonEventArgs e) - { - CurrentState?.MouseUp(e); - } - - public void MouseDown(MouseButtonEventArgs e) - { - CurrentState?.MouseDown(e); - } - - public void MouseMove(MouseMoveEventArgs e) - { - CurrentState?.MouseMove(e); - } - - public void MouseWheelMove(MouseWheelEventArgs e) - { - CurrentState?.MouseWheelMove(e); - } - - public void MouseEntered(EventArgs e) - { - CurrentState?.MouseEntered(e); - } - - public void MouseLeft(EventArgs e) - { - CurrentState?.MouseLeft(e); - } - - #endregion Input } } diff --git a/Robust.Client/State/States/GameScreen.cs b/Robust.Client/State/States/GameScreen.cs index f6c8678854..dc6a4eafd1 100644 --- a/Robust.Client/State/States/GameScreen.cs +++ b/Robust.Client/State/States/GameScreen.cs @@ -83,38 +83,12 @@ namespace Robust.Client.State.States } } - public override void MouseDown(MouseButtonEventArgs eventargs) - { - if (playerManager.LocalPlayer == null) - return; - - var mousePosWorld = eyeManager.ScreenToWorld(new ScreenCoordinates(eventargs.Position)); - var entityToClick = GetEntityUnderPosition(mousePosWorld); - - //Dispatches clicks to relevant clickable components, another single exit point for UI - if (entityToClick == null) - return; - - var clickable = entityToClick.GetComponent(); - clickable.DispatchClick(playerManager.LocalPlayer.ControlledEntity, eventargs.ClickType); - } - public IEntity GetEntityUnderPosition(GridCoordinates coordinates) { var entitiesUnderPosition = GetEntitiesUnderPosition(coordinates); return entitiesUnderPosition.Count > 0 ? entitiesUnderPosition[0] : null; } - /// - /// Gets all the entities currently under the mouse cursor. - /// - /// A list of the entities, sorted such that the first entry is the top entity. - public IList GetEntitiesUnderMouse() - { - var mousePosWorld = eyeManager.ScreenToWorld(new ScreenCoordinates(inputManager.MouseScreenPosition)); - return GetEntitiesUnderPosition(mousePosWorld); - } - public IList GetEntitiesUnderPosition(GridCoordinates coordinates) { // Find all the entities intersecting our click diff --git a/Robust.Shared/GameObjects/ComponentMessages/Messages.cs b/Robust.Shared/GameObjects/ComponentMessages/Messages.cs index c879db75ca..96d51bf737 100644 --- a/Robust.Shared/GameObjects/ComponentMessages/Messages.cs +++ b/Robust.Shared/GameObjects/ComponentMessages/Messages.cs @@ -17,20 +17,6 @@ namespace Robust.Shared.GameObjects } } - [Serializable, NetSerializable] - public class ClientEntityClickMsg : ComponentMessage - { - public EntityUid Uid { get; } - public ClickType Click { get; } - - public ClientEntityClickMsg(EntityUid uid, ClickType click) - { - Directed = true; - Uid = uid; - Click = click; - } - } - public class RelayMovementEntityMessage : ComponentMessage { public IEntity Entity { get; set; }