diff --git a/Content.Shared/Chemistry/Components/SolutionManager/ExaminableSolutionComponent.cs b/Content.Shared/Chemistry/Components/SolutionManager/ExaminableSolutionComponent.cs index 76e7967db2..1abe81180c 100644 --- a/Content.Shared/Chemistry/Components/SolutionManager/ExaminableSolutionComponent.cs +++ b/Content.Shared/Chemistry/Components/SolutionManager/ExaminableSolutionComponent.cs @@ -5,4 +5,10 @@ public sealed partial class ExaminableSolutionComponent : Component { [DataField, ViewVariables(VVAccess.ReadWrite)] public string Solution = "default"; + + /// + /// If false then the hidden solution is always visible. + /// + [DataField] + public bool HeldOnly; } diff --git a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs index d71fffcdee..5bb97e83eb 100644 --- a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs +++ b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs @@ -13,6 +13,8 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Runtime.CompilerServices; using System.Text; +using Content.Shared.Hands.Components; +using Content.Shared.Hands.EntitySystems; using Dependency = Robust.Shared.IoC.DependencyAttribute; namespace Content.Shared.Chemistry.EntitySystems; @@ -53,6 +55,7 @@ public abstract partial class SharedSolutionContainerSystem : EntitySystem [Dependency] protected readonly ChemicalReactionSystem ChemicalReactionSystem = default!; [Dependency] protected readonly ExamineSystemShared ExamineSystem = default!; [Dependency] protected readonly SharedAppearanceSystem AppearanceSystem = default!; + [Dependency] protected readonly SharedHandsSystem Hands = default!; [Dependency] protected readonly SharedContainerSystem ContainerSystem = default!; public override void Initialize() @@ -729,6 +732,9 @@ public abstract partial class SharedSolutionContainerSystem : EntitySystem return; } + if (!CanSeeHiddenSolution(entity,args.Examiner)) + return; + var primaryReagent = solution.GetPrimaryReagentId(); if (string.IsNullOrEmpty(primaryReagent?.Prototype)) @@ -825,6 +831,9 @@ public abstract partial class SharedSolutionContainerSystem : EntitySystem return; } + if (!CanSeeHiddenSolution(entity,args.User)) + return; + var target = args.Target; var user = args.User; var verb = new ExamineVerb() @@ -874,5 +883,22 @@ public abstract partial class SharedSolutionContainerSystem : EntitySystem return msg; } + /// + /// Check if examinable solution requires you to hold the item in hand. + /// + private bool CanSeeHiddenSolution(Entity entity, EntityUid examiner) + { + // If not held-only then it's always visible. + if (!entity.Comp.HeldOnly) + return true; + + if (TryComp(examiner, out HandsComponent? handsComp)) + { + return Hands.IsHolding(examiner, entity, out _, handsComp); + } + + return true; + } + #endregion Event Handlers } diff --git a/Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml b/Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml index abcabd7481..dbc78a8409 100644 --- a/Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml +++ b/Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml @@ -417,6 +417,7 @@ solution: hypospray - type: ExaminableSolution solution: hypospray + heldOnly: true # Allow examination only when held in hand. - type: Hypospray onlyAffectsMobs: false - type: UseDelay