CatStation/Content.Shared/SmartFridge/SmartFridgeComponent.cs
slarticodefast 2736c458c4
Predict reagent grinder (#42815)
* prediction!!!

* fixes

* fixes and add debug logs

* fix prediction and cleanup

* raise event on client + comp access

* reapply power state changes

* Update Content.Client/Kitchen/EntitySystems/ReagentGrinderSystem.cs

Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>

* Update Content.Shared/Kitchen/Components/ReagentGrinderComponent.cs

Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>

* comments and prefilled grinder protos

* t

---------

Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com>
Co-authored-by: ScarKy0 <scarky0@onet.eu>
2026-03-15 19:15:36 +00:00

115 lines
3.2 KiB
C#

using Content.Shared.Whitelist;
using Robust.Shared.Analyzers;
using Robust.Shared.Audio;
using Robust.Shared.GameObjects;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.SmartFridge;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
[Access(typeof(SharedSmartFridgeSystem))]
public sealed partial class SmartFridgeComponent : Component
{
/// <summary>
/// The container ID that this SmartFridge stores its inventory in
/// </summary>
[DataField]
public string Container = "smart_fridge_inventory";
/// <summary>
/// Whitelist for what entities can be inserted
/// </summary>
[DataField]
public EntityWhitelist? Whitelist;
/// <summary>
/// Blacklist for what entities can be inserted
/// </summary>
[DataField]
public EntityWhitelist? Blacklist;
/// <summary>
/// The sound played on inserting an item into the fridge
/// </summary>
[DataField]
public SoundSpecifier? InsertSound = new SoundCollectionSpecifier("MachineInsert");
/// <summary>
/// A list of entries to display in the UI
/// </summary>
[DataField, AutoNetworkedField]
public List<SmartFridgeEntry> Entries = new();
/// <summary>
/// A mapping of smart fridge entries to the actual contained contents
/// </summary>
[DataField, AutoNetworkedField]
[Access(typeof(SharedSmartFridgeSystem), Other = AccessPermissions.ReadExecute)]
public Dictionary<SmartFridgeEntry, HashSet<NetEntity>> ContainedEntries = new();
/// <summary>
/// The flavour text displayed at the bottom of the SmartFridge's UI
/// </summary>
[DataField]
public LocId FlavorText = "smart-fridge-request-generic";
/// <summary>
/// Sound that plays when ejecting an item
/// </summary>
[DataField]
public SoundSpecifier SoundVend = new SoundCollectionSpecifier("VendingDispense")
{
Params = new AudioParams
{
Volume = -4f,
Variation = 0.15f
}
};
/// <summary>
/// Sound that plays when an item can't be ejected
/// </summary>
[DataField]
public SoundSpecifier SoundDeny = new SoundCollectionSpecifier("VendingDeny");
}
/// <summary>
/// A single entry in the smart fridge UI.
/// May contain multiple items of the same type.
/// </summary>
[Serializable, NetSerializable, DataRecord]
public partial record struct SmartFridgeEntry
{
public string Name;
public SmartFridgeEntry(string name)
{
Name = name;
}
}
[Serializable, NetSerializable]
public enum SmartFridgeUiKey : byte
{
Key,
}
/// <summary>
/// Sent by the client when trying to dispense an item inside the fridge.
/// </summary>
[Serializable, NetSerializable]
public sealed class SmartFridgeDispenseItemMessage(SmartFridgeEntry entry) : BoundUserInterfaceMessage
{
public SmartFridgeEntry Entry = entry;
}
/// <summary>
/// Sent by the client when trying to remove an empty smart fridge entry from the list of items in the UI.
/// </summary>
[Serializable, NetSerializable]
public sealed class SmartFridgeRemoveEntryMessage(SmartFridgeEntry entry) : BoundUserInterfaceMessage
{
public SmartFridgeEntry Entry = entry;
}