Fix combat mode context menu (#19743)
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using Content.Client.Hands.Systems;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Targeting;
|
||||
using Content.Shared.CCVar;
|
||||
@@ -17,30 +18,29 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
[Dependency] private readonly IInputManager _inputManager = default!;
|
||||
[Dependency] private readonly IEyeManager _eye = default!;
|
||||
public event Action? LocalPlayerCombatModeUpdated;
|
||||
|
||||
/// <summary>
|
||||
/// Raised whenever combat mode changes.
|
||||
/// </summary>
|
||||
public event Action<bool>? LocalPlayerCombatModeUpdated;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<CombatModeComponent, ComponentHandleState>(OnHandleState);
|
||||
SubscribeLocalEvent<CombatModeComponent, AfterAutoHandleStateEvent>(OnHandleState);
|
||||
|
||||
_cfg.OnValueChanged(CCVars.CombatModeIndicatorsPointShow, OnShowCombatIndicatorsChanged, true);
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, CombatModeComponent component, ref ComponentHandleState args)
|
||||
private void OnHandleState(EntityUid uid, CombatModeComponent component, ref AfterAutoHandleStateEvent args)
|
||||
{
|
||||
if (args.Current is not CombatModeComponentState state)
|
||||
return;
|
||||
|
||||
component.IsInCombatMode = state.IsInCombatMode;
|
||||
component.ActiveZone = state.TargetingZone;
|
||||
UpdateHud(uid);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
{
|
||||
_cfg.OnValueChanged(CCVars.CombatModeIndicatorsPointShow, OnShowCombatIndicatorsChanged);
|
||||
_cfg.UnsubValueChanged(CCVars.CombatModeIndicatorsPointShow, OnShowCombatIndicatorsChanged);
|
||||
_overlayManager.RemoveOverlay<CombatModeIndicatorsOverlay>();
|
||||
|
||||
base.Shutdown();
|
||||
@@ -61,9 +61,9 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
|
||||
return IsInCombatMode(entity.Value);
|
||||
}
|
||||
|
||||
public override void SetInCombatMode(EntityUid entity, bool inCombatMode, CombatModeComponent? component = null)
|
||||
public override void SetInCombatMode(EntityUid entity, bool value, CombatModeComponent? component = null)
|
||||
{
|
||||
base.SetInCombatMode(entity, inCombatMode, component);
|
||||
base.SetInCombatMode(entity, value, component);
|
||||
UpdateHud(entity);
|
||||
}
|
||||
|
||||
@@ -75,12 +75,13 @@ public sealed class CombatModeSystem : SharedCombatModeSystem
|
||||
|
||||
private void UpdateHud(EntityUid entity)
|
||||
{
|
||||
if (entity != _playerManager.LocalPlayer?.ControlledEntity)
|
||||
if (entity != _playerManager.LocalPlayer?.ControlledEntity || !Timing.IsFirstTimePredicted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
LocalPlayerCombatModeUpdated?.Invoke();
|
||||
var inCombatMode = IsInCombatMode();
|
||||
LocalPlayerCombatModeUpdated?.Invoke(inCombatMode);
|
||||
}
|
||||
|
||||
private void OnShowCombatIndicatorsChanged(bool isShow)
|
||||
|
||||
Reference in New Issue
Block a user