From abd9aec8bd6ead47428cde8d1a202fc14a8daa6f Mon Sep 17 00:00:00 2001 From: Atakku Date: Mon, 27 Oct 2025 23:33:56 +0100 Subject: [PATCH] Implemented parenting and minimum default for loadout groups (#40861) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Implemented parenting and minimum default for loadouts * Fix a mistake * Apply suggestion from @iaada Co-authored-by: āda * Implement @iaada's suggestion to rename MinDefault to DefaultSelected * happy little accidents * Moved Parents and Abstract fields to under ID, added inheritdoc --------- Co-authored-by: āda --- .../Loadouts/LoadoutGroupPrototype.cs | 19 ++++++++++++++++++- .../Preferences/Loadouts/RoleLoadout.cs | 4 ++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/Content.Shared/Preferences/Loadouts/LoadoutGroupPrototype.cs b/Content.Shared/Preferences/Loadouts/LoadoutGroupPrototype.cs index 990f1b74a2..b65f332885 100644 --- a/Content.Shared/Preferences/Loadouts/LoadoutGroupPrototype.cs +++ b/Content.Shared/Preferences/Loadouts/LoadoutGroupPrototype.cs @@ -1,4 +1,5 @@ using Robust.Shared.Prototypes; +using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Array; namespace Content.Shared.Preferences.Loadouts; @@ -6,11 +7,20 @@ namespace Content.Shared.Preferences.Loadouts; /// Corresponds to a set of loadouts for a particular slot. /// [Prototype] -public sealed partial class LoadoutGroupPrototype : IPrototype +public sealed partial class LoadoutGroupPrototype : IPrototype, IInheritingPrototype { [IdDataField] public string ID { get; private set; } = string.Empty; + /// + [ParentDataFieldAttribute(typeof(AbstractPrototypeIdArraySerializer))] + public string[]? Parents { get; } + + /// + [NeverPushInheritance] + [AbstractDataField] + public bool Abstract { get; } + /// /// User-friendly name for the group. /// @@ -22,6 +32,12 @@ public sealed partial class LoadoutGroupPrototype : IPrototype /// [DataField] public int MinLimit = 1; + + /// + /// Number of loadouts that are selected by default. + /// + [DataField] + public int DefaultSelected = 0; /// /// Maximum limit for the category. @@ -35,6 +51,7 @@ public sealed partial class LoadoutGroupPrototype : IPrototype [DataField] public bool Hidden; + [AlwaysPushInheritance] [DataField(required: true)] public List> Loadouts = new(); } diff --git a/Content.Shared/Preferences/Loadouts/RoleLoadout.cs b/Content.Shared/Preferences/Loadouts/RoleLoadout.cs index 9b7f4ae05e..d9f79f543a 100644 --- a/Content.Shared/Preferences/Loadouts/RoleLoadout.cs +++ b/Content.Shared/Preferences/Loadouts/RoleLoadout.cs @@ -228,13 +228,13 @@ public sealed partial class RoleLoadout : IEquatable var loadouts = new List(); SelectedLoadouts[group] = loadouts; - if (groupProto.MinLimit > 0) + if (groupProto.MinLimit > 0 || loadouts.Count < groupProto.DefaultSelected) { // Apply any loadouts we can. foreach (var protoId in groupProto.Loadouts) { // Reached the limit, time to stop - if (loadouts.Count >= groupProto.MinLimit) + if (loadouts.Count >= Math.Max(groupProto.MinLimit, groupProto.DefaultSelected)) break; if (!protoManager.TryIndex(protoId, out var loadoutProto))