From 74fed841a3886925b27b41d9e8bd8b68c6583ef6 Mon Sep 17 00:00:00 2001 From: Vera Aguilera Puerto Date: Sat, 2 Jan 2021 20:51:02 +0100 Subject: [PATCH] Fixes alert category being the same but alert type changing to one without severity Also adds alert type to the exceptions in AlertPrototype --- Content.Shared/Alert/AlertPrototype.cs | 10 +++++----- .../Components/Mobs/SharedAlertsComponent.cs | 3 +++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/Content.Shared/Alert/AlertPrototype.cs b/Content.Shared/Alert/AlertPrototype.cs index 7c7ba74014..e2af7906b0 100644 --- a/Content.Shared/Alert/AlertPrototype.cs +++ b/Content.Shared/Alert/AlertPrototype.cs @@ -123,7 +123,7 @@ namespace Content.Shared.Alert { if (!SupportsSeverity && severity != null) { - throw new InvalidOperationException("This alert does not support severity"); + throw new InvalidOperationException($"This alert ({AlertKey}) does not support severity"); } if (!SupportsSeverity) @@ -131,24 +131,24 @@ namespace Content.Shared.Alert if (severity == null) { - throw new ArgumentException("No severity specified but this alert has severity.", nameof(severity)); + throw new ArgumentException($"No severity specified but this alert ({AlertKey}) has severity.", nameof(severity)); } if (severity < MinSeverity) { - throw new ArgumentOutOfRangeException(nameof(severity), "Severity below minimum severity."); + throw new ArgumentOutOfRangeException(nameof(severity), $"Severity below minimum severity in {AlertKey}."); } if (severity > MaxSeverity) { - throw new ArgumentOutOfRangeException(nameof(severity), "Severity above maximum severity."); + throw new ArgumentOutOfRangeException(nameof(severity), $"Severity above maximum severity in {AlertKey}."); } var severityText = severity.Value.ToString(CultureInfo.InvariantCulture); switch (Icon) { case SpriteSpecifier.EntityPrototype entityPrototype: - throw new InvalidOperationException("Severity not supported for EntityPrototype icon"); + throw new InvalidOperationException($"Severity not supported for EntityPrototype icon in {AlertKey}"); case SpriteSpecifier.Rsi rsi: return new SpriteSpecifier.Rsi(rsi.RsiPath, rsi.RsiState + severityText); case SpriteSpecifier.Texture texture: diff --git a/Content.Shared/GameObjects/Components/Mobs/SharedAlertsComponent.cs b/Content.Shared/GameObjects/Components/Mobs/SharedAlertsComponent.cs index 30b24fdb14..1adb20d45c 100644 --- a/Content.Shared/GameObjects/Components/Mobs/SharedAlertsComponent.cs +++ b/Content.Shared/GameObjects/Components/Mobs/SharedAlertsComponent.cs @@ -93,6 +93,9 @@ namespace Content.Shared.GameObjects.Components.Mobs return; } + // In the case we're changing the alert type but not the category, we need to remove it first. + _alerts.Remove(alert.AlertKey); + _alerts[alert.AlertKey] = new AlertState {Cooldown = cooldown, Severity = severity};