diff --git a/Content.Client/_CorvaxNext/CrewMedal/UI/CrewMedalBoundUserInterface.cs b/Content.Client/_CorvaxNext/CrewMedal/UI/CrewMedalBoundUserInterface.cs index 17274d81f87..30ef2141bb2 100644 --- a/Content.Client/_CorvaxNext/CrewMedal/UI/CrewMedalBoundUserInterface.cs +++ b/Content.Client/_CorvaxNext/CrewMedal/UI/CrewMedalBoundUserInterface.cs @@ -38,10 +38,12 @@ protected override void Open() /// private void HandleReasonChanged(string newReason) { - if (_entityManager.TryGetComponent(Owner, out var component)) + if (!_entityManager.TryGetComponent(Owner, out var component)) + return; + + if (!component.Reason.Equals(newReason)) { - if (!component.Reason.Equals(newReason)) - SendPredictedMessage(new CrewMedalReasonChangedMessage(newReason)); + SendPredictedMessage(new CrewMedalReasonChangedMessage(newReason)); } } @@ -50,7 +52,7 @@ private void HandleReasonChanged(string newReason) /// public void Reload() { - if (_window == null) + if (_window is null) return; if (!_entityManager.TryGetComponent(Owner, out var component)) diff --git a/Content.Server/_CorvaxNext/CrewMedal/CrewMedalSystem.cs b/Content.Server/_CorvaxNext/CrewMedal/CrewMedalSystem.cs index 2e47642eade..1e4ce6cbe99 100644 --- a/Content.Server/_CorvaxNext/CrewMedal/CrewMedalSystem.cs +++ b/Content.Server/_CorvaxNext/CrewMedal/CrewMedalSystem.cs @@ -17,7 +17,7 @@ public sealed class CrewMedalSystem : SharedCrewMedalSystem public override void Initialize() { - base.Initialize(); + base.Initialize(); SubscribeLocalEvent(OnMedalEquipped); SubscribeLocalEvent(OnMedalReasonChanged); SubscribeLocalEvent(OnRoundEndText); @@ -96,17 +96,18 @@ private void OnRoundEndText(RoundEndTextAppendEvent ev) if (awardedMedals.Count == 0) return; - awardedMedals = awardedMedals.OrderBy(x => x.RecipientName).ToList(); + // Sort and convert to array + var sortedMedals = awardedMedals.OrderBy(x => x.RecipientName).ToArray(); var result = new StringBuilder(); result.AppendLine( Loc.GetString( "comp-crew-medal-round-end-result", - ("count", awardedMedals.Count) + ("count", sortedMedals.Length) ) ); - foreach (var medal in awardedMedals) + foreach (var medal in sortedMedals) { result.AppendLine( Loc.GetString( diff --git a/Content.Shared/_CorvaxNext/CrewMedal/CrewMedalEvents.cs b/Content.Shared/_CorvaxNext/CrewMedal/CrewMedalEvents.cs index 53b31e63061..b6345083f41 100644 --- a/Content.Shared/_CorvaxNext/CrewMedal/CrewMedalEvents.cs +++ b/Content.Shared/_CorvaxNext/CrewMedal/CrewMedalEvents.cs @@ -15,15 +15,10 @@ public enum CrewMedalUiKey : byte /// Message sent when the reason for the medal is changed via the user interface. /// [Serializable, NetSerializable] -public sealed class CrewMedalReasonChangedMessage : BoundUserInterfaceMessage +public sealed class CrewMedalReasonChangedMessage(string Reason) : BoundUserInterfaceMessage { /// /// The new reason for the medal. /// - public string Reason { get; } - - public CrewMedalReasonChangedMessage(string reason) - { - Reason = reason; - } + public string Reason { get; } = Reason; } diff --git a/Content.Shared/_CorvaxNext/CrewMedal/SharedCrewMedalSystem.cs b/Content.Shared/_CorvaxNext/CrewMedal/SharedCrewMedalSystem.cs index ada4f82b58d..35df39c2430 100644 --- a/Content.Shared/_CorvaxNext/CrewMedal/SharedCrewMedalSystem.cs +++ b/Content.Shared/_CorvaxNext/CrewMedal/SharedCrewMedalSystem.cs @@ -6,7 +6,6 @@ public abstract class SharedCrewMedalSystem : EntitySystem { public override void Initialize() { - base.Initialize(); SubscribeLocalEvent(OnExamined); }