Convert sus events to eventbus (#5044)

This commit is contained in:
metalgearsloth
2021-10-27 19:53:10 +11:00
committed by GitHub
parent 3b508b041b
commit a12eb29464
8 changed files with 41 additions and 40 deletions

View File

@@ -1,4 +1,6 @@
using System.Collections.Generic;
using Content.Server.Roles;
using Content.Server.Suspicion.Roles;
using Content.Shared.GameTicking;
using JetBrains.Annotations;
using Robust.Server.GameObjects;
@@ -20,20 +22,34 @@ namespace Content.Server.Suspicion.EntitySystems
base.Initialize();
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
SubscribeLocalEvent<SuspicionRoleComponent, PlayerAttachedEvent>((HandlePlayerAttached));
SubscribeLocalEvent<SuspicionRoleComponent, PlayerDetachedEvent>((HandlePlayerDetached));
SubscribeLocalEvent<SuspicionRoleComponent, PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<SuspicionRoleComponent, PlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<SuspicionRoleComponent, RoleAddedEvent>(OnRoleAdded);
SubscribeLocalEvent<SuspicionRoleComponent, RoleRemovedEvent>(OnRoleRemoved);
}
private void HandlePlayerDetached(EntityUid uid, SuspicionRoleComponent component, PlayerDetachedEvent args)
private void OnPlayerDetached(EntityUid uid, SuspicionRoleComponent component, PlayerDetachedEvent args)
{
component.SyncRoles();
}
private void HandlePlayerAttached(EntityUid uid, SuspicionRoleComponent component, PlayerAttachedEvent args)
private void OnPlayerAttached(EntityUid uid, SuspicionRoleComponent component, PlayerAttachedEvent args)
{
component.SyncRoles();
}
private void OnRoleAdded(EntityUid uid, SuspicionRoleComponent component, RoleAddedEvent args)
{
if (args.Role is not SuspicionRole role) return;
component.Role = role;
}
private void OnRoleRemoved(EntityUid uid, SuspicionRoleComponent component, RoleRemovedEvent args)
{
if (args.Role is not SuspicionRole) return;
component.Role = null;
}
#endregion
public void AddTraitor(SuspicionRoleComponent role)