diff --git a/Chummer/Backend/Attributes/AttributeSection.cs b/Chummer/Backend/Attributes/AttributeSection.cs index 99b85561d2..f6f586f7e6 100644 --- a/Chummer/Backend/Attributes/AttributeSection.cs +++ b/Chummer/Backend/Attributes/AttributeSection.cs @@ -539,6 +539,21 @@ public AttributeSection(Character objCharacter) AttributeList.BeforeClearCollectionChangedAsync += AttributeListOnBeforeClearCollectionChanged; SpecialAttributeList.CollectionChangedAsync += SpecialAttributeListOnCollectionChanged; SpecialAttributeList.BeforeClearCollectionChangedAsync += SpecialAttributeListOnBeforeClearCollectionChanged; + _objCharacter.MultiplePropertiesChangedAsync += CharacterOnMultiplePropertiesChangedAsync; + } + + private Task CharacterOnMultiplePropertiesChangedAsync(object sender, MultiplePropertiesChangedEventArgs e, CancellationToken token) + { + if (token.IsCancellationRequested) + return Task.FromCanceled(token); + if (e.PropertyNames.Contains(nameof(Character.MAGEnabled)) || + e.PropertyNames.Contains(nameof(Character.RESEnabled)) || + e.PropertyNames.Contains(nameof(Character.DEPEnabled))) + { + return InitializeAttributesListAsync(token); + } + + return Task.CompletedTask; } private async Task SpecialAttributeListOnBeforeClearCollectionChanged(object sender, diff --git a/Chummer/Forms/Character Forms/CharacterCreate.cs b/Chummer/Forms/Character Forms/CharacterCreate.cs index 4ecdb4bcde..c6f5d3fa34 100644 --- a/Chummer/Forms/Character Forms/CharacterCreate.cs +++ b/Chummer/Forms/Character Forms/CharacterCreate.cs @@ -2388,17 +2388,22 @@ await CharacterObject.AttributeSection.Attributes if (e.PropertyNames.Contains(nameof(Character.DEPEnabled))) { - if (await CharacterObject.GetDEPEnabledAsync(token).ConfigureAwait(false) && !await CharacterObject - .AttributeSection.Attributes - .ContainsAsync(CharacterObject.DEP, token) - .ConfigureAwait(false)) + if (await CharacterObject.GetDEPEnabledAsync(token).ConfigureAwait(false)) + { + if (!await CharacterObject + .AttributeSection.Attributes + .ContainsAsync(CharacterObject.DEP, token) + .ConfigureAwait(false)) + { + await CharacterObject.AttributeSection.Attributes + .AddAsync(CharacterObject.DEP, token).ConfigureAwait(false); + } + } + else { await CharacterObject.AttributeSection.Attributes - .AddAsync(CharacterObject.DEP, token).ConfigureAwait(false); + .RemoveAsync(CharacterObject.DEP, token).ConfigureAwait(false); } - - await CharacterObject.AttributeSection.Attributes - .RemoveAsync(CharacterObject.DEP, token).ConfigureAwait(false); } if (e.PropertyNames.Contains(nameof(Character.Ambidextrous)))