2020-08-13 14:40:27 +02:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using Content.Server.GameObjects.Components;
|
2020-07-28 16:13:39 -06:00
|
|
|
|
using Robust.Shared.GameObjects.Systems;
|
|
|
|
|
|
using Robust.Shared.Interfaces.GameObjects;
|
|
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.GameObjects.EntitySystems
|
|
|
|
|
|
{
|
2020-08-13 22:17:12 +10:00
|
|
|
|
internal sealed class RadioSystem : EntitySystem
|
2020-07-28 16:13:39 -06:00
|
|
|
|
{
|
2020-08-13 22:17:12 +10:00
|
|
|
|
private readonly List<string> _messages = new List<string>();
|
2020-07-28 16:13:39 -06:00
|
|
|
|
|
|
|
|
|
|
public void SpreadMessage(IEntity source, string message)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_messages.Contains(message))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_messages.Add(message);
|
|
|
|
|
|
|
2020-08-13 22:17:12 +10:00
|
|
|
|
foreach (var radio in ComponentManager.EntityQuery<RadioComponent>())
|
2020-07-28 16:13:39 -06:00
|
|
|
|
{
|
2020-08-13 22:17:12 +10:00
|
|
|
|
if (radio.Owner == source || !radio.RadioOn)
|
2020-07-28 16:13:39 -06:00
|
|
|
|
{
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
radio.Speaker(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_messages.Remove(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|