Two more events (#6906)

* vent clog!

* forgot you

* Breaker flip event, to annoy engineering.

* small fix.
This commit is contained in:
Moony
2022-02-26 21:04:01 -06:00
committed by GitHub
parent 1c45674871
commit 8b2184a53c
7 changed files with 163 additions and 5 deletions

View File

@@ -0,0 +1,40 @@
using System.Linq;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using JetBrains.Annotations;
using Robust.Shared.Random;
namespace Content.Server.StationEvents.Events;
[UsedImplicitly]
public sealed class BreakerFlip : StationEvent
{
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IRobustRandom _random = default!;
public override string Name => "BreakerFlip";
public override string? StartAnnouncement =>
Loc.GetString("station-event-breaker-flip-announcement", ("data", Loc.GetString(Loc.GetString($"random-sentience-event-data-{_random.Next(1, 6)}"))));
public override float Weight => WeightNormal;
protected override float EndAfter => 1.0f;
public override int? MaxOccurrences => 5;
public override int MinimumPlayers => 15;
public override void Startup()
{
base.Startup();
var apcSys = EntitySystem.Get<ApcSystem>();
var allApcs = _entityManager.EntityQuery<ApcComponent>().ToList();
var toDisable = Math.Min(_random.Next(3, 7), allApcs.Count);
if (toDisable == 0)
return;
_random.Shuffle(allApcs);
for (var i = 0; i < toDisable; i++)
{
apcSys.ApcToggleBreaker(allApcs[i].Owner, allApcs[i]);
}
}
}

View File

@@ -0,0 +1,78 @@
using System.Linq;
using Content.Server.Atmos.Piping.Unary.Components;
using Content.Server.Chemistry.ReactionEffects;
using Content.Shared.Chemistry.Components;
using Content.Shared.Chemistry.Reagent;
using Content.Shared.Sound;
using JetBrains.Annotations;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
using Robust.Shared.Utility;
namespace Content.Server.StationEvents.Events;
[UsedImplicitly]
public sealed class VentClog : StationEvent
{
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override string Name => "VentClog";
public override string? StartAnnouncement =>
Loc.GetString("station-event-vent-clog-start-announcement");
public override string? StartAudio => "/Audio/Announcements/bloblarm.ogg";
public override int EarliestStart => 15;
public override int MinimumPlayers => 15;
public override float Weight => WeightLow;
public override int? MaxOccurrences => 2;
// Give players time to reach cover.
protected override float StartAfter => 50f;
protected override float EndAfter => 1.0f;
public readonly IReadOnlyList<string> SafeishVentChemicals = new[]
{
"Water", "Iron", "Oxygen", "Tritium", "Plasma", "SulfuricAcid", "Blood", "SpaceDrugs", "SpaceCleaner", "Flour",
"Nutriment", "Sugar", "SpaceLube", "Ethanol", "Mercury", "Ephedrine", "WeldingFuel"
};
public override void Startup()
{
base.Startup();
// TODO: "safe random" for chems. Right now this includes admin chemicals.
var allReagents = _prototypeManager.EnumeratePrototypes<ReagentPrototype>()
.Where(x => !x.Abstract)
.Select(x => x.ID).ToList();
// This is gross, but not much can be done until event refactor, which needs Dynamic.
var sound = new SoundPathSpecifier("/Audio/Effects/extinguish.ogg");
foreach (var (_, transform) in _entityManager.EntityQuery<GasVentPumpComponent, TransformComponent>())
{
var solution = new Solution();
if (_random.Prob(0.05f))
{
solution.AddReagent(_random.Pick(allReagents), 100);
}
else
{
solution.AddReagent(_random.Pick(SafeishVentChemicals), 100);
}
FoamAreaReactionEffect.SpawnFoam("Foam", transform.Coordinates, solution, _random.Next(2, 6), 20, 1,
1, sound, _entityManager);
}
}
}