using Content.Shared.Access;
using Content.Shared.Cargo.Prototypes;
using Robust.Shared.Audio;
using Robust.Shared.GameStates;
using Content.Shared.Radio;
using Content.Shared.Stacks;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Cargo.Components;
///
/// Handles sending order requests to cargo. Doesn't handle orders themselves via shuttle or telepads.
///
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState, AutoGenerateComponentPause]
[Access(typeof(SharedCargoSystem))]
public sealed partial class CargoOrderConsoleComponent : Component
{
///
/// The account that this console pulls from for ordering.
///
[DataField]
public ProtoId Account = "Cargo";
[DataField]
public SoundSpecifier ErrorSound = new SoundCollectionSpecifier("CargoError");
///
/// Sound made when is toggled.
///
[DataField]
public SoundSpecifier ToggleLimitSound = new SoundCollectionSpecifier("CargoToggleLimit");
///
/// If true, account transfers have no limit and a lower cooldown.
///
[DataField, AutoNetworkedField]
public bool TransferUnbounded;
[ViewVariables]
public float TransferLimit => TransferUnbounded ? 1 : BaseTransferLimit;
///
/// The maximum percent of total funds that can be transferred or withdrawn in one action.
///
[DataField, AutoNetworkedField]
public float BaseTransferLimit = 0.20f;
///
/// The time at which account actions can be performed again.
///
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField, AutoPausedField]
public TimeSpan NextAccountActionTime;
[ViewVariables]
public TimeSpan AccountActionDelay => TransferUnbounded ? UnboundedAccountActionDelay : BaseAccountActionDelay;
///
/// The minimum time between account actions when is false
///
[DataField]
public TimeSpan BaseAccountActionDelay = TimeSpan.FromMinutes(1);
///
/// The minimum time between account actions when is true
///
[DataField]
public TimeSpan UnboundedAccountActionDelay = TimeSpan.FromSeconds(10);
///
/// The stack representing cash dispensed on withdrawals.
///
[DataField]
public ProtoId CashType = "Credit";
///
/// All of the s that are supported.
///
[DataField, AutoNetworkedField]
public List> AllowedGroups = new()
{
"market",
"SalvageJobReward2",
"SalvageJobReward3",
"SalvageJobRewardMAX",
};
///
/// Access needed to toggle the limit on this console.
///
[DataField]
public HashSet> RemoveLimitAccess = new();
///
/// Radio channel on which order approval announcements are transmitted
///
[DataField, ViewVariables(VVAccess.ReadWrite)]
public ProtoId AnnouncementChannel = "Supply";
///
/// Secondary radio channel which always receives order announcements.
///
public static readonly ProtoId BaseAnnouncementChannel = "Supply";
///
/// The behaviour of the cargo console regarding orders
///
[DataField]
public CargoOrderConsoleMode Mode = CargoOrderConsoleMode.DirectOrder;
///
/// The time at which the console will be able to print a slip again.
///
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
public TimeSpan NextPrintTime = TimeSpan.Zero;
///
/// The time between prints.
///
[DataField]
public TimeSpan PrintDelay = TimeSpan.FromSeconds(5);
///
/// The sound made when printing occurs
///
[DataField]
public SoundSpecifier PrintSound = new SoundCollectionSpecifier("PrinterPrint");
///
/// The sound made when an order slip is scanned
///
[DataField]
public SoundSpecifier ScanSound = new SoundCollectionSpecifier("CargoBeep");
///
/// The time at which the console will be able to play the deny sound.
///
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
public TimeSpan NextDenySoundTime = TimeSpan.Zero;
///
/// The time between playing the deny sound.
///
[DataField]
public TimeSpan DenySoundDelay = TimeSpan.FromSeconds(2);
}
///
/// The behaviour of the cargo order console
///
[Serializable, NetSerializable]
public enum CargoOrderConsoleMode : byte
{
///
/// Place orders directly
///
DirectOrder,
///
/// Print a slip to be inserted into a DirectOrder console
///
PrintSlip,
///
/// Transfers the order to the primary account
///
SendToPrimary,
}
///
/// Withdraw funds from an account
///
[Serializable, NetSerializable]
public sealed class CargoConsoleWithdrawFundsMessage : BoundUserInterfaceMessage
{
public ProtoId? Account;
public int Amount;
public CargoConsoleWithdrawFundsMessage(ProtoId? account, int amount)
{
Account = account;
Amount = amount;
}
}
///
/// Toggle the limit on withdrawals and transfers.
///
[Serializable, NetSerializable]
public sealed class CargoConsoleToggleLimitMessage : BoundUserInterfaceMessage;