mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Fix placement blueprints not being correctly removed after a rolled back placement
This commit is contained in:
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <summary>
|
||||
/// Whether the <see cref="HitObject"/> is currently mid-placement, but has not necessarily finished being placed.
|
||||
/// </summary>
|
||||
public bool PlacementActive { get; private set; }
|
||||
public PlacementState PlacementActive { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The <see cref="HitObject"/> that is being placed.
|
||||
@ -72,7 +72,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
protected void BeginPlacement(bool commitStart = false)
|
||||
{
|
||||
placementHandler.BeginPlacement(HitObject);
|
||||
PlacementActive |= commitStart;
|
||||
if (commitStart)
|
||||
PlacementActive = PlacementState.Active;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -82,10 +83,19 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <param name="commit">Whether the object should be committed.</param>
|
||||
public void EndPlacement(bool commit)
|
||||
{
|
||||
if (!PlacementActive)
|
||||
BeginPlacement();
|
||||
switch (PlacementActive)
|
||||
{
|
||||
case PlacementState.Finished:
|
||||
return;
|
||||
|
||||
case PlacementState.Waiting:
|
||||
// ensure placement was started before ending to make state handling simpler.
|
||||
BeginPlacement();
|
||||
break;
|
||||
}
|
||||
|
||||
placementHandler.EndPlacement(HitObject, commit);
|
||||
PlacementActive = false;
|
||||
PlacementActive = PlacementState.Finished;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -94,7 +104,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <param name="result">The snap result information.</param>
|
||||
public virtual void UpdateTimeAndPosition(SnapResult result)
|
||||
{
|
||||
if (!PlacementActive)
|
||||
if (PlacementActive == PlacementState.Waiting)
|
||||
HitObject.StartTime = result.Time ?? EditorClock?.CurrentTime ?? Time.Current;
|
||||
}
|
||||
|
||||
@ -125,5 +135,12 @@ namespace osu.Game.Rulesets.Edit
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public enum PlacementState
|
||||
{
|
||||
Waiting,
|
||||
Active,
|
||||
Finished
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user