Files
tbd-station-14/Content.Shared/Item/ItemComponent.cs
Nemanja cc8984d096 Grid Inventory (#21931)
* Grid Inventory

* oh boy we keep cracking on

* auto insertion is kinda working? gross, too!

* pieces and proper layouts

* fix the sprites

* mousing over grid pieces... finally

* dragging deez nuts all over the screen

* eek!

* dragging is 90% less horrendous

* auto-rotating

* flatten

* Rotation at last

* fix rotation and change keybind for removing items.

* rebinding and keybinding

* wow! look at that! configurable with a button! cool!

* dragging is a bit cooler, eh?

* hover insert, my beloved

* add some grids for storage, fix 1x1 storages, fix multiple inputs at once

* el navigation

* oh yeah some stuff i forgor

* more fixes and QOL stuff

* the griddening

* the last of it (yippee)

* sloth review :)
2023-12-04 16:04:39 -07:00

75 lines
2.3 KiB
C#

using Content.Shared.Hands.Components;
using Robust.Shared.GameStates;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization;
namespace Content.Shared.Item;
/// <summary>
/// Handles items which can be picked up to hands and placed in pockets, as well as storage containers
/// like backpacks.
/// </summary>
[RegisterComponent]
[NetworkedComponent]
[Access(typeof(SharedItemSystem))]
public sealed partial class ItemComponent : Component
{
[DataField, ViewVariables(VVAccess.ReadWrite)]
[Access(typeof(SharedItemSystem))]
public ProtoId<ItemSizePrototype> Size = "Small";
[Access(typeof(SharedItemSystem))]
[DataField]
public Dictionary<HandLocation, List<PrototypeLayerData>> InhandVisuals = new();
[Access(typeof(SharedItemSystem))]
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
public string? HeldPrefix;
/// <summary>
/// Rsi of the sprite shown on the player when this item is in their hands. Used to generate a default entry for <see cref="InhandVisuals"/>
/// </summary>
[Access(typeof(SharedItemSystem))]
[ViewVariables(VVAccess.ReadWrite)]
[DataField("sprite")]
public string? RsiPath;
/// <summary>
/// An optional override for the shape of the item within the grid storage.
/// If null, a default shape will be used based on <see cref="Size"/>.
/// </summary>
[DataField, AutoNetworkedField]
public List<Box2i>? Shape;
}
[Serializable, NetSerializable]
public sealed class ItemComponentState : ComponentState
{
public ProtoId<ItemSizePrototype> Size { get; }
public string? HeldPrefix { get; }
public ItemComponentState(ProtoId<ItemSizePrototype> size, string? heldPrefix)
{
Size = size;
HeldPrefix = heldPrefix;
}
}
/// <summary>
/// Raised when an item's visual state is changed. The event is directed at the entity that contains this item, so
/// that it can properly update its hands or inventory sprites and GUI.
/// </summary>
[Serializable, NetSerializable]
public sealed class VisualsChangedEvent : EntityEventArgs
{
public readonly NetEntity Item;
public readonly string ContainerId;
public VisualsChangedEvent(NetEntity item, string containerId)
{
Item = item;
ContainerId = containerId;
}
}