mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Add hitobject lifetime support
This commit is contained in:
@ -16,6 +16,7 @@ using System.Threading;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||
using osu.Framework.Extensions.TypeExtensions;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Pooling;
|
||||
using osu.Framework.Input;
|
||||
@ -246,6 +247,16 @@ namespace osu.Game.Rulesets.UI
|
||||
Playfield.Add(drawableObject);
|
||||
}
|
||||
|
||||
protected sealed override HitObjectLifetimeEntry CreateLifetimeEntry(HitObject hitObject)
|
||||
{
|
||||
if (!(hitObject is TObject tHitObject))
|
||||
throw new InvalidOperationException($"Unexpected hitobject type: {hitObject.GetType().ReadableName()}");
|
||||
|
||||
return CreateLifetimeEntry(tHitObject);
|
||||
}
|
||||
|
||||
protected virtual HitObjectLifetimeEntry CreateLifetimeEntry(TObject hitObject) => new HitObjectLifetimeEntry(hitObject);
|
||||
|
||||
public override void SetRecordTarget(Replay recordingReplay)
|
||||
{
|
||||
if (!(KeyBindingInputManager is IHasRecordingHandler recordingInputManager))
|
||||
@ -564,9 +575,21 @@ namespace osu.Game.Rulesets.UI
|
||||
m.ApplyToDrawableHitObjects(dho.Yield());
|
||||
}
|
||||
|
||||
dho.Apply(hitObject);
|
||||
dho.Apply(hitObject, GetLifetimeEntry(hitObject));
|
||||
});
|
||||
}
|
||||
|
||||
protected abstract HitObjectLifetimeEntry CreateLifetimeEntry(HitObject hitObject);
|
||||
|
||||
private readonly Dictionary<HitObject, HitObjectLifetimeEntry> lifetimeEntries = new Dictionary<HitObject, HitObjectLifetimeEntry>();
|
||||
|
||||
protected HitObjectLifetimeEntry GetLifetimeEntry(HitObject hitObject)
|
||||
{
|
||||
if (lifetimeEntries.TryGetValue(hitObject, out var entry))
|
||||
return entry;
|
||||
|
||||
return lifetimeEntries[hitObject] = CreateLifetimeEntry(hitObject);
|
||||
}
|
||||
}
|
||||
|
||||
public class BeatmapInvalidForRulesetException : ArgumentException
|
||||
|
Reference in New Issue
Block a user