Use overriding instead of hiding in HitObjectLifetimeEntry

Hidden properties are used when the type is the base class. It caused issues when `DrawableHitObject` logic is factored out to `PoolableDrawableWithLifetime` because it is using the base `LifetimeEntry`, not `HitObjectLifetimeEntry`.
This commit is contained in:
ekrctb
2021-04-27 15:23:33 +09:00
parent 7980d16b4c
commit a2c0951d94
2 changed files with 13 additions and 33 deletions

View File

@ -38,40 +38,19 @@ namespace osu.Game.Rulesets.Objects
startTimeBindable.BindValueChanged(onStartTimeChanged, true);
}
// The lifetime start, as set by the hitobject.
// The lifetime, as set by the hitobject.
private double realLifetimeStart = double.MinValue;
/// <summary>
/// The time at which the <see cref="HitObject"/> should become alive.
/// </summary>
public new double LifetimeStart
{
get => realLifetimeStart;
set => setLifetime(realLifetimeStart = value, LifetimeEnd);
}
// The lifetime end, as set by the hitobject.
private double realLifetimeEnd = double.MaxValue;
/// <summary>
/// The time at which the <see cref="HitObject"/> should become dead.
/// </summary>
public new double LifetimeEnd
public override void SetLifetime(double start, double end)
{
get => realLifetimeEnd;
set => setLifetime(LifetimeStart, realLifetimeEnd = value);
}
realLifetimeStart = start;
realLifetimeEnd = end;
private void setLifetime(double start, double end)
{
if (keepAlive)
{
start = double.MinValue;
end = double.MaxValue;
}
base.LifetimeStart = start;
base.LifetimeEnd = end;
base.SetLifetime(double.MinValue, double.MaxValue);
else
base.SetLifetime(start, end);
}
private bool keepAlive;
@ -87,7 +66,7 @@ namespace osu.Game.Rulesets.Objects
return;
keepAlive = value;
setLifetime(realLifetimeStart, realLifetimeEnd);
SetLifetime(realLifetimeStart, realLifetimeEnd);
}
}
@ -98,12 +77,12 @@ namespace osu.Game.Rulesets.Objects
/// <remarks>
/// This is only used as an optimisation to delay the initial update of the <see cref="HitObject"/> and may be tuned more aggressively if required.
/// It is indirectly used to decide the automatic transform offset provided to <see cref="DrawableHitObject.UpdateInitialTransforms"/>.
/// A more accurate <see cref="LifetimeStart"/> should be set for further optimisation (in <see cref="DrawableHitObject.LoadComplete"/>, for example).
/// A more accurate <see cref="LifetimeEntry.LifetimeStart"/> should be set for further optimisation (in <see cref="DrawableHitObject.LoadComplete"/>, for example).
/// </remarks>
protected virtual double InitialLifetimeOffset => 10000;
/// <summary>
/// Resets <see cref="LifetimeStart"/> according to the change in start time of the <see cref="HitObject"/>.
/// Resets <see cref="LifetimeEntry.LifetimeStart"/> according to the change in start time of the <see cref="HitObject"/>.
/// </summary>
private void onStartTimeChanged(ValueChangedEvent<double> startTime) => LifetimeStart = HitObject.StartTime - InitialLifetimeOffset;
}