mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Improve performance when entering gameplay by delaying hitobjec… (#5370)
Improve performance when entering gameplay by delaying hitobject updates
This commit is contained in:
commit
e42217cbc4
@ -29,6 +29,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
ShakeDuration = 30,
|
ShakeDuration = 30,
|
||||||
RelativeSizeAxes = Axes.Both
|
RelativeSizeAxes = Axes.Both
|
||||||
});
|
});
|
||||||
|
|
||||||
Alpha = 0;
|
Alpha = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,6 +39,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
protected override void ClearInternal(bool disposeChildren = true) => shakeContainer.Clear(disposeChildren);
|
protected override void ClearInternal(bool disposeChildren = true) => shakeContainer.Clear(disposeChildren);
|
||||||
protected override bool RemoveInternal(Drawable drawable) => shakeContainer.Remove(drawable);
|
protected override bool RemoveInternal(Drawable drawable) => shakeContainer.Remove(drawable);
|
||||||
|
|
||||||
|
protected sealed override double InitialLifetimeOffset => HitObject.TimePreempt;
|
||||||
|
|
||||||
protected sealed override void UpdateState(ArmedState state)
|
protected sealed override void UpdateState(ArmedState state)
|
||||||
{
|
{
|
||||||
double transformTime = HitObject.StartTime - HitObject.TimePreempt;
|
double transformTime = HitObject.StartTime - HitObject.TimePreempt;
|
||||||
|
@ -179,6 +179,38 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
UpdateResult(false);
|
UpdateResult(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private double? lifetimeStart;
|
||||||
|
|
||||||
|
public override double LifetimeStart
|
||||||
|
{
|
||||||
|
get => lifetimeStart ?? (HitObject.StartTime - InitialLifetimeOffset);
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.LifetimeStart = value;
|
||||||
|
lifetimeStart = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A safe offset prior to the start time of <see cref="HitObject"/> at which this <see cref="DrawableHitObject"/> may begin displaying contents.
|
||||||
|
/// By default, <see cref="DrawableHitObject"/>s are assumed to display their contents within 10 seconds prior to the start time of <see cref="HitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// This is only used as an optimisation to delay the initial update of this <see cref="DrawableHitObject"/> and may be tuned more aggressively if required.
|
||||||
|
/// A more accurate <see cref="LifetimeStart"/> should be set inside <see cref="UpdateState"/> for an <see cref="ArmedState.Idle"/> state.
|
||||||
|
/// </remarks>
|
||||||
|
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.
|
||||||
|
/// </summary>
|
||||||
|
internal void OnLifetimeEnd()
|
||||||
|
{
|
||||||
|
foreach (var nested in NestedHitObjects)
|
||||||
|
nested.OnLifetimeEnd();
|
||||||
|
UpdateResult(false);
|
||||||
|
}
|
||||||
|
|
||||||
protected virtual void AddNested(DrawableHitObject h)
|
protected virtual void AddNested(DrawableHitObject h)
|
||||||
{
|
{
|
||||||
h.OnNewResult += (d, r) => OnNewResult?.Invoke(d, r);
|
h.OnNewResult += (d, r) => OnNewResult?.Invoke(d, r);
|
||||||
@ -223,16 +255,6 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
OnNewResult?.Invoke(this, Result);
|
OnNewResult?.Invoke(this, Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Will called at least once after the <see cref="Drawable.LifetimeEnd"/> of this <see cref="DrawableHitObject"/> has been passed.
|
|
||||||
/// </summary>
|
|
||||||
internal void OnLifetimeEnd()
|
|
||||||
{
|
|
||||||
foreach (var nested in NestedHitObjects)
|
|
||||||
nested.OnLifetimeEnd();
|
|
||||||
UpdateResult(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Processes this <see cref="DrawableHitObject"/>, checking if a scoring result has occurred.
|
/// Processes this <see cref="DrawableHitObject"/>, checking if a scoring result has occurred.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user