mirror of
https://github.com/ppy/osu.git
synced 2025-02-14 00:53:19 +08:00
Recycle slider paths when the parenting slider dies (#5383)
Recycle slider paths when the parenting slider dies Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
commit
a82b1ca9ad
@ -63,6 +63,6 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.702.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.711.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.717.1" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -156,6 +156,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnKilled()
|
||||
{
|
||||
base.OnKilled();
|
||||
Body.RecyclePath();
|
||||
}
|
||||
|
||||
protected override void SkinChanged(ISkinSource skin, bool allowFallback)
|
||||
{
|
||||
base.SkinChanged(skin, allowFallback);
|
||||
|
@ -13,7 +13,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
{
|
||||
public const float DEFAULT_BORDER_SIZE = 1;
|
||||
|
||||
private readonly SliderPath path;
|
||||
private SliderPath path;
|
||||
|
||||
protected Path Path => path;
|
||||
|
||||
public float PathRadius
|
||||
@ -77,6 +78,22 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
||||
InternalChild = path = new SliderPath();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises a new <see cref="SliderPath"/>, releasing all resources retained by the old one.
|
||||
/// </summary>
|
||||
public void RecyclePath()
|
||||
{
|
||||
InternalChild = path = new SliderPath
|
||||
{
|
||||
Position = path.Position,
|
||||
PathRadius = path.PathRadius,
|
||||
AccentColour = path.AccentColour,
|
||||
BorderColour = path.BorderColour,
|
||||
BorderSize = path.BorderSize,
|
||||
Vertices = path.Vertices
|
||||
};
|
||||
}
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => path.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
/// <summary>
|
||||
|
@ -7,7 +7,6 @@ using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.TypeExtensions;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Primitives;
|
||||
using osu.Game.Audio;
|
||||
using osu.Game.Graphics;
|
||||
@ -202,12 +201,13 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
protected virtual double InitialLifetimeOffset => 10000;
|
||||
|
||||
/// <summary>
|
||||
/// Will called at least once after the <see cref="Drawable.LifetimeEnd"/> of this <see cref="DrawableHitObject"/> has been passed.
|
||||
/// Will be called at least once after this <see cref="DrawableHitObject"/> has become not alive.
|
||||
/// </summary>
|
||||
internal void OnLifetimeEnd()
|
||||
public virtual void OnKilled()
|
||||
{
|
||||
foreach (var nested in NestedHitObjects)
|
||||
nested.OnLifetimeEnd();
|
||||
nested.OnKilled();
|
||||
|
||||
UpdateResult(false);
|
||||
}
|
||||
|
||||
|
@ -34,8 +34,14 @@ namespace osu.Game.Rulesets.UI
|
||||
|
||||
protected override void OnChildLifetimeBoundaryCrossed(LifetimeBoundaryCrossedEvent e)
|
||||
{
|
||||
if (e.Kind == LifetimeBoundaryKind.End && e.Direction == LifetimeBoundaryCrossingDirection.Forward && e.Child is DrawableHitObject hitObject)
|
||||
hitObject.OnLifetimeEnd();
|
||||
if (!(e.Child is DrawableHitObject hitObject))
|
||||
return;
|
||||
|
||||
if ((e.Kind == LifetimeBoundaryKind.End && e.Direction == LifetimeBoundaryCrossingDirection.Forward)
|
||||
|| (e.Kind == LifetimeBoundaryKind.Start && e.Direction == LifetimeBoundaryCrossingDirection.Backward))
|
||||
{
|
||||
hitObject.OnKilled();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.4" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.702.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.711.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.717.1" />
|
||||
<PackageReference Include="SharpCompress" Version="0.23.0" />
|
||||
<PackageReference Include="NUnit" Version="3.12.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|
@ -105,8 +105,8 @@
|
||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
|
||||
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.702.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.711.0" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.711.0" />
|
||||
<PackageReference Include="ppy.osu.Framework" Version="2019.717.1" />
|
||||
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.717.1" />
|
||||
<PackageReference Include="SharpCompress" Version="0.22.0" />
|
||||
<PackageReference Include="NUnit" Version="3.11.0" />
|
||||
<PackageReference Include="SharpRaven" Version="2.4.0" />
|
||||
|
Loading…
Reference in New Issue
Block a user