Fix 'Hypopen shouldn't display solution examine text' (#26453)
* 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>
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user