2021-06-22 11:30:09 +08:00
|
|
|
// 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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2022-05-08 23:01:05 +08:00
|
|
|
using System;
|
2021-06-22 11:30:09 +08:00
|
|
|
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 class BananaShowerPlacementBlueprint : CatchPlacementBlueprint<BananaShower>
|
|
|
|
{
|
|
|
|
private readonly TimeSpanOutline outline;
|
|
|
|
|
2022-05-08 23:01:05 +08:00
|
|
|
private double placementStartTime;
|
|
|
|
private double placementEndTime;
|
|
|
|
|
2021-06-22 11:30:09 +08:00
|
|
|
public BananaShowerPlacementBlueprint()
|
|
|
|
{
|
|
|
|
InternalChild = outline = new TimeSpanOutline();
|
|
|
|
}
|
|
|
|
|
2022-05-08 22:10:51 +08:00
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
BeginPlacement();
|
|
|
|
}
|
|
|
|
|
2021-06-22 11:30:09 +08:00
|
|
|
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(HitObject.Duration > 0);
|
|
|
|
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:
|
2022-05-08 23:01:05 +08:00
|
|
|
placementStartTime = placementEndTime = time;
|
2021-06-22 11:30:09 +08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PlacementState.Active:
|
2022-05-08 23:01:05 +08:00
|
|
|
placementEndTime = time;
|
2021-06-22 11:30:09 +08:00
|
|
|
break;
|
|
|
|
}
|
2022-05-08 23:01:05 +08:00
|
|
|
|
|
|
|
HitObject.StartTime = Math.Min(placementStartTime, placementEndTime);
|
|
|
|
HitObject.EndTime = Math.Max(placementStartTime, placementEndTime);
|
2021-06-22 11:30:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|