diff --git a/Content.Client/Chat/UI/SpeechBubble.cs b/Content.Client/Chat/UI/SpeechBubble.cs index 2d0c8c8ad2..a8d9261a4a 100644 --- a/Content.Client/Chat/UI/SpeechBubble.cs +++ b/Content.Client/Chat/UI/SpeechBubble.cs @@ -90,6 +90,12 @@ namespace Content.Client.Chat.UI base.FrameUpdate(args); _timeLeft -= args.DeltaSeconds; + if (_entityManager.Deleted(_senderEntity) || _timeLeft <= 0) + { + // Timer spawn to prevent concurrent modification exception. + Timer.Spawn(0, Die); + return; + } // Lerp to our new vertical offset if it's been modified. if (MathHelper.CloseToPercent(_verticalOffsetAchieved - VerticalOffset, 0, 0.1)) @@ -101,7 +107,8 @@ namespace Content.Client.Chat.UI _verticalOffsetAchieved = MathHelper.Lerp(_verticalOffsetAchieved, VerticalOffset, 10 * args.DeltaSeconds); } - if (!_entityManager.GetComponent(_senderEntity).Coordinates.IsValid(_entityManager)) + if (!_entityManager.TryGetComponent(_senderEntity, out var xform) + || !xform.Coordinates.IsValid(_entityManager)) { Modulate = Color.White.WithAlpha(0); return; @@ -118,14 +125,8 @@ namespace Content.Client.Chat.UI Modulate = Color.White; } - if (_entityManager.Deleted(_senderEntity) || _timeLeft <= 0) - { - // Timer spawn to prevent concurrent modification exception. - Timer.Spawn(0, Die); - return; - } - var worldPos = _entityManager.GetComponent(_senderEntity).WorldPosition; + var worldPos = xform.WorldPosition; var scale = _eyeManager.MainViewport.GetRenderScale(); var offset = new Vector2(0, EntityVerticalOffset * EyeManager.PixelsPerMeter * scale); var lowerCenter = (_eyeManager.WorldToScreen(worldPos) - offset) / UIScale;