Convert ItemSize to prototypes (#21481)
* item sizes are prototypes * eek
This commit is contained in:
@@ -6,12 +6,14 @@ 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] protected readonly SharedContainerSystem Container = default!;
|
||||
|
||||
@@ -30,7 +32,7 @@ public abstract class SharedItemSystem : EntitySystem
|
||||
|
||||
#region Public API
|
||||
|
||||
public void SetSize(EntityUid uid, ItemSize size, ItemComponent? component = null)
|
||||
public void SetSize(EntityUid uid, ProtoId<ItemSizePrototype> size, ItemComponent? component = null)
|
||||
{
|
||||
if (!Resolve(uid, ref component, false))
|
||||
return;
|
||||
@@ -128,6 +130,11 @@ public abstract class SharedItemSystem : EntitySystem
|
||||
("size", GetItemSizeLocale(component.Size))));
|
||||
}
|
||||
|
||||
public ItemSizePrototype GetSizePrototype(ProtoId<ItemSizePrototype> id)
|
||||
{
|
||||
return _prototype.Index(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies any entity that is holding or wearing this item that they may need to update their sprite.
|
||||
/// </summary>
|
||||
@@ -140,14 +147,14 @@ public abstract class SharedItemSystem : EntitySystem
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public static string GetItemSizeLocale(ItemSize size)
|
||||
public string GetItemSizeLocale(ProtoId<ItemSizePrototype> size)
|
||||
{
|
||||
return Robust.Shared.Localization.Loc.GetString($"item-component-size-{size.ToString()}");
|
||||
return Loc.GetString(GetSizePrototype(size).Name);
|
||||
}
|
||||
|
||||
[PublicAPI]
|
||||
public static int GetItemSizeWeight(ItemSize size)
|
||||
public int GetItemSizeWeight(ProtoId<ItemSizePrototype> size)
|
||||
{
|
||||
return (int) size;
|
||||
return GetSizePrototype(size).Weight;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user