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
37 lines
1 KiB
C#
37 lines
1 KiB
C#
using Content.Server.Objectives.Components;
|
|
using Content.Shared.Mind;
|
|
using Content.Shared.Objectives.Components;
|
|
|
|
namespace Content.Server.Objectives.Systems;
|
|
|
|
/// <summary>
|
|
/// Handles keep alive condition logic.
|
|
/// </summary>
|
|
public sealed partial class KeepAliveConditionSystem : EntitySystem
|
|
{
|
|
[Dependency] private SharedMindSystem _mind = default!;
|
|
[Dependency] private TargetObjectiveSystem _target = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<KeepAliveConditionComponent, ObjectiveGetProgressEvent>(OnGetProgress);
|
|
}
|
|
|
|
private void OnGetProgress(EntityUid uid, KeepAliveConditionComponent comp, ref ObjectiveGetProgressEvent args)
|
|
{
|
|
if (!_target.GetTarget(uid, out var target))
|
|
return;
|
|
|
|
args.Progress = GetProgress(target.Value);
|
|
}
|
|
|
|
private float GetProgress(EntityUid target)
|
|
{
|
|
if (!TryComp<MindComponent>(target, out var mind))
|
|
return 0f;
|
|
|
|
return _mind.IsCharacterDeadIc(mind) ? 0f : 1f;
|
|
}
|
|
}
|