1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-15 05:17:25 +08:00
osu-lazer/osu.Game/Storyboards/Drawables/DrawableStoryboardLayer.cs

40 lines
1.2 KiB
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
using System.Threading;
2018-04-13 17:19:50 +08:00
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
namespace osu.Game.Storyboards.Drawables
{
public class DrawableStoryboardLayer : LifetimeManagementContainer
2018-04-13 17:19:50 +08:00
{
public StoryboardLayer Layer { get; private set; }
public bool Enabled;
public override bool IsPresent => Enabled && base.IsPresent;
public DrawableStoryboardLayer(StoryboardLayer layer)
{
Layer = layer;
RelativeSizeAxes = Axes.Both;
Anchor = Anchor.Centre;
Origin = Anchor.Centre;
Enabled = layer.EnabledWhenPassing;
}
[BackgroundDependencyLoader]
2019-05-10 16:42:45 +08:00
private void load(CancellationToken? cancellationToken)
2018-04-13 17:19:50 +08:00
{
foreach (var element in Layer.Elements)
{
2019-05-10 16:42:45 +08:00
cancellationToken?.ThrowIfCancellationRequested();
2018-04-13 17:19:50 +08:00
if (element.IsDrawable)
AddInternal(element.CreateDrawable());
2018-04-13 17:19:50 +08:00
}
}
}
}