// 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);
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;
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))
!_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;
--- /dev/null
+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
+{
+}
/// <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;
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)