3 using System.Collections.Generic;
16 private readonly Dictionary<AbilityEffectType, List<CharacterAbilityGroupEffect>> characterAbilityGroupEffectDictionary =
new Dictionary<AbilityEffectType, List<CharacterAbilityGroupEffect>>();
18 private readonly List<CharacterAbilityGroupInterval> characterAbilityGroupIntervals =
new List<CharacterAbilityGroupInterval>();
26 Character = character ??
throw new ArgumentNullException(nameof(character));
27 Prefab = talentPrefab ??
throw new ArgumentNullException(nameof(talentPrefab));
31 foreach (var subElement
in element.Elements())
33 switch (subElement.Name.ToString().ToLowerInvariant())
35 case "abilitygroupeffect":
36 LoadAbilityGroupEffect(subElement);
38 case "abilitygroupinterval":
39 LoadAbilityGroupInterval(subElement);
42 if (subElement.GetAttributeIdentifier(
"itemidentifier", Identifier.Empty) is { IsEmpty: false } recipeIdentifier)
48 DebugConsole.ThrowError($
"No recipe identifier defined for talent {DebugIdentifier}",
49 contentPackage: element.ContentPackage);
52 case "addedstoreitem":
53 if (subElement.GetAttributeIdentifier(
"itemtag", Identifier.Empty) is { IsEmpty: false } storeItemTag)
59 DebugConsole.ThrowError($
"No store item identifier defined for talent {DebugIdentifier}",
60 contentPackage: element.ContentPackage);
69 foreach (var characterAbilityGroupInterval
in characterAbilityGroupIntervals)
71 characterAbilityGroupInterval.UpdateAbilityGroup(deltaTime);
75 private static readonly HashSet<Identifier> checkedNonStackableTalents =
new();
82 checkedNonStackableTalents.Clear();
89 if (checkedNonStackableTalents.Contains(characterTalent.
Prefab.
Identifier)) {
continue; }
100 if (characterAbilityGroupEffectDictionary.TryGetValue(abilityEffectType, out var characterAbilityGroups))
102 foreach (var characterAbilityGroup
in characterAbilityGroups)
104 characterAbilityGroup.CheckAbilityGroup(abilityObject);
111 foreach (var characterAbilityGroups
in characterAbilityGroupEffectDictionary.Values)
113 foreach (var characterAbilityGroup
in characterAbilityGroups)
115 characterAbilityGroup.ActivateAbilityGroup(addingFirstTime);
126 private void LoadAbilityGroupEffect(ContentXElement abilityGroup)
134 if (characterAbilityGroupEffectDictionary.TryGetValue(abilityEffectType, out var characterAbilityList))
136 characterAbilityList.Add(characterAbilityGroup);
140 List<CharacterAbilityGroupEffect> characterAbilityGroups =
new List<CharacterAbilityGroupEffect>();
141 characterAbilityGroups.Add(characterAbilityGroup);
142 characterAbilityGroupEffectDictionary.Add(abilityEffectType, characterAbilityGroups);
148 if (!Enum.TryParse(abilityEffectTypeString,
true, out
AbilityEffectType abilityEffectType))
150 DebugConsole.ThrowError(
"Invalid ability effect type \"" + abilityEffectTypeString +
"\" in CharacterTalent (" + characterTalent.
DebugIdentifier +
")",
155 DebugConsole.ThrowError(
"Ability effect type not defined in CharacterTalent (" + characterTalent.
DebugIdentifier +
")",
159 return abilityEffectType;
IReadOnlyCollection< CharacterTalent > CharacterTalents
readonly TalentPrefab Prefab
List< Identifier > UnlockedRecipes
CharacterTalent(TalentPrefab talentPrefab, Character character)
void AddAbilityGroupEffect(CharacterAbilityGroupEffect characterAbilityGroup, AbilityEffectType abilityEffectType=AbilityEffectType.None)
static AbilityEffectType ParseAbilityEffectType(CharacterTalent characterTalent, string abilityEffectTypeString)
List< Identifier > UnlockedStoreItems
void ActivateTalent(bool addingFirstTime)
static void CheckTalentsForCrew(IEnumerable< Character > crew, AbilityEffectType type, AbilityObject abilityObject)
Checks talents for a given AbilityObject taking into account non-stackable talents.
void CheckTalent(AbilityEffectType abilityEffectType, AbilityObject abilityObject)
virtual void UpdateTalent(float deltaTime)
ContentPackage? ContentPackage
readonly Identifier Identifier
bool AbilityEffectsStackWithSameTalent
When set to false the AbilityEffects of multiple of the same talent will not be checked and only the ...
ContentXElement ConfigElement