mirror of
https://github.com/ppy/osu.git
synced 2024-12-18 03:52:54 +08:00
f443cfb93e
Until now, these were haphazardly enforce inline in blueprint implementations. The only thing stopping complete breakage is that `EndPlacement` wasn't called (too much) from outside the blueprint, leaving them responsible for their own placement. By moving this conditional out of the provided paramters to `EndPlacement`, it allows more flexible usage of that method externally. Coming in a future PR.
83 lines
2.3 KiB
C#
83 lines
2.3 KiB
C#
// 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.
|
|
|
|
using System;
|
|
using osu.Framework.Input.Events;
|
|
using osu.Game.Rulesets.Catch.Edit.Blueprints.Components;
|
|
using osu.Game.Rulesets.Catch.Objects;
|
|
using osu.Game.Rulesets.Edit;
|
|
using osuTK.Input;
|
|
|
|
namespace osu.Game.Rulesets.Catch.Edit.Blueprints
|
|
{
|
|
public partial class BananaShowerPlacementBlueprint : CatchPlacementBlueprint<BananaShower>
|
|
{
|
|
private readonly TimeSpanOutline outline;
|
|
|
|
private double placementStartTime;
|
|
private double placementEndTime;
|
|
|
|
protected override bool IsValidForPlacement => HitObject.Duration > 0;
|
|
|
|
public BananaShowerPlacementBlueprint()
|
|
{
|
|
InternalChild = outline = new TimeSpanOutline();
|
|
}
|
|
|
|
protected override void LoadComplete()
|
|
{
|
|
base.LoadComplete();
|
|
|
|
BeginPlacement();
|
|
}
|
|
|
|
protected override void Update()
|
|
{
|
|
base.Update();
|
|
|
|
outline.UpdateFrom(HitObjectContainer, HitObject);
|
|
}
|
|
|
|
protected override bool OnMouseDown(MouseDownEvent e)
|
|
{
|
|
switch (PlacementActive)
|
|
{
|
|
case PlacementState.Waiting:
|
|
if (e.Button != MouseButton.Left) break;
|
|
|
|
BeginPlacement(true);
|
|
return true;
|
|
|
|
case PlacementState.Active:
|
|
if (e.Button != MouseButton.Right) break;
|
|
|
|
EndPlacement(true);
|
|
return true;
|
|
}
|
|
|
|
return base.OnMouseDown(e);
|
|
}
|
|
|
|
public override void UpdateTimeAndPosition(SnapResult result)
|
|
{
|
|
base.UpdateTimeAndPosition(result);
|
|
|
|
if (!(result.Time is double time)) return;
|
|
|
|
switch (PlacementActive)
|
|
{
|
|
case PlacementState.Waiting:
|
|
placementStartTime = placementEndTime = time;
|
|
break;
|
|
|
|
case PlacementState.Active:
|
|
placementEndTime = time;
|
|
break;
|
|
}
|
|
|
|
HitObject.StartTime = Math.Min(placementStartTime, placementEndTime);
|
|
HitObject.EndTime = Math.Max(placementStartTime, placementEndTime);
|
|
}
|
|
}
|
|
}
|