mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-09 18:31:17 +03:00
* IoC source gen compatibility Can be merged before or after https://github.com/space-wizards/RobustToolbox/pull/6549 doesn't really matter. * Missed a spot
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 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);
|
|
}
|
|
}
|