2021-03-16 15:50:20 +01:00
|
|
|
|
using System.Collections.Generic;
|
2020-10-07 14:02:12 +02:00
|
|
|
|
using System.Linq;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Server.Radio.Components;
|
2020-10-07 14:02:12 +02:00
|
|
|
|
using JetBrains.Annotations;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-07-28 16:13:39 -06:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Server.Radio.EntitySystems
|
2020-07-28 16:13:39 -06:00
|
|
|
|
{
|
2020-10-07 14:02:12 +02:00
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
|
public class RadioSystem : EntitySystem
|
2020-07-28 16:13:39 -06:00
|
|
|
|
{
|
2021-03-16 15:50:20 +01:00
|
|
|
|
private readonly List<string> _messages = new();
|
2020-10-07 14:02:12 +02:00
|
|
|
|
|
|
|
|
|
|
public void SpreadMessage(IRadio source, IEntity speaker, string message, int channel)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_messages.Contains(message)) return;
|
2020-07-28 16:13:39 -06:00
|
|
|
|
|
|
|
|
|
|
_messages.Add(message);
|
|
|
|
|
|
|
2021-09-28 13:35:29 +02:00
|
|
|
|
foreach (var radio in EntityManager.EntityQuery<IRadio>(true))
|
2020-07-28 16:13:39 -06:00
|
|
|
|
{
|
2020-10-07 14:02:12 +02:00
|
|
|
|
if (radio.Channels.Contains(channel))
|
2020-07-28 16:13:39 -06:00
|
|
|
|
{
|
2020-10-07 14:02:12 +02:00
|
|
|
|
//TODO: once voice identity gets added, pass into receiver via source.GetSpeakerVoice()
|
|
|
|
|
|
radio.Receive(message, channel, speaker);
|
2020-07-28 16:13:39 -06:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
_messages.Remove(message);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|