mirror of
https://github.com/ppy/osu
synced 2024-12-28 18:02:53 +00:00
Remove Component inheritance
This commit is contained in:
parent
633f841a0f
commit
97f4f7bbd1
@ -12,7 +12,7 @@ using osu.Game.Tests.Visual;
|
||||
|
||||
namespace osu.Game.Tests.Editing
|
||||
{
|
||||
public class TestSceneHitObjectContainerEventQueue : OsuTestScene
|
||||
public class TestSceneHitObjectContainerEventBuffer : OsuTestScene
|
||||
{
|
||||
private readonly TestHitObject testObj = new TestHitObject();
|
||||
|
||||
@ -50,7 +50,6 @@ namespace osu.Game.Tests.Editing
|
||||
{
|
||||
topPlayfield,
|
||||
intermediateDrawable = new TestDrawable(),
|
||||
eventBuffer
|
||||
};
|
||||
});
|
||||
|
||||
@ -117,6 +116,12 @@ namespace osu.Game.Tests.Editing
|
||||
addCheckStep(finished: true);
|
||||
}
|
||||
|
||||
protected override void UpdateAfterChildren()
|
||||
{
|
||||
base.UpdateAfterChildren();
|
||||
eventBuffer.Update();
|
||||
}
|
||||
|
||||
private void addResetStep() => AddStep("reset", reset);
|
||||
|
||||
private void reset()
|
@ -23,6 +23,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
protected readonly HitObjectComposer Composer;
|
||||
|
||||
private HitObjectUsageEventBuffer usageEventBuffer;
|
||||
|
||||
protected EditorBlueprintContainer(HitObjectComposer composer)
|
||||
{
|
||||
Composer = composer;
|
||||
@ -46,14 +48,19 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
foreach (var obj in Composer.HitObjects)
|
||||
AddBlueprintFor(obj.HitObject);
|
||||
|
||||
var eventQueue = new HitObjectUsageEventBuffer(Composer.Playfield);
|
||||
eventQueue.HitObjectUsageBegan += AddBlueprintFor;
|
||||
eventQueue.HitObjectUsageFinished += RemoveBlueprintFor;
|
||||
eventQueue.HitObjectUsageTransferred += TransferBlueprintFor;
|
||||
AddInternal(eventQueue);
|
||||
usageEventBuffer = new HitObjectUsageEventBuffer(Composer.Playfield);
|
||||
usageEventBuffer.HitObjectUsageBegan += AddBlueprintFor;
|
||||
usageEventBuffer.HitObjectUsageFinished += RemoveBlueprintFor;
|
||||
usageEventBuffer.HitObjectUsageTransferred += TransferBlueprintFor;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
base.Update();
|
||||
usageEventBuffer?.Update();
|
||||
}
|
||||
|
||||
protected override IEnumerable<SelectionBlueprint<HitObject>> SortForMovement(IReadOnlyList<SelectionBlueprint<HitObject>> blueprints)
|
||||
=> blueprints.OrderBy(b => b.Item.StartTime);
|
||||
|
||||
@ -145,6 +152,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
Beatmap.HitObjectAdded -= AddBlueprintFor;
|
||||
Beatmap.HitObjectRemoved -= RemoveBlueprintFor;
|
||||
}
|
||||
|
||||
usageEventBuffer?.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.UI;
|
||||
@ -15,7 +14,7 @@ namespace osu.Game.Screens.Edit.Compose
|
||||
/// <summary>
|
||||
/// Buffers events from the many <see cref="HitObjectContainer"/>s in a nested <see cref="Playfield"/> hierarchy.
|
||||
/// </summary>
|
||||
internal class HitObjectUsageEventBuffer : Component
|
||||
internal class HitObjectUsageEventBuffer : IDisposable
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when a <see cref="HitObject"/> becomes used by a <see cref="DrawableHitObject"/>.
|
||||
@ -91,10 +90,8 @@ namespace osu.Game.Screens.Edit.Compose
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
public void Update()
|
||||
{
|
||||
base.Update();
|
||||
|
||||
foreach (var (hitObject, e) in pendingEvents)
|
||||
{
|
||||
switch (e)
|
||||
@ -116,12 +113,13 @@ namespace osu.Game.Screens.Edit.Compose
|
||||
pendingEvents.Clear();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool isDisposing)
|
||||
public void Dispose()
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
playfield.HitObjectUsageBegan -= onHitObjectUsageBegan;
|
||||
playfield.HitObjectUsageFinished -= onHitObjectUsageFinished;
|
||||
if (playfield != null)
|
||||
{
|
||||
playfield.HitObjectUsageBegan -= onHitObjectUsageBegan;
|
||||
playfield.HitObjectUsageFinished -= onHitObjectUsageFinished;
|
||||
}
|
||||
}
|
||||
|
||||
private enum EventType
|
||||
|
Loading…
Reference in New Issue
Block a user