Files
tbd-station-14/Content.Server/GameObjects/EntitySystems/SuspicionRoleSystem.cs
DrSmugleaf 5c0cf1b1a0 Use 'new' expression in places where the type is evident for content (#2590)
* Content.Client

* Content.Benchmarks

* Content.IntegrationTests

* Content.Server

* Content.Server.Database

* Content.Shared

* Content.Tests

* Merge fixes

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
2020-11-27 21:00:49 +11:00

52 lines
1.2 KiB
C#

using System.Collections.Generic;
using Content.Server.GameObjects.Components.Suspicion;
using JetBrains.Annotations;
using Robust.Shared.GameObjects.Systems;
namespace Content.Server.GameObjects.EntitySystems
{
[UsedImplicitly]
public class SuspicionRoleSystem : EntitySystem
{
private readonly HashSet<SuspicionRoleComponent> _traitors = new();
public IReadOnlyCollection<SuspicionRoleComponent> Traitors => _traitors;
public void AddTraitor(SuspicionRoleComponent role)
{
if (!_traitors.Add(role))
{
return;
}
foreach (var traitor in _traitors)
{
traitor.AddAlly(role);
}
role.SetAllies(_traitors);
}
public void RemoveTraitor(SuspicionRoleComponent role)
{
if (!_traitors.Remove(role))
{
return;
}
foreach (var traitor in _traitors)
{
traitor.RemoveAlly(role);
}
role.ClearAllies();
}
public override void Shutdown()
{
_traitors.Clear();
base.Shutdown();
}
}
}