diff --git a/Content.Client/GameObjects/Components/Chemistry/ReagentDispenserBoundUserInterface.cs b/Content.Client/GameObjects/Components/Chemistry/ReagentDispenserBoundUserInterface.cs
index a81f7dc79f..29c92fc658 100644
--- a/Content.Client/GameObjects/Components/Chemistry/ReagentDispenserBoundUserInterface.cs
+++ b/Content.Client/GameObjects/Components/Chemistry/ReagentDispenserBoundUserInterface.cs
@@ -1,6 +1,7 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using System.Linq;
+using Content.Shared.GameObjects.Components.Chemistry;
+using JetBrains.Annotations;
using Robust.Client.GameObjects.Components.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.GameObjects.Components.UserInterface;
@@ -13,6 +14,7 @@ namespace Content.Client.GameObjects.Components.Chemistry
///
/// Initializes a and updates it when new server messages are received.
///
+ [UsedImplicitly]
public class ReagentDispenserBoundUserInterface : BoundUserInterface
{
#pragma warning disable 649
@@ -42,7 +44,7 @@ namespace Content.Client.GameObjects.Components.Chemistry
Title = _localizationManager.GetString("Reagent dispenser"),
Size = (500, 600)
};
-
+
_window.OpenCenteredMinSize();
_window.OnClose += Close;
@@ -60,7 +62,10 @@ namespace Content.Client.GameObjects.Components.Chemistry
///
/// Update the ui each time new state data is sent from the server.
///
- /// Data of the that this ui represents. Sent from the server.
+ ///
+ /// Data of the that this ui represents.
+ /// Sent from the server.
+ ///
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
@@ -70,8 +75,6 @@ namespace Content.Client.GameObjects.Components.Chemistry
_window?.UpdateState(castState); //Update window state
UpdateReagentsList(castState.Inventory); //Update reagents list & reagent button actions
-
- _window.ForceRunLayoutUpdate();
}
///
@@ -103,7 +106,7 @@ namespace Content.Client.GameObjects.Components.Chemistry
}
}
- public void ButtonPressed(UiButton button, int dispenseIndex = -1)
+ private void ButtonPressed(UiButton button, int dispenseIndex = -1)
{
SendMessage(new UiButtonPressedMessage(button, dispenseIndex));
}
diff --git a/Content.Client/GameObjects/Components/Chemistry/ReagentDispenserWindow.cs b/Content.Client/GameObjects/Components/Chemistry/ReagentDispenserWindow.cs
index fac745a745..9be4688ddc 100644
--- a/Content.Client/GameObjects/Components/Chemistry/ReagentDispenserWindow.cs
+++ b/Content.Client/GameObjects/Components/Chemistry/ReagentDispenserWindow.cs
@@ -1,8 +1,9 @@
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
using Content.Client.UserInterface;
using Content.Shared.Chemistry;
+using Content.Shared.GameObjects.Components.Chemistry;
using Robust.Client.Graphics.Drawing;
+using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.GameObjects.Components.UserInterface;
@@ -15,33 +16,39 @@ using static Content.Shared.GameObjects.Components.Chemistry.SharedReagentDispen
namespace Content.Client.GameObjects.Components.Chemistry
{
///
- /// Client-side UI used to control a
+ /// Client-side UI used to control a
///
public class ReagentDispenserWindow : SS14Window
{
- /// Sets the dispense amount to 1 when pressed.
- public Button DispenseButton1;
- /// Sets the dispense amount to 5 when pressed.
- public Button DispenseButton5;
- /// Sets the dispense amount to 10 when pressed.
- public Button DispenseButton10;
- /// Sets the dispense amount to 25 when pressed.
- public Button DispenseButton25;
- /// Sets the dispense amount to 50 when pressed.
- public Button DispenseButton50;
- /// Sets the dispense amount to 100 when pressed.
- public Button DispenseButton100;
-
/// Contains info about the reagent container such as it's contents, if one is loaded into the dispenser.
- public VBoxContainer ContainerInfo;
+ private readonly VBoxContainer ContainerInfo;
+
+ /// Sets the dispense amount to 1 when pressed.
+ public Button DispenseButton1 { get; }
+
+ /// Sets the dispense amount to 5 when pressed.
+ public Button DispenseButton5 { get; }
+
+ /// Sets the dispense amount to 10 when pressed.
+ public Button DispenseButton10 { get; }
+
+ /// Sets the dispense amount to 25 when pressed.
+ public Button DispenseButton25 { get; }
+
+ /// Sets the dispense amount to 50 when pressed.
+ public Button DispenseButton50 { get; }
+
+ /// Sets the dispense amount to 100 when pressed.
+ public Button DispenseButton100 { get; }
/// Ejects the reagent container from the dispenser.
- public Button ClearButton;
+ public Button ClearButton { get; }
+
/// Removes all reagents from the reagent container.
- public Button EjectButton;
+ public Button EjectButton { get; }
/// A grid of buttons for each reagent which can be dispensed.
- public GridContainer ChemicalList;
+ public GridContainer ChemicalList { get; }
#pragma warning disable 649
[Dependency] private readonly IPrototypeManager _prototypeManager;
@@ -54,8 +61,9 @@ namespace Content.Client.GameObjects.Components.Chemistry
///
public ReagentDispenserWindow()
{
- _prototypeManager = IoCManager.Resolve();
- _localizationManager = IoCManager.Resolve();
+ IoCManager.InjectDependencies(this);
+
+ var dispenseAmountGroup = new ButtonGroup();
Contents.AddChild(new VBoxContainer
{
@@ -66,16 +74,17 @@ namespace Content.Client.GameObjects.Components.Chemistry
{
Children =
{
- new Label{Text = _localizationManager.GetString("Amount ")},
- (DispenseButton1 = new Button{Text = "1"}),
- (DispenseButton5 = new Button{Text = "5"}),
- (DispenseButton10 = new Button{Text = "10"}),
- (DispenseButton25 = new Button{Text = "25"}),
- (DispenseButton50 = new Button{Text = "50"}),
- (DispenseButton100 = new Button{Text = "100"}),
+ new Label {Text = _localizationManager.GetString("Amount")},
+ new Control {CustomMinimumSize = (20, 0)}, //Padding
+ (DispenseButton1 = new Button {Text = "1", Group = dispenseAmountGroup}),
+ (DispenseButton5 = new Button {Text = "5", Group = dispenseAmountGroup}),
+ (DispenseButton10 = new Button {Text = "10", Group = dispenseAmountGroup}),
+ (DispenseButton25 = new Button {Text = "25", Group = dispenseAmountGroup}),
+ (DispenseButton50 = new Button {Text = "50", Group = dispenseAmountGroup}),
+ (DispenseButton100 = new Button {Text = "100", Group = dispenseAmountGroup}),
}
},
- new Panel{CustomMinimumSize = (0.0f, 10.0f)}, //Padding
+ new Control {CustomMinimumSize = (0.0f, 10.0f)}, //Padding
(ChemicalList = new GridContainer //Grid of which reagents can be dispensed.
{
CustomMinimumSize = (470.0f, 200.0f),
@@ -83,37 +92,43 @@ namespace Content.Client.GameObjects.Components.Chemistry
SizeFlagsHorizontal = SizeFlags.FillExpand,
Columns = 5
}),
- new Panel{CustomMinimumSize = (0.0f, 10.0f)}, //Padding
+ new Control {CustomMinimumSize = (0.0f, 10.0f)}, //Padding
new HBoxContainer
{
Children =
{
- new Label{Text = _localizationManager.GetString("Container: ")},
- (ClearButton = new Button{Text = _localizationManager.GetString("Clear")}),
- (EjectButton = new Button{Text = _localizationManager.GetString("Eject")})
+ new Label {Text = _localizationManager.GetString("Container: ")},
+ (ClearButton = new Button {Text = _localizationManager.GetString("Clear")}),
+ (EjectButton = new Button {Text = _localizationManager.GetString("Eject")})
}
},
- new PanelContainer //Wrap the container info in a PanelContainer so we can color it's background differently.
- {
- SizeFlagsVertical = SizeFlags.FillExpand,
- SizeFlagsStretchRatio = 6,
- PanelOverride = new StyleBoxFlat
+ new
+ PanelContainer //Wrap the container info in a PanelContainer so we can color it's background differently.
{
- BackgroundColor = new Color(27, 27, 30)
- },
- Children =
- {
- (ContainerInfo = new VBoxContainer //Currently empty, when server sends state data this will have container contents and fill volume.
+ SizeFlagsVertical = SizeFlags.FillExpand,
+ SizeFlagsStretchRatio = 6,
+ PanelOverride = new StyleBoxFlat
{
- MarginLeft = 5.0f,
- SizeFlagsHorizontal = SizeFlags.FillExpand,
- Children =
- {
- new Label{Text = _localizationManager.GetString("No container loaded.")}
- }
- }),
- }
- },
+ BackgroundColor = new Color(27, 27, 30)
+ },
+ Children =
+ {
+ (ContainerInfo =
+ new
+ VBoxContainer //Currently empty, when server sends state data this will have container contents and fill volume.
+ {
+ MarginLeft = 5.0f,
+ SizeFlagsHorizontal = SizeFlags.FillExpand,
+ Children =
+ {
+ new Label
+ {
+ Text = _localizationManager.GetString("No container loaded.")
+ }
+ }
+ }),
+ }
+ },
}
});
}
@@ -134,13 +149,12 @@ namespace Content.Client.GameObjects.Components.Chemistry
{
if (_prototypeManager.TryIndex(entry.ID, out ReagentPrototype proto))
{
- ChemicalList.AddChild(new Button { Text = proto.Name });
+ ChemicalList.AddChild(new Button {Text = proto.Name});
}
else
{
- ChemicalList.AddChild(new Button { Text = _localizationManager.GetString("Reagent name not found") });
+ ChemicalList.AddChild(new Button {Text = _localizationManager.GetString("Reagent name not found")});
}
-
}
}
@@ -150,9 +164,31 @@ namespace Content.Client.GameObjects.Components.Chemistry
/// State data sent by the server.
public void UpdateState(BoundUserInterfaceState state)
{
- var castState = (ReagentDispenserBoundUserInterfaceState)state;
+ var castState = (ReagentDispenserBoundUserInterfaceState) state;
Title = castState.DispenserName;
UpdateContainerInfo(castState);
+
+ switch (castState.SelectedDispenseAmount)
+ {
+ case 1:
+ DispenseButton1.Pressed = true;
+ break;
+ case 5:
+ DispenseButton5.Pressed = true;
+ break;
+ case 10:
+ DispenseButton10.Pressed = true;
+ break;
+ case 25:
+ DispenseButton25.Pressed = true;
+ break;
+ case 50:
+ DispenseButton50.Pressed = true;
+ break;
+ case 100:
+ DispenseButton100.Pressed = true;
+ break;
+ }
}
///
@@ -161,83 +197,80 @@ namespace Content.Client.GameObjects.Components.Chemistry
///
/// State data for the dispenser.
/// Prototype id of the reagent whose dispense button is currently being mouse hovered.
- public void UpdateContainerInfo(ReagentDispenserBoundUserInterfaceState state, string highlightedReagentId = "InvalidReagent")
+ public void UpdateContainerInfo(ReagentDispenserBoundUserInterfaceState state,
+ string highlightedReagentId = null)
{
ContainerInfo.Children.Clear();
- if (state.HasBeaker) //If the dispenser doesn't have a beaker/container don't bother with this.
+
+ if (!state.HasBeaker)
{
- ContainerInfo.Children.Add(new HBoxContainer //Name of the container and it's fill status (Ex: 44/100u)
+ ContainerInfo.Children.Add(new Label {Text = _localizationManager.GetString("No container loaded.")});
+ return;
+ }
+
+ ContainerInfo.Children.Add(new HBoxContainer // Name of the container and its fill status (Ex: 44/100u)
+ {
+ Children =
{
- Children =
+ new Label {Text = $"{state.ContainerName}: "},
+ new Label
{
- new Label{Text = $"{state.ContainerName}: "},
- new Label{Text = $"{state.BeakerCurrentVolume}/{state.BeakerMaxVolume}", StyleClasses = { NanoStyle.StyleClassLabelSecondaryColor }}
- }
- });
- //List the reagents in the container if it has any at all.
- if (state.ContainerReagents != null)
- {
- //Loop through the reagents in the container.
- foreach (var reagent in state.ContainerReagents)
- {
- //Try to the prototype for the given reagent. This gives us it's name.
- if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto))
- {
- //Check if the reagent is being moused over. If so, color it green.
- if (proto.ID == highlightedReagentId)
- {
- ContainerInfo.Children.Add(new HBoxContainer
- {
- Children =
- {
- new Label {Text = $"{proto.Name}: ", StyleClasses = {NanoStyle.StyleClassPowerStateGood}},
- new Label
- {
- Text = $"{reagent.Quantity}u",
- StyleClasses = {NanoStyle.StyleClassPowerStateGood}
- }
- }
- });
- }
- else //Otherwise, color it the normal colors.
- {
- ContainerInfo.Children.Add(new HBoxContainer
- {
- Children =
- {
- new Label {Text = $"{proto.Name}: "},
- new Label
- {
- Text = $"{reagent.Quantity}u",
- StyleClasses = {NanoStyle.StyleClassLabelSecondaryColor}
- }
- }
- });
- }
- }
- else //If you fail to get the reagents name, just call it "Unknown reagent".
- {
- ContainerInfo.Children.Add(new HBoxContainer
- {
- Children =
- {
- new Label {Text = _localizationManager.GetString("Unknown reagent: ")},
- new Label
- {
- Text = $"{reagent.Quantity}u",
- StyleClasses = {NanoStyle.StyleClassLabelSecondaryColor}
- }
- }
- });
- }
+ Text = $"{state.BeakerCurrentVolume}/{state.BeakerMaxVolume}",
+ StyleClasses = {NanoStyle.StyleClassLabelSecondaryColor}
}
}
- }
- else
+ });
+
+ if (state.ContainerReagents == null)
{
- ContainerInfo.Children.Add(new Label{Text = _localizationManager.GetString("No container loaded.")});
+ return;
+ }
+
+ foreach (var reagent in state.ContainerReagents)
+ {
+ var name = _localizationManager.GetString("Unknown reagent");
+ //Try to the prototype for the given reagent. This gives us it's name.
+ if (_prototypeManager.TryIndex(reagent.ReagentId, out ReagentPrototype proto))
+ {
+ name = proto.Name;
+ }
+
+ //Check if the reagent is being moused over. If so, color it green.
+ if (proto.ID == highlightedReagentId)
+ {
+ ContainerInfo.Children.Add(new HBoxContainer
+ {
+ Children =
+ {
+ new Label
+ {
+ Text = $"{name}: ",
+ StyleClasses = {NanoStyle.StyleClassPowerStateGood}
+ },
+ new Label
+ {
+ Text = $"{reagent.Quantity}u",
+ StyleClasses = {NanoStyle.StyleClassPowerStateGood}
+ }
+ }
+ });
+ }
+ else //Otherwise, color it the normal colors.
+ {
+ ContainerInfo.Children.Add(new HBoxContainer
+ {
+ Children =
+ {
+ new Label {Text = $"{name}: "},
+ new Label
+ {
+ Text = $"{reagent.Quantity}u",
+ StyleClasses = {NanoStyle.StyleClassLabelSecondaryColor}
+ }
+ }
+ });
+ }
}
- ForceRunLayoutUpdate(); //Force a layout update to avoid text hanging off the window until the user manually resizes it.
}
}
}
diff --git a/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs b/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs
index ca49803cc0..b044a3d9e1 100644
--- a/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs
+++ b/Content.Server/GameObjects/Components/Chemistry/ReagentDispenserComponent.cs
@@ -1,5 +1,6 @@
using System;
using System.Linq;
+using Content.Server.GameObjects.Components.Sound;
using Content.Server.GameObjects.EntitySystems;
using Content.Server.Interfaces;
using Content.Server.Interfaces.GameObjects;
@@ -8,11 +9,13 @@ using Content.Shared.GameObjects.Components.Chemistry;
using Robust.Server.GameObjects.Components.Container;
using Robust.Server.GameObjects.Components.UserInterface;
using Robust.Server.Interfaces.GameObjects;
+using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
+using Robust.Shared.ViewVariables;
namespace Content.Server.GameObjects.Components.Chemistry
{
@@ -32,14 +35,15 @@ namespace Content.Server.GameObjects.Components.Chemistry
[Dependency] private readonly ILocalizationManager _localizationManager;
#pragma warning restore 649
- private BoundUserInterface _userInterface;
- private ContainerSlot _beakerContainer;
- private string _packPrototypeId;
+ [ViewVariables] private BoundUserInterface _userInterface;
+ [ViewVariables] private ContainerSlot _beakerContainer;
+ [ViewVariables] private string _packPrototypeId;
- public bool HasBeaker => _beakerContainer.ContainedEntity != null;
- public int DispenseAmount = 10;
+ [ViewVariables] private bool HasBeaker => _beakerContainer.ContainedEntity != null;
+ [ViewVariables] private int DispenseAmount = 10;
- private SolutionComponent _solution => _beakerContainer.ContainedEntity.GetComponent();
+ [ViewVariables]
+ private SolutionComponent Solution => _beakerContainer.ContainedEntity.GetComponent();
///
/// Shows the serializer how to save/load this components yaml prototype.
@@ -59,10 +63,12 @@ namespace Content.Server.GameObjects.Components.Chemistry
public override void Initialize()
{
base.Initialize();
- _userInterface = Owner.GetComponent().GetBoundUserInterface(ReagentDispenserUiKey.Key);
+ _userInterface = Owner.GetComponent()
+ .GetBoundUserInterface(ReagentDispenserUiKey.Key);
_userInterface.OnReceiveMessage += OnUiReceiveMessage;
- _beakerContainer = ContainerManagerComponent.Ensure($"{Name}-reagentContainerContainer", Owner);
+ _beakerContainer =
+ ContainerManagerComponent.Ensure($"{Name}-reagentContainerContainer", Owner);
InitializeFromPrototype();
UpdateUserInterface();
@@ -95,7 +101,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
/// A user interface message from the client.
private void OnUiReceiveMessage(ServerBoundUserInterfaceMessage obj)
{
- var msg = (UiButtonPressedMessage)obj.Message;
+ var msg = (UiButtonPressedMessage) obj.Message;
switch (msg.Button)
{
case UiButton.Eject:
@@ -127,14 +133,17 @@ namespace Content.Server.GameObjects.Components.Chemistry
{
TryDispense(msg.DispenseIndex);
}
+
break;
default:
throw new ArgumentOutOfRangeException();
}
+
+ ClickSound();
}
///
- /// Gets component data to be used to update the user interface client-side.
+ /// Gets component data to be used to update the user interface client-side.
///
/// Returns a
private ReagentDispenserBoundUserInterfaceState GetUserInterfaceState()
@@ -142,19 +151,16 @@ namespace Content.Server.GameObjects.Components.Chemistry
var beaker = _beakerContainer.ContainedEntity;
if (beaker == null)
{
- return new ReagentDispenserBoundUserInterfaceState(false, 0,0,
- "", Inventory, Owner.Name, null);
+ return new ReagentDispenserBoundUserInterfaceState(false, 0, 0,
+ "", Inventory, Owner.Name, null, DispenseAmount);
}
var solution = beaker.GetComponent();
return new ReagentDispenserBoundUserInterfaceState(true, solution.CurrentVolume, solution.MaxVolume,
- beaker.Name, Inventory, Owner.Name, solution.ReagentList.ToList());
+ beaker.Name, Inventory, Owner.Name, solution.ReagentList.ToList(), DispenseAmount);
}
- ///
- /// Gets current component data as a and sends it to the client.
- ///
- public void UpdateUserInterface()
+ private void UpdateUserInterface()
{
var state = GetUserInterfaceState();
_userInterface.SetState(state);
@@ -163,10 +169,10 @@ namespace Content.Server.GameObjects.Components.Chemistry
///
/// If this component contains an entity with a , eject it.
///
- public void TryEject()
+ private void TryEject()
{
- if(!HasBeaker) return;
- _solution.SolutionChanged -= HandleSolutionChangedEvent;
+ if (!HasBeaker) return;
+ Solution.SolutionChanged -= HandleSolutionChangedEvent;
_beakerContainer.Remove(_beakerContainer.ContainedEntity);
UpdateUserInterface();
@@ -193,7 +199,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
if (!HasBeaker) return;
var solution = _beakerContainer.ContainedEntity.GetComponent();
- solution.TryAddReagent(Inventory[dispenseIndex].ID, DispenseAmount, out int acceptedQuantity);
+ solution.TryAddReagent(Inventory[dispenseIndex].ID, DispenseAmount, out _);
UpdateUserInterface();
}
@@ -202,12 +208,13 @@ namespace Content.Server.GameObjects.Components.Chemistry
/// Called when you click the owner entity with an empty hand. Opens the UI client-side if possible.
///
/// Data relevant to the event such as the actor which triggered it.
- public void Activate(ActivateEventArgs args)
+ void IActivate.Activate(ActivateEventArgs args)
{
if (!args.User.TryGetComponent(out IActorComponent actor))
{
return;
}
+
if (!args.User.TryGetComponent(out IHandsComponent hands))
{
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
@@ -229,7 +236,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
///
/// Data relevant to the event such as the actor which triggered it.
///
- public bool AttackBy(AttackByEventArgs args)
+ bool IAttackBy.AttackBy(AttackByEventArgs args)
{
if (!args.User.TryGetComponent(out IHandsComponent hands))
{
@@ -246,7 +253,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
_localizationManager.GetString("This dispenser already has a container in it."));
}
- else if ((solution.Capabilities & SolutionCaps.FitsInDispenser) == 0)
+ else if ((solution.Capabilities & SolutionCaps.FitsInDispenser) == 0)
{
//If it can't fit in the dispenser, don't put it in. For example, buckets and mop buckets can't fit.
_notifyManager.PopupMessage(Owner.Transform.GridPosition, args.User,
@@ -255,7 +262,7 @@ namespace Content.Server.GameObjects.Components.Chemistry
else
{
_beakerContainer.Insert(activeHandEntity);
- _solution.SolutionChanged += HandleSolutionChangedEvent;
+ Solution.SolutionChanged += HandleSolutionChangedEvent;
UpdateUserInterface();
}
}
@@ -268,9 +275,17 @@ namespace Content.Server.GameObjects.Components.Chemistry
return true;
}
- void HandleSolutionChangedEvent()
+ private void HandleSolutionChangedEvent()
{
UpdateUserInterface();
}
+
+ private void ClickSound()
+ {
+ if (Owner.TryGetComponent(out SoundComponent sound))
+ {
+ sound.Play("/Audio/machines/machine_switch.ogg", AudioParams.Default.WithVolume(-2f));
+ }
+ }
}
}
diff --git a/Content.Shared/GameObjects/Components/Chemistry/SharedReagentDispenserComponent.cs b/Content.Shared/GameObjects/Components/Chemistry/SharedReagentDispenserComponent.cs
index 086ab14c8b..0066dc3d50 100644
--- a/Content.Shared/GameObjects/Components/Chemistry/SharedReagentDispenserComponent.cs
+++ b/Content.Shared/GameObjects/Components/Chemistry/SharedReagentDispenserComponent.cs
@@ -20,12 +20,12 @@ namespace Content.Shared.GameObjects.Components.Chemistry
///
/// A list of reagents which this may dispense. Defined in yaml prototype, see .
///
- public List Inventory = new List();
+ protected readonly List Inventory = new List();
[Serializable, NetSerializable]
public class ReagentDispenserBoundUserInterfaceState : BoundUserInterfaceState
{
- public readonly bool HasBeaker;
+ public readonly bool HasBeaker;
public readonly int BeakerCurrentVolume;
public readonly int BeakerMaxVolume;
public readonly string ContainerName;
@@ -38,9 +38,10 @@ namespace Content.Shared.GameObjects.Components.Chemistry
///
public readonly List ContainerReagents;
public readonly string DispenserName;
+ public readonly int SelectedDispenseAmount;
public ReagentDispenserBoundUserInterfaceState(bool hasBeaker, int beakerCurrentVolume, int beakerMaxVolume, string containerName,
- List inventory, string dispenserName, List containerReagents)
+ List inventory, string dispenserName, List containerReagents, int selectedDispenseAmount)
{
HasBeaker = hasBeaker;
BeakerCurrentVolume = beakerCurrentVolume;
@@ -49,6 +50,7 @@ namespace Content.Shared.GameObjects.Components.Chemistry
Inventory = inventory;
DispenserName = dispenserName;
ContainerReagents = containerReagents;
+ SelectedDispenseAmount = selectedDispenseAmount;
}
}
@@ -98,9 +100,10 @@ namespace Content.Shared.GameObjects.Components.Chemistry
/// Information about a reagent which the dispenser can dispense.
///
[Serializable, NetSerializable]
- public class ReagentDispenserInventoryEntry
+ public struct ReagentDispenserInventoryEntry
{
- public string ID;
+ public readonly string ID;
+
public ReagentDispenserInventoryEntry(string id)
{
ID = id;
diff --git a/Resources/Prototypes/Entities/buildings/booze_dispenser.yml b/Resources/Prototypes/Entities/buildings/booze_dispenser.yml
index d6739ad82b..232a6dfe77 100644
--- a/Resources/Prototypes/Entities/buildings/booze_dispenser.yml
+++ b/Resources/Prototypes/Entities/buildings/booze_dispenser.yml
@@ -2,31 +2,14 @@
id: booze_dispenser
name: Booze Dispenser
description: A booze dispenser with a single slot for a container to be filled.
+ parent: reagent_dispenser_base
components:
- type: Sprite
texture: Buildings/booze_dispenser.png
- type: Icon
texture: Buildings/booze_dispenser.png
- - type: Clickable
- - type: Collidable
- shapes:
- - !type:PhysShapeAabb
- bounds: "-0.4,-0.25,0.4,0.25"
- mask: 19
- layer: 16
- IsScrapingFloor: true
- - type: Physics
- mass: 25
- Anchored: true
- - type: SnapGrid
- offset: Center
- type: ReagentDispenser
pack: BoozeDispenserInventory
- - type: PowerDevice
- - type: UserInterface
- interfaces:
- - key: enum.ReagentDispenserUiKey.Key
- type: ReagentDispenserBoundUserInterface
- type: reagentDispenserInventory
id: BoozeDispenserInventory
@@ -34,4 +17,4 @@
- chem.Whiskey
- chem.Ale
- chem.Wine
- - chem.Ice
\ No newline at end of file
+ - chem.Ice
diff --git a/Resources/Prototypes/Entities/buildings/chem_dispenser.yml b/Resources/Prototypes/Entities/buildings/chem_dispenser.yml
index 042b6796b0..3d807ee003 100644
--- a/Resources/Prototypes/Entities/buildings/chem_dispenser.yml
+++ b/Resources/Prototypes/Entities/buildings/chem_dispenser.yml
@@ -1,32 +1,15 @@
- type: entity
id: chem_dispenser
name: Chemical Dispenser
+ parent: reagent_dispenser_base
description: An industrial grade chemical dispenser with a sizeable chemical supply.
components:
- type: Sprite
texture: Buildings/industrial_dispenser.png
- type: Icon
texture: Buildings/industrial_dispenser.png
- - type: Clickable
- - type: Collidable
- shapes:
- - !type:PhysShapeAabb
- bounds: "-0.4,-0.25,0.4,0.25"
- mask: 19
- layer: 16
- IsScrapingFloor: true
- - type: Physics
- mass: 25
- Anchored: true
- - type: SnapGrid
- offset: Center
- type: ReagentDispenser
pack: ChemDispenserStandardInventory
- - type: PowerDevice
- - type: UserInterface
- interfaces:
- - key: enum.ReagentDispenserUiKey.Key
- type: ReagentDispenserBoundUserInterface
- type: reagentDispenserInventory
id: ChemDispenserStandardInventory
diff --git a/Resources/Prototypes/Entities/buildings/reagent_dispenser_base.yml b/Resources/Prototypes/Entities/buildings/reagent_dispenser_base.yml
new file mode 100644
index 0000000000..8e3647e2c0
--- /dev/null
+++ b/Resources/Prototypes/Entities/buildings/reagent_dispenser_base.yml
@@ -0,0 +1,25 @@
+- type: entity
+ abstract: true
+ id: reagent_dispenser_base
+ components:
+ - type: Clickable
+ - type: Collidable
+ shapes:
+ - !type:PhysShapeAabb
+ bounds: "-0.4,-0.25,0.4,0.25"
+ mask: 19
+ layer: 16
+ IsScrapingFloor: true
+ - type: Physics
+ mass: 25
+ Anchored: true
+ - type: SnapGrid
+ offset: Center
+ - type: ReagentDispenser
+ - type: PowerDevice
+ - type: UserInterface
+ interfaces:
+ - key: enum.ReagentDispenserUiKey.Key
+ type: ReagentDispenserBoundUserInterface
+ - type: Sound
+
diff --git a/Resources/Prototypes/Entities/buildings/soda_dispenser.yml b/Resources/Prototypes/Entities/buildings/soda_dispenser.yml
index 67570a84a2..5c54c0bdc9 100644
--- a/Resources/Prototypes/Entities/buildings/soda_dispenser.yml
+++ b/Resources/Prototypes/Entities/buildings/soda_dispenser.yml
@@ -1,32 +1,15 @@
- type: entity
id: soda_dispenser
name: Soda Dispenser
+ parent: reagent_dispenser_base
description: A beverage dispenser with a selection of soda and several other common beverages. Has a single fill slot for containers.
components:
- type: Sprite
texture: Buildings/soda_dispenser.png
- type: Icon
texture: Buildings/soda_dispenser.png
- - type: Clickable
- - type: Collidable
- shapes:
- - !type:PhysShapeAabb
- bounds: "-0.4,-0.25,0.4,0.25"
- mask: 19
- layer: 16
- IsScrapingFloor: true
- - type: Physics
- mass: 25
- Anchored: true
- - type: SnapGrid
- offset: Center
- type: ReagentDispenser
pack: SodaDispenserInventory
- - type: PowerDevice
- - type: UserInterface
- interfaces:
- - key: enum.ReagentDispenserUiKey.Key
- type: ReagentDispenserBoundUserInterface
- type: reagentDispenserInventory
id: SodaDispenserInventory
@@ -35,4 +18,4 @@
- chem.Coffee
- chem.Tea
- chem.Ice
- - chem.H2O
\ No newline at end of file
+ - chem.H2O