Skip to content

Support prefab-aware trough queues for balls. - #578

Merged
freezy merged 1 commit into
masterfrom
feat/prefab-aware-trough-queues
Sep 16, 2026
Merged

freezy merged 1 commit into
masterfrom
feat/prefab-aware-trough-queues

Conversation

@freezy

@freezy freezy commented Sep 16, 2026 •

Copy link
Copy Markdown
Owner

Summary

Troughs can now hold a distinct ball prefab per queue slot, and a drained ball goes back into the queue as the prefab it was created from, so a table with visually different balls keeps them in rotation instead of re-creating every ball from one prefab.

Changes

  • TroughComponent gains BallPrefabs, the prefabs in ejection order; an empty slot uses the current render pipeline's default ball. The old single Ball prefab field is kept hidden for migration.
  • TroughApi keeps a BallPrefabQueue sized to the ball count. Ejecting a ball dequeues the front prefab and creates the ball from it; draining a ball destroys it and enqueues its source prefab at the back. A drain for a ball that no longer exists is logged and ignored, and an empty queue while the trough still counts a ball is reported instead of throwing.
  • Stack-switch counting is bounded by the number of configured stack switches rather than the nominal ball count.
  • BallComponent records the prefab a runtime ball was instantiated from. BallManager validates that a ball prefab carries a BallComponent with a positive radius on its root and scales the instance relative to the prefab's authored radius instead of overriding its scale.
  • The default ball prefab uses a correctly sized UV-mapped mesh.
  • The trough inspector shows one prefab field per slot, migrates a legacy single prefab into the slots, validates each prefab, and handles multi-selection with differing types or ball counts.

Tests

  • TroughTests.ShouldPutDrainedBallPrefabsAtBackOfQueue covers the queue order when balls drain out of order.
  • BallManagerPlayModeTests checks the default ball's mesh and scale, and that a runtime ball is scaled relative to its authored prefab and tracks its source prefab.

Known limitation

Ball prefabs are not carried through a VPE package. The package format stores scriptable-object assets, audio clips and collider meshes, not prefab assets, and the previous single ball prefab was not packaged either. A packaged table ejects the render pipeline's default ball, as before. Packaging authored ball prefabs needs prefab-asset support in the packaging layer and is a separate change.

@freezy freezy changed the title ball: support prefab-aware trough queues Support prefab-aware trough queues for balls. Sep 16, 2026
@greptile-apps

greptile-apps Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 4/5

The PR should not merge until per-slot ball prefab references survive VPE package export and restoration.

Findings

  1. P1 Package Drops Ball Prefabs ▶

Summary

This PR adds prefab-aware trough queues so each ejected and subsequently drained ball retains its source prefab, updates runtime ball scaling and source tracking, improves trough bounds handling, and replaces the default ball mesh. The per-slot prefab state is not yet carried through VPE package serialization.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  Config["Trough BallPrefabs"] --> Queue["BallPrefabQueue"]
  Queue -->|dequeue| Eject["Exit kicker creates ball"]
  Eject --> Source["BallComponent.SourcePrefab"]
  Source --> Drain["Entry switch drains ball"]
  Drain -->|enqueue source prefab| Queue
  Config -. currently omitted .-> Package["VPE package"]
  Package -. restores empty array .-> Queue
Loading

Reviews (1) · Last reviewed commit: "ball: support prefab-aware trough queues"

@freezy
freezy merged commit 1521c70 into master Sep 16, 2026
15 checks passed
@freezy
freezy deleted the feat/prefab-aware-trough-queues branch September 16, 2026 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant