* Clothing & Gender fields: Add to database [MODIFIED TO NOT DEPEND ON SAPHIRE-DB-REFACTOR] Sorry about this, Saphire. * Clothing & Gender fields: Add UI [FALLBACK II] * Clothing & Gender fields: Actually apply gender * Clothing & Gender fields: Import innerclothingskirt field from my previous attempt Couldn't import actual prototypes because of a change to IDs * Clothing & Gender fields: Add innerclothingskirt field to everything * Clothing & Gender fields: Jumpskirts now work * Clothing & Gender fields: Gender field will follow sex field if it's not different (UX improvement) [FALLBACK II] * Clothing & Gender fields: Gender -> Pronouns to reduce confusion. Also, fix profile summary. Properly. [FALLBACK II] * Clothing & Pronoun fields: Refactor so that profile equipment adjustments are performed in StartingGearPrototype.
75 lines
2.4 KiB
C#
75 lines
2.4 KiB
C#
#nullable enable
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.ViewVariables;
|
|
using YamlDotNet.RepresentationModel;
|
|
using Content.Shared.Preferences;
|
|
using static Content.Shared.GameObjects.Components.Inventory.EquipmentSlotDefines;
|
|
|
|
namespace Content.Shared.Roles
|
|
{
|
|
[Prototype("startingGear")]
|
|
public class StartingGearPrototype : IPrototype, IIndexedPrototype
|
|
{
|
|
private string _id = default!;
|
|
private Dictionary<Slots, string> _equipment = default!;
|
|
|
|
/// <summary>
|
|
/// if empty, there is no skirt override - instead the uniform provided in equipment is added.
|
|
/// </summary>
|
|
private string _innerClothingSkirt = default!;
|
|
|
|
public IReadOnlyDictionary<string, string> Inhand => _inHand;
|
|
/// <summary>
|
|
/// hand index, item prototype
|
|
/// </summary>
|
|
private Dictionary<string, string> _inHand = default!;
|
|
|
|
[ViewVariables] public string ID => _id;
|
|
|
|
public void LoadFrom(YamlMappingNode mapping)
|
|
{
|
|
var serializer = YamlObjectSerializer.NewReader(mapping);
|
|
|
|
serializer.DataField(ref _id, "id", string.Empty);
|
|
serializer.DataField(ref _inHand, "inhand", new Dictionary<string, string>(0));
|
|
|
|
var equipment = serializer.ReadDataField<Dictionary<string, string>>("equipment");
|
|
|
|
_equipment = equipment.ToDictionary(slotStr =>
|
|
{
|
|
var (key, _) = slotStr;
|
|
if (!Enum.TryParse(key, true, out Slots slot))
|
|
{
|
|
throw new Exception($"{key} is an invalid equipment slot.");
|
|
}
|
|
|
|
return slot;
|
|
}, type => type.Value);
|
|
|
|
serializer.DataField(ref _innerClothingSkirt, "innerclothingskirt", string.Empty);
|
|
}
|
|
|
|
public string GetGear(Slots slot, HumanoidCharacterProfile? profile)
|
|
{
|
|
if (profile != null)
|
|
{
|
|
if ((slot == Slots.INNERCLOTHING) && (profile.Clothing == ClothingPreference.Jumpskirt) && (_innerClothingSkirt != ""))
|
|
return _innerClothingSkirt;
|
|
}
|
|
|
|
if (_equipment.ContainsKey(slot))
|
|
{
|
|
return _equipment[slot];
|
|
}
|
|
else
|
|
{
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
}
|