mirror of
https://github.com/ppy/osu
synced 2024-12-26 17:02:59 +00:00
Completely delegate DHO lifetime to Entry lifetime
A downside is lifetime update is not caught by LifetimeManagementContainer if used.
This commit is contained in:
parent
b88e5a31ea
commit
5aa522b1c2
@ -45,15 +45,16 @@ namespace osu.Game.Tests.Gameplay
|
|||||||
AddStep("Create DHO", () =>
|
AddStep("Create DHO", () =>
|
||||||
{
|
{
|
||||||
dho = new TestDrawableHitObject(null);
|
dho = new TestDrawableHitObject(null);
|
||||||
dho.Apply(entry = new TestLifetimeEntry(new HitObject())
|
dho.Apply(entry = new TestLifetimeEntry(new HitObject()));
|
||||||
{
|
|
||||||
LifetimeStart = 0,
|
|
||||||
LifetimeEnd = 1000,
|
|
||||||
});
|
|
||||||
Child = dho;
|
Child = dho;
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("KeepAlive = true", () => entry.KeepAlive = true);
|
AddStep("KeepAlive = true", () =>
|
||||||
|
{
|
||||||
|
entry.LifetimeStart = 0;
|
||||||
|
entry.LifetimeEnd = 1000;
|
||||||
|
entry.KeepAlive = true;
|
||||||
|
});
|
||||||
AddAssert("Lifetime is overriden", () => entry.LifetimeStart == double.MinValue && entry.LifetimeEnd == double.MaxValue);
|
AddAssert("Lifetime is overriden", () => entry.LifetimeStart == double.MinValue && entry.LifetimeEnd == double.MaxValue);
|
||||||
|
|
||||||
AddStep("Set LifetimeStart", () => dho.LifetimeStart = 500);
|
AddStep("Set LifetimeStart", () => dho.LifetimeStart = 500);
|
||||||
|
@ -28,14 +28,20 @@ namespace osu.Game.Rulesets.Objects.Pooling
|
|||||||
|
|
||||||
public override double LifetimeStart
|
public override double LifetimeStart
|
||||||
{
|
{
|
||||||
get => base.LifetimeStart;
|
get => Entry?.LifetimeStart ?? double.MinValue;
|
||||||
set => setLifetime(value, LifetimeEnd);
|
set
|
||||||
|
{
|
||||||
|
if (Entry != null) Entry.LifetimeStart = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override double LifetimeEnd
|
public override double LifetimeEnd
|
||||||
{
|
{
|
||||||
get => base.LifetimeEnd;
|
get => Entry?.LifetimeEnd ?? double.MaxValue;
|
||||||
set => setLifetime(LifetimeStart, value);
|
set
|
||||||
|
{
|
||||||
|
if (Entry != null) Entry.LifetimeEnd = value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool RemoveWhenNotAlive => false;
|
public override bool RemoveWhenNotAlive => false;
|
||||||
@ -64,11 +70,8 @@ namespace osu.Game.Rulesets.Objects.Pooling
|
|||||||
if (HasEntryApplied)
|
if (HasEntryApplied)
|
||||||
free();
|
free();
|
||||||
|
|
||||||
setLifetime(entry.LifetimeStart, entry.LifetimeEnd);
|
|
||||||
Entry = entry;
|
Entry = entry;
|
||||||
|
|
||||||
OnApply(entry);
|
OnApply(entry);
|
||||||
|
|
||||||
HasEntryApplied = true;
|
HasEntryApplied = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,27 +98,12 @@ namespace osu.Game.Rulesets.Objects.Pooling
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setLifetime(double start, double end)
|
|
||||||
{
|
|
||||||
base.LifetimeStart = start;
|
|
||||||
base.LifetimeEnd = end;
|
|
||||||
|
|
||||||
if (Entry != null)
|
|
||||||
{
|
|
||||||
Entry.LifetimeStart = start;
|
|
||||||
Entry.LifetimeEnd = end;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void free()
|
private void free()
|
||||||
{
|
{
|
||||||
Debug.Assert(Entry != null && HasEntryApplied);
|
Debug.Assert(Entry != null && HasEntryApplied);
|
||||||
|
|
||||||
OnFree(Entry);
|
OnFree(Entry);
|
||||||
|
|
||||||
Entry = null;
|
Entry = null;
|
||||||
setLifetime(double.MaxValue, double.MaxValue);
|
|
||||||
|
|
||||||
HasEntryApplied = false;
|
HasEntryApplied = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user