Skip to content

Commit

Permalink
Merge pull request #596 from LumpBloom7/Fix-mirror-mod
Browse files Browse the repository at this point in the history
Avoid using bindables to swap note playfields
  • Loading branch information
LumpBloom7 authored Jun 29, 2024
2 parents eee3d57 + 1d9f88a commit 42cb61f
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,21 @@ public LineLifetimeEntry(DrawableSentakkiRuleset? drawableSentakkiRuleset, doubl

public void Add(SentakkiLanedHitObject hitObject)
{
hitObject.LaneBindable.ValueChanged += onLaneChanged;
hitObject.BreakBindable.ValueChanged += onBreakChanged;
hitObject.ColourBindable.ValueChanged += onColorChanged;
HitObjects.AddInPlace(hitObject, Comparer<SentakkiLanedHitObject>.Create((lhs, rhs) => lhs.Lane.CompareTo(rhs.Lane)));
UpdateLine();
}

public void Remove(SentakkiLanedHitObject hitObject)
{
hitObject.LaneBindable.ValueChanged -= onLaneChanged;
hitObject.BreakBindable.ValueChanged -= onBreakChanged;
HitObjects.Remove(hitObject);
UpdateLine();
}

private void onLaneChanged(ValueChangedEvent<int> obj) => UpdateLine();

private void onBreakChanged(ValueChangedEvent<bool> obj) => UpdateLine();
private void onColorChanged(ValueChangedEvent<Color4> obj) => UpdateLine();

public Action<LineLifetimeEntry> OnLineUpdated = null!;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ public void AddHitObject(SentakkiLanedHitObject hitObject)

public void RemoveHitObject(SentakkiLanedHitObject hitObject)
{
// Ensure that we don't continue to receive time changes
startTimeMap[hitObject].UnbindAll();

startTimeMap.Remove(hitObject);

removeHitObjectFromEntry(hitObject.StartTime, hitObject);
}

Expand Down
19 changes: 6 additions & 13 deletions osu.Game.Rulesets.Sentakki/UI/LanedPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,20 +59,13 @@ public LanedPlayfield()
});
}

public override void Add(HitObject h)
public override void Add(HitObject hitObject)
{
switch (h)
{
case SentakkiLanedHitObject laned:
HitObjectLineRenderer.AddHitObject(laned);
laned.LaneBindable.BindValueChanged(lane =>
{
if (lane.OldValue != lane.NewValue)
Lanes[lane.OldValue].Remove(h);
Lanes[lane.NewValue].Add(h);
}, true);
break;
}
if (hitObject is not SentakkiLanedHitObject lanedHitObject)
return;

HitObjectLineRenderer.AddHitObject(lanedHitObject);
Lanes[lanedHitObject.Lane].Add(lanedHitObject);
}

public override bool Remove(HitObject hitObject)
Expand Down
14 changes: 14 additions & 0 deletions osu.Game.Rulesets.Sentakki/UI/SentakkiPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,20 @@ public override void Add(HitObject h)
}
}

public override bool Remove(HitObject h)
{
switch (h)
{
case SentakkiLanedHitObject:
return LanedPlayfield.Remove(h);

case Touch:
return touchPlayfield.Remove(h);
default:
return base.Remove(h);
}
}

private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
{
if (!judgedObject.DisplayResult || !DisplayJudgements.Value || judgedObject is not DrawableSentakkiHitObject sentakkiHitObject)
Expand Down

0 comments on commit 42cb61f

Please sign in to comment.