Removes all dependencies on engine component events. (#4199)
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
using Content.Client.Construction;
|
||||
using Content.Client.Construction;
|
||||
using Content.Client.DragDrop;
|
||||
using Content.Shared.Input;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Input;
|
||||
@@ -66,6 +67,9 @@ namespace Content.Client.Actions
|
||||
.BindBefore(EngineKeyFunctions.Use, new PointerInputCmdHandler(TargetingOnUse),
|
||||
typeof(ConstructionSystem), typeof(DragDropSystem))
|
||||
.Register<ActionsSystem>();
|
||||
|
||||
SubscribeLocalEvent<ClientActionsComponent, PlayerAttachedEvent>((_, component, _) => component.PlayerAttached());
|
||||
SubscribeLocalEvent<ClientActionsComponent, PlayerDetachedEvent>((_, component, _) => component.PlayerDetached());
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using Content.Client.Actions.Assignments;
|
||||
using Content.Client.Actions.UI;
|
||||
using Content.Client.Hands;
|
||||
@@ -51,20 +51,6 @@ namespace Content.Client.Actions
|
||||
PlayerDetached();
|
||||
}
|
||||
|
||||
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
||||
{
|
||||
base.HandleMessage(message, component);
|
||||
switch (message)
|
||||
{
|
||||
case PlayerAttachedMsg _:
|
||||
PlayerAttached();
|
||||
break;
|
||||
case PlayerDetachedMsg _:
|
||||
PlayerDetached();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
base.HandleComponentState(curState, nextState);
|
||||
@@ -77,7 +63,7 @@ namespace Content.Client.Actions
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
private void PlayerAttached()
|
||||
public void PlayerAttached()
|
||||
{
|
||||
if (!CurrentlyControlled || _ui != null)
|
||||
{
|
||||
@@ -89,7 +75,7 @@ namespace Content.Client.Actions
|
||||
UpdateUI();
|
||||
}
|
||||
|
||||
private void PlayerDetached()
|
||||
public void PlayerDetached()
|
||||
{
|
||||
if (_ui == null) return;
|
||||
IoCManager.Resolve<IUserInterfaceManager>().StateRoot.RemoveChild(_ui);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Client.Alerts.UI;
|
||||
using Content.Shared.Alert;
|
||||
@@ -41,20 +41,6 @@ namespace Content.Client.Alerts
|
||||
PlayerDetached();
|
||||
}
|
||||
|
||||
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
||||
{
|
||||
base.HandleMessage(message, component);
|
||||
switch (message)
|
||||
{
|
||||
case PlayerAttachedMsg _:
|
||||
PlayerAttached();
|
||||
break;
|
||||
case PlayerDetachedMsg _:
|
||||
PlayerDetached();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public override void HandleComponentState(ComponentState? curState, ComponentState? nextState)
|
||||
{
|
||||
base.HandleComponentState(curState, nextState);
|
||||
@@ -67,7 +53,7 @@ namespace Content.Client.Alerts
|
||||
UpdateAlertsControls();
|
||||
}
|
||||
|
||||
private void PlayerAttached()
|
||||
public void PlayerAttached()
|
||||
{
|
||||
if (!CurrentlyControlled || _ui != null)
|
||||
{
|
||||
@@ -86,7 +72,7 @@ namespace Content.Client.Alerts
|
||||
UpdateAlertsControls();
|
||||
}
|
||||
|
||||
private void PlayerDetached()
|
||||
public void PlayerDetached()
|
||||
{
|
||||
foreach (var alertControl in _alertControls.Values)
|
||||
{
|
||||
|
||||
16
Content.Client/Alerts/ClientAlertsSystem.cs
Normal file
16
Content.Client/Alerts/ClientAlertsSystem.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Alerts
|
||||
{
|
||||
internal class ClientAlertsSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<ClientAlertsComponent, PlayerAttachedEvent>((_, component, _) => component.PlayerAttached());
|
||||
SubscribeLocalEvent<ClientAlertsComponent, PlayerDetachedEvent>((_, component, _) => component.PlayerDetached());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,39 +76,32 @@ namespace Content.Client.CharacterInterface
|
||||
inputMgr.SetInputCommand(ContentKeyFunctions.OpenCharacterMenu, null);
|
||||
}
|
||||
|
||||
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
||||
public void PlayerDetached()
|
||||
{
|
||||
base.HandleMessage(message, component);
|
||||
|
||||
switch (message)
|
||||
if (Window != null)
|
||||
{
|
||||
case PlayerAttachedMsg _:
|
||||
if (Window != null)
|
||||
_gameHud.CharacterButtonVisible = false;
|
||||
Window.Close();
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayerAttached()
|
||||
{
|
||||
if (Window != null)
|
||||
{
|
||||
_gameHud.CharacterButtonVisible = true;
|
||||
|
||||
_gameHud.CharacterButtonToggled = b =>
|
||||
{
|
||||
if (b)
|
||||
{
|
||||
_gameHud.CharacterButtonVisible = true;
|
||||
_gameHud.CharacterButtonToggled = b =>
|
||||
{
|
||||
if (b)
|
||||
{
|
||||
Window.OpenCentered();
|
||||
}
|
||||
else
|
||||
{
|
||||
Window.Close();
|
||||
}
|
||||
};
|
||||
Window.OpenCentered();
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case PlayerDetachedMsg _:
|
||||
if (Window != null)
|
||||
else
|
||||
{
|
||||
_gameHud.CharacterButtonVisible = false;
|
||||
Window.Close();
|
||||
}
|
||||
|
||||
break;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Client.HUD;
|
||||
using Content.Shared.Input;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -23,6 +24,9 @@ namespace Content.Client.CharacterInterface
|
||||
.Bind(ContentKeyFunctions.OpenCharacterMenu,
|
||||
InputCmdHandler.FromDelegate(s => HandleOpenCharacterMenu()))
|
||||
.Register<CharacterInterfaceSystem>();
|
||||
|
||||
SubscribeLocalEvent<CharacterInterfaceComponent, PlayerAttachedEvent>((_, component, _) => component.PlayerAttached());
|
||||
SubscribeLocalEvent<CharacterInterfaceComponent, PlayerDetachedEvent>((_, component, _) => component.PlayerDetached());
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Client.HUD;
|
||||
using Content.Client.HUD;
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Targeting;
|
||||
using Robust.Client.GameObjects;
|
||||
@@ -35,21 +35,12 @@ namespace Content.Client.CombatMode
|
||||
}
|
||||
}
|
||||
|
||||
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
||||
public void PlayerDetached() { _gameHud.CombatPanelVisible = false; }
|
||||
|
||||
public void PlayerAttached()
|
||||
{
|
||||
base.HandleMessage(message, component);
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case PlayerAttachedMsg _:
|
||||
_gameHud.CombatPanelVisible = true;
|
||||
UpdateHud();
|
||||
break;
|
||||
|
||||
case PlayerDetachedMsg _:
|
||||
_gameHud.CombatPanelVisible = false;
|
||||
break;
|
||||
}
|
||||
_gameHud.CombatPanelVisible = true;
|
||||
UpdateHud();
|
||||
}
|
||||
|
||||
private void UpdateHud()
|
||||
|
||||
@@ -20,6 +20,9 @@ namespace Content.Client.CombatMode
|
||||
base.Initialize();
|
||||
|
||||
_gameHud.OnTargetingZoneChanged = OnTargetingZoneChanged;
|
||||
|
||||
SubscribeLocalEvent<CombatModeComponent, PlayerAttachedEvent>((_, component, _) => component.PlayerAttached());
|
||||
SubscribeLocalEvent<CombatModeComponent, PlayerDetachedEvent>((_, component, _) => component.PlayerDetached());
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
|
||||
@@ -210,22 +210,6 @@ namespace Content.Client.Hands
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case PlayerAttachedMsg _:
|
||||
if (_gui == null)
|
||||
{
|
||||
_gui = new HandsGui();
|
||||
}
|
||||
else
|
||||
{
|
||||
_gui.Parent?.RemoveChild(_gui);
|
||||
}
|
||||
|
||||
_gameHud.HandsContainer.AddChild(_gui);
|
||||
_gui.UpdateHandIcons();
|
||||
break;
|
||||
case PlayerDetachedMsg _:
|
||||
_gui?.Parent?.RemoveChild(_gui);
|
||||
break;
|
||||
case HandEnabledMsg msg:
|
||||
{
|
||||
var hand = GetHand(msg.Name);
|
||||
@@ -255,6 +239,23 @@ namespace Content.Client.Hands
|
||||
}
|
||||
}
|
||||
|
||||
public void PlayerDetached() { _gui?.Parent?.RemoveChild(_gui); }
|
||||
|
||||
public void PlayerAttached()
|
||||
{
|
||||
if (_gui == null)
|
||||
{
|
||||
_gui = new HandsGui();
|
||||
}
|
||||
else
|
||||
{
|
||||
_gui.Parent?.RemoveChild(_gui);
|
||||
}
|
||||
|
||||
_gameHud.HandsContainer.AddChild(_gui);
|
||||
_gui.UpdateHandIcons();
|
||||
}
|
||||
|
||||
public override void HandleNetworkMessage(ComponentMessage message, INetChannel netChannel, ICommonSession? session = null)
|
||||
{
|
||||
base.HandleNetworkMessage(message, netChannel, session);
|
||||
|
||||
16
Content.Client/Hands/HandsSystem.cs
Normal file
16
Content.Client/Hands/HandsSystem.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Hands
|
||||
{
|
||||
internal class HandsSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<HandsComponent, PlayerAttachedEvent>((_, component, _) => component.PlayerAttached());
|
||||
SubscribeLocalEvent<HandsComponent, PlayerDetachedEvent>((_, component, _) => component.PlayerDetached());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Linq;
|
||||
using Content.Client.Clothing;
|
||||
@@ -252,22 +252,16 @@ namespace Content.Client.Inventory
|
||||
SendNetworkMessage(new OpenSlotStorageUIMessage(slot));
|
||||
}
|
||||
|
||||
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
||||
public void PlayerDetached()
|
||||
{
|
||||
base.HandleMessage(message, component);
|
||||
InterfaceController.PlayerDetached();
|
||||
_playerAttached = false;
|
||||
}
|
||||
|
||||
switch (message)
|
||||
{
|
||||
case PlayerAttachedMsg _:
|
||||
InterfaceController.PlayerAttached();
|
||||
_playerAttached = true;
|
||||
break;
|
||||
|
||||
case PlayerDetachedMsg _:
|
||||
InterfaceController.PlayerDetached();
|
||||
_playerAttached = false;
|
||||
break;
|
||||
}
|
||||
public void PlayerAttached()
|
||||
{
|
||||
InterfaceController.PlayerAttached();
|
||||
_playerAttached = true;
|
||||
}
|
||||
|
||||
public bool TryGetSlot(Slots slot, [NotNullWhen(true)] out IEntity? item)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
using Content.Client.HUD;
|
||||
using Content.Shared.Input;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -12,7 +12,6 @@ namespace Content.Client.Inventory
|
||||
public sealed class ClientInventorySystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IGameHud _gameHud = default!;
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -22,6 +21,9 @@ namespace Content.Client.Inventory
|
||||
.Bind(ContentKeyFunctions.OpenInventoryMenu,
|
||||
InputCmdHandler.FromDelegate(_ => HandleOpenInventoryMenu()))
|
||||
.Register<ClientInventorySystem>();
|
||||
|
||||
SubscribeLocalEvent<ClientInventoryComponent, PlayerAttachedEvent>((_, component, _) => component.PlayerAttached());
|
||||
SubscribeLocalEvent<ClientInventoryComponent, PlayerDetachedEvent>((_, component, _) => component.PlayerDetached());
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
|
||||
@@ -102,35 +102,29 @@ namespace Content.Client.Suspicion
|
||||
Allies.AddRange(state.Allies);
|
||||
}
|
||||
|
||||
public override void HandleMessage(ComponentMessage message, IComponent? component)
|
||||
public void PlayerDetached()
|
||||
{
|
||||
base.HandleMessage(message, component);
|
||||
_gui?.Parent?.RemoveChild(_gui);
|
||||
RemoveTraitorOverlay();
|
||||
}
|
||||
|
||||
switch (message)
|
||||
public void PlayerAttached()
|
||||
{
|
||||
if (_gui == null)
|
||||
{
|
||||
case PlayerAttachedMsg _:
|
||||
if (_gui == null)
|
||||
{
|
||||
_gui = new SuspicionGui();
|
||||
}
|
||||
else
|
||||
{
|
||||
_gui.Parent?.RemoveChild(_gui);
|
||||
}
|
||||
_gui = new SuspicionGui();
|
||||
}
|
||||
else
|
||||
{
|
||||
_gui.Parent?.RemoveChild(_gui);
|
||||
}
|
||||
|
||||
_gameHud.SuspicionContainer.AddChild(_gui);
|
||||
_gui.UpdateLabel();
|
||||
_gameHud.SuspicionContainer.AddChild(_gui);
|
||||
_gui.UpdateLabel();
|
||||
|
||||
if (_antagonist ?? false)
|
||||
{
|
||||
AddTraitorOverlay();
|
||||
}
|
||||
|
||||
break;
|
||||
case PlayerDetachedMsg _:
|
||||
_gui?.Parent?.RemoveChild(_gui);
|
||||
RemoveTraitorOverlay();
|
||||
break;
|
||||
if (_antagonist ?? false)
|
||||
{
|
||||
AddTraitorOverlay();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
16
Content.Client/Suspicion/SuspicionRoleSystem.cs
Normal file
16
Content.Client/Suspicion/SuspicionRoleSystem.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.Suspicion
|
||||
{
|
||||
class SuspicionRoleSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<SuspicionRoleComponent, PlayerAttachedEvent>((_, component, _) => component.PlayerAttached());
|
||||
SubscribeLocalEvent<SuspicionRoleComponent, PlayerDetachedEvent>((_, component, _) => component.PlayerDetached());
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user