From 527d31908d7a2b7af67d5edbef534ebca0c127ec Mon Sep 17 00:00:00 2001 From: SleepyScarecrow <136123749+SleepyScarecrow@users.noreply.github.com> Date: Wed, 11 Sep 2024 16:02:51 -0400 Subject: [PATCH] Penlight-Fixes (#900) # Description Tweaked penlights some. You can no longer examine random objects, you cannot examine your own eyes, and the penlight now needs to be actually on in order to use. Also tweaked the messages to be more accurate. # Changelog :cl: Tilkku - tweak: Penlight Exam Messages - fix: Penlights now need to be on in order to examine - fix: Penlights can no longer be used on self --------- Signed-off-by: SleepyScarecrow <136123749+SleepyScarecrow@users.noreply.github.com> Co-authored-by: VMSolidus --- Content.Server/Medical/PenLightSystem.cs | 46 +++++++++++++++---- Content.Shared/Medical/PenLightComponent.cs | 1 + .../en-US/medical/components/penlight.ftl | 5 +- 3 files changed, 41 insertions(+), 11 deletions(-) diff --git a/Content.Server/Medical/PenLightSystem.cs b/Content.Server/Medical/PenLightSystem.cs index f48a84d047..0e0f22684a 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.Drunk; 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 sealed class PenLightSystem : EntitySystem 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 @@ public sealed class PenLightSystem : EntitySystem 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 sealed class PenLightSystem : EntitySystem 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 sealed class PenLightSystem : EntitySystem } 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 @@ public sealed class PenLightSystem : EntitySystem 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 50dacae3dc..770e8af7e9 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 f0639ad738..c8a5d66f5d 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