CatStation/Content.Shared/Containers/ItemSlots/ItemSlotEvents.cs
AndrewFenriz d782d03627
Refactor ItemSlotsSystem and fix insertion/ejection handling (#45284)
* Split

* Upd

* Rename

* fix CopyFrom

* cleanup

* fix HandleItemSlotsState

* fix Insert/Eject

* upd

* Normalize api

* fix SortEmpty

* Fix ItemSlots interactions and documentation

* Revert "Rename"

This reverts commit c79b33b458a58ec39b9857038ceac0ed1eb82297.

* cleaner

* giant entity<T> upd

* rename

* no more CopyFrom

* fix!
2026-08-16 17:04:00 +00:00

40 lines
1.4 KiB
C#

using Robust.Shared.Serialization;
namespace Content.Shared.Containers.ItemSlots;
/// <summary>
/// Used for item-slot insert and eject buttons.
/// </summary>
[Serializable, NetSerializable]
public sealed class ItemSlotButtonPressedEvent(
string slotId,
bool tryEject = true,
bool tryInsert = true) : BoundUserInterfaceMessage
{
/// <summary>
/// The ID of the slot/container from which to insert or eject an item.
/// </summary>
public string SlotId = slotId;
/// <summary>
/// Whether to attempt to insert an item into the slot if there is not already one inside.
/// </summary>
public bool TryInsert = tryInsert;
/// <summary>
/// Whether to attempt to eject the item from the slot if it has one.
/// </summary>
public bool TryEject = tryEject;
}
/// <summary>
/// Event raised on the slot entity and the item being inserted to determine if insertion is allowed.
/// </summary>
[ByRefEvent]
public record struct ItemSlotInsertAttemptEvent(EntityUid SlotEntity, EntityUid Item, EntityUid? User, ItemSlot Slot, bool Cancelled = false);
/// <summary>
/// Event raised on the slot entity and the item being ejected to determine if ejection is allowed.
/// </summary>
[ByRefEvent]
public record struct ItemSlotEjectAttemptEvent(EntityUid SlotEntity, EntityUid Item, EntityUid? User, ItemSlot Slot, bool Cancelled = false);