Prevent storing liquids in equipped buckets (#24412)

* Block access to solutions in equipped spillables.

* Stop Drink verb appearing if the solution can't be accessed.
This commit is contained in:
Tayrtahn
2024-03-31 00:40:22 -04:00
committed by GitHub
parent 6b7427e3ee
commit 1b94e01563
4 changed files with 36 additions and 0 deletions

View File

@@ -0,0 +1,11 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Chemistry.Components;
/// <summary>
/// Blocks all attempts to access solutions contained by this entity.
/// </summary>
[RegisterComponent, NetworkedComponent]
public sealed partial class BlockSolutionAccessComponent : Component
{
}

View File

@@ -133,6 +133,12 @@ public abstract partial class SharedSolutionContainerSystem : EntitySystem
/// <inheritdoc cref="TryGetSolution"/>
public bool TryGetSolution(Entity<SolutionContainerManagerComponent?> container, string? name, [NotNullWhen(true)] out Entity<SolutionComponent>? entity)
{
if (TryComp(container, out BlockSolutionAccessComponent? blocker))
{
entity = null;
return false;
}
EntityUid uid;
if (name is null)
uid = container;
@@ -178,6 +184,9 @@ public abstract partial class SharedSolutionContainerSystem : EntitySystem
if (!Resolve(container, ref container.Comp, logMissing: false))
yield break;
if (HasComp<BlockSolutionAccessComponent>(container))
yield break;
foreach (var name in container.Comp.Containers)
{
if (ContainerSystem.GetContainer(container, $"solution@{name}") is ContainerSlot slot && slot.ContainedEntity is { } solutionId)