diff --git a/Content.Client/GameObjects/EntitySystems/CombatModeSystem.cs b/Content.Client/GameObjects/EntitySystems/CombatModeSystem.cs index bdc5bc0a44..60ecdcd3fe 100644 --- a/Content.Client/GameObjects/EntitySystems/CombatModeSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/CombatModeSystem.cs @@ -25,8 +25,6 @@ namespace Content.Client.GameObjects.EntitySystems [UsedImplicitly] public sealed class CombatModeSystem : SharedCombatModeSystem { - private const float AttackTimeThreshold = 0.15f; - #pragma warning disable 649 [Dependency] private readonly IGameHud _gameHud; [Dependency] private readonly IPlayerManager _playerManager; @@ -37,9 +35,6 @@ namespace Content.Client.GameObjects.EntitySystems private InputSystem _inputSystem; - public bool UseOrAttackIsDown { get; private set; } - private float _timeHeld; - public override void Initialize() { base.Initialize(); @@ -48,10 +43,8 @@ namespace Content.Client.GameObjects.EntitySystems _gameHud.OnTargetingZoneChanged = OnTargetingZoneChanged; _inputSystem = EntitySystemManager.GetEntitySystem(); - _inputSystem.BindMap.BindFunction(ContentKeyFunctions.UseOrAttack, new InputHandler(this)); _inputSystem.BindMap.BindFunction(ContentKeyFunctions.ToggleCombatMode, InputCmdHandler.FromDelegate(CombatModeToggled)); - _overlayManager.AddOverlay(new CombatModeOverlay(this)); } private void CombatModeToggled(ICommonSession session) @@ -60,20 +53,10 @@ namespace Content.Client.GameObjects.EntitySystems { EntityManager.RaisePredictiveEvent( new CombatModeSystemMessages.SetCombatModeActiveMessage(!IsInCombatMode())); - - // Just in case. - UseOrAttackIsDown = false; } } - public override void Shutdown() - { - base.Shutdown(); - - _overlayManager.RemoveOverlay(nameof(CombatModeOverlay)); - } - - private bool IsInCombatMode() + public bool IsInCombatMode() { var entity = _playerManager.LocalPlayer.ControlledEntity; if (entity == null || !entity.TryGetComponent(out CombatModeComponent combatMode)) @@ -92,104 +75,6 @@ namespace Content.Client.GameObjects.EntitySystems private void OnCombatModeChanged(bool obj) { EntityManager.RaisePredictiveEvent(new CombatModeSystemMessages.SetCombatModeActiveMessage(obj)); - - // Just in case. - UseOrAttackIsDown = false; - } - - private bool HandleInputMessage(ICommonSession session, InputCmdMessage message) - { - if (!(message is FullInputCmdMessage msg)) - return false; - - void SendMsg(BoundKeyFunction function, BoundKeyState state) - { - var functionId = _inputManager.NetworkBindMap.KeyFunctionID(function); - - var sendMsg = new FullInputCmdMessage(msg.Tick, functionId, state, - msg.Coordinates, msg.ScreenCoordinates, msg.Uid); - _inputSystem.HandleInputCommand(session, function, sendMsg); - } - - // If we are not in combat mode, relay it as a regular Use instead. - if (!IsInCombatMode()) - { - SendMsg(EngineKeyFunctions.Use, msg.State); - return true; - } - - if (msg.State == BoundKeyState.Down) - { - UseOrAttackIsDown = true; - _timeHeld = 0; - return true; - } - - // Up. - if (UseOrAttackIsDown && _timeHeld >= AttackTimeThreshold) - { - // Attack. - SendMsg(ContentKeyFunctions.Attack, BoundKeyState.Down); - SendMsg(ContentKeyFunctions.Attack, BoundKeyState.Up); - } - else - { - // Use. - SendMsg(EngineKeyFunctions.Use, BoundKeyState.Down); - SendMsg(EngineKeyFunctions.Use, BoundKeyState.Up); - } - - UseOrAttackIsDown = false; - - return true; - } - - public override void FrameUpdate(float frameTime) - { - if (UseOrAttackIsDown) - { - _timeHeld += frameTime; - } - } - - // Custom input handler type so we get the ENTIRE InputCmdMessage. - private sealed class InputHandler : InputCmdHandler - { - private readonly CombatModeSystem _combatModeSystem; - - public InputHandler(CombatModeSystem combatModeSystem) - { - _combatModeSystem = combatModeSystem; - } - - public override bool HandleCmdMessage(ICommonSession session, InputCmdMessage message) - { - return _combatModeSystem.HandleInputMessage(session, message); - } - } - - private sealed class CombatModeOverlay : Overlay - { - private readonly CombatModeSystem _system; - - public CombatModeOverlay(CombatModeSystem system) : base(nameof(CombatModeOverlay)) - { - _system = system; - } - - protected override void Draw(DrawingHandleBase handle) - { - var screenHandle = (DrawingHandleScreen) handle; - - var mousePos = IoCManager.Resolve().MouseScreenPosition; - - if (_system.UseOrAttackIsDown && _system._timeHeld > AttackTimeThreshold) - { - var tex = ResC.GetTexture($"/Textures/Objects/Tools/toolbox_r.png"); - - screenHandle.DrawTextureRect(tex, UIBox2.FromDimensions(mousePos, tex.Size * 2)); - } - } } } } diff --git a/Content.Client/GameObjects/EntitySystems/RangedWeaponSystem.cs b/Content.Client/GameObjects/EntitySystems/RangedWeaponSystem.cs index d34001cb27..8a0c991055 100644 --- a/Content.Client/GameObjects/EntitySystems/RangedWeaponSystem.cs +++ b/Content.Client/GameObjects/EntitySystems/RangedWeaponSystem.cs @@ -39,8 +39,8 @@ namespace Content.Client.GameObjects.EntitySystems base.Update(frameTime); var canFireSemi = _isFirstShot; - var state = _inputSystem.CmdStates.GetState(ContentKeyFunctions.Attack); - if (!_combatModeSystem.UseOrAttackIsDown && state != BoundKeyState.Down) + var state = _inputSystem.CmdStates.GetState(EngineKeyFunctions.Use); + if (!_combatModeSystem.IsInCombatMode() && state != BoundKeyState.Down) { _isFirstShot = true; _blocked = false; diff --git a/Content.Client/Input/ContentContexts.cs b/Content.Client/Input/ContentContexts.cs index 5301d8ba4f..4249ef2704 100644 --- a/Content.Client/Input/ContentContexts.cs +++ b/Content.Client/Input/ContentContexts.cs @@ -15,7 +15,6 @@ namespace Content.Client.Input common.AddFunction(ContentKeyFunctions.FocusChat); common.AddFunction(ContentKeyFunctions.ExamineEntity); common.AddFunction(ContentKeyFunctions.OpenTutorial); - common.AddFunction(ContentKeyFunctions.UseOrAttack); common.AddFunction(ContentKeyFunctions.TakeScreenshot); common.AddFunction(ContentKeyFunctions.TakeScreenshotNoUI); @@ -31,7 +30,7 @@ namespace Content.Client.Input human.AddFunction(ContentKeyFunctions.OpenInventoryMenu); human.AddFunction(ContentKeyFunctions.MouseMiddle); human.AddFunction(ContentKeyFunctions.ToggleCombatMode); - human.AddFunction(ContentKeyFunctions.Attack); + human.AddFunction(ContentKeyFunctions.WideAttack); var ghost = contexts.New("ghost", "common"); ghost.AddFunction(EngineKeyFunctions.MoveUp); diff --git a/Content.Client/UserInterface/TutorialWindow.cs b/Content.Client/UserInterface/TutorialWindow.cs index cc81193dbf..ffdfc2a2b0 100644 --- a/Content.Client/UserInterface/TutorialWindow.cs +++ b/Content.Client/UserInterface/TutorialWindow.cs @@ -73,6 +73,8 @@ Open inventory: [color=#a4885c]{7}[/color] Open character window: [color=#a4885c]{8}[/color] Open crafting window: [color=#a4885c]{9}[/color] Focus chat: [color=#a4885c]{10}[/color] +Use hand/object in hand: [color=#a4885c]{22}[/color] +Do wide attack: [color=#a4885c]{23}[/color] Use targeted entity: [color=#a4885c]{11}[/color] Throw held item: [color=#a4885c]{12}[/color] Examine entity: [color=#a4885c]{13}[/color] @@ -102,16 +104,18 @@ Toggle sandbox window: [color=#a4885c]{21}[/color]", Key(ShowDebugMonitors), Key(OpenEntitySpawnWindow), Key(OpenTileSpawnWindow), - Key(OpenSandboxWindow))); - - //Gameplay - VBox.AddChild(new Label { FontOverride = headerFont, Text = Loc.GetString("\nSandbox spawner", Key(OpenSandboxWindow)) }); - AddFormattedText(SandboxSpawnerContents); + Key(OpenSandboxWindow), + Key(Use), + Key(WideAttack))); //Gameplay VBox.AddChild(new Label { FontOverride = headerFont, Text = "\nGameplay" }); AddFormattedText(GameplayContents); + //Gameplay + VBox.AddChild(new Label { FontOverride = headerFont, Text = Loc.GetString("\nSandbox spawner", Key(OpenSandboxWindow)) }); + AddFormattedText(SandboxSpawnerContents); + //Feedback VBox.AddChild(new Label { FontOverride = headerFont, Text = "\nFeedback" }); AddFormattedText(FeedbackContents); diff --git a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs index e42c37978c..1dcf645020 100644 --- a/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/Click/InteractionSystem.cs @@ -302,8 +302,8 @@ namespace Content.Server.GameObjects.EntitySystems var inputSys = EntitySystemManager.GetEntitySystem(); inputSys.BindMap.BindFunction(EngineKeyFunctions.Use, new PointerInputCmdHandler(HandleUseItemInHand)); - inputSys.BindMap.BindFunction(ContentKeyFunctions.Attack, - new PointerInputCmdHandler(HandleAttack)); + inputSys.BindMap.BindFunction(ContentKeyFunctions.WideAttack, + new PointerInputCmdHandler(HandleWideAttack)); inputSys.BindMap.BindFunction(ContentKeyFunctions.ActivateItemInWorld, new PointerInputCmdHandler(HandleActivateItemInWorld)); } @@ -362,7 +362,7 @@ namespace Content.Server.GameObjects.EntitySystems activateComp.Activate(new ActivateEventArgs {User = user}); } - private bool HandleAttack(ICommonSession session, GridCoordinates coords, EntityUid uid) + private bool HandleWideAttack(ICommonSession session, GridCoordinates coords, EntityUid uid) { // client sanitization if (!_mapManager.GridExists(coords.GridID)) diff --git a/Content.Shared/Input/ContentKeyFunctions.cs b/Content.Shared/Input/ContentKeyFunctions.cs index a713c7db54..f2a17daa5d 100644 --- a/Content.Shared/Input/ContentKeyFunctions.cs +++ b/Content.Shared/Input/ContentKeyFunctions.cs @@ -5,8 +5,7 @@ namespace Content.Shared.Input [KeyFunctions] public static class ContentKeyFunctions { - public static readonly BoundKeyFunction UseOrAttack = "UseOrAttack"; - public static readonly BoundKeyFunction Attack = "Attack"; + public static readonly BoundKeyFunction WideAttack = "WideAttack"; public static readonly BoundKeyFunction ActivateItemInHand = "ActivateItemInHand"; public static readonly BoundKeyFunction ActivateItemInWorld = "ActivateItemInWorld"; // default action on world entity public static readonly BoundKeyFunction Drop = "Drop"; diff --git a/Resources/keybinds.yml b/Resources/keybinds.yml index 29eeb8fbc7..18e7cfc951 100644 --- a/Resources/keybinds.yml +++ b/Resources/keybinds.yml @@ -1,9 +1,12 @@ version: 1 # Not used right now, whatever. binds: -- function: UseOrAttack +- function: Use type: state key: MouseLeft canFocus: true +- function: WideAttack + type: state + key: Space - function: ShowDebugMonitors type: Toggle key: F3