Files
tbd-station-14/Content.Shared/GameObjects/Components/Chemistry/ReagentDispenser/SharedReagentDispenserComponent.cs
Visne 9b94d5c195 Added nullable to most Content.Shared files (#3238)
* Add nullable to some Content.Shared files.

* Use [NotNullWhen(true)]

* Undo adding now redundant !'s

* Forgot one

* Add a ton more nullable

* You can guess

* Fix some issues

* It actually compiles now

* Auto stash before merge of "null2" and "origin/master"

* I lied

* enable annotations -> enable

* Revert ActionBlockerSystem.cs to original

* Fix ActionBlockerSystem.cs

* More nullable

* Undo some added exclamation marks

* Fix issues

* Update Content.Shared/Maps/ContentTileDefinition.cs

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>

* Resolve some issues

* Remove unused method

* Fix more issues

* Fix more issues

* Fix more issues

* Fix more issues

* Fix issue, rollback SharedGhostComponent.cs

* Update submodule

* Fix issue, invert some if-statements to reduce nesting

* Revert RobustToolbox

* FIx things broken by merge

* Some fixes

- Replaced with string.Empty
- Remove some exclamation marks
- Revert file

* Some fixes

* Trivial #nullable enable

* Fix null ables

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
2021-02-27 14:12:09 +11:00

119 lines
4.8 KiB
C#

#nullable enable
using System;
using System.Collections.Generic;
using Content.Shared.Chemistry;
using Robust.Shared.GameObjects;
using Robust.Shared.Serialization;
namespace Content.Shared.GameObjects.Components.Chemistry.ReagentDispenser
{
/// <summary>
/// Shared class for <c>ReagentDispenserComponent</c>. Provides a way for entities to dispense and remove reagents from other entities with SolutionComponents via a user interface.
/// <para>This is useful for machines such as the chemical dispensers, booze dispensers, or soda dispensers.</para>
/// <para>The chemicals which may be dispensed are defined by specifying a reagent pack. See <see cref="ReagentDispenserInventoryPrototype"/> for more information on that.</para>
/// </summary>
public class SharedReagentDispenserComponent : Component
{
public override string Name => "ReagentDispenser";
/// <summary>
/// A list of reagents which this may dispense. Defined in yaml prototype, see <see cref="ReagentDispenserInventoryPrototype"/>.
/// </summary>
protected readonly List<ReagentDispenserInventoryEntry> Inventory = new();
[Serializable, NetSerializable]
public class ReagentDispenserBoundUserInterfaceState : BoundUserInterfaceState
{
public readonly bool HasPower;
public readonly bool HasBeaker;
public readonly ReagentUnit BeakerCurrentVolume;
public readonly ReagentUnit BeakerMaxVolume;
public readonly string ContainerName;
/// <summary>
/// A list of the reagents which this dispenser can dispense.
/// </summary>
public readonly List<ReagentDispenserInventoryEntry> Inventory;
/// <summary>
/// A list of the reagents and their amounts within the beaker/reagent container, if applicable.
/// </summary>
public readonly List<Solution.ReagentQuantity>? ContainerReagents;
public readonly string DispenserName;
public readonly ReagentUnit SelectedDispenseAmount;
public ReagentDispenserBoundUserInterfaceState(bool hasPower, bool hasBeaker, ReagentUnit beakerCurrentVolume, ReagentUnit beakerMaxVolume, string containerName,
List<ReagentDispenserInventoryEntry> inventory, string dispenserName, List<Solution.ReagentQuantity>? containerReagents, ReagentUnit selectedDispenseAmount)
{
HasPower = hasPower;
HasBeaker = hasBeaker;
BeakerCurrentVolume = beakerCurrentVolume;
BeakerMaxVolume = beakerMaxVolume;
ContainerName = containerName;
Inventory = inventory;
DispenserName = dispenserName;
ContainerReagents = containerReagents;
SelectedDispenseAmount = selectedDispenseAmount;
}
}
/// <summary>
/// Message data sent from client to server when a dispenser ui button is pressed.
/// </summary>
[Serializable, NetSerializable]
public 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
}
/// <summary>
/// Used in <see cref="UiButtonPressedMessage"/> to specify which button was pressed.
/// </summary>
public enum UiButton
{
Eject,
Clear,
SetDispenseAmount1,
SetDispenseAmount5,
SetDispenseAmount10,
SetDispenseAmount15,
SetDispenseAmount20,
SetDispenseAmount25,
SetDispenseAmount30,
SetDispenseAmount50,
SetDispenseAmount100,
/// <summary>
/// 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 <see cref="UiButtonPressedMessage.DispenseIndex"/>.
/// </summary>
Dispense
}
/// <summary>
/// Information about a reagent which the dispenser can dispense.
/// </summary>
[Serializable, NetSerializable]
public struct ReagentDispenserInventoryEntry
{
public readonly string ID;
public ReagentDispenserInventoryEntry(string id)
{
ID = id;
}
}
}
}