Communications Console: The ECSining (#8374)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Chat;
|
||||
using Content.Server.Disease.Components;
|
||||
using Content.Server.Disease;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.Disease;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Sound;
|
||||
@@ -17,7 +18,6 @@ public sealed class DiseaseOutbreak : StationEvent
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||
|
||||
/// <summary>
|
||||
/// Disease prototypes I decided were not too deadly for a random event
|
||||
@@ -36,6 +36,7 @@ public sealed class DiseaseOutbreak : StationEvent
|
||||
|
||||
public override SoundSpecifier? StartAudio => new SoundPathSpecifier("/Audio/Announcements/outbreak7.ogg");
|
||||
protected override float EndAfter => 1.0f;
|
||||
|
||||
/// <summary>
|
||||
/// Finds 2-5 random, alive entities that can host diseases
|
||||
/// and gives them a randomly selected disease.
|
||||
@@ -44,6 +45,7 @@ public sealed class DiseaseOutbreak : StationEvent
|
||||
public override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
HashSet<EntityUid> stationsToNotify = new();
|
||||
List<DiseaseCarrierComponent> aliveList = new();
|
||||
foreach (var (carrier, mobState) in _entityManager.EntityQuery<DiseaseCarrierComponent, MobStateComponent>())
|
||||
{
|
||||
@@ -61,15 +63,25 @@ public sealed class DiseaseOutbreak : StationEvent
|
||||
return;
|
||||
|
||||
var diseaseSystem = EntitySystem.Get<DiseaseSystem>();
|
||||
/// Now we give it to people in the list of living disease carriers earlier
|
||||
var stationSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<StationSystem>();
|
||||
var chatSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>();
|
||||
// Now we give it to people in the list of living disease carriers earlier
|
||||
foreach (var target in aliveList)
|
||||
{
|
||||
if (toInfect-- == 0)
|
||||
break;
|
||||
|
||||
diseaseSystem.TryAddDisease(target.Owner, disease, target);
|
||||
|
||||
var station = stationSystem.GetOwningStation(target.Owner);
|
||||
if(station == null) continue;
|
||||
stationsToNotify.Add((EntityUid) station);
|
||||
}
|
||||
|
||||
foreach (var station in stationsToNotify)
|
||||
{
|
||||
chatSystem.DispatchStationAnnouncement(station, Loc.GetString("station-event-disease-outbreak-announcement"),
|
||||
playDefaultSound: false, colorOverride: Color.YellowGreen);
|
||||
}
|
||||
_chatManager.DispatchStationAnnouncement(Loc.GetString("station-event-disease-outbreak-announcement"),
|
||||
playDefaultSound: false, colorOverride: Color.YellowGreen);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Chat;
|
||||
using Content.Server.Ghost.Roles.Components;
|
||||
using Content.Server.Mind.Commands;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Server.StationEvents.Components;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
@@ -11,7 +12,6 @@ public sealed class RandomSentience : StationEvent
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||
|
||||
public override string Name => "RandomSentience";
|
||||
|
||||
@@ -22,6 +22,7 @@ public sealed class RandomSentience : StationEvent
|
||||
public override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
HashSet<EntityUid> stationsToNotify = new();
|
||||
|
||||
var targetList = _entityManager.EntityQuery<SentienceTargetComponent>().ToList();
|
||||
_random.Shuffle(targetList);
|
||||
@@ -49,13 +50,26 @@ public sealed class RandomSentience : StationEvent
|
||||
var kind1 = groupList.Count > 0 ? groupList[0] : "???";
|
||||
var kind2 = groupList.Count > 1 ? groupList[1] : "???";
|
||||
var kind3 = groupList.Count > 2 ? groupList[2] : "???";
|
||||
_chatManager.DispatchStationAnnouncement(
|
||||
Loc.GetString("station-event-random-sentience-announcement",
|
||||
("kind1", kind1), ("kind2", kind2), ("kind3", kind3), ("amount", groupList.Count),
|
||||
("data", Loc.GetString($"random-sentience-event-data-{_random.Next(1, 6)}")),
|
||||
("strength", Loc.GetString($"random-sentience-event-strength-{_random.Next(1, 8)}"))),
|
||||
|
||||
var stationSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<StationSystem>();
|
||||
var chatSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>();
|
||||
foreach (var target in targetList)
|
||||
{
|
||||
var station = stationSystem.GetOwningStation(target.Owner);
|
||||
if(station == null) continue;
|
||||
stationsToNotify.Add((EntityUid) station);
|
||||
}
|
||||
foreach (var station in stationsToNotify)
|
||||
{
|
||||
chatSystem.DispatchStationAnnouncement(
|
||||
(EntityUid) station,
|
||||
Loc.GetString("station-event-random-sentience-announcement",
|
||||
("kind1", kind1), ("kind2", kind2), ("kind3", kind3), ("amount", groupList.Count),
|
||||
("data", Loc.GetString($"random-sentience-event-data-{_random.Next(1, 6)}")),
|
||||
("strength", Loc.GetString($"random-sentience-event-strength-{_random.Next(1, 8)}"))),
|
||||
playDefaultSound: false,
|
||||
colorOverride: Color.Gold
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Content.Server.Administration.Logs;
|
||||
using Content.Server.Atmos.EntitySystems;
|
||||
using Content.Server.Chat;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.GameTicking;
|
||||
using Content.Server.Station.Components;
|
||||
@@ -140,8 +141,8 @@ namespace Content.Server.StationEvents.Events
|
||||
|
||||
if (StartAnnouncement != null)
|
||||
{
|
||||
var chatManager = IoCManager.Resolve<IChatManager>();
|
||||
chatManager.DispatchStationAnnouncement(StartAnnouncement, playDefaultSound: false, colorOverride: Color.Gold);
|
||||
var chatSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>();
|
||||
chatSystem.DispatchGlobalStationAnnouncement(StartAnnouncement, playDefaultSound: false, colorOverride: Color.Gold);
|
||||
}
|
||||
|
||||
if (StartAudio != null)
|
||||
@@ -163,8 +164,8 @@ namespace Content.Server.StationEvents.Events
|
||||
|
||||
if (EndAnnouncement != null)
|
||||
{
|
||||
var chatManager = IoCManager.Resolve<IChatManager>();
|
||||
chatManager.DispatchStationAnnouncement(EndAnnouncement, playDefaultSound: false, colorOverride: Color.Gold);
|
||||
var chatSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>();
|
||||
chatSystem.DispatchGlobalStationAnnouncement(EndAnnouncement, playDefaultSound: false, colorOverride: Color.Gold);
|
||||
}
|
||||
|
||||
if (EndAudio != null)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using Content.Server.Chat;
|
||||
using Robust.Shared.Random;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.Disease.Zombie.Components;
|
||||
using Content.Server.Station.Systems;
|
||||
using Content.Shared.MobState.Components;
|
||||
using Content.Shared.Sound;
|
||||
|
||||
@@ -13,7 +14,6 @@ namespace Content.Server.StationEvents.Events
|
||||
{
|
||||
[Dependency] private readonly IRobustRandom _random = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||
|
||||
public override string Name => "ZombieOutbreak";
|
||||
public override int EarliestStart => 50;
|
||||
@@ -31,6 +31,7 @@ namespace Content.Server.StationEvents.Events
|
||||
public override void Startup()
|
||||
{
|
||||
base.Startup();
|
||||
HashSet<EntityUid> stationsToNotify = new();
|
||||
List<MobStateComponent> deadList = new();
|
||||
foreach (var mobState in _entityManager.EntityQuery<MobStateComponent>())
|
||||
{
|
||||
@@ -41,16 +42,25 @@ namespace Content.Server.StationEvents.Events
|
||||
|
||||
var toInfect = _random.Next(1, 3);
|
||||
|
||||
/// Now we give it to people in the list of dead entities earlier.
|
||||
// Now we give it to people in the list of dead entities earlier.
|
||||
var stationSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<StationSystem>();
|
||||
var chatSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>();
|
||||
foreach (var target in deadList)
|
||||
{
|
||||
if (toInfect-- == 0)
|
||||
break;
|
||||
|
||||
_entityManager.EnsureComponent<DiseaseZombieComponent>(target.Owner);
|
||||
|
||||
var station = stationSystem.GetOwningStation(target.Owner);
|
||||
if(station == null) continue;
|
||||
stationsToNotify.Add((EntityUid) station);
|
||||
}
|
||||
foreach (var station in stationsToNotify)
|
||||
{
|
||||
chatSystem.DispatchStationAnnouncement((EntityUid) station, Loc.GetString("station-event-zombie-outbreak-announcement"),
|
||||
playDefaultSound: false, colorOverride: Color.DarkMagenta);
|
||||
}
|
||||
_chatManager.DispatchStationAnnouncement(Loc.GetString("station-event-zombie-outbreak-announcement"),
|
||||
playDefaultSound: false, colorOverride: Color.DarkMagenta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user