Make starting gear automatically find hands for inhand items (#20861)
This commit is contained in:
@@ -1,34 +1,28 @@
|
||||
using Content.Shared.Preferences;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
|
||||
|
||||
namespace Content.Shared.Roles
|
||||
{
|
||||
[Prototype("startingGear")]
|
||||
public sealed class StartingGearPrototype : IPrototype
|
||||
{
|
||||
[DataField("equipment", customTypeSerializer: typeof(PrototypeIdValueDictionarySerializer<string, EntityPrototype>))]
|
||||
private Dictionary<string, string> _equipment = new();
|
||||
[DataField]
|
||||
public Dictionary<string, EntProtoId> Equipment = new();
|
||||
|
||||
/// <summary>
|
||||
/// if empty, there is no skirt override - instead the uniform provided in equipment is added.
|
||||
/// </summary>
|
||||
[DataField("innerclothingskirt", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
private string? _innerClothingSkirt;
|
||||
[DataField]
|
||||
public EntProtoId? InnerClothingSkirt;
|
||||
|
||||
[DataField("satchel", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
private string? _satchel;
|
||||
[DataField]
|
||||
public EntProtoId? Satchel;
|
||||
|
||||
[DataField("duffelbag", customTypeSerializer:typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
private string? _duffelbag;
|
||||
[DataField]
|
||||
public EntProtoId? Duffelbag;
|
||||
|
||||
public IReadOnlyDictionary<string, string> Inhand => _inHand;
|
||||
/// <summary>
|
||||
/// hand index, item prototype
|
||||
/// </summary>
|
||||
[DataField("inhand")]
|
||||
private Dictionary<string, string> _inHand = new(0);
|
||||
[DataField]
|
||||
public List<EntProtoId> Inhand = new(0);
|
||||
|
||||
[ViewVariables]
|
||||
[IdDataField]
|
||||
@@ -38,15 +32,15 @@ namespace Content.Shared.Roles
|
||||
{
|
||||
if (profile != null)
|
||||
{
|
||||
if (slot == "jumpsuit" && profile.Clothing == ClothingPreference.Jumpskirt && !string.IsNullOrEmpty(_innerClothingSkirt))
|
||||
return _innerClothingSkirt;
|
||||
if (slot == "back" && profile.Backpack == BackpackPreference.Satchel && !string.IsNullOrEmpty(_satchel))
|
||||
return _satchel;
|
||||
if (slot == "back" && profile.Backpack == BackpackPreference.Duffelbag && !string.IsNullOrEmpty(_duffelbag))
|
||||
return _duffelbag;
|
||||
if (slot == "jumpsuit" && profile.Clothing == ClothingPreference.Jumpskirt && !string.IsNullOrEmpty(InnerClothingSkirt))
|
||||
return InnerClothingSkirt;
|
||||
if (slot == "back" && profile.Backpack == BackpackPreference.Satchel && !string.IsNullOrEmpty(Satchel))
|
||||
return Satchel;
|
||||
if (slot == "back" && profile.Backpack == BackpackPreference.Duffelbag && !string.IsNullOrEmpty(Duffelbag))
|
||||
return Duffelbag;
|
||||
}
|
||||
|
||||
return _equipment.TryGetValue(slot, out var equipment) ? equipment : string.Empty;
|
||||
return Equipment.TryGetValue(slot, out var equipment) ? equipment : string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user