* Add department-specific radio channels
This commit adds working department-specific radio channels, while
minimizing damage to the current codebase. It is expected that a future
refactor will clean this up a bit.
ChatSystem now has a RadioPrefix() method that recognizes
department-specific channels (e.g. ":e" and ":m") in addition to the
global channel (";"). It strips the prefix from the message and assigns
messages an integer representing the destination channel, if any.
IListen and IRadio now accept optional 'channel' arguments with this
channel in mind.
The ugly is that the integer channel number is hard-coded and also shows
up in chat.
Comms are not modeled at this time. You cannot break comms (yet).
All headsets have channels soldered into them. You cannot change
encryption keys to hop on new channels. Steal a headset instead.
* Remove debugging print
* Convert to prototypes
* Use prototype names in headset prototype
* Adjust list style
* Document prototype fields
* cringe
* some cleanup
* colours
* Remove alphas at least
* cc
Co-authored-by: Kevin Zheng <kevinz5000@gmail.com>
75 lines
2.8 KiB
C#
75 lines
2.8 KiB
C#
using Content.Server.Chat;
|
|
using Robust.Shared.Random;
|
|
using Content.Server.Chat.Managers;
|
|
using Content.Server.Chat.Systems;
|
|
using Content.Server.Station.Systems;
|
|
using Content.Shared.MobState.Components;
|
|
using Content.Shared.Sound;
|
|
using Content.Server.Zombies;
|
|
|
|
namespace Content.Server.StationEvents.Events
|
|
{
|
|
/// <summary>
|
|
/// Revives several dead entities as zombies
|
|
/// </summary>
|
|
public sealed class ZombieOutbreak : StationEvent
|
|
{
|
|
[Dependency] private readonly IRobustRandom _random = default!;
|
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
|
|
|
public override string Name => "ZombieOutbreak";
|
|
public override int EarliestStart => 50;
|
|
public override float Weight => WeightLow / 2;
|
|
public override SoundSpecifier? StartAudio => new SoundPathSpecifier("/Audio/Announcements/bloblarm.ogg");
|
|
protected override float EndAfter => 1.0f;
|
|
public override int? MaxOccurrences => 1;
|
|
public override bool AnnounceEvent => false;
|
|
|
|
/// <summary>
|
|
/// Finds 1-3 random, dead entities accross the station
|
|
/// and turns them into zombies.
|
|
/// </summary>
|
|
public override void Startup()
|
|
{
|
|
base.Startup();
|
|
HashSet<EntityUid> stationsToNotify = new();
|
|
List<MobStateComponent> deadList = new();
|
|
foreach (var mobState in _entityManager.EntityQuery<MobStateComponent>())
|
|
{
|
|
if (mobState.IsDead() || mobState.IsCritical())
|
|
deadList.Add(mobState);
|
|
}
|
|
_random.Shuffle(deadList);
|
|
|
|
var toInfect = _random.Next(1, 3);
|
|
|
|
var zombifysys = _entityManager.EntitySysManager.GetEntitySystem<ZombifyOnDeathSystem>();
|
|
|
|
// Now we give it to people in the list of dead entities earlier.
|
|
var entSysMgr = IoCManager.Resolve<IEntitySystemManager>();
|
|
var stationSystem = entSysMgr.GetEntitySystem<StationSystem>();
|
|
var chatSystem = entSysMgr.GetEntitySystem<ChatSystem>();
|
|
|
|
foreach (var target in deadList)
|
|
{
|
|
if (toInfect-- == 0)
|
|
break;
|
|
|
|
zombifysys.ZombifyEntity(target.Owner);
|
|
|
|
var station = stationSystem.GetOwningStation(target.Owner);
|
|
if(station == null) continue;
|
|
stationsToNotify.Add((EntityUid) station);
|
|
}
|
|
|
|
if (!AnnounceEvent)
|
|
return;
|
|
foreach (var station in stationsToNotify)
|
|
{
|
|
chatSystem.DispatchStationAnnouncement((EntityUid) station, Loc.GetString("station-event-zombie-outbreak-announcement"),
|
|
playDefaultSound: false, colorOverride: Color.DarkMagenta);
|
|
}
|
|
}
|
|
}
|
|
}
|