Skip to content

Commit

Permalink
Ensure line renderer behaves correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
LumpBloom7 committed Jun 19, 2024
1 parent c2a6c5b commit 1d9f88a
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public LineLifetimeEntry(DrawableSentakkiRuleset? drawableSentakkiRuleset, doubl
public void Add(SentakkiLanedHitObject hitObject)
{
hitObject.BreakBindable.ValueChanged += onBreakChanged;
hitObject.ColourBindable.ValueChanged += onColorChanged;
HitObjects.AddInPlace(hitObject, Comparer<SentakkiLanedHitObject>.Create((lhs, rhs) => lhs.Lane.CompareTo(rhs.Lane)));
UpdateLine();
}
Expand All @@ -46,6 +47,7 @@ public void Remove(SentakkiLanedHitObject hitObject)
}

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
33 changes: 7 additions & 26 deletions osu.Game.Rulesets.Sentakki/UI/LanedPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Pooling;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Sentakki.Objects;
using osu.Game.Rulesets.Sentakki.Objects.Drawables;
using osu.Game.Rulesets.Sentakki.Objects.Drawables.Pieces.Slides;
Expand Down Expand Up @@ -60,41 +59,23 @@ public LanedPlayfield()
});
}

public override void Add(HitObject h)
public override void Add(HitObject hitObject)
{
switch (h)
{
case SentakkiLanedHitObject laned:
HitObjectLineRenderer.AddHitObject(laned);
Lanes[laned.Lane].Add(h);
break;
}
if (hitObject is not SentakkiLanedHitObject lanedHitObject)
return;

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

public override bool Remove(HitObject hitObject)
{
if (hitObject is not SentakkiLanedHitObject lanedHitObject)
return false;

HitObjectLineRenderer.RemoveHitObject(lanedHitObject);
return Lanes[lanedHitObject.Lane].Remove(lanedHitObject);
}
public override void Add(DrawableHitObject h)
{
switch (h)
{
case DrawableSentakkiLanedHitObject laned:
Lanes[laned.HitObject.Lane].Add(h);
break;
}
}

public override bool Remove(DrawableHitObject hitObject)
{
if (hitObject is not DrawableSentakkiLanedHitObject lanedHitObject)
return false;

return Lanes[lanedHitObject.HitObject.Lane].Remove(lanedHitObject);
}

private void onHitObjectLoaded(Drawable hitObject)
{
Expand Down
33 changes: 0 additions & 33 deletions osu.Game.Rulesets.Sentakki/UI/SentakkiPlayfield.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,39 +157,6 @@ public override bool Remove(HitObject h)
}
}

public override void Add(DrawableHitObject h)
{
switch (h)
{
case SentakkiLanedHitObject:
LanedPlayfield.Add(h);
break;

case Touch:
touchPlayfield.Add(h);
break;

default:
base.Add(h);
break;
}
}

public override bool Remove(DrawableHitObject 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 1d9f88a

Please sign in to comment.