Files
Delta-v/Content.Shared/_DV/SmartFridge/SmartFridgeComponent.cs
T
c7077a388c 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-06-29 12:44:09 +02:00

98 lines
2.8 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;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared._DV.SmartFridge;
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true), AutoGenerateComponentPause]
[Access(typeof(SharedSmartFridgeSystem))]
public sealed partial class SmartFridgeComponent : Component
{
[DataField]
public string Container = "smart_fridge_inventory";
[DataField]
public EntityWhitelist? Whitelist;
[DataField]
public EntityWhitelist? Blacklist;
[DataField]
public SoundSpecifier? InsertSound = new SoundPathSpecifier("/Audio/Weapons/Guns/MagIn/revolver_magin.ogg");
[DataField, AutoNetworkedField]
public HashSet<SmartFridgeEntry> Entries = new();
[DataField, AutoNetworkedField]
[Access(typeof(SharedSmartFridgeSystem), Other = AccessPermissions.ReadExecute)]
public Dictionary<SmartFridgeEntry, HashSet<NetEntity>> ContainedEntries = new();
[DataField]
public TimeSpan EjectCooldown = TimeSpan.FromSeconds(1.2);
[ViewVariables]
public bool Ejecting => EjectEnd != null;
[DataField(customTypeSerializer:typeof(TimeOffsetSerializer)), AutoPausedField]
public TimeSpan? EjectEnd;
/// <summary>
/// Sound that plays when ejecting an item
/// </summary>
[DataField]
public SoundSpecifier SoundVend = new SoundPathSpecifier("/Audio/Machines/machine_vend.ogg")
{
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 SoundPathSpecifier("/Audio/Machines/custom_deny.ogg");
}
[Serializable, NetSerializable, DataRecord]
public partial record struct SmartFridgeEntry
{
public string Name;
public SmartFridgeEntry(string name)
{
Name = name;
}
}
[Serializable, NetSerializable]
public enum SmartFridgeUiKey
{
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;
}