From 493b80095dbe0cb866eeb27418eebd996ada8fb3 Mon Sep 17 00:00:00 2001 From: moneyl <8206401+Moneyl@users.noreply.github.com> Date: Wed, 29 Jan 2020 13:15:35 -0500 Subject: [PATCH] Chem dispenser attempts to eject into hands (#576) Previously the chem dispenser eject button placed the container on top of the dispenser. Now it will attempt to place it in your active hand, then your secondary hand. If both hands are full then it'll place it on top of the dispenser like before. --- .../Chemistry/ReagentDispenserComponent.cs | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs b/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs index 85caf70269..fa3a65e6c5 100644 --- a/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs +++ b/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs @@ -109,7 +109,7 @@ namespace Content.Server.GameObjects.Components.Chemistry switch (msg.Button) { case UiButton.Eject: - TryEject(); + TryEject(obj.Session.AttachedEntity); break; case UiButton.Clear: TryClear(); @@ -189,14 +189,22 @@ namespace Content.Server.GameObjects.Components.Chemistry /// /// If this component contains an entity with a , eject it. + /// Tries to eject into user's hands first, then ejects onto dispenser if both hands are full. /// - private void TryEject() + private void TryEject(IEntity user) { - if (!HasBeaker) return; + if (!HasBeaker) + return; + + var beaker = _beakerContainer.ContainedEntity; Solution.SolutionChanged -= HandleSolutionChangedEvent; _beakerContainer.Remove(_beakerContainer.ContainedEntity); - UpdateUserInterface(); + + if(!user.TryGetComponent(out var hands) || !beaker.TryGetComponent(out var item)) + return; + if (hands.CanPutInHand(item)) + hands.PutInHand(item); } ///