1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 19:27:24 +08:00

Throw an exception if try to modify lifetime of PoolableDrawableWithLifetime without lifetime

This commit is contained in:
ekrctb 2021-05-04 16:04:58 +09:00
parent fd8e552a8b
commit 36438175a0

View File

@ -3,6 +3,7 @@
#nullable enable
using System;
using System.Diagnostics;
using osu.Framework.Graphics.Performance;
using osu.Framework.Graphics.Pooling;
@ -31,7 +32,12 @@ namespace osu.Game.Rulesets.Objects.Pooling
get => Entry?.LifetimeStart ?? double.MinValue;
set
{
if (Entry != null) Entry.LifetimeStart = value;
if (LifetimeStart == value) return;
if (Entry == null)
throw new InvalidOperationException($"Cannot modify lifetime of {nameof(PoolableDrawableWithLifetime<TEntry>)} when entry is not set");
Entry.LifetimeStart = value;
}
}
@ -40,7 +46,12 @@ namespace osu.Game.Rulesets.Objects.Pooling
get => Entry?.LifetimeEnd ?? double.MaxValue;
set
{
if (Entry != null) Entry.LifetimeEnd = value;
if (LifetimeEnd == value) return;
if (Entry == null)
throw new InvalidOperationException($"Cannot modify lifetime of {nameof(PoolableDrawableWithLifetime<TEntry>)} when entry is not set");
Entry.LifetimeEnd = value;
}
}