Skip to content

Commit

Permalink
made it so the light needs to be on
Browse files Browse the repository at this point in the history
  • Loading branch information
SleepyScarecrow committed Sep 10, 2024
1 parent e0d2b72 commit 24fd446
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion Content.Server/Medical/PenLightSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Server.DoAfter;
using Content.Server.Popups;
using Content.Server.PowerCell;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
Expand All @@ -23,7 +24,9 @@ public sealed class PenLightSystem : EntitySystem
[Dependency] private readonly IEntityManager _entityManager = default!;
[Dependency] private readonly DoAfterSystem _doAfter = default!;
[Dependency] private readonly PowerCellSystem _powerCell = default!;
[Dependency] private readonly PopupSystem _popup = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;

/// <inheritdoc/>
public override void Initialize()
{
Expand Down Expand Up @@ -54,7 +57,13 @@ private void OnDoAfter(Entity<PenLightComponent> uid, ref PenLightDoAfterEvent a
args.Handled = true;
}


/// <summary>
/// Checks if the PointLight component is enabled.
/// </summary>
private bool IsLightEnabled(EntityUid uid)
{
return TryComp<PointLightComponent>(uid, out var pointLight) && pointLight.Enabled;
}
/// <summary>
/// Actually handles the exam interaction.
/// </summary>
Expand All @@ -63,6 +72,13 @@ public bool TryStartExam(EntityUid uid, EntityUid target, EntityUid user, PenLig
if (!Resolve(uid, ref component))
return false;

if (!IsLightEnabled(uid))
{
if (user != null)
_popup.PopupEntity(Loc.GetString("penlight-off"), uid, user);
return false;
}

return _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.ExamSpeed, new PenLightDoAfterEvent(),
uid, target, uid)
{
Expand Down
1 change: 1 addition & 0 deletions Content.Shared/Medical/PenLightComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace Content.Shared.Medical;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentPause]
public sealed partial class PenLightComponent : Component
{

/// <summary>
/// Cooldown Time, exams take a bit
/// </summary>
Expand Down

0 comments on commit 24fd446

Please sign in to comment.