diff --git a/Content.Client/Chat/UI/SpeechBubble.cs b/Content.Client/Chat/UI/SpeechBubble.cs index a430b11757..5ceea05f05 100644 --- a/Content.Client/Chat/UI/SpeechBubble.cs +++ b/Content.Client/Chat/UI/SpeechBubble.cs @@ -111,8 +111,7 @@ namespace Content.Client.Chat.UI _verticalOffsetAchieved = MathHelper.Lerp(_verticalOffsetAchieved, VerticalOffset, 10 * args.DeltaSeconds); } - if (!_entityManager.TryGetComponent(_senderEntity, out var xform) - || !xform.Coordinates.IsValid(_entityManager)) + if (!_entityManager.TryGetComponent(_senderEntity, out var xform) || xform.MapID != _eyeManager.CurrentMap) { Modulate = Color.White.WithAlpha(0); return; @@ -129,7 +128,6 @@ namespace Content.Client.Chat.UI Modulate = Color.White; } - var worldPos = xform.WorldPosition; var scale = _eyeManager.MainViewport.GetRenderScale(); var offset = new Vector2(0, EntityVerticalOffset * EyeManager.PixelsPerMeter * scale); diff --git a/Content.Client/Popups/PopupSystem.cs b/Content.Client/Popups/PopupSystem.cs index 0164a251ef..9256b3cb27 100644 --- a/Content.Client/Popups/PopupSystem.cs +++ b/Content.Client/Popups/PopupSystem.cs @@ -43,7 +43,10 @@ namespace Content.Client.Popups public void PopupCoordinates(string message, EntityCoordinates coordinates) { - PopupMessage(message, _eyeManager.CoordinatesToScreen(coordinates)); + var mapCoords = coordinates.ToMap(EntityManager); + if (_eyeManager.CurrentMap != mapCoords.MapId) + return; + PopupMessage(message, _eyeManager.MapToScreen(mapCoords)); } public void PopupEntity(string message, EntityUid uid) @@ -52,6 +55,9 @@ namespace Content.Client.Popups return; var transform = EntityManager.GetComponent(uid); + if (_eyeManager.CurrentMap != transform.MapID) + return; // TODO: entity may be outside of PVS, but enter PVS at a later time. So the pop-up should still get tracked? + PopupMessage(message, _eyeManager.CoordinatesToScreen(transform.Coordinates), uid); } @@ -217,12 +223,13 @@ namespace Content.Client.Popups screenCoords = _eyeManager.CoordinatesToScreen(xform.Coordinates); else { - // Entity has probably been deleted. Visible = false; - TotalTime += PopupLifetime; + if (Entity != null && _entityManager.Deleted(Entity)) + TotalTime += PopupLifetime; return; } + Visible = true; var position = screenCoords.Position / UIScale - DesiredSize / 2; LayoutContainer.SetPosition(this, position - (0, 20 * (TotalTime * TotalTime + TotalTime)));