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.Chemistry.Reagent ;
using Content.Shared.Cloning ;
2020-07-17 15:41:19 -05:00
using Robust.Shared.GameObjects ;
using Robust.Shared.Serialization ;
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>
public class SharedChemMasterComponent : Component
{
public override string Name = > "ChemMaster" ;
[Serializable, NetSerializable]
public class ChemMasterBoundUserInterfaceState : BoundUserInterfaceState
{
2020-08-10 16:30:56 +02:00
public readonly bool HasPower ;
2020-07-17 15:41:19 -05:00
public readonly bool HasBeaker ;
public readonly ReagentUnit BeakerCurrentVolume ;
public readonly ReagentUnit BeakerMaxVolume ;
public readonly string ContainerName ;
/// <summary>
/// A list of the reagents and their amounts within the beaker/reagent container, if applicable.
/// </summary>
2021-06-09 22:19:39 +02:00
public readonly IReadOnlyList < Solution . 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-06-09 22:19:39 +02:00
public readonly IReadOnlyList < Solution . Solution . ReagentQuantity > BufferReagents ;
2020-07-17 15:41:19 -05:00
public readonly string DispenserName ;
public readonly bool BufferModeTransfer ;
public readonly ReagentUnit BufferCurrentVolume ;
2020-08-10 16:30:56 +02:00
public ChemMasterBoundUserInterfaceState ( bool hasPower , bool hasBeaker , ReagentUnit beakerCurrentVolume , ReagentUnit beakerMaxVolume , string containerName ,
2021-06-09 22:19:39 +02:00
string dispenserName , IReadOnlyList < Solution . Solution . ReagentQuantity > containerReagents , IReadOnlyList < Solution . Solution . ReagentQuantity > bufferReagents , bool bufferModeTransfer , ReagentUnit bufferCurrentVolume )
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 ;
DispenserName = dispenserName ;
ContainerReagents = containerReagents ;
BufferReagents = bufferReagents ;
BufferModeTransfer = bufferModeTransfer ;
BufferCurrentVolume = bufferCurrentVolume ;
}
}
/// <summary>
/// Message data sent from client to server when a ChemMaster ui button is pressed.
/// </summary>
[Serializable, NetSerializable]
public class UiActionMessage : BoundUserInterfaceMessage
{
public readonly UiAction action ;
public readonly ReagentUnit amount ;
public readonly string id = "" ;
public readonly bool isBuffer ;
public readonly int pillAmount ;
public readonly int bottleAmount ;
public UiActionMessage ( UiAction _action , ReagentUnit ? _amount , string? _id , bool? _isBuffer , int? _pillAmount , int? _bottleAmount )
{
action = _action ;
if ( action = = UiAction . ChemButton )
{
amount = _amount . GetValueOrDefault ( ) ;
if ( _id = = null )
{
id = "null" ;
}
else
{
id = _id ;
}
isBuffer = _isBuffer . GetValueOrDefault ( ) ;
}
else
{
pillAmount = _pillAmount . GetValueOrDefault ( ) ;
bottleAmount = _bottleAmount . GetValueOrDefault ( ) ;
}
}
}
[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 ,
CreateBottles
}
}
}