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:
@@ -29,6 +29,7 @@ public sealed partial class PuddleSystem
|
||||
// Openable handles the event if it's closed
|
||||
SubscribeLocalEvent<SpillableComponent, MeleeHitEvent>(SplashOnMeleeHit, after: [typeof(OpenableSystem)]);
|
||||
SubscribeLocalEvent<SpillableComponent, GotEquippedEvent>(OnGotEquipped);
|
||||
SubscribeLocalEvent<SpillableComponent, GotUnequippedEvent>(OnGotUnequipped);
|
||||
SubscribeLocalEvent<SpillableComponent, SolutionContainerOverflowEvent>(OnOverflow);
|
||||
SubscribeLocalEvent<SpillableComponent, SpillDoAfterEvent>(OnDoAfter);
|
||||
SubscribeLocalEvent<SpillableComponent, AttemptPacifiedThrowEvent>(OnAttemptPacifiedThrow);
|
||||
@@ -114,6 +115,9 @@ public sealed partial class PuddleSystem
|
||||
if (!_solutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.SolutionName, out var soln, out var solution))
|
||||
return;
|
||||
|
||||
// block access to the solution while worn
|
||||
AddComp<BlockSolutionAccessComponent>(entity);
|
||||
|
||||
if (solution.Volume == 0)
|
||||
return;
|
||||
|
||||
@@ -122,6 +126,14 @@ public sealed partial class PuddleSystem
|
||||
TrySplashSpillAt(entity.Owner, Transform(args.Equipee).Coordinates, drainedSolution, out _);
|
||||
}
|
||||
|
||||
private void OnGotUnequipped(Entity<SpillableComponent> entity, ref GotUnequippedEvent args)
|
||||
{
|
||||
if (!entity.Comp.SpillWorn)
|
||||
return;
|
||||
|
||||
RemCompDeferred<BlockSolutionAccessComponent>(entity);
|
||||
}
|
||||
|
||||
private void SpillOnLand(Entity<SpillableComponent> entity, ref LandEvent args)
|
||||
{
|
||||
if (!_solutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.SolutionName, out var soln, out var solution))
|
||||
|
||||
@@ -410,6 +410,10 @@ public sealed class DrinkSystem : EntitySystem
|
||||
!_body.TryGetBodyOrganComponents<StomachComponent>(ev.User, out var stomachs, body))
|
||||
return;
|
||||
|
||||
// Make sure the solution exists
|
||||
if (!_solutionContainer.TryGetSolution(entity.Owner, entity.Comp.Solution, out var solution))
|
||||
return;
|
||||
|
||||
// no drinking from living drinks, have to kill them first.
|
||||
if (_mobState.IsAlive(entity))
|
||||
return;
|
||||
|
||||
@@ -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
|
||||
{
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user