diff --git a/Content.Server/GameObjects/Components/Chemistry/SolutionTransferVerbs.cs b/Content.Server/GameObjects/Components/Chemistry/AdminAddReagentVerb.cs similarity index 56% rename from Content.Server/GameObjects/Components/Chemistry/SolutionTransferVerbs.cs rename to Content.Server/GameObjects/Components/Chemistry/AdminAddReagentVerb.cs index 9fc25fabdb..f6a8fa36c9 100644 --- a/Content.Server/GameObjects/Components/Chemistry/SolutionTransferVerbs.cs +++ b/Content.Server/GameObjects/Components/Chemistry/AdminAddReagentVerb.cs @@ -1,4 +1,4 @@ -using System.Diagnostics.CodeAnalysis; +using System.Diagnostics.CodeAnalysis; using Content.Server.Administration; using Content.Server.Eui; using Content.Server.GameObjects.Components.GUI; @@ -18,132 +18,6 @@ using Robust.Shared.Localization; namespace Content.Server.GameObjects.Components.Chemistry { - internal abstract class SolutionTransferVerbBase : GlobalVerb - { - protected static bool GetHeldSolution( - IEntity holder, - [NotNullWhen(true)] - out IEntity? held, - [NotNullWhen(true)] - out ISolutionInteractionsComponent? heldSolution) - { - if (!holder.TryGetComponent(out HandsComponent? hands) - || hands.GetActiveHand == null - || !hands.GetActiveHand.Owner.TryGetComponent(out heldSolution)) - { - held = null; - heldSolution = null; - return false; - } - - held = heldSolution.Owner; - return true; - } - } - - /// - /// Transfers solution from the held container to the target container. - /// - [GlobalVerb] - internal sealed class SolutionFillTargetVerb : SolutionTransferVerbBase - { - public override void GetData(IEntity user, IEntity target, VerbData data) - { - if (!target.TryGetComponent(out ISolutionInteractionsComponent? targetSolution) || - !ActionBlockerSystem.CanInteract(user) || - !GetHeldSolution(user, out var source, out var sourceSolution) || - source != target || - !sourceSolution.CanDrain || - !targetSolution.CanRefill) - { - data.Visibility = VerbVisibility.Invisible; - return; - } - - data.Visibility = VerbVisibility.Visible; - data.Text = Loc.GetString("Transfer liquid from [{0}] to [{1}].", source.Name, target.Name); - } - - public override void Activate(IEntity user, IEntity target) - { - if (!GetHeldSolution(user, out _, out var handSolutionComp)) - { - return; - } - - if (!handSolutionComp.CanDrain || - !target.TryGetComponent(out ISolutionInteractionsComponent? targetComp) || - !targetComp.CanRefill) - { - return; - } - - var transferQuantity = ReagentUnit.Min( - targetComp.RefillSpaceAvailable, - handSolutionComp.DrainAvailable, - ReagentUnit.New(10)); - - if (transferQuantity <= 0) - { - return; - } - - var transferSolution = handSolutionComp.Drain(transferQuantity); - targetComp.Refill(transferSolution); - } - } - - /// - /// Transfers solution from a target container to the held container. - /// - [GlobalVerb] - internal sealed class SolutionDrainTargetVerb : SolutionTransferVerbBase - { - public override void GetData(IEntity user, IEntity target, VerbData data) - { - if (!target.TryGetComponent(out ISolutionInteractionsComponent? sourceSolution) || - !ActionBlockerSystem.CanInteract(user) || - !GetHeldSolution(user, out var held, out var targetSolution) || - !sourceSolution.CanDrain || - !targetSolution.CanRefill) - { - data.Visibility = VerbVisibility.Invisible; - return; - } - - data.Visibility = VerbVisibility.Visible; - data.Text = Loc.GetString("Transfer liquid from [{0}] to [{1}].", held.Name, target.Name); - } - - public override void Activate(IEntity user, IEntity target) - { - if (!GetHeldSolution(user, out _, out var targetComp)) - { - return; - } - - if (!targetComp.CanRefill || - !target.TryGetComponent(out ISolutionInteractionsComponent? sourceComp) || - !sourceComp.CanDrain) - { - return; - } - - var transferQuantity = ReagentUnit.Min( - targetComp.RefillSpaceAvailable, - sourceComp.DrainAvailable, - ReagentUnit.New(10)); - - if (transferQuantity <= 0) - { - return; - } - - var transferSolution = sourceComp.Drain(transferQuantity); - targetComp.Refill(transferSolution); - } - } - [GlobalVerb] internal sealed class AdminAddReagentVerb : GlobalVerb {