Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion osu.Game.Rulesets.Catch/UI/CatcherTrailEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Graphics.Performance;

using osuTK;

namespace osu.Game.Rulesets.Catch.UI
{
public class CatcherTrailEntry : LifetimeEntry
public class CatcherTrailEntry : LifetimeEntryBase<CatcherTrailEntry>
{
public readonly CatcherAnimationState CatcherState;

Expand Down
3 changes: 2 additions & 1 deletion osu.Game.Rulesets.Catch/UI/HitExplosionEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
using osu.Framework.Graphics.Performance;
using osu.Game.Rulesets.Catch.Objects;
using osu.Game.Rulesets.Judgements;

using osuTK.Graphics;

namespace osu.Game.Rulesets.Catch.UI
{
public class HitExplosionEntry : LifetimeEntry
public class HitExplosionEntry : LifetimeEntryBase<HitExplosionEntry>
{
/// <summary>
/// The judgement result that triggered this explosion.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,16 @@

using System;
using System.Diagnostics;

using osu.Framework.Bindables;
using osu.Framework.Graphics.Performance;
using osu.Game.Rulesets.Objects;

using osuTK;

namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
{
public class FollowPointLifetimeEntry : LifetimeEntry
public class FollowPointLifetimeEntry : LifetimeEntryBase<FollowPointLifetimeEntry>
{
public event Action? Invalidated;
public readonly OsuHitObject Start;
Expand Down
9 changes: 5 additions & 4 deletions osu.Game/Rulesets/Objects/HitObjectLifetimeEntry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.Generic;

using osu.Framework.Bindables;
using osu.Framework.Graphics.Performance;
using osu.Game.Rulesets.Judgements;
Expand All @@ -11,9 +12,9 @@
namespace osu.Game.Rulesets.Objects
{
/// <summary>
/// A <see cref="LifetimeEntry"/> that stores the lifetime for a <see cref="HitObject"/>.
/// A <see cref="LifetimeEntryBase{T}"/> that stores the lifetime for a <see cref="HitObject"/>.
/// </summary>
public class HitObjectLifetimeEntry : LifetimeEntry
public class HitObjectLifetimeEntry : LifetimeEntryBase<HitObjectLifetimeEntry>
{
/// <summary>
/// The <see cref="HitObject"/>.
Expand Down Expand Up @@ -122,12 +123,12 @@ internal bool KeepAlive
/// </summary>
/// <remarks>
/// This is only used as an optimisation to delay the initial application of the <see cref="HitObject"/> to a <see cref="DrawableHitObject"/>.
/// A more accurate <see cref="LifetimeEntry.LifetimeStart"/> should be set on the hit object application, for further optimisation.
/// A more accurate <see cref="LifetimeEntryBase{T}.LifetimeStart"/> should be set on the hit object application, for further optimisation.
/// </remarks>
protected virtual double InitialLifetimeOffset => 10000;

/// <summary>
/// Set <see cref="LifetimeEntry.LifetimeStart"/> using <see cref="InitialLifetimeOffset"/>.
/// Set <see cref="LifetimeEntryBase{T}.LifetimeStart"/> using <see cref="InitialLifetimeOffset"/>.
/// </summary>
internal void SetInitialLifetime() => LifetimeStart = HitObject.StartTime - InitialLifetimeOffset;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Diagnostics;

using osu.Framework.Graphics;
using osu.Framework.Graphics.Performance;
using osu.Framework.Graphics.Pooling;
Expand All @@ -12,8 +13,8 @@ namespace osu.Game.Rulesets.Objects.Pooling
/// <summary>
/// A <see cref="PoolableDrawable"/> that is controlled by <see cref="Entry"/> to implement drawable pooling and replay rewinding.
/// </summary>
/// <typeparam name="TEntry">The <see cref="LifetimeEntry"/> type storing state and controlling this drawable.</typeparam>
public abstract partial class PoolableDrawableWithLifetime<TEntry> : PoolableDrawable where TEntry : LifetimeEntry
/// <typeparam name="TEntry">The <see cref="LifetimeEntryBase{T}"/> type storing state and controlling this drawable.</typeparam>
public abstract partial class PoolableDrawableWithLifetime<TEntry> : PoolableDrawable where TEntry : LifetimeEntryBase<TEntry>
{
private TEntry? entry;

Expand Down Expand Up @@ -150,7 +151,7 @@ private void free()
HasEntryApplied = false;
}

private void setLifetimeFromEntry(LifetimeEntry entry)
private void setLifetimeFromEntry(TEntry entry)
{
Debug.Assert(entry == Entry);
base.LifetimeStart = entry.LifetimeStart;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

using osu.Framework.Extensions.ListExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
Expand All @@ -20,7 +21,7 @@ namespace osu.Game.Rulesets.Objects.Pooling
/// <typeparam name="TEntry">The type of entries managed by this container.</typeparam>
/// <typeparam name="TDrawable">The type of drawables corresponding to the entries.</typeparam>
public abstract partial class PooledDrawableWithLifetimeContainer<TEntry, TDrawable> : CompositeDrawable
where TEntry : LifetimeEntry
where TEntry : LifetimeEntryBase<TEntry>
where TDrawable : Drawable
{
/// <summary>
Expand All @@ -40,8 +41,8 @@ public abstract partial class PooledDrawableWithLifetimeContainer<TEntry, TDrawa
public readonly SlimReadOnlyDictionaryWrapper<TEntry, TDrawable> AliveEntries;

/// <summary>
/// Whether to remove an entry when clock goes backward and crossed its <see cref="LifetimeEntry.LifetimeStart"/>.
/// Used when entries are dynamically added at its <see cref="LifetimeEntry.LifetimeStart"/> to prevent duplicated entries.
/// Whether to remove an entry when clock goes backward and crossed its <see cref="LifetimeEntryBase{T}.LifetimeStart"/>.
/// Used when entries are dynamically added at its <see cref="LifetimeEntryBase{T}.LifetimeStart"/> to prevent duplicated entries.
/// </summary>
protected virtual bool RemoveRewoundEntry => false;

Expand All @@ -58,7 +59,7 @@ public abstract partial class PooledDrawableWithLifetimeContainer<TEntry, TDrawa
private readonly Dictionary<TEntry, TDrawable> aliveDrawableMap = new Dictionary<TEntry, TDrawable>();
private readonly HashSet<TEntry> allEntries = new HashSet<TEntry>();

private readonly LifetimeEntryManager lifetimeManager = new LifetimeEntryManager();
private readonly LifetimeEntryManager<TEntry> lifetimeManager = new();

protected PooledDrawableWithLifetimeContainer()
{
Expand Down Expand Up @@ -102,9 +103,9 @@ public virtual bool Remove(TEntry entry)
/// <returns>The <typeparamref name="TDrawable"/> corresponding to the entry.</returns>
protected abstract TDrawable GetDrawable(TEntry entry);

private void entryBecameAlive(LifetimeEntry lifetimeEntry)
private void entryBecameAlive(TEntry lifetimeEntry)
{
var entry = (TEntry)lifetimeEntry;
var entry = lifetimeEntry;
Debug.Assert(!aliveDrawableMap.ContainsKey(entry));

TDrawable drawable = GetDrawable(entry);
Expand All @@ -120,9 +121,9 @@ private void entryBecameAlive(LifetimeEntry lifetimeEntry)
/// </remarks>
protected virtual void AddDrawable(TEntry entry, TDrawable drawable) => AddInternal(drawable);

private void entryBecameDead(LifetimeEntry lifetimeEntry)
private void entryBecameDead(TEntry lifetimeEntry)
{
var entry = (TEntry)lifetimeEntry;
var entry = lifetimeEntry;
Debug.Assert(aliveDrawableMap.ContainsKey(entry));

TDrawable drawable = aliveDrawableMap[entry];
Expand All @@ -138,10 +139,10 @@ private void entryBecameDead(LifetimeEntry lifetimeEntry)
/// </remarks>
protected virtual void RemoveDrawable(TEntry entry, TDrawable drawable) => RemoveInternal(drawable, false);

private void entryCrossedBoundary(LifetimeEntry lifetimeEntry, LifetimeBoundaryKind kind, LifetimeBoundaryCrossingDirection direction)
private void entryCrossedBoundary(TEntry lifetimeEntry, LifetimeBoundaryKind kind, LifetimeBoundaryCrossingDirection direction)
{
if (RemoveRewoundEntry && kind == LifetimeBoundaryKind.Start && direction == LifetimeBoundaryCrossingDirection.Backward)
Remove((TEntry)lifetimeEntry);
Remove(lifetimeEntry);
}

/// <summary>
Expand Down