Revert "Storage TEST MERGE" (#21258)
This commit is contained in:
@@ -13,17 +13,18 @@ namespace Content.Shared.Item;
|
||||
[Access(typeof(SharedItemSystem))]
|
||||
public sealed partial class ItemComponent : Component
|
||||
{
|
||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||
[Access(typeof(SharedItemSystem))]
|
||||
public ItemSize Size = ItemSize.Small;
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("size")]
|
||||
[Access(typeof(SharedItemSystem), Other = AccessPermissions.ReadExecute)]
|
||||
public int Size = 5;
|
||||
|
||||
[Access(typeof(SharedItemSystem))]
|
||||
[DataField]
|
||||
[DataField("inhandVisuals")]
|
||||
public Dictionary<HandLocation, List<PrototypeLayerData>> InhandVisuals = new();
|
||||
|
||||
[Access(typeof(SharedItemSystem))]
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField]
|
||||
[DataField("heldPrefix")]
|
||||
public string? HeldPrefix;
|
||||
|
||||
/// <summary>
|
||||
@@ -38,10 +39,10 @@ public sealed partial class ItemComponent : Component
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class ItemComponentState : ComponentState
|
||||
{
|
||||
public ItemSize Size { get; }
|
||||
public int Size { get; }
|
||||
public string? HeldPrefix { get; }
|
||||
|
||||
public ItemComponentState(ItemSize size, string? heldPrefix)
|
||||
public ItemComponentState(int size, string? heldPrefix)
|
||||
{
|
||||
Size = size;
|
||||
HeldPrefix = heldPrefix;
|
||||
@@ -65,43 +66,6 @@ public sealed class VisualsChangedEvent : EntityEventArgs
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Abstracted sizes for items.
|
||||
/// Used to determine what can fit into inventories.
|
||||
/// </summary>
|
||||
public enum ItemSize
|
||||
{
|
||||
/// <summary>
|
||||
/// Items that can be held completely in one's hand.
|
||||
/// </summary>
|
||||
Tiny = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Items that can fit inside of a standard pocket.
|
||||
/// </summary>
|
||||
Small = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Items that can fit inside of a standard bag.
|
||||
/// </summary>
|
||||
Normal = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Items that are too large to fit inside of standard bags, but can worn in exterior slots or placed in custom containers.
|
||||
/// </summary>
|
||||
Large = 4,
|
||||
|
||||
/// <summary>
|
||||
/// Items that are too large to place inside of any kind of container.
|
||||
/// </summary>
|
||||
Huge = 5,
|
||||
|
||||
/// <summary>
|
||||
/// Picture furry gf
|
||||
/// </summary>
|
||||
Ginormous = 6
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reference sizes for common containers and items.
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Shared.Item;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
@@ -21,11 +20,11 @@ public sealed partial class ItemToggleComponent : Component
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("offSize")]
|
||||
public ItemSize OffSize = ItemSize.Small;
|
||||
public int OffSize = 1;
|
||||
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("onSize")]
|
||||
public ItemSize OnSize = ItemSize.Huge;
|
||||
public int OnSize = 9999;
|
||||
}
|
||||
|
||||
[ByRefEvent]
|
||||
|
||||
@@ -1,27 +1,23 @@
|
||||
using Content.Shared.CombatMode;
|
||||
using Content.Shared.Hands.EntitySystems;
|
||||
using Content.Shared.Interaction;
|
||||
using Content.Shared.Stacks;
|
||||
using Content.Shared.Verbs;
|
||||
using Content.Shared.Examine;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Item;
|
||||
|
||||
public abstract class SharedItemSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototype = default!;
|
||||
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
|
||||
[Dependency] private readonly SharedCombatModeSystem _combatMode = default!;
|
||||
[Dependency] protected readonly SharedContainerSystem Container = default!;
|
||||
|
||||
public const int ItemSizeWeightTiny = 1;
|
||||
public const int ItemSizeWeightSmall = 2;
|
||||
public const int ItemSizeWeightNormal = 4;
|
||||
public const int ItemSizeWeightLarge = 8;
|
||||
public const int ItemSizeWeightHuge = 16;
|
||||
public const int ItemSizeWeightGinormous = 32;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
@@ -37,13 +33,13 @@ public abstract class SharedItemSystem : EntitySystem
|
||||
|
||||
#region Public API
|
||||
|
||||
public void SetSize(EntityUid uid, ItemSize size, ItemComponent? component = null)
|
||||
public void SetSize(EntityUid uid, int size, ItemComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component, false))
|
||||
return;
|
||||
|
||||
component.Size = size;
|
||||
Dirty(uid, component);
|
||||
Dirty(component);
|
||||
}
|
||||
|
||||
public void SetHeldPrefix(EntityUid uid, string? heldPrefix, ItemComponent? component = null)
|
||||
@@ -55,7 +51,7 @@ public abstract class SharedItemSystem : EntitySystem
|
||||
return;
|
||||
|
||||
component.HeldPrefix = heldPrefix;
|
||||
Dirty(uid, component);
|
||||
Dirty(component);
|
||||
VisualsChanged(uid);
|
||||
}
|
||||
|
||||
@@ -71,7 +67,7 @@ public abstract class SharedItemSystem : EntitySystem
|
||||
item.InhandVisuals = otherItem.InhandVisuals;
|
||||
item.HeldPrefix = otherItem.HeldPrefix;
|
||||
|
||||
Dirty(uid, item);
|
||||
Dirty(item);
|
||||
VisualsChanged(uid);
|
||||
}
|
||||
|
||||
@@ -87,7 +83,14 @@ public abstract class SharedItemSystem : EntitySystem
|
||||
|
||||
protected virtual void OnStackCountChanged(EntityUid uid, ItemComponent component, StackCountChangedEvent args)
|
||||
{
|
||||
if (!TryComp<StackComponent>(uid, out var stack))
|
||||
return;
|
||||
|
||||
if (!_prototype.TryIndex<StackPrototype>(stack.StackTypeId, out var stackProto) ||
|
||||
stackProto.ItemSize is not { } size)
|
||||
return;
|
||||
|
||||
SetSize(uid, args.NewCount * size, component);
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, ItemComponent component, ref ComponentHandleState args)
|
||||
@@ -132,7 +135,7 @@ public abstract class SharedItemSystem : EntitySystem
|
||||
private void OnExamine(EntityUid uid, ItemComponent component, ExaminedEvent args)
|
||||
{
|
||||
args.PushMarkup(Loc.GetString("item-component-on-examine-size",
|
||||
("size", GetItemSizeLocale(component.Size))));
|
||||
("size", component.Size)));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -145,32 +148,4 @@ public abstract class SharedItemSystem : EntitySystem
|
||||
public virtual void VisualsChanged(EntityUid owner)
|
||||
{
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public static string GetItemSizeLocale(ItemSize size)
|
||||
{
|
||||
return Robust.Shared.Localization.Loc.GetString($"item-component-size-{size.ToString()}");
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public static int GetItemSizeWeight(ItemSize size)
|
||||
{
|
||||
switch (size)
|
||||
{
|
||||
case ItemSize.Tiny:
|
||||
return ItemSizeWeightTiny;
|
||||
case ItemSize.Small:
|
||||
return ItemSizeWeightSmall;
|
||||
case ItemSize.Normal:
|
||||
return ItemSizeWeightNormal;
|
||||
case ItemSize.Large:
|
||||
return ItemSizeWeightLarge;
|
||||
case ItemSize.Huge:
|
||||
return ItemSizeWeightHuge;
|
||||
case ItemSize.Ginormous:
|
||||
return ItemSizeWeightGinormous;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(size), size, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user