2022-07-29 13:02:09 +12:00
|
|
|
using Content.Shared.Hands.Components;
|
|
|
|
|
using Robust.Shared.GameStates;
|
2023-11-06 02:20:50 -05:00
|
|
|
using Robust.Shared.Prototypes;
|
2022-07-27 03:53:47 -07:00
|
|
|
using Robust.Shared.Serialization;
|
2023-12-06 19:59:16 -05:00
|
|
|
using Robust.Shared.Utility;
|
2022-07-27 03:53:47 -07:00
|
|
|
|
|
|
|
|
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]
|
2022-07-29 13:02:09 +12:00
|
|
|
[NetworkedComponent]
|
2024-01-03 17:24:02 +11:00
|
|
|
[Access(typeof(SharedItemSystem)), AutoGenerateComponentState(true)]
|
2023-08-22 18:14:33 -07:00
|
|
|
public sealed partial class ItemComponent : Component
|
2022-07-27 03:53:47 -07:00
|
|
|
{
|
2024-01-03 17:24:02 +11:00
|
|
|
[DataField, ViewVariables(VVAccess.ReadWrite), AutoNetworkedField]
|
2023-10-30 23:55:55 -04:00
|
|
|
[Access(typeof(SharedItemSystem))]
|
2023-11-06 02:20:50 -05:00
|
|
|
public ProtoId<ItemSizePrototype> Size = "Small";
|
2022-07-27 03:53:47 -07:00
|
|
|
|
2022-09-14 10:42:14 +02:00
|
|
|
[Access(typeof(SharedItemSystem))]
|
2023-10-30 23:55:55 -04:00
|
|
|
[DataField]
|
2023-04-30 18:09:52 +12:00
|
|
|
public Dictionary<HandLocation, List<PrototypeLayerData>> InhandVisuals = new();
|
2022-07-27 03:53:47 -07:00
|
|
|
|
|
|
|
|
[Access(typeof(SharedItemSystem))]
|
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
2024-01-03 17:24:02 +11:00
|
|
|
[DataField, AutoNetworkedField]
|
2022-07-27 03:53:47 -07:00
|
|
|
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>
|
2022-09-14 10:42:14 +02:00
|
|
|
[Access(typeof(SharedItemSystem))]
|
2022-07-27 03:53:47 -07:00
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
|
|
|
[DataField("sprite")]
|
2022-09-14 10:42:14 +02:00
|
|
|
public string? RsiPath;
|
2023-12-04 18:04:39 -05:00
|
|
|
|
|
|
|
|
/// <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;
|
2023-12-06 19:59:16 -05:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A sprite used to depict this entity specifically when it is displayed in the storage UI.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField, AutoNetworkedField]
|
|
|
|
|
public SpriteSpecifier? StoredSprite;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// An additional angle offset, in degrees, applied to the visual depiction of the item when displayed in the storage UI.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField, AutoNetworkedField]
|
|
|
|
|
public float StoredRotation = 0;
|
2024-01-14 17:44:17 +01:00
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// An additional offset, in pixels, applied to the visual depiction of the item when displayed in the storage UI.
|
|
|
|
|
/// </summary>
|
|
|
|
|
[DataField, AutoNetworkedField]
|
|
|
|
|
public Vector2i StoredOffset;
|
2022-07-27 03:53:47 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <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
|
|
|
|
|
{
|
2023-09-11 09:42:41 +10:00
|
|
|
public readonly NetEntity Item;
|
2022-07-27 03:53:47 -07:00
|
|
|
public readonly string ContainerId;
|
|
|
|
|
|
2023-09-11 09:42:41 +10:00
|
|
|
public VisualsChangedEvent(NetEntity item, string containerId)
|
2022-07-27 03:53:47 -07:00
|
|
|
{
|
|
|
|
|
Item = item;
|
|
|
|
|
ContainerId = containerId;
|
|
|
|
|
}
|
|
|
|
|
}
|