Penlight-Fixes (#900)

<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

# Description

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

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

<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

🆑 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 <evilexecutive@gmail.com>
This commit is contained in:
SleepyScarecrow
2024-09-11 16:02:51 -04:00
committed by Remuchi
parent da5a815cce
commit 527d31908d
3 changed files with 41 additions and 11 deletions

View File

@@ -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!;
/// <inheritdoc/>
public override void Initialize()
{
@@ -30,20 +34,23 @@ public sealed class PenLightSystem : EntitySystem
SubscribeLocalEvent<PenLightComponent, PenLightDoAfterEvent>(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<MobStateComponent>(target)
|| !_powerCell.HasDrawCharge(uid, user: args.User))
return;
args.Handled = TryStartExam(uid, target, args.User, component);
}
private void OnDoAfter(Entity<PenLightComponent> 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;
}
/// <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.
@@ -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<ActorComponent>(user, out var actor)
if (!TryComp<ActorComponent>(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<EyeComponent>(target))
|| !HasComp<EyeComponent>(target)
|| !HasComp<DamageableComponent>(target))
return;
// Blind
var blind = _entityManager.HasComponent<PermanentBlindnessComponent>(target);

View File

@@ -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>

View File

@@ -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.