osu/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaPlacementBlueprint.cs

48 lines
1.4 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.
using osu.Framework.Graphics;
2018-11-29 10:29:36 +00:00
using osu.Framework.Input;
2018-11-13 05:13:29 +00:00
using osu.Framework.Input.Events;
using osu.Game.Rulesets.Edit;
using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.UI;
using osuTK.Input;
namespace osu.Game.Rulesets.Mania.Edit.Blueprints
{
2018-11-29 10:29:36 +00:00
public abstract class ManiaPlacementBlueprint<T> : PlacementBlueprint,
IRequireHighFrequencyMousePosition // the playfield could be moving behind us
where T : ManiaHitObject
{
protected new T HitObject => (T)base.HitObject;
2018-11-29 10:29:36 +00:00
protected Column Column;
2018-11-19 08:59:52 +00:00
protected ManiaPlacementBlueprint(T hitObject)
: base(hitObject)
{
RelativeSizeAxes = Axes.None;
}
2018-11-29 10:29:36 +00:00
protected override bool OnMouseDown(MouseDownEvent e)
{
if (e.Button != MouseButton.Left)
return false;
2018-11-29 10:29:36 +00:00
if (Column == null)
return base.OnMouseDown(e);
HitObject.Column = Column.Index;
BeginPlacement(true);
2018-11-29 10:29:36 +00:00
return true;
}
public override void UpdatePosition(SnapResult result)
2018-11-13 05:13:29 +00:00
{
if (!PlacementActive)
2020-05-20 10:09:04 +00:00
Column = (result as ManiaSnapResult)?.Column;
}
}
}