mirror of https://github.com/ppy/osu
Change order of OnParentReceived()
This commit is contained in:
parent
a5bb194cb8
commit
73e99718bc
|
@ -47,6 +47,11 @@ protected override void OnParentReceived(DrawableHitObject parent)
|
|||
base.OnParentReceived(parent);
|
||||
|
||||
drawableSlider = (DrawableSlider)parent;
|
||||
}
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
base.OnApply();
|
||||
|
||||
pathVersion.BindTo(drawableSlider.PathVersion);
|
||||
|
||||
|
|
|
@ -65,6 +65,11 @@ protected override void OnParentReceived(DrawableHitObject parent)
|
|||
base.OnParentReceived(parent);
|
||||
|
||||
drawableSlider = (DrawableSlider)parent;
|
||||
}
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
base.OnApply();
|
||||
|
||||
Position = HitObject.Position - drawableSlider.Position;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ public class DrawableSliderTick : DrawableOsuHitObject, IRequireTracking
|
|||
public override bool DisplayResult => false;
|
||||
|
||||
private SkinnableDrawable scaleContainer;
|
||||
private DrawableSlider drawableSlider;
|
||||
|
||||
public DrawableSliderTick()
|
||||
: base(null)
|
||||
|
@ -66,7 +67,14 @@ protected override void OnParentReceived(DrawableHitObject parent)
|
|||
{
|
||||
base.OnParentReceived(parent);
|
||||
|
||||
Position = HitObject.Position - ((DrawableSlider)parent).HitObject.Position;
|
||||
drawableSlider = (DrawableSlider)parent;
|
||||
}
|
||||
|
||||
protected override void OnApply()
|
||||
{
|
||||
base.OnApply();
|
||||
|
||||
Position = HitObject.Position - drawableSlider.HitObject.Position;
|
||||
}
|
||||
|
||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||
|
|
|
@ -24,6 +24,7 @@ public DrawableSpinnerTick(SpinnerTick spinnerTick)
|
|||
protected override void OnParentReceived(DrawableHitObject parent)
|
||||
{
|
||||
base.OnParentReceived(parent);
|
||||
|
||||
drawableSpinner = (DrawableSpinner)parent;
|
||||
}
|
||||
|
||||
|
|
|
@ -230,12 +230,12 @@ public void Apply([NotNull] HitObject hitObject, [CanBeNull] HitObjectLifetimeEn
|
|||
|
||||
foreach (var h in HitObject.NestedHitObjects)
|
||||
{
|
||||
var pooledDrawableNested = pooledObjectProvider?.GetPooledDrawableRepresentation(h);
|
||||
var pooledDrawableNested = pooledObjectProvider?.GetPooledDrawableRepresentation(h, this);
|
||||
var drawableNested = pooledDrawableNested
|
||||
?? CreateNestedHitObject(h)
|
||||
?? throw new InvalidOperationException($"{nameof(CreateNestedHitObject)} returned null for {h.GetType().ReadableName()}.");
|
||||
|
||||
// Invoke the event only if this nested object is just created by `CreateNestedHitObject`.
|
||||
// Only invoke the event for non-pooled DHOs, otherwise the event will be fired by the playfield.
|
||||
if (pooledDrawableNested == null)
|
||||
OnNestedDrawableCreated?.Invoke(drawableNested);
|
||||
|
||||
|
@ -243,10 +243,12 @@ public void Apply([NotNull] HitObject hitObject, [CanBeNull] HitObjectLifetimeEn
|
|||
drawableNested.OnRevertResult += onRevertResult;
|
||||
drawableNested.ApplyCustomUpdateState += onApplyCustomUpdateState;
|
||||
|
||||
// ApplyParent() should occur before Apply() in all cases, so it's invoked before the nested DHO is added to the hierarchy below, but after its events are initialised.
|
||||
if (pooledDrawableNested == null)
|
||||
drawableNested.ApplyParent(this);
|
||||
|
||||
nestedHitObjects.Value.Add(drawableNested);
|
||||
AddNestedHitObject(drawableNested);
|
||||
|
||||
drawableNested.OnParentReceived(this);
|
||||
}
|
||||
|
||||
StartTimeBindable.BindTo(HitObject.StartTimeBindable);
|
||||
|
@ -348,6 +350,12 @@ protected virtual void OnFree()
|
|||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies a parenting <see cref="DrawableHitObject"/> to this <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="parent">The parenting <see cref="DrawableHitObject"/>.</param>
|
||||
public void ApplyParent(DrawableHitObject parent) => OnParentReceived(parent);
|
||||
|
||||
/// <summary>
|
||||
/// Invoked when this <see cref="DrawableHitObject"/> receives a new parenting <see cref="DrawableHitObject"/>.
|
||||
/// </summary>
|
||||
|
|
|
@ -105,7 +105,7 @@ private void addDrawable(HitObjectLifetimeEntry entry)
|
|||
{
|
||||
Debug.Assert(!drawableMap.ContainsKey(entry));
|
||||
|
||||
var drawable = pooledObjectProvider?.GetPooledDrawableRepresentation(entry.HitObject);
|
||||
var drawable = pooledObjectProvider?.GetPooledDrawableRepresentation(entry.HitObject, null);
|
||||
if (drawable == null)
|
||||
throw new InvalidOperationException($"A drawable representation could not be retrieved for hitobject type: {entry.HitObject.GetType().ReadableName()}.");
|
||||
|
||||
|
|
|
@ -13,8 +13,9 @@ internal interface IPooledHitObjectProvider
|
|||
/// Attempts to retrieve the poolable <see cref="DrawableHitObject"/> representation of a <see cref="HitObject"/>.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The <see cref="HitObject"/> to retrieve the <see cref="DrawableHitObject"/> representation of.</param>
|
||||
/// <param name="parent">The parenting <see cref="DrawableHitObject"/>, if any.</param>
|
||||
/// <returns>The <see cref="DrawableHitObject"/> representing <see cref="HitObject"/>, or <c>null</c> if no poolable representation exists.</returns>
|
||||
[CanBeNull]
|
||||
DrawableHitObject GetPooledDrawableRepresentation([NotNull] HitObject hitObject);
|
||||
DrawableHitObject GetPooledDrawableRepresentation([NotNull] HitObject hitObject, [CanBeNull] DrawableHitObject parent);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ protected void RegisterPool<TObject, TDrawable>([NotNull] DrawablePool<TDrawable
|
|||
AddInternal(pool);
|
||||
}
|
||||
|
||||
DrawableHitObject IPooledHitObjectProvider.GetPooledDrawableRepresentation(HitObject hitObject)
|
||||
DrawableHitObject IPooledHitObjectProvider.GetPooledDrawableRepresentation(HitObject hitObject, DrawableHitObject parent)
|
||||
{
|
||||
var lookupType = hitObject.GetType();
|
||||
|
||||
|
@ -359,6 +359,8 @@ DrawableHitObject IPooledHitObjectProvider.GetPooledDrawableRepresentation(HitOb
|
|||
if (!lifetimeEntryMap.TryGetValue(hitObject, out var entry))
|
||||
lifetimeEntryMap[hitObject] = entry = CreateLifetimeEntry(hitObject);
|
||||
|
||||
if (parent != null)
|
||||
dho.ApplyParent(parent);
|
||||
dho.Apply(hitObject, entry);
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue