Files
wwdpublic/Content.Shared/Prototypes/CharacterItemGroupPrototype.cs
Cinkafox b2d255cdd2 [tweak] UI Tweaks (#1001)
* - tweak: update StyleSheetify

* - add: flexbox

* - fix: size of flexbox in launchergui

* - tweak: Profile editor: start.

* - add: categories

* - tweak: help me please with this shi... loadouts

* - fix: container path think

* - tweak: thinks for optimisation

* - add: group selection for loadoutpicker

* - tweak: change position of preview

* - add: reason text

* - fix: Кролькины фиксы

* - fix: кролькины фиксы ч.2

* - fix: кролькины фиксы ч.3

* - кролькины фиксы - финал

* - fix: Ворчливого дедушкины фиксы, удаление старого барахла и пометка wwdp

* - tweak: some ui change for LoadoutCategories and LoadoutEntry

* - ворчливый дед фиксы ч.2

* - fix: очередные кролькины фиксы

* - add: loadout prototype validation

* - fix: description read from edit field
2026-01-04 23:33:01 +02:00

59 lines
1.8 KiB
C#

using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Content.Shared.Clothing.Loadouts.Prototypes;
using Content.Shared.Clothing.Loadouts.Systems;
using Content.Shared.Preferences;
using Content.Shared.Traits;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;
namespace Content.Shared.Prototypes;
[Prototype]
public sealed partial class CharacterItemGroupPrototype : IPrototype
{
[IdDataField]
public string ID { get; } = default!;
/// How many items from this group can be selected at once
[DataField]
public int MaxItems = 1;
/// An arbitrary list of traits, loadouts, etc
[DataField]
public List<CharacterItemGroupItem> Items = new();
}
[DataDefinition]
public sealed partial class CharacterItemGroupItem
{
[DataField(required: true)]
public string Type;
[DataField("id", required: true)]
public string ID;
/// Tries to get Value from whatever Type maps to on a character profile
//TODO: Make a test for this
public bool TryGetValue(HumanoidCharacterProfile profile, IPrototypeManager protoMan, [NotNullWhen(true)] out object? value)
{
value = null;
// This sucks
switch (Type)
{
case "trait":
// RobustToolbox my beloved
value = profile.TraitPreferences.FirstOrNull(
p => protoMan.Index<TraitPrototype>((string) p).ID == ID);
return value != null;
case "loadout":
return profile.LoadoutPreferencesList.TryFirstOrDefault( // WWDP EDIT
p => protoMan.Index<LoadoutPrototype>(((Loadout) p).LoadoutName).ID == ID, out value);
default:
DebugTools.Assert($"Invalid CharacterItemGroupItem Type: {Type}");
return false;
}
}
}