From 8aaa500431b490adfd898fb722c75f3582f6f179 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Thu, 12 Nov 2020 18:34:50 +0900 Subject: [PATCH] Add lifetime extensions --- osu.Game/Rulesets/UI/HitObjectContainer.cs | 12 +++++++- osu.Game/Rulesets/UI/Playfield.cs | 36 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/osu.Game/Rulesets/UI/HitObjectContainer.cs b/osu.Game/Rulesets/UI/HitObjectContainer.cs index 1797f0acb8..bca2466968 100644 --- a/osu.Game/Rulesets/UI/HitObjectContainer.cs +++ b/osu.Game/Rulesets/UI/HitObjectContainer.cs @@ -58,6 +58,16 @@ namespace osu.Game.Rulesets.UI /// public event Action HitObjectUsageFinished; + /// + /// The amount of time prior to the current time within which s should be considered alive. + /// + public double PastLifetimeExtension { get; set; } + + /// + /// The amount of time after the current time within which s should be considered alive. + /// + public double FutureLifetimeExtension { get; set; } + private readonly Dictionary startTimeMap = new Dictionary(); private readonly Dictionary drawableMap = new Dictionary(); private readonly LifetimeEntryManager lifetimeManager = new LifetimeEntryManager(); @@ -179,7 +189,7 @@ namespace osu.Game.Rulesets.UI protected override bool CheckChildrenLife() { bool aliveChanged = base.CheckChildrenLife(); - aliveChanged |= lifetimeManager.Update(Time.Current, Time.Current); + aliveChanged |= lifetimeManager.Update(Time.Current - PastLifetimeExtension, Time.Current + FutureLifetimeExtension); return aliveChanged; } diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index 8f2be81c36..5794ff348c 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -240,6 +240,42 @@ namespace osu.Game.Rulesets.UI p.KeepAllAlive(); } + /// + /// The amount of time prior to the current time within which s should be considered alive. + /// + public double PastLifetimeExtension + { + get => HitObjectContainer.PastLifetimeExtension; + set + { + HitObjectContainer.PastLifetimeExtension = value; + + if (!nestedPlayfields.IsValueCreated) + return; + + foreach (var nested in nestedPlayfields.Value) + nested.PastLifetimeExtension = value; + } + } + + /// + /// The amount of time after the current time within which s should be considered alive. + /// + public double FutureLifetimeExtension + { + get => HitObjectContainer.FutureLifetimeExtension; + set + { + HitObjectContainer.FutureLifetimeExtension = value; + + if (!nestedPlayfields.IsValueCreated) + return; + + foreach (var nested in nestedPlayfields.Value) + nested.FutureLifetimeExtension = value; + } + } + /// /// The cursor currently being used by this . May be null if no cursor is provided. ///