Files
Delta-v/Content.Server/_DV/Objectives/Systems/RecruitingConditionSystem.cs
T
deltanedasanddeltanedas ec94579ebc the great namespace refactor (#2574)
* refactor DeltaV/deltav resources to _DV

* change DeltaV namespaces to _DV

* add space before all DeltaV comments

* update xamls

* fix and move arena parallax to _DV

* more fix

* refactor even more stuff

* fix the grid fills

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
2025-01-01 07:50:34 +00:00

31 lines
870 B
C#

using Content.Server.Objectives.Components;
using Content.Shared.Objectives.Components;
namespace Content.Server.Objectives.Systems;
public sealed class RecruitingConditionSystem : EntitySystem
{
[Dependency] private readonly NumberObjectiveSystem _number = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<RecruitingConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress);
}
private void OnGetProgress(Entity<RecruitingConditionComponent> ent, ref ObjectiveGetProgressEvent args)
{
args.Progress = Progress(ent.Comp.Recruited, _number.GetTarget(ent.Owner));
}
private float Progress(int recruited, int target)
{
// prevent divide-by-zero
if (target == 0)
return 1f;
return MathF.Min(recruited / (float) target, 1f);
}
}