From 32b6ca08a0256ce2662865e94b5fbba0207f1036 Mon Sep 17 00:00:00 2001 From: Aviu00 <93730715+Aviu00@users.noreply.github.com> Date: Mon, 14 Aug 2023 15:48:26 +0300 Subject: [PATCH] Fix combat mode outline (#301) --- .../Outline/InteractionOutlineSystem.cs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Content.Client/Outline/InteractionOutlineSystem.cs b/Content.Client/Outline/InteractionOutlineSystem.cs index bb341785d0..891a1a0181 100644 --- a/Content.Client/Outline/InteractionOutlineSystem.cs +++ b/Content.Client/Outline/InteractionOutlineSystem.cs @@ -3,7 +3,9 @@ using Content.Client.Gameplay; using Content.Client.Interactable.Components; using Content.Client.Viewport; using Content.Shared.CCVar; +using Content.Shared.CombatMode; using Content.Shared.Interaction; +using Content.Shared.Weapons.Melee; using Robust.Client.Graphics; using Robust.Client.Input; using Robust.Client.Player; @@ -23,6 +25,8 @@ public sealed class InteractionOutlineSystem : EntitySystem [Dependency] private readonly IStateManager _stateManager = default!; [Dependency] private readonly IUserInterfaceManager _uiManager = default!; [Dependency] private readonly SharedInteractionSystem _interactionSystem = default!; + [Dependency] private readonly SharedCombatModeSystem _combatMode = default!; // WD + [Dependency] private readonly SharedMeleeWeaponSystem _meleeWeapon = default!; // WD /// /// Whether to currently draw the outline. The outline may be temporarily disabled by other systems @@ -138,6 +142,18 @@ public sealed class InteractionOutlineSystem : EntitySystem if (localPlayer.ControlledEntity != null && !Deleted(entityToClick)) { inRange = _interactionSystem.InRangeUnobstructed(localPlayer.ControlledEntity.Value, entityToClick.Value); + + // WD START + if (_combatMode.IsInCombatMode(localPlayer.ControlledEntity) && + (_meleeWeapon.TryGetWeapon(localPlayer.ControlledEntity.Value, out _, out var weapon) || + TryComp(localPlayer.ControlledEntity, out weapon))) + { + var mousePos = _eyeManager.ScreenToMap(_inputManager.MouseScreenPosition); + var userPos = Transform(localPlayer.ControlledEntity.Value).MapPosition; + + if (mousePos.MapId != userPos.MapId || (userPos.Position - mousePos.Position).Length() > weapon.Range) + inRange = false; + } // WD END } InteractionOutlineComponent? outline;