using System.Collections.Immutable; using Barotrauma.PerkBehaviors; namespace Barotrauma { internal sealed class DisembarkPerkPrefab : PrefabWithUintIdentifier { public static readonly PrefabCollection Prefabs = new PrefabCollection(); public LocalizedString Name { get; } public LocalizedString Description { get; } public Identifier SortCategory { get; } /// /// After the perks have been sorted by category and cost, they are sorted using this key. /// Use if you want the perks to be arranged in specific order when their cost are the same. /// public int SortKey { get; } /// /// When set to an identifier of another perk, this perk cannot be selected unless the prerequisite perk is selected. /// public Identifier Prerequisite { get; } /// /// When this perk is selected, the perks in this set cannot be selected at the same time. /// public ImmutableHashSet MutuallyExclusivePerks { get; } public int Cost { get; } public ImmutableArray PerkBehaviors { get; } public DisembarkPerkPrefab(ContentXElement element, DisembarkPerkFile prefabFile) : base(prefabFile, element.GetAttributeIdentifier("identifier", "")) { Name = TextManager.Get($"disembarkperk.{Identifier}").Fallback(Identifier.ToString()); Description = TextManager.Get($"disembarkperkdescription.{Identifier}").Fallback(""); Cost = element.GetAttributeInt("cost", 0); SortCategory = element.GetAttributeIdentifier("sortcategory", Identifier); Prerequisite = element.GetAttributeIdentifier("prerequisite", Identifier.Empty); MutuallyExclusivePerks = element.GetAttributeIdentifierImmutableHashSet("mutuallyexclusiveperks", ImmutableHashSet.Empty); SortKey = element.GetAttributeInt("sortkey", 0); var builder = ImmutableArray.CreateBuilder(); foreach (var child in element.Elements()) { if (PerkBase.TryLoadFromXml(child, this, out var perk)) { builder.Add(perk); } } PerkBehaviors = builder.ToImmutable(); } public override void Dispose() { } } }