UI/SpeechBubble: check deletion before doing things, plz (#5811)
This commit is contained in:
@@ -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<TransformComponent>(_senderEntity).Coordinates.IsValid(_entityManager))
|
||||
if (!_entityManager.TryGetComponent<TransformComponent>(_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<TransformComponent>(_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;
|
||||
|
||||
Reference in New Issue
Block a user