using System; using System.Collections.Generic; using Content.Shared.Chemistry.Reagent; using Content.Shared.Containers.ItemSlots; using Content.Shared.FixedPoint; using Robust.Shared.GameObjects; using Robust.Shared.Serialization; using Robust.Shared.Serialization.Manager.Attributes; namespace Content.Shared.Chemistry.Dispenser { /// /// Shared class for ReagentDispenserComponent. Provides a way for entities to dispense and remove reagents from other entities with SolutionComponents via a user interface. /// This is useful for machines such as the chemical dispensers, booze dispensers, or soda dispensers. /// The chemicals which may be dispensed are defined by specifying a reagent pack. See for more information on that. /// [Virtual] public class SharedReagentDispenserComponent : Component { [DataField("beakerSlot")] public ItemSlot BeakerSlot = new(); /// /// A list of reagents which this may dispense. Defined in yaml prototype, see . /// public readonly List Inventory = new(); [Serializable, NetSerializable] public sealed class ReagentDispenserBoundUserInterfaceState : BoundUserInterfaceState { public readonly bool HasPower; public readonly bool HasBeaker; public readonly FixedPoint2 BeakerCurrentVolume; public readonly FixedPoint2 BeakerMaxVolume; public readonly string ContainerName; /// /// A list of the reagents which this dispenser can dispense. /// public readonly List Inventory; /// /// A list of the reagents and their amounts within the beaker/reagent container, if applicable. /// public readonly List? ContainerReagents; public readonly string DispenserName; public readonly FixedPoint2 SelectedDispenseAmount; public ReagentDispenserBoundUserInterfaceState(bool hasPower, bool hasBeaker, FixedPoint2 beakerCurrentVolume, FixedPoint2 beakerMaxVolume, string containerName, List inventory, string dispenserName, List? containerReagents, FixedPoint2 selectedDispenseAmount) { HasPower = hasPower; HasBeaker = hasBeaker; BeakerCurrentVolume = beakerCurrentVolume; BeakerMaxVolume = beakerMaxVolume; ContainerName = containerName; Inventory = inventory; DispenserName = dispenserName; ContainerReagents = containerReagents; SelectedDispenseAmount = selectedDispenseAmount; } } /// /// Message data sent from client to server when a dispenser ui button is pressed. /// [Serializable, NetSerializable] public sealed class UiButtonPressedMessage : BoundUserInterfaceMessage { public readonly UiButton Button; public readonly int DispenseIndex; //Index of dispense button / reagent being pressed. Only used when a dispense button is pressed. public UiButtonPressedMessage(UiButton button, int dispenseIndex) { Button = button; DispenseIndex = dispenseIndex; } } [Serializable, NetSerializable] public enum ReagentDispenserUiKey { Key } /// /// Used in to specify which button was pressed. /// public enum UiButton { Eject, Clear, SetDispenseAmount1, SetDispenseAmount5, SetDispenseAmount10, SetDispenseAmount15, SetDispenseAmount20, SetDispenseAmount25, SetDispenseAmount30, SetDispenseAmount50, SetDispenseAmount100, /// /// Used when any dispense button is pressed. Such as "Carbon", or "Oxygen" buttons on the chem dispenser. /// The index of the reagent attached to that dispense button is sent as . /// Dispense } /// /// Information about a reagent which the dispenser can dispense. /// [Serializable, NetSerializable] public struct ReagentDispenserInventoryEntry { public readonly string ID; public ReagentDispenserInventoryEntry(string id) { ID = id; } } } }