Skip to content

Commit

Permalink
hotfix SAI
Browse files Browse the repository at this point in the history
  • Loading branch information
Rxup committed Feb 13, 2024
1 parent f0d58fe commit fc18796
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 5 deletions.
43 changes: 43 additions & 0 deletions Content.Client/Administration/AdminNameOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,55 @@ public AdminNameOverlay(AdminSystem system, IEntityManager entityManager, IEyeMa

public override OverlaySpace Space => OverlaySpace.ScreenSpace;

// start-backmen: SAI

private void DrawVisitedOwner(in Content.Shared.Administration.PlayerInfo playerInfo, in OverlayDrawArgs args)
{
var entity = _entityManager.GetEntity(playerInfo.NetEntityOwn);

// Otherwise the entity can not exist yet
if (entity == null || !_entityManager.EntityExists(entity))
{
return;
}

// if not on the same map, continue
if (_entityManager.GetComponent<TransformComponent>(entity.Value).MapID != _eyeManager.CurrentMap)
{
return;
}

var aabb = _entityLookup.GetWorldAABB(entity.Value);

// if not on screen, continue
if (!aabb.Intersects(in args.WorldAABB))
{
return;
}

var lineoffset = new Vector2(0f, 11f);
var screenCoordinates = _eyeManager.WorldToScreen(aabb.Center +
new Angle(-_eyeManager.CurrentEye.Rotation).RotateVec(
aabb.TopRight - aabb.Center)) + new Vector2(1f, 7f);
if (playerInfo.Antag)
{
args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 3), "ANTAG", Color.OrangeRed);
}
args.ScreenHandle.DrawString(_font, screenCoordinates+lineoffset, playerInfo.Username, playerInfo.Connected ? Color.Yellow : Color.White);
args.ScreenHandle.DrawString(_font, screenCoordinates, playerInfo.CharacterName, playerInfo.Connected ? Color.Aquamarine : Color.White);

args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), "(In REMOTE)", Color.Cyan);
}

// end-backmen: SAI

protected override void Draw(in OverlayDrawArgs args)
{
var viewport = args.WorldAABB;

foreach (var playerInfo in _system.PlayerList)
{
DrawVisitedOwner(playerInfo,args); // backmen: SAI
var entity = _entityManager.GetEntity(playerInfo.NetEntity);

// Otherwise the entity can not exist yet
Expand Down
9 changes: 8 additions & 1 deletion Content.Server/Administration/Systems/AdminSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,15 @@ private PlayerInfo GetPlayerInfo(SessionData data, ICommonSession? session)
overallPlaytime = playTime;
}

// start-backmen: SAI
var parentAttachedEntity = CompOrNull<Shared.Mind.MindComponent>(
CompOrNull<Shared.Mind.Components.VisitingMindComponent>(session?.AttachedEntity)?.MindId)?.OwnedEntity;
// end-backmen: SAI

return new PlayerInfo(name, entityName, identityName, startingRole, antag, GetNetEntity(session?.AttachedEntity), data.UserId,
connected, _roundActivePlayers.Contains(data.UserId), overallPlaytime);
connected, _roundActivePlayers.Contains(data.UserId), overallPlaytime,
GetNetEntity(parentAttachedEntity) // backmen: SAI
);
}

private void OnPanicBunkerChanged(bool enabled)
Expand Down
2 changes: 1 addition & 1 deletion Content.Server/Backmen/StationAI/InnateItemSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ private void StartBeforeInteract(EntityUid uid, InnateItemComponent component, I

if (TryComp<AIEyeComponent>(uid, out var aiEyeComponent))
{
if (!aiEyeComponent.AiCore.HasValue || !TerminatingOrDeleted(aiEyeComponent.AiCore.Value))
if (!aiEyeComponent.AiCore.HasValue || TerminatingOrDeleted(aiEyeComponent.AiCore.Value))
{
return;
}
Expand Down
4 changes: 3 additions & 1 deletion Content.Shared/Administration/PlayerInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ public record PlayerInfo(
NetUserId SessionId,
bool Connected,
bool ActiveThisRound,
TimeSpan? OverallPlaytime)
TimeSpan? OverallPlaytime,
NetEntity? NetEntityOwn // backmen: SAI display visited mind
)
{
private string? _playtimeString;

Expand Down
20 changes: 18 additions & 2 deletions Content.Shared/Mind/SharedMindSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,20 @@ private void OnExamined(EntityUid uid, MindContainerComponent mindContainer, Exa
return;

var dead = _mobState.IsDead(uid);
var hasUserId = CompOrNull<MindComponent>(mindContainer.Mind)?.UserId;
var hasSession = CompOrNull<MindComponent>(mindContainer.Mind)?.Session;

// start-backmen: SAI
var mind = CompOrNull<MindComponent>(mindContainer.Mind);

var remoteMind = CompOrNull<VisitingMindComponent>(uid);
if (remoteMind != null)
{
mind = CompOrNull<MindComponent>(remoteMind.MindId);
}

var hasUserId = mind?.UserId;
var hasSession = mind?.Session;

// end-backmen: SAI

if (dead && hasUserId == null)
args.PushMarkup($"[color=mediumpurple]{Loc.GetString("comp-mind-examined-dead-and-irrecoverable", ("ent", uid))}[/color]");
Expand All @@ -165,6 +177,10 @@ private void OnExamined(EntityUid uid, MindContainerComponent mindContainer, Exa
args.PushMarkup($"[color=mediumpurple]{Loc.GetString("comp-mind-examined-catatonic", ("ent", uid))}[/color]");
else if (hasSession == null)
args.PushMarkup($"[color=yellow]{Loc.GetString("comp-mind-examined-ssd", ("ent", uid))}[/color]");

// start-backmen: SAI
if(remoteMind != null) args.PushMarkup($"[color=red]{Loc.GetString("comp-mind-examined-remote-controlled")}[/color]");
// end-backmen: SAI
}

private void OnSuicide(EntityUid uid, MindContainerComponent component, SuicideEvent args)
Expand Down

0 comments on commit fc18796

Please sign in to comment.