1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 23:12:56 +08:00

Simplify HitObjectLifetimeEntry logic a bit

This commit is contained in:
ekrctb 2021-04-27 19:37:01 +09:00
parent 003553aba3
commit b87446a577

View File

@ -45,25 +45,18 @@ namespace osu.Game.Rulesets.Objects
// This method is called even if `start == LifetimeStart` when `KeepAlive` is true (necessary to update `realLifetimeStart`). // This method is called even if `start == LifetimeStart` when `KeepAlive` is true (necessary to update `realLifetimeStart`).
protected override void SetLifetimeStart(double start) protected override void SetLifetimeStart(double start)
{ {
// This assignment cannot be done in `SetLifetime` because otherwise setting only `LifetimeStart` will make `realLifetimeEnd` to be lost.
realLifetimeStart = start; realLifetimeStart = start;
if (!keepAlive)
base.SetLifetimeStart(start); base.SetLifetimeStart(start);
} }
protected override void SetLifetimeEnd(double end) protected override void SetLifetimeEnd(double end)
{ {
realLifetimeEnd = end; realLifetimeEnd = end;
if (!keepAlive)
base.SetLifetimeEnd(end); base.SetLifetimeEnd(end);
} }
protected override void SetLifetime(double start, double end)
{
if (keepAlive)
base.SetLifetime(double.MinValue, double.MaxValue);
else
base.SetLifetime(start, end);
}
private bool keepAlive; private bool keepAlive;
/// <summary> /// <summary>
@ -77,6 +70,9 @@ namespace osu.Game.Rulesets.Objects
return; return;
keepAlive = value; keepAlive = value;
if (keepAlive)
SetLifetime(double.MinValue, double.MaxValue);
else
SetLifetime(realLifetimeStart, realLifetimeEnd); SetLifetime(realLifetimeStart, realLifetimeEnd);
} }
} }