diff --git a/Content.Server/Medical/PenLightSystem.cs b/Content.Server/Medical/PenLightSystem.cs
index f48a84d0476..0e0f22684a7 100644
--- a/Content.Server/Medical/PenLightSystem.cs
+++ b/Content.Server/Medical/PenLightSystem.cs
@@ -1,4 +1,5 @@
using Content.Server.DoAfter;
+using Content.Server.Popups;
using Content.Server.PowerCell;
using Content.Shared.Damage;
using Content.Shared.DoAfter;
@@ -7,6 +8,7 @@
using Content.Shared.Eye.Blinding.Components;
using Content.Shared.Interaction;
using Content.Shared.Medical;
+using Content.Shared.Mobs.Components;
using Content.Shared.Mobs.Systems;
using Content.Shared.Traits.Assorted.Components;
using Robust.Server.GameObjects;
@@ -22,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!;
+
///
public override void Initialize()
{
@@ -30,20 +34,23 @@ public override void Initialize()
SubscribeLocalEvent(OnDoAfter);
}
- private void OnAfterInteract(EntityUid uid, PenLightComponent component, AfterInteractEvent args)
+ private void OnAfterInteract(EntityUid uid, PenLightComponent component, ref AfterInteractEvent args)
{
- if (args.Handled
- || args.Target is not { } target)
+ if (args.Handled
+ || args.Target is not {} target
+ || target == null
+ || !args.CanReach
+ || !HasComp(target)
+ || !_powerCell.HasDrawCharge(uid, user: args.User))
return;
-
args.Handled = TryStartExam(uid, target, args.User, component);
}
private void OnDoAfter(Entity uid, ref PenLightDoAfterEvent args)
{
- if (args.Handled
- || args.Cancelled
- || args.Target == null
+ if (args.Handled
+ || args.Cancelled
+ || args.Target == null
|| !_powerCell.HasDrawCharge(uid, user: args.User))
return;
@@ -52,6 +59,13 @@ private void OnDoAfter(Entity uid, ref PenLightDoAfterEvent a
args.Handled = true;
}
+ ///
+ /// Checks if the PointLight component is enabled.
+ ///
+ private bool IsLightEnabled(EntityUid uid)
+ {
+ return TryComp(uid, out var pointLight) && pointLight.Enabled;
+ }
///
/// Actually handles the exam interaction.
@@ -61,6 +75,18 @@ 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;
+ }
+ // can't examine your own eyes, dingus
+ if (user == target)
+ {
+ _popup.PopupEntity(Loc.GetString("penlight-cannot-examine-self"), uid, user);
+ return false;
+ }
return _doAfter.TryStartDoAfter(new DoAfterArgs(EntityManager, user, component.ExamSpeed, new PenLightDoAfterEvent(),
uid, target, uid)
{
@@ -73,7 +99,7 @@ public bool TryStartExam(EntityUid uid, EntityUid target, EntityUid user, PenLig
}
private void OpenUserInterface(EntityUid user, EntityUid penlight)
{
- if (!TryComp(user, out var actor)
+ if (!TryComp(user, out var actor)
|| !_uiSystem.TryGetUi(penlight, PenLightUiKey.Key, out var ui))
return;
@@ -86,8 +112,10 @@ private void OpenUserInterface(EntityUid user, EntityUid penlight)
private void Diagnose(EntityUid penlight, EntityUid target)
{
if (!_uiSystem.TryGetUi(penlight, PenLightUiKey.Key, out var ui)
- || !HasComp(target))
+ || !HasComp(target)
+ || !HasComp(target))
return;
+
// Blind
var blind = _entityManager.HasComponent(target);
diff --git a/Content.Shared/Medical/PenLightComponent.cs b/Content.Shared/Medical/PenLightComponent.cs
index 50dacae3dc8..770e8af7e9e 100644
--- a/Content.Shared/Medical/PenLightComponent.cs
+++ b/Content.Shared/Medical/PenLightComponent.cs
@@ -9,6 +9,7 @@ namespace Content.Shared.Medical;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentPause]
public sealed partial class PenLightComponent : Component
{
+
///
/// Cooldown Time, exams take a bit
///
diff --git a/Resources/Locale/en-US/medical/components/penlight.ftl b/Resources/Locale/en-US/medical/components/penlight.ftl
index f0639ad7381..c8a5d66f5d5 100644
--- a/Resources/Locale/en-US/medical/components/penlight.ftl
+++ b/Resources/Locale/en-US/medical/components/penlight.ftl
@@ -1,11 +1,12 @@
penlight-off = The pen light is off.
+penlight-cannot-examine-self = You cannot examine your own eyes.
pen-light-exam-title = Pen Light
pen-light-window-entity-eyes-text = {$entityName}'s conditions:
pen-light-window-no-patient-data-text = No patient data.
pen-light-window-entity-unknown-text = unknown
pen-light-exam-blind-text = The patient's eyes are glassy and unfocused. They can't follow the light at all.
-pen-light-exam-drunk-text = The patient's eyes are slow to follow the light, droopy.
-pen-light-exam-eyedamage-text = The patient's eyes are partially focused, though they struggle to look at the light for too long.
+pen-light-exam-drunk-text = There's a clear delay between moving the light and the patient's eyes following.
+pen-light-exam-eyedamage-text = The patient's eyes have dark spots within the pupil, evident when the light is shone in them.
pen-light-exam-hallucinating-text = The patient's eyes are wandering around, with dilated pupils. They don't focus on the light.
pen-light-exam-healthy-text = The patient follows the light perfectly with no stuttering.
\ No newline at end of file