2020-07-17 15:41:19 -05:00
using System ;
using System.Collections.Generic ;
2021-06-09 22:19:39 +02:00
using Content.Shared.Cloning ;
2021-11-24 20:03:07 +13:00
using Content.Shared.Containers.ItemSlots ;
2021-11-03 16:48:03 -07:00
using Content.Shared.FixedPoint ;
2020-07-17 15:41:19 -05:00
using Robust.Shared.GameObjects ;
using Robust.Shared.Serialization ;
2021-11-24 20:03:07 +13:00
using Robust.Shared.Serialization.Manager.Attributes ;
2020-07-17 15:41:19 -05:00
2021-06-09 22:19:39 +02:00
namespace Content.Shared.Chemistry.Components
2020-07-17 15:41:19 -05:00
{
/// <summary>
/// Shared class for <c>ChemMasterComponent</c>. Provides a way for entities to split reagents from a beaker and produce pills and bottles via a user interface.
/// </summary>
2022-02-16 00:23:23 -07:00
[Virtual]
2020-07-17 15:41:19 -05:00
public class SharedChemMasterComponent : Component
{
2021-11-24 20:03:07 +13:00
[DataField("beakerSlot")]
public ItemSlot BeakerSlot = new ( ) ;
2021-09-06 15:49:44 +02:00
public const string SolutionName = "buffer" ;
2020-07-17 15:41:19 -05:00
[Serializable, NetSerializable]
2022-02-16 00:23:23 -07:00
public sealed class ChemMasterBoundUserInterfaceState : BoundUserInterfaceState
2020-07-17 15:41:19 -05:00
{
2020-08-10 16:30:56 +02:00
public readonly bool HasPower ;
2020-07-17 15:41:19 -05:00
public readonly bool HasBeaker ;
2021-11-03 16:48:03 -07:00
public readonly FixedPoint2 BeakerCurrentVolume ;
public readonly FixedPoint2 BeakerMaxVolume ;
2020-07-17 15:41:19 -05:00
public readonly string ContainerName ;
2021-11-28 18:25:23 -08:00
public readonly string Label ;
2020-07-17 15:41:19 -05:00
/// <summary>
/// A list of the reagents and their amounts within the beaker/reagent container, if applicable.
/// </summary>
2021-09-06 15:49:44 +02:00
public readonly IReadOnlyList < Solution . ReagentQuantity > ContainerReagents ;
2020-07-17 15:41:19 -05:00
/// <summary>
/// A list of the reagents and their amounts within the buffer, if applicable.
/// </summary>
2021-09-06 15:49:44 +02:00
public readonly IReadOnlyList < Solution . ReagentQuantity > BufferReagents ;
2020-07-17 15:41:19 -05:00
public readonly string DispenserName ;
public readonly bool BufferModeTransfer ;
2021-11-03 16:48:03 -07:00
public readonly FixedPoint2 BufferCurrentVolume ;
2021-11-26 22:44:36 -08:00
public readonly uint SelectedPillType ;
2020-07-17 15:41:19 -05:00
2021-11-28 18:25:23 -08:00
public ChemMasterBoundUserInterfaceState ( bool hasPower , bool hasBeaker , FixedPoint2 beakerCurrentVolume , FixedPoint2 beakerMaxVolume , string containerName , string label ,
2021-11-26 22:44:36 -08:00
string dispenserName , IReadOnlyList < Solution . ReagentQuantity > containerReagents , IReadOnlyList < Solution . ReagentQuantity > bufferReagents , bool bufferModeTransfer , FixedPoint2 bufferCurrentVolume , uint selectedPillType )
2020-07-17 15:41:19 -05:00
{
2020-08-10 16:30:56 +02:00
HasPower = hasPower ;
2020-07-17 15:41:19 -05:00
HasBeaker = hasBeaker ;
BeakerCurrentVolume = beakerCurrentVolume ;
BeakerMaxVolume = beakerMaxVolume ;
ContainerName = containerName ;
2021-11-28 18:25:23 -08:00
Label = label ;
2020-07-17 15:41:19 -05:00
DispenserName = dispenserName ;
ContainerReagents = containerReagents ;
BufferReagents = bufferReagents ;
BufferModeTransfer = bufferModeTransfer ;
BufferCurrentVolume = bufferCurrentVolume ;
2021-11-26 22:44:36 -08:00
SelectedPillType = selectedPillType ;
2020-07-17 15:41:19 -05:00
}
}
/// <summary>
/// Message data sent from client to server when a ChemMaster ui button is pressed.
/// </summary>
[Serializable, NetSerializable]
2022-02-16 00:23:23 -07:00
public sealed class UiActionMessage : BoundUserInterfaceMessage
2020-07-17 15:41:19 -05:00
{
2021-11-26 22:44:36 -08:00
public readonly UiAction Action ;
public readonly FixedPoint2 Amount ;
public readonly string Id = "" ;
public readonly bool IsBuffer ;
2021-11-28 18:25:23 -08:00
public readonly string Label = "" ;
2021-11-26 22:44:36 -08:00
public readonly uint PillType ;
public readonly int PillAmount ;
public readonly int BottleAmount ;
2020-07-17 15:41:19 -05:00
2021-11-28 18:25:23 -08:00
public UiActionMessage ( UiAction action , FixedPoint2 ? amount , string? id , bool? isBuffer , string? label , uint? pillType , int? pillAmount , int? bottleAmount )
2020-07-17 15:41:19 -05:00
{
2021-11-26 22:44:36 -08:00
Action = action ;
if ( Action = = UiAction . ChemButton )
2020-07-17 15:41:19 -05:00
{
2021-11-26 22:44:36 -08:00
Amount = amount . GetValueOrDefault ( ) ;
if ( id = = null )
2020-07-17 15:41:19 -05:00
{
2021-11-26 22:44:36 -08:00
Id = "null" ;
2020-07-17 15:41:19 -05:00
}
else
{
2021-11-26 22:44:36 -08:00
Id = id ;
2020-07-17 15:41:19 -05:00
}
2021-11-28 18:25:23 -08:00
IsBuffer = isBuffer . GetValueOrDefault ( ) ;
2020-07-17 15:41:19 -05:00
}
else
{
2021-11-26 22:44:36 -08:00
PillAmount = pillAmount . GetValueOrDefault ( ) ;
PillType = pillType . GetValueOrDefault ( ) ;
BottleAmount = bottleAmount . GetValueOrDefault ( ) ;
2021-11-28 18:25:23 -08:00
if ( label = = null )
{
Label = "null" ;
}
else
{
Label = label ;
}
2020-07-17 15:41:19 -05:00
}
}
}
[Serializable, NetSerializable]
public enum ChemMasterUiKey
{
Key
}
/// <summary>
2021-01-03 17:20:17 +01:00
/// Used in <see cref="AcceptCloningChoiceMessage"/> to specify which button was pressed.
2020-07-17 15:41:19 -05:00
/// </summary>
public enum UiAction
{
Eject ,
Transfer ,
Discard ,
ChemButton ,
CreatePills ,
2021-11-26 22:44:36 -08:00
CreateBottles ,
SetPillType
2020-07-17 15:41:19 -05:00
}
}
}