Removes all dependencies on engine component events. (#4199)

This commit is contained in:
Acruid
2021-06-18 01:49:18 -07:00
committed by GitHub
parent 9fea68707c
commit e1e54e9cb1
27 changed files with 235 additions and 184 deletions

View File

@@ -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();
}
}

View 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());
}
}
}