Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 19 additions & 13 deletions osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,25 @@ public float Y

private HitObjectProperty<int> stackHeight;

public Bindable<int> StackHeightBindable => stackHeight.Bindable;
public Bindable<int> StackHeightBindable
{
get
{
if (stackHeight.BindableCreated)
return stackHeight.Bindable;

stackHeight.Bindable.BindValueChanged(height =>
{
foreach (var nested in NestedHitObjects)
{
if (nested is OsuHitObject osuHitObject)
osuHitObject.StackHeight = height.NewValue;
}
});

return stackHeight.Bindable;
Comment on lines +88 to +100

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's hope this doesn't get torpedoed by its lack of thread safety I guess? Closest proxy to knowing that is letting CI run, so I'm going to wait for that before clicking any buttons.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is where we find out that everything was relying on this being in place to give nested objects correct values.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

diff --git a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs
index 0bdbce13d3..0039247eac 100644
--- a/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs
+++ b/osu.Game.Rulesets.Osu/Objects/OsuHitObject.cs
@@ -104,7 +104,19 @@ public Bindable<int> StackHeightBindable
         public int StackHeight
         {
             get => stackHeight.Value;
-            set => stackHeight.Value = value;
+            set
+            {
+                stackHeight.Value = value;
+
+                if (!stackHeight.BindableCreated)
+                {
+                    foreach (var nested in NestedHitObjects)
+                    {
+                        if (nested is OsuHitObject osuHitObject)
+                            osuHitObject.StackHeight = value;
+                    }
+                }
+            }
         }
 
         public virtual Vector2 StackOffset => new Vector2(StackHeight * Scale * -6.4f);

fixes the direct failures I guess. If a bit ugly.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm not sure how far we want to go with this.

}
}

public int StackHeight
{
Expand Down Expand Up @@ -155,18 +173,6 @@ public bool LastInCombo
set => lastInCombo.Value = value;
}

protected OsuHitObject()
{
StackHeightBindable.BindValueChanged(height =>
{
foreach (var nested in NestedHitObjects)
{
if (nested is OsuHitObject osuHitObject)
osuHitObject.StackHeight = height.NewValue;
}
});
}

protected override void ApplyDefaultsToSelf(ControlPointInfo controlPointInfo, IBeatmapDifficultyInfo difficulty)
{
base.ApplyDefaultsToSelf(controlPointInfo, difficulty);
Expand Down
5 changes: 5 additions & 0 deletions osu.Game/Rulesets/Objects/HitObjectProperty.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ public struct HitObjectProperty<T>
/// </summary>
public Bindable<T> Bindable => backingBindable ??= new Bindable<T>(defaultValue) { Value = backingValue };

/// <summary>
/// Whether the backing bindable has already been created.
/// </summary>
public bool BindableCreated => backingBindable != null;

/// <summary>
/// The current value, derived from and delegated to <see cref="Bindable"/> if initialised, or a temporary field otherwise.
/// </summary>
Expand Down
Loading