mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 07:22:54 +08:00
Change order of OnParentReceived()
This commit is contained in:
parent
a5bb194cb8
commit
73e99718bc
@ -47,6 +47,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
base.OnParentReceived(parent);
|
base.OnParentReceived(parent);
|
||||||
|
|
||||||
drawableSlider = (DrawableSlider)parent;
|
drawableSlider = (DrawableSlider)parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnApply()
|
||||||
|
{
|
||||||
|
base.OnApply();
|
||||||
|
|
||||||
pathVersion.BindTo(drawableSlider.PathVersion);
|
pathVersion.BindTo(drawableSlider.PathVersion);
|
||||||
|
|
||||||
|
@ -65,6 +65,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
base.OnParentReceived(parent);
|
base.OnParentReceived(parent);
|
||||||
|
|
||||||
drawableSlider = (DrawableSlider)parent;
|
drawableSlider = (DrawableSlider)parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnApply()
|
||||||
|
{
|
||||||
|
base.OnApply();
|
||||||
|
|
||||||
Position = HitObject.Position - drawableSlider.Position;
|
Position = HitObject.Position - drawableSlider.Position;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +23,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
public override bool DisplayResult => false;
|
public override bool DisplayResult => false;
|
||||||
|
|
||||||
private SkinnableDrawable scaleContainer;
|
private SkinnableDrawable scaleContainer;
|
||||||
|
private DrawableSlider drawableSlider;
|
||||||
|
|
||||||
public DrawableSliderTick()
|
public DrawableSliderTick()
|
||||||
: base(null)
|
: base(null)
|
||||||
@ -66,7 +67,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
{
|
{
|
||||||
base.OnParentReceived(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)
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||||
|
@ -24,6 +24,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
protected override void OnParentReceived(DrawableHitObject parent)
|
protected override void OnParentReceived(DrawableHitObject parent)
|
||||||
{
|
{
|
||||||
base.OnParentReceived(parent);
|
base.OnParentReceived(parent);
|
||||||
|
|
||||||
drawableSpinner = (DrawableSpinner)parent;
|
drawableSpinner = (DrawableSpinner)parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -230,12 +230,12 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
|
|
||||||
foreach (var h in HitObject.NestedHitObjects)
|
foreach (var h in HitObject.NestedHitObjects)
|
||||||
{
|
{
|
||||||
var pooledDrawableNested = pooledObjectProvider?.GetPooledDrawableRepresentation(h);
|
var pooledDrawableNested = pooledObjectProvider?.GetPooledDrawableRepresentation(h, this);
|
||||||
var drawableNested = pooledDrawableNested
|
var drawableNested = pooledDrawableNested
|
||||||
?? CreateNestedHitObject(h)
|
?? CreateNestedHitObject(h)
|
||||||
?? throw new InvalidOperationException($"{nameof(CreateNestedHitObject)} returned null for {h.GetType().ReadableName()}.");
|
?? 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)
|
if (pooledDrawableNested == null)
|
||||||
OnNestedDrawableCreated?.Invoke(drawableNested);
|
OnNestedDrawableCreated?.Invoke(drawableNested);
|
||||||
|
|
||||||
@ -243,10 +243,12 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
drawableNested.OnRevertResult += onRevertResult;
|
drawableNested.OnRevertResult += onRevertResult;
|
||||||
drawableNested.ApplyCustomUpdateState += onApplyCustomUpdateState;
|
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);
|
nestedHitObjects.Value.Add(drawableNested);
|
||||||
AddNestedHitObject(drawableNested);
|
AddNestedHitObject(drawableNested);
|
||||||
|
|
||||||
drawableNested.OnParentReceived(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StartTimeBindable.BindTo(HitObject.StartTimeBindable);
|
StartTimeBindable.BindTo(HitObject.StartTimeBindable);
|
||||||
@ -348,6 +350,12 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <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>
|
/// <summary>
|
||||||
/// Invoked when this <see cref="DrawableHitObject"/> receives a new parenting <see cref="DrawableHitObject"/>.
|
/// Invoked when this <see cref="DrawableHitObject"/> receives a new parenting <see cref="DrawableHitObject"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -105,7 +105,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
{
|
{
|
||||||
Debug.Assert(!drawableMap.ContainsKey(entry));
|
Debug.Assert(!drawableMap.ContainsKey(entry));
|
||||||
|
|
||||||
var drawable = pooledObjectProvider?.GetPooledDrawableRepresentation(entry.HitObject);
|
var drawable = pooledObjectProvider?.GetPooledDrawableRepresentation(entry.HitObject, null);
|
||||||
if (drawable == null)
|
if (drawable == null)
|
||||||
throw new InvalidOperationException($"A drawable representation could not be retrieved for hitobject type: {entry.HitObject.GetType().ReadableName()}.");
|
throw new InvalidOperationException($"A drawable representation could not be retrieved for hitobject type: {entry.HitObject.GetType().ReadableName()}.");
|
||||||
|
|
||||||
|
@ -13,8 +13,9 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// Attempts to retrieve the poolable <see cref="DrawableHitObject"/> representation of a <see cref="HitObject"/>.
|
/// Attempts to retrieve the poolable <see cref="DrawableHitObject"/> representation of a <see cref="HitObject"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObject">The <see cref="HitObject"/> to retrieve the <see cref="DrawableHitObject"/> representation of.</param>
|
/// <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>
|
/// <returns>The <see cref="DrawableHitObject"/> representing <see cref="HitObject"/>, or <c>null</c> if no poolable representation exists.</returns>
|
||||||
[CanBeNull]
|
[CanBeNull]
|
||||||
DrawableHitObject GetPooledDrawableRepresentation([NotNull] HitObject hitObject);
|
DrawableHitObject GetPooledDrawableRepresentation([NotNull] HitObject hitObject, [CanBeNull] DrawableHitObject parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,7 @@ namespace osu.Game.Rulesets.UI
|
|||||||
AddInternal(pool);
|
AddInternal(pool);
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawableHitObject IPooledHitObjectProvider.GetPooledDrawableRepresentation(HitObject hitObject)
|
DrawableHitObject IPooledHitObjectProvider.GetPooledDrawableRepresentation(HitObject hitObject, DrawableHitObject parent)
|
||||||
{
|
{
|
||||||
var lookupType = hitObject.GetType();
|
var lookupType = hitObject.GetType();
|
||||||
|
|
||||||
@ -359,6 +359,8 @@ namespace osu.Game.Rulesets.UI
|
|||||||
if (!lifetimeEntryMap.TryGetValue(hitObject, out var entry))
|
if (!lifetimeEntryMap.TryGetValue(hitObject, out var entry))
|
||||||
lifetimeEntryMap[hitObject] = entry = CreateLifetimeEntry(hitObject);
|
lifetimeEntryMap[hitObject] = entry = CreateLifetimeEntry(hitObject);
|
||||||
|
|
||||||
|
if (parent != null)
|
||||||
|
dho.ApplyParent(parent);
|
||||||
dho.Apply(hitObject, entry);
|
dho.Apply(hitObject, entry);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user