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);
|
base.FrameUpdate(args);
|
||||||
|
|
||||||
_timeLeft -= args.DeltaSeconds;
|
_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.
|
// Lerp to our new vertical offset if it's been modified.
|
||||||
if (MathHelper.CloseToPercent(_verticalOffsetAchieved - VerticalOffset, 0, 0.1))
|
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);
|
_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);
|
Modulate = Color.White.WithAlpha(0);
|
||||||
return;
|
return;
|
||||||
@@ -118,14 +125,8 @@ namespace Content.Client.Chat.UI
|
|||||||
Modulate = Color.White;
|
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 scale = _eyeManager.MainViewport.GetRenderScale();
|
||||||
var offset = new Vector2(0, EntityVerticalOffset * EyeManager.PixelsPerMeter * scale);
|
var offset = new Vector2(0, EntityVerticalOffset * EyeManager.PixelsPerMeter * scale);
|
||||||
var lowerCenter = (_eyeManager.WorldToScreen(worldPos) - offset) / UIScale;
|
var lowerCenter = (_eyeManager.WorldToScreen(worldPos) - offset) / UIScale;
|
||||||
|
|||||||
Reference in New Issue
Block a user