rev roundend shows converted count (#21854)

* add ConvertedCount field to role

* make objectives roundend title logic reusable

* change rev system + use GetTitle

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2023-11-27 21:43:48 +00:00
committed by GitHub
parent 94f67f86dd
commit 24476721af
4 changed files with 59 additions and 45 deletions

View File

@@ -110,26 +110,9 @@ public sealed class ObjectivesSystem : SharedObjectivesSystem
if (!TryComp(mindId, out MindComponent? mind))
continue;
var name = mind.CharacterName;
_mind.TryGetSession(mindId, out var session);
var username = session?.Name;
string title;
if (username != null)
{
if (name != null)
title = Loc.GetString("objectives-player-user-named", ("user", username), ("name", name));
else
title = Loc.GetString("objectives-player-user", ("user", username));
}
else
{
// nothing to identify the player by, just give up
if (name == null)
continue;
title = Loc.GetString("objectives-player-named", ("name", name));
}
var title = GetTitle(mindId, mind);
if (title == null)
continue;
result += "\n";
@@ -230,6 +213,33 @@ public sealed class ObjectivesSystem : SharedObjectivesSystem
return originalEntityInCustody || (TryComp<CuffableComponent>(mind.OwnedEntity, out var cuffed) && cuffed.CuffedHandCount > 0
&& _emergencyShuttle.IsTargetEscaping(mind.OwnedEntity.Value));
}
/// <summary>
/// Get the title for a player's mind used in round end.
/// </summary>
public string? GetTitle(EntityUid mindId, MindComponent? mind = null)
{
if (!Resolve(mindId, ref mind))
return null;
var name = mind.CharacterName;
_mind.TryGetSession(mindId, out var session);
var username = session?.Name;
if (username != null)
{
if (name != null)
return Loc.GetString("objectives-player-user-named", ("user", username), ("name", name));
return Loc.GetString("objectives-player-user", ("user", username));
}
// nothing to identify the player by, just give up
if (name == null)
return null;
return Loc.GetString("objectives-player-named", ("name", name));
}
}
/// <summary>