Fix do_after throwing on attaching to new entity (#1679)
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -43,6 +43,25 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
|
||||
LayoutContainer.SetGrowVertical(this, LayoutContainer.GrowDirection.Begin);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called when the mind is detached from an entity
|
||||
/// </summary>
|
||||
/// Rather than just dispose of the Gui we'll just remove its child controls and re-use the control.
|
||||
public void Detached()
|
||||
{
|
||||
foreach (var (_, control) in _doAfterControls)
|
||||
{
|
||||
control.Dispose();
|
||||
}
|
||||
_doAfterControls.Clear();
|
||||
foreach (var (_, control) in _doAfterBars)
|
||||
{
|
||||
control.Dispose();
|
||||
}
|
||||
_doAfterBars.Clear();
|
||||
_cancelledDoAfters.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add the necessary control for a DoAfter progress bar.
|
||||
/// </summary>
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace Content.Client.GameObjects.EntitySystems.DoAfter
|
||||
{
|
||||
_player = entity;
|
||||
// Setup the GUI and pass the new data to it if applicable.
|
||||
Gui?.Dispose();
|
||||
Gui?.Detached();
|
||||
|
||||
if (entity == null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user