Files
tbd-station-14/Content.Server/GameObjects/EntitySystems/RadioSystem.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

40 lines
1.1 KiB
C#

using Content.Server.Interfaces;
using System.Collections.Generic;
using System.Linq;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
namespace Content.Server.GameObjects.EntitySystems
{
[UsedImplicitly]
public class RadioSystem : EntitySystem
{
private List<string> _messages;
public override void Initialize()
{
base.Initialize();
_messages = new List<string>();
}
public void SpreadMessage(IRadio source, IEntity speaker, string message, int channel)
{
if (_messages.Contains(message)) return;
_messages.Add(message);
foreach (var radio in ComponentManager.EntityQuery<IRadio>(true))
{
if (radio.Channels.Contains(channel))
{
//TODO: once voice identity gets added, pass into receiver via source.GetSpeakerVoice()
radio.Receive(message, channel, speaker);
}
}
_messages.Remove(message);
}
}
}