mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-01 00:27:59 +00:00
* 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>
31 lines
870 B
C#
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);
|
|
}
|
|
}
|