Remove combat mode component reference (#15206)

This commit is contained in:
DrSmugleaf
2023-04-08 13:16:48 -07:00
committed by GitHub
parent b4164e62b1
commit 34bcd042d1
29 changed files with 126 additions and 159 deletions

View File

@@ -1,8 +1,10 @@
using System.Threading;
using Content.Client.CombatMode;
using Content.Client.Gameplay;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controllers;
using Timer = Robust.Shared.Timing.Timer;
namespace Content.Client.ContextMenu.UI
{
/// <summary>
@@ -13,7 +15,7 @@ namespace Content.Client.ContextMenu.UI
/// <remarks>
/// This largely involves setting up timers to open and close sub-menus when hovering over other menu elements.
/// </remarks>
public sealed class ContextMenuUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>
public sealed class ContextMenuUIController : UIController, IOnStateEntered<GameplayState>, IOnStateExited<GameplayState>, IOnSystemChanged<CombatModeSystem>
{
public static readonly TimeSpan HoverDelay = TimeSpan.FromSeconds(0.2);
@@ -206,5 +208,20 @@ namespace Content.Client.ContextMenu.UI
menu.InvalidateMeasure();
}
private void OnCombatModeUpdated()
{
Close();
}
public void OnSystemLoaded(CombatModeSystem system)
{
system.LocalPlayerCombatModeUpdated += OnCombatModeUpdated;
}
public void OnSystemUnloaded(CombatModeSystem system)
{
system.LocalPlayerCombatModeUpdated -= OnCombatModeUpdated;
}
}
}