]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix 'Hypopen shouldn't display solution examine text' (#26453)
authordrteaspoon420 <87363733+drteaspoon420@users.noreply.github.com>
Sun, 31 Mar 2024 04:59:36 +0000 (07:59 +0300)
committerGitHub <noreply@github.com>
Sun, 31 Mar 2024 04:59:36 +0000 (15:59 +1100)
* stealthy hypo

* ExaminableSolution hand check when in covert implement.

ExaminableSolution now has 'hidden' datafield to enable chemical inspection only in hand.

* cleaning code

* more cleaning

* Hidden datafield renamed to HeldOnly

* review

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
Content.Shared/Chemistry/Components/SolutionManager/ExaminableSolutionComponent.cs
Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs
Resources/Prototypes/Entities/Objects/Specific/Medical/hypospray.yml

index 76e7967db2695470fe342bc0fa064e45b806f532..1abe81180c846c4c363eab99e3ccb580f0966c0c 100644 (file)
@@ -5,4 +5,10 @@ public sealed partial class ExaminableSolutionComponent : Component
 {
     [DataField, ViewVariables(VVAccess.ReadWrite)]
     public string Solution = "default";
+
+    /// <summary>
+    /// If false then the hidden solution is always visible.
+    /// </summary>
+    [DataField]
+    public bool HeldOnly;
 }
index d71fffcdee675cc1b9020b541b5261b473737b82..5bb97e83ebf9cbe9ee5ae7f214ee6600671f89be 100644 (file)
@@ -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;
     }
 
+    /// <summary>
+    /// Check if examinable solution requires you to hold the item in hand.
+    /// </summary>
+    private bool CanSeeHiddenSolution(Entity<ExaminableSolutionComponent> 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
 }
index abcabd74810c665861f73b9441c86619281e0679..dbc78a8409859c46cd7d111c97a8f7f4c17973cc 100644 (file)
     solution: hypospray
   - type: ExaminableSolution
     solution: hypospray
+    heldOnly: true # Allow examination only when held in hand.
   - type: Hypospray
     onlyAffectsMobs: false
   - type: UseDelay