Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vonsant committed Jan 2, 2025
1 parent 154d0ea commit ff62ce3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ protected override void Open()
/// </summary>
private void HandleReasonChanged(string newReason)
{
if (_entityManager.TryGetComponent<CrewMedalComponent>(Owner, out var component))
if (!_entityManager.TryGetComponent<CrewMedalComponent>(Owner, out var component))
return;

if (!component.Reason.Equals(newReason))
{
if (!component.Reason.Equals(newReason))
SendPredictedMessage(new CrewMedalReasonChangedMessage(newReason));
SendPredictedMessage(new CrewMedalReasonChangedMessage(newReason));
}
}

Expand All @@ -50,7 +52,7 @@ private void HandleReasonChanged(string newReason)
/// </summary>
public void Reload()
{
if (_window == null)
if (_window is null)
return;

if (!_entityManager.TryGetComponent<CrewMedalComponent>(Owner, out var component))
Expand Down
9 changes: 5 additions & 4 deletions Content.Server/_CorvaxNext/CrewMedal/CrewMedalSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public sealed class CrewMedalSystem : SharedCrewMedalSystem

public override void Initialize()
{
base.Initialize();
base.Initialize();
SubscribeLocalEvent<CrewMedalComponent, ClothingGotEquippedEvent>(OnMedalEquipped);
SubscribeLocalEvent<CrewMedalComponent, CrewMedalReasonChangedMessage>(OnMedalReasonChanged);
SubscribeLocalEvent<RoundEndTextAppendEvent>(OnRoundEndText);
Expand Down Expand Up @@ -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(
Expand Down
9 changes: 2 additions & 7 deletions Content.Shared/_CorvaxNext/CrewMedal/CrewMedalEvents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,10 @@ public enum CrewMedalUiKey : byte
/// Message sent when the reason for the medal is changed via the user interface.
/// </summary>
[Serializable, NetSerializable]
public sealed class CrewMedalReasonChangedMessage : BoundUserInterfaceMessage
public sealed class CrewMedalReasonChangedMessage(string Reason) : BoundUserInterfaceMessage
{
/// <summary>
/// The new reason for the medal.
/// </summary>
public string Reason { get; }

public CrewMedalReasonChangedMessage(string reason)
{
Reason = reason;
}
public string Reason { get; } = Reason;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ public abstract class SharedCrewMedalSystem : EntitySystem
{
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<CrewMedalComponent, ExaminedEvent>(OnExamined);
}

Expand Down

0 comments on commit ff62ce3

Please sign in to comment.