diff --git a/Content.Server/Fluids/EntitySystems/PuddleSystem.Spillable.cs b/Content.Server/Fluids/EntitySystems/PuddleSystem.Spillable.cs index ce5b5b3637..a365b8d0a4 100644 --- a/Content.Server/Fluids/EntitySystems/PuddleSystem.Spillable.cs +++ b/Content.Server/Fluids/EntitySystems/PuddleSystem.Spillable.cs @@ -29,6 +29,7 @@ public sealed partial class PuddleSystem // Openable handles the event if it's closed SubscribeLocalEvent(SplashOnMeleeHit, after: [typeof(OpenableSystem)]); SubscribeLocalEvent(OnGotEquipped); + SubscribeLocalEvent(OnGotUnequipped); SubscribeLocalEvent(OnOverflow); SubscribeLocalEvent(OnDoAfter); SubscribeLocalEvent(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(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 entity, ref GotUnequippedEvent args) + { + if (!entity.Comp.SpillWorn) + return; + + RemCompDeferred(entity); + } + private void SpillOnLand(Entity entity, ref LandEvent args) { if (!_solutionContainerSystem.TryGetSolution(entity.Owner, entity.Comp.SolutionName, out var soln, out var solution)) diff --git a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs index 5fb090087a..036c855dbb 100644 --- a/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/DrinkSystem.cs @@ -410,6 +410,10 @@ public sealed class DrinkSystem : EntitySystem !_body.TryGetBodyOrganComponents(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; diff --git a/Content.Shared/Chemistry/Components/BlockSolutionAccessComponent.cs b/Content.Shared/Chemistry/Components/BlockSolutionAccessComponent.cs new file mode 100644 index 0000000000..182f92d7d3 --- /dev/null +++ b/Content.Shared/Chemistry/Components/BlockSolutionAccessComponent.cs @@ -0,0 +1,11 @@ +using Robust.Shared.GameStates; + +namespace Content.Shared.Chemistry.Components; + +/// +/// Blocks all attempts to access solutions contained by this entity. +/// +[RegisterComponent, NetworkedComponent] +public sealed partial class BlockSolutionAccessComponent : Component +{ +} diff --git a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs index 6e762aa598..d71fffcdee 100644 --- a/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs +++ b/Content.Shared/Chemistry/EntitySystems/SharedSolutionContainerSystem.cs @@ -133,6 +133,12 @@ public abstract partial class SharedSolutionContainerSystem : EntitySystem /// public bool TryGetSolution(Entity container, string? name, [NotNullWhen(true)] out Entity? 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(container)) + yield break; + foreach (var name in container.Comp.Containers) { if (ContainerSystem.GetContainer(container, $"solution@{name}") is ContainerSlot slot && slot.ContainedEntity is { } solutionId)