Skip to content

Commit

Permalink
fix commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ReeZer2 committed Feb 23, 2025
1 parent d583cd0 commit 26ec7c4
Showing 1 changed file with 31 additions and 39 deletions.
70 changes: 31 additions & 39 deletions Content.Server/Chat/Systems/ChatSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -968,69 +968,61 @@ public string BuildGibberishString(IReadOnlyList<char> charOptions, int length)
//ss220 add identity concealment for chat and radio messages start
public string GetRadioName(EntityUid entity)
{
var idName = GetIdCardName(entity);
return idName ?? Loc.GetString("comp-pda-ui-unknown");
return GetIdCardName(entity) ?? Loc.GetString("comp-pda-ui-unknown");
}

private string GetChatName(EntityUid entity)
{
var idName = GetIdCardName(entity);

if (IsIdentityHidden(entity) && idName != null)
{
return idName;
}
if (!IsIdentityHidden(entity))
return Name(entity);

if (IsIdentityHidden(entity))
{
if (TryComp<HumanoidAppearanceComponent>(entity, out var humanoid))
{
var species = _humanoidAppearance.GetSpeciesRepresentation(humanoid.Species);
var age = _humanoidAppearance.GetAgeRepresentation(humanoid.Species, humanoid.Age);
return Loc.GetString("chat-msg-sender-species-and-age", ("species", species), ("age", age));
}
if (idName != null)
return idName;

if (!TryComp<HumanoidAppearanceComponent>(entity, out var humanoid))
return Loc.GetString("comp-pda-ui-unknown");
}

return Name(entity);
var species = _humanoidAppearance.GetSpeciesRepresentation(humanoid.Species);
var age = _humanoidAppearance.GetAgeRepresentation(humanoid.Species, humanoid.Age);

return Loc.GetString("chat-msg-sender-species-and-age", ("species", species), ("age", age));
}

private string? GetIdCardName(EntityUid entity)
{
if (_inventory.TryGetSlotEntity(entity, "id", out var idUid))
{
if (TryComp<PdaComponent>(idUid, out var pda) && pda.ContainedId != null)
{
if (TryComp<IdCardComponent>(pda.ContainedId, out var idComp) && !string.IsNullOrEmpty(idComp.FullName))
{
return idComp.FullName;
}
}
if (!_inventory.TryGetSlotEntity(entity, "id", out var idUid))
return null;

if (TryComp<IdCardComponent>(idUid, out var id) && !string.IsNullOrEmpty(id.FullName))
{
return id.FullName;
}
if (TryComp<PdaComponent>(idUid, out var pda) &&
pda.ContainedId != null &&
TryComp<IdCardComponent>(pda.ContainedId, out var idComp) &&
!string.IsNullOrEmpty(idComp.FullName))
{
return idComp.FullName;
}

if (TryComp<IdCardComponent>(pda?.ContainedId ?? idUid, out var id) && !string.IsNullOrEmpty(id.FullName))
return id.FullName;

return null;
}

private bool IsIdentityHidden(EntityUid entity)
{
if (_inventory.TryGetContainerSlotEnumerator(entity, out var enumerSlot))
if (!_inventory.TryGetContainerSlotEnumerator(entity, out var enumerSlot))
return false;

while (enumerSlot.MoveNext(out var slot))
{
while (enumerSlot.MoveNext(out var slot))
{
if (slot.ContainedEntity == null)
continue;
if (slot.ContainedEntity == null)
continue;

if (TryComp<IdentityBlockerComponent>(slot.ContainedEntity.Value, out var blocker)
&& blocker is { Enabled: true, Coverage: IdentityBlockerCoverage.FULL })
{
return true;
}
if (TryComp<IdentityBlockerComponent>(slot.ContainedEntity.Value, out var blocker)
&& blocker is { Enabled: true, Coverage: IdentityBlockerCoverage.FULL })
{
return true;
}
}

Expand Down

0 comments on commit 26ec7c4

Please sign in to comment.