Skip to content

Code quality improvements for child/draw order handling in HandOfCards#37423

Merged
peppy merged 4 commits intoppy:masterfrom
minetoblend:rp-handofcards-codequality
Apr 21, 2026
Merged

Code quality improvements for child/draw order handling in HandOfCards#37423
peppy merged 4 commits intoppy:masterfrom
minetoblend:rp-handofcards-codequality

Conversation

@minetoblend
Copy link
Copy Markdown
Contributor

@minetoblend minetoblend commented Apr 20, 2026

Attempt at adressing the points made in #37419 (comment)

  • CardContainer is now being sorted immediately instead of only doing it once per frame. Given that its only ever gonna have a handful of children there wasn't really a need to optimize that that in the first place.
  • HandOfCards.Cards now exposes cardLookup.Values as an IEnumerable instead of exposing the card container's children directly.
  • HandOfCard now exposes GetCardsInDisplayOrder which returns a copy of all cards in display order. Since it's making a copy I made sure this isn't called on any hot code paths.
  • HandOfCard.Clear previously didn't clear the cardLookup dictionary. Didn't cause any issues since we're not re-adding cards to the hand anywhere but not good regardless.
    Switched to looping over all cards and calling RemoveCard to make sure changes to the removal logic can't get overlooked there again.

@minetoblend minetoblend force-pushed the rp-handofcards-codequality branch from ef9a137 to 4f24c68 Compare April 20, 2026 10:18
@peppy peppy self-requested a review April 21, 2026 13:52
Copy link
Copy Markdown
Member

@peppy peppy left a comment

Choose a reason for hiding this comment

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

seems alright

@peppy peppy merged commit 7b0e5ec into ppy:master Apr 21, 2026
8 of 10 checks passed
@peppy
Copy link
Copy Markdown
Member

peppy commented Apr 21, 2026

FWIW I'm still very weirded out by the use of Focus state in this system. It seems like a misuse to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants