mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 20:22:55 +08:00
Update playfield/stage/column implementations for pooling
This commit is contained in:
parent
4e7551d50e
commit
789025a7ce
@ -92,6 +92,13 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
RegisterPool<HoldNoteTick, DrawableHoldNoteTick>(50, 200);
|
RegisterPool<HoldNoteTick, DrawableHoldNoteTick>(50, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
NewResult += OnNewResult;
|
||||||
|
}
|
||||||
|
|
||||||
public ColumnType ColumnType { get; set; }
|
public ColumnType ColumnType { get; set; }
|
||||||
|
|
||||||
public bool IsSpecial => ColumnType == ColumnType.Special;
|
public bool IsSpecial => ColumnType == ColumnType.Special;
|
||||||
@ -105,28 +112,14 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
return dependencies;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
protected override void OnNewDrawableHitObject(DrawableHitObject drawableHitObject)
|
||||||
/// Adds a DrawableHitObject to this Playfield.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="hitObject">The DrawableHitObject to add.</param>
|
|
||||||
public override void Add(DrawableHitObject hitObject)
|
|
||||||
{
|
{
|
||||||
hitObject.AccentColour.Value = AccentColour;
|
base.OnNewDrawableHitObject(drawableHitObject);
|
||||||
hitObject.OnNewResult += OnNewResult;
|
|
||||||
|
|
||||||
DrawableManiaHitObject maniaObject = (DrawableManiaHitObject)hitObject;
|
drawableHitObject.AccentColour.Value = AccentColour;
|
||||||
|
|
||||||
|
DrawableManiaHitObject maniaObject = (DrawableManiaHitObject)drawableHitObject;
|
||||||
maniaObject.CheckHittable = hitPolicy.IsHittable;
|
maniaObject.CheckHittable = hitPolicy.IsHittable;
|
||||||
|
|
||||||
base.Add(hitObject);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override bool Remove(DrawableHitObject h)
|
|
||||||
{
|
|
||||||
if (!base.Remove(h))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
h.OnNewResult -= OnNewResult;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
||||||
|
@ -9,6 +9,7 @@ using System.Linq;
|
|||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
@ -56,6 +57,10 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Add(HitObject hitObject) => getStageByColumn(((ManiaHitObject)hitObject).Column).Add(hitObject);
|
||||||
|
|
||||||
|
public override bool Remove(HitObject hitObject) => getStageByColumn(((ManiaHitObject)hitObject).Column).Remove(hitObject);
|
||||||
|
|
||||||
public override void Add(DrawableHitObject h) => getStageByColumn(((ManiaHitObject)h.HitObject).Column).Add(h);
|
public override void Add(DrawableHitObject h) => getStageByColumn(((ManiaHitObject)h.HitObject).Column).Add(h);
|
||||||
|
|
||||||
public override bool Remove(DrawableHitObject h) => getStageByColumn(((ManiaHitObject)h.HitObject).Column).Remove(h);
|
public override bool Remove(DrawableHitObject h) => getStageByColumn(((ManiaHitObject)h.HitObject).Column).Remove(h);
|
||||||
|
@ -11,6 +11,7 @@ using osu.Game.Rulesets.Mania.Beatmaps;
|
|||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Mania.Objects;
|
||||||
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
using osu.Game.Rulesets.Mania.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Mania.UI.Components;
|
using osu.Game.Rulesets.Mania.UI.Components;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Rulesets.UI.Scrolling;
|
using osu.Game.Rulesets.UI.Scrolling;
|
||||||
@ -132,10 +133,37 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
NewResult += OnNewResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Add(HitObject hitObject)
|
||||||
|
{
|
||||||
|
var maniaObject = (ManiaHitObject)hitObject;
|
||||||
|
int columnIndex = -1;
|
||||||
|
|
||||||
|
maniaObject.ColumnBindable.BindValueChanged(_ =>
|
||||||
|
{
|
||||||
|
if (columnIndex != -1)
|
||||||
|
Columns.ElementAt(columnIndex).Remove(hitObject);
|
||||||
|
|
||||||
|
columnIndex = maniaObject.Column - firstColumnIndex;
|
||||||
|
Columns.ElementAt(columnIndex).Add(hitObject);
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public override bool Remove(HitObject hitObject)
|
||||||
|
{
|
||||||
|
var maniaObject = (ManiaHitObject)hitObject;
|
||||||
|
int columnIndex = maniaObject.Column - firstColumnIndex;
|
||||||
|
return Columns.ElementAt(columnIndex).Remove(hitObject);
|
||||||
|
}
|
||||||
|
|
||||||
public override void Add(DrawableHitObject h)
|
public override void Add(DrawableHitObject h)
|
||||||
{
|
{
|
||||||
var maniaObject = (ManiaHitObject)h.HitObject;
|
var maniaObject = (ManiaHitObject)h.HitObject;
|
||||||
|
|
||||||
int columnIndex = -1;
|
int columnIndex = -1;
|
||||||
|
|
||||||
maniaObject.ColumnBindable.BindValueChanged(_ =>
|
maniaObject.ColumnBindable.BindValueChanged(_ =>
|
||||||
@ -146,18 +174,13 @@ namespace osu.Game.Rulesets.Mania.UI
|
|||||||
columnIndex = maniaObject.Column - firstColumnIndex;
|
columnIndex = maniaObject.Column - firstColumnIndex;
|
||||||
Columns.ElementAt(columnIndex).Add(h);
|
Columns.ElementAt(columnIndex).Add(h);
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
h.OnNewResult += OnNewResult;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Remove(DrawableHitObject h)
|
public override bool Remove(DrawableHitObject h)
|
||||||
{
|
{
|
||||||
var maniaObject = (ManiaHitObject)h.HitObject;
|
var maniaObject = (ManiaHitObject)h.HitObject;
|
||||||
int columnIndex = maniaObject.Column - firstColumnIndex;
|
int columnIndex = maniaObject.Column - firstColumnIndex;
|
||||||
Columns.ElementAt(columnIndex).Remove(h);
|
return Columns.ElementAt(columnIndex).Remove(h);
|
||||||
|
|
||||||
h.OnNewResult -= OnNewResult;
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Add(BarLine barline) => base.Add(new DrawableBarLine(barline));
|
public void Add(BarLine barline) => base.Add(new DrawableBarLine(barline));
|
||||||
|
Loading…
Reference in New Issue
Block a user