mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 19:01:13 +03:00
* science explosions are projected to go up by 1% * eof * huh * review * newline * make it exclusive
41 lines
1.3 KiB
C#
41 lines
1.3 KiB
C#
using Content.Server.Objectives.Components;
|
|
using Content.Shared.Anomaly.Components;
|
|
using Content.Shared.Objectives.Components;
|
|
|
|
namespace Content.Server.Objectives.Systems;
|
|
|
|
public sealed partial class SupercriticalAnomaliesConditionSystem : EntitySystem
|
|
{
|
|
[Dependency] private readonly NumberObjectiveSystem _numberObjective = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<AnomalyShutdownEvent>(OnAnomalySupercrit);
|
|
SubscribeLocalEvent<SupercriticalAnomaliesConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress);
|
|
}
|
|
|
|
private void OnAnomalySupercrit(ref AnomalyShutdownEvent args)
|
|
{
|
|
if (!args.Supercritical)
|
|
return;
|
|
|
|
var query = EntityQueryEnumerator<SupercriticalAnomaliesConditionComponent>();
|
|
while (query.MoveNext(out var comp))
|
|
{
|
|
comp.SupercriticalAnomalies += 1;
|
|
}
|
|
}
|
|
|
|
private void OnGetProgress(Entity<SupercriticalAnomaliesConditionComponent> ent, ref ObjectiveGetProgressEvent args)
|
|
{
|
|
var target = _numberObjective.GetTarget(ent);
|
|
if (target == 0)
|
|
{
|
|
args.Progress = 0f;
|
|
return;
|
|
}
|
|
args.Progress = MathF.Min((float)ent.Comp.SupercriticalAnomalies / target, 1f);
|
|
}
|
|
}
|