Removes all dependencies on engine component events. (#4199)
This commit is contained in:
@@ -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